From 1c26e9016c61fe32363911c4d981399894a93167 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Thu, 24 Apr 2014 07:58:35 +0200 Subject: [PATCH] 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 --- converse.js | 26 +++++++++----------------- index.html | 2 +- main.js | 1 + tests_main.js | 1 - 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/converse.js b/converse.js index 73482e47e..76cef861a 100644 --- a/converse.js +++ b/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); }, diff --git a/index.html b/index.html index 3e3dbf924..62ce04ad6 100644 --- a/index.html +++ b/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 diff --git a/main.js b/main.js index 019bf31ca..6967489bf 100644 --- a/main.js +++ b/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'] }, diff --git a/tests_main.js b/tests_main.js index 4229a14c9..fdc777f39 100644 --- a/tests_main.js +++ b/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({