Ver código fonte

Fixed chatbox positioning and better disabling of effects

* The animate config option now disables jQuery effects
* Make sure the controlbox is always to the right of all other chatboxes
* Make sure new chatboxes are always created immediately left of the controlbox
JC Brand 11 anos atrás
pai
commit
1c26e9016c
4 arquivos alterados com 11 adições e 19 exclusões
  1. 9 17
      converse.js
  2. 1 1
      index.html
  3. 1 0
      main.js
  4. 0 1
      tests_main.js

+ 9 - 17
converse.js

@@ -207,6 +207,7 @@
             'xhr_user_search',
             'xhr_user_search_url'
         ]));
+        $.fx.off = !this.animate;
 
         // Only allow OTR if we have the capability
         this.allow_otr = this.allow_otr && HAS_CRYPTO;
@@ -917,7 +918,7 @@
                     this.showMessage({'message': text, 'sender': 'them'});
                 }, this);
                 this.updateVCard();
-                this.$el.appendTo(converse.chatboxviews.$el);
+                this.$el.insertAfter(converse.chatboxviews.get("controlbox").$el);
                 this.render().show().focus().model.messages.fetch({add: true});
                 if (this.model.get('status')) {
                     this.showStatusMessage(this.model.get('status'));
@@ -932,9 +933,7 @@
                 this.$el.attr('id', this.model.get('box_id'))
                     .html(
                         converse.templates.chatbox(
-                            _.extend(
-                                this.model.toJSON(),
-                                {
+                            _.extend(this.model.toJSON(), {
                                     show_toolbar: converse.show_toolbar,
                                     label_personal_message: __('Personal message')
                                 }
@@ -943,6 +942,9 @@
                     );
                 this.renderToolbar().renderAvatar();
                 converse.emit('onChatBoxOpened', this);
+                setTimeout(function () {
+                    converse.refreshWebkit();
+                }, 50);
                 return this;
             },
 
@@ -1441,9 +1443,8 @@
             },
 
             hide: function () {
-                var speed = converse.animate ? 'fast' : null;
                 if (this.$el.is(':visible') && this.$el.css('opacity') == "1") {
-                    this.$el.hide(speed, converse.refreshWebkit);
+                    this.$el.hide('fast', converse.refreshWebkit);
                     converse.emit('onChatBoxClosed', this);
                 }
             },
@@ -1452,12 +1453,7 @@
                 if (this.$el.is(':visible') && this.$el.css('opacity') == "1") {
                     return this;
                 }
-                if (converse.animate) {
-                    this.$el.show(callback);
-                } else {
-                    this.$el.show();
-                    if (typeof callback === 'function') { callback(); }
-                }
+                this.$el.show(callback);
                 if (converse.connection) {
                     // Without a connection, we haven't yet initialized
                     // localstorage
@@ -1795,7 +1791,7 @@
             },
 
             initialize: function () {
-                this.$el.appendTo(converse.chatboxviews.$el);
+                this.$el.insertAfter(converse.controlboxtoggle.$el);
                 this.model.on('change', $.proxy(function (item, changed) {
                     var i;
                     if (_.has(item.changed, 'connected')) {
@@ -2508,10 +2504,6 @@
                         delete view.model; // Remove ref to old model to help garbage collection
                         view.model = item;
                         view.initialize();
-                        if (item.get('id') !== 'controlbox') {
-                            // XXX: Why is it necessary to again append chatboxes?
-                            view.$el.appendTo(this.$el);
-                        }
                     }
                 }, this);
             },

+ 1 - 1
index.html

@@ -193,7 +193,7 @@
             allow_otr: true,
             auto_list_rooms: false,
             auto_subscribe: false,
-            bosh_service_url: 'http://devbox:5280/http-bind', // Please use this connection manager only for testing purposes
+            bosh_service_url: 'https://bind.conversejs.org', // Please use this connection manager only for testing purposes
             debug: true ,
             hide_muc_server: false,
             i18n: locales['en'], // Refer to ./locale/locales.js to see which locales are supported

+ 1 - 0
main.js

@@ -68,6 +68,7 @@ config = {
         'crypto.sha1':          { deps: ['crypto.core'] },
         'crypto.sha256':        { deps: ['crypto.core'] },
         'jquery.tinysort':      { deps: ['jquery'] },
+        'jquery.browser':       { deps: ['jquery'] },
         'strophe':              { deps: ['jquery'] },
         'strophe.disco':        { deps: ['strophe'] },
         'strophe.muc':          { deps: ['strophe', 'jquery'] },

+ 0 - 1
tests_main.js

@@ -37,7 +37,6 @@ require([
     "jasmine-html"
     ], function($, converse, mock, jasmine) {
         // Set up converse.js
-        $.fx.off = true;
         window.converse_api = converse;
         window.localStorage.clear();
         converse.initialize({