Browse Source

Add docstrings

JC Brand 7 years ago
parent
commit
b1ffb34b76
2 changed files with 24 additions and 5 deletions
  1. 21 4
      src/converse-chatboxes.js
  2. 3 1
      src/converse-chatview.js

+ 21 - 4
src/converse-chatboxes.js

@@ -117,6 +117,17 @@
                 },
 
                 getMessageAttributes (message, delay, original_stanza) {
+                    /* Parses a passed in message stanza and returns an object
+                     * of attributes.
+                     *
+                     * Parameters:
+                     *    (XMLElement) message - The message stanza
+                     *    (XMLElement) delay - The <delay> node from the
+                     *      stanza, if there was one.
+                     *    (XMLElement) original_stanza - The original stanza,
+                     *      that contains the message stanza, if it was
+                     *      contained, otherwise it's the message stanza itself.
+                     */
                     delay = delay || message.querySelector('delay');
                     const type = message.getAttribute('type'),
                         body = this.getMessageBody(message);
@@ -157,13 +168,16 @@
                 },
 
                 createMessage (message, delay, original_stanza) {
+                    /* Create a Backbone.Message object inside this chat box
+                     * based on the identified message stanza.
+                     */
                     return this.messages.create(this.getMessageAttributes.apply(this, arguments));
                 },
 
                 newMessageWillBeHidden () {
                     /* Returns a boolean to indicate whether a newly received
-                    * message will be visible to the user or not.
-                    */
+                     * message will be visible to the user or not.
+                     */
                     return this.get('hidden') ||
                         this.get('minimized') ||
                         this.isScrolledUp() ||
@@ -256,8 +270,11 @@
 
                 onMessage (message) {
                     /* Handler method for all incoming single-user chat "message"
-                    * stanzas.
-                    */
+                     * stanzas.
+                     *
+                     * Parameters:
+                     *    (XMLElement) message - The incoming message stanza
+                     */
                     let contact_jid, delay, resource,
                         from_jid = message.getAttribute('from'),
                         to_jid = message.getAttribute('to');

+ 3 - 1
src/converse-chatview.js

@@ -946,7 +946,9 @@
                 },
 
                 renderToolbar (toolbar, options) {
-                    if (!_converse.show_toolbar) { return; }
+                    if (!_converse.show_toolbar) {
+                        return this;
+                    }
                     toolbar = toolbar || tpl_toolbar;
                     options = _.assign(
                         this.model.toJSON(),