Bladeren bron

Allow non-roster contacts to be invited to a chatroom.

JC Brand 8 jaren geleden
bovenliggende
commit
495c6060f9
2 gewijzigde bestanden met toevoegingen van 26 en 10 verwijderingen
  1. 1 0
      docs/CHANGES.md
  2. 25 10
      src/converse-muc.js

+ 1 - 0
docs/CHANGES.md

@@ -13,6 +13,7 @@
 - New configuration setting:
 - New configuration setting:
   [show_chatstate_notifications](https://conversejs.org/docs/html/configuration.html#show-chatstate-notifications)
   [show_chatstate_notifications](https://conversejs.org/docs/html/configuration.html#show-chatstate-notifications)
   [jcbrand]
   [jcbrand]
+- Allow JIDs not on the roster to be invited to a chatroom. [jcbrand]
 - #770 Allow setting contact attrs on chats.open [Ape]
 - #770 Allow setting contact attrs on chats.open [Ape]
 
 
 ## 2.0.6 (2017-02-13)
 ## 2.0.6 (2017-02-13)

+ 25 - 10
src/converse-muc.js

@@ -2037,7 +2037,31 @@
                     }
                     }
                 },
                 },
 
 
+                promptForInvite: function (suggestion) {
+                    var reason = prompt(
+                        __(___('You are about to invite %1$s to the chat room "%2$s". '), suggestion.text.label, this.model.get('id')) +
+                        __("You may optionally include a message, explaining the reason for the invitation.")
+                    );
+                    if (reason !== null) {
+                        this.chatroomview.directInvite(suggestion.text.value, reason);
+                    }
+                    suggestion.target.value = '';
+                },
+
+                inviteFormSubmitted: function (evt) {
+                    evt.preventDefault();
+                    var el = evt.target.querySelector('input.invited-contact');
+                    this.promptForInvite({
+                        'target': el,
+                        'text': {
+                            'label': el.value,
+                            'value': el.value
+                        }});
+                },
+
                 initInviteWidget: function () {
                 initInviteWidget: function () {
+                    var form = this.el.querySelector('form.room-invite');
+                    form.addEventListener('submit', this.inviteFormSubmitted.bind(this));
                     var el = this.el.querySelector('input.invited-contact');
                     var el = this.el.querySelector('input.invited-contact');
                     var list = _converse.roster.map(function (item) {
                     var list = _converse.roster.map(function (item) {
                             var label = item.get('fullname') || item.get('jid');
                             var label = item.get('fullname') || item.get('jid');
@@ -2047,16 +2071,7 @@
                         'minChars': 1,
                         'minChars': 1,
                         'list': list
                         'list': list
                     });
                     });
-                    el.addEventListener('awesomplete-selectcomplete', function (suggestion) {
-                        var reason = prompt(
-                            __(___('You are about to invite %1$s to the chat room "%2$s". '), suggestion.text.label, this.model.get('id')) +
-                            __("You may optionally include a message, explaining the reason for the invitation.")
-                        );
-                        if (reason !== null) {
-                            this.chatroomview.directInvite(suggestion.text.value, reason);
-                        }
-                        el.value = '';
-                    }.bind(this));
+                    el.addEventListener('awesomplete-selectcomplete', this.promptForInvite.bind(this));
                     return this;
                     return this;
                 }
                 }
             });
             });