Refactor code out into backbone.overview
This commit is contained in:
parent
76545632fc
commit
81f3814e32
@ -17,16 +17,17 @@
|
||||
"backbone.localStorage": "1.1.7",
|
||||
"strophe": "git@github.com:strophe/strophejs-bower.git#v1.1.3",
|
||||
"strophe.roster": "https://raw.github.com/strophe/strophejs-plugins/b1f364eb6e854ffe844c57add38e885cfeb9b498/roster/strophe.roster.js",
|
||||
"strophe.vcard": "https://raw.github.com/strophe/strophejs-plugins/f5c9e16b463610d501591452cded0359f53aae48/vcard/strophe.vcard.js",
|
||||
"strophe.disco": "https://raw.github.com/jcbrand/strophejs-plugins/75c8693992bc357c699b6d615eeb396e799f5c02/disco/strophe.disco.js",
|
||||
"strophe.muc": "https://raw.github.com/strophe/strophejs-plugins/02310ad1b8da2962cd05b0f4bceaecca134efed4/muc/strophe.muc.js",
|
||||
"strophe.vcard": "https://raw.github.com/strophe/strophejs-plugins/f5c9e16b463610d501591452cded0359f53aae48/vcard/strophe.vcard.js",
|
||||
"strophe.disco": "https://raw.github.com/jcbrand/strophejs-plugins/75c8693992bc357c699b6d615eeb396e799f5c02/disco/strophe.disco.js",
|
||||
"strophe.muc": "https://raw.github.com/strophe/strophejs-plugins/02310ad1b8da2962cd05b0f4bceaecca134efed4/muc/strophe.muc.js",
|
||||
"otr": "0.2.12",
|
||||
"crypto-js-evanvosberg": "~3.1.2",
|
||||
"almond": "~0.2.9",
|
||||
"requirejs-text": "~2.0.12",
|
||||
"requirejs-tpl-jcbrand": "*",
|
||||
"momentjs": "~2.6.0",
|
||||
"jquery.browser": "~0.0.6"
|
||||
"jquery.browser": "~0.0.6",
|
||||
"backbone.overview": "*"
|
||||
},
|
||||
"exportsOverride": {}
|
||||
}
|
||||
|
31
converse.js
31
converse.js
@ -3,7 +3,7 @@
|
||||
* http://conversejs.org
|
||||
*
|
||||
* Copyright (c) 2012, Jan-Carel Brand <jc@opkode.com>
|
||||
* Dual licensed under the MIT and GPL Licenses
|
||||
* Licensed under the Mozilla Public License (MPL)
|
||||
*/
|
||||
|
||||
// AMD/global registrations
|
||||
@ -1339,6 +1339,7 @@
|
||||
// the opposite of trim, i.e. restoring a trimmed chat box
|
||||
this.$el.insertAfter(converse.chatboxviews.get("controlbox").$el).show();
|
||||
this.focus();
|
||||
converse.refreshWebkit();
|
||||
this.model.trigger('grow', this.model);
|
||||
},
|
||||
|
||||
@ -2512,17 +2513,11 @@
|
||||
}
|
||||
});
|
||||
|
||||
this.ChatBoxViews = Backbone.View.extend({
|
||||
this.ChatBoxViews = Backbone.Overview.extend({
|
||||
|
||||
initialize: function () {
|
||||
var views = {};
|
||||
this.get = function (id) { return views[id]; };
|
||||
this.add = function (id, view) { views[id] = view; };
|
||||
this.getAll = function () { return views; };
|
||||
|
||||
this.trimmed_chatboxes_view = new converse.TrimmedChatBoxesView({model: this.model});
|
||||
this.render();
|
||||
|
||||
this.model.on("add", this.onChatAdded, this);
|
||||
this.model.on("grow", function (item) {
|
||||
this.trimChats(this.get(item.get('id')));
|
||||
@ -2667,20 +2662,9 @@
|
||||
}
|
||||
});
|
||||
|
||||
this.TrimmedChatBoxesView = Backbone.View.extend({
|
||||
this.TrimmedChatBoxesView = Backbone.Overview.extend({
|
||||
|
||||
initialize: function () {
|
||||
var views = {};
|
||||
this.get = function (id) { return views[id]; };
|
||||
this.add = function (id, view) { views[id] = view; };
|
||||
this.remove = function (id) {
|
||||
var view = views[id];
|
||||
if (view) {
|
||||
view.remove();
|
||||
delete views[id];
|
||||
}
|
||||
};
|
||||
|
||||
this.model.on("change:trimmed", function (item) {
|
||||
var view;
|
||||
if (item.get('trimmed')) {
|
||||
@ -3125,15 +3109,11 @@
|
||||
}
|
||||
});
|
||||
|
||||
this.RosterView = Backbone.View.extend({
|
||||
this.RosterView = Backbone.Overview.extend({
|
||||
tagName: 'dl',
|
||||
id: 'converse-roster',
|
||||
|
||||
initialize: function () {
|
||||
var views = {};
|
||||
this.get = function (id) { return views[id]; };
|
||||
this.add = function (id, view) { views[id] = view; };
|
||||
|
||||
this.model.on("add", function (item) {
|
||||
this.addRosterItemView(item).render(item);
|
||||
if (!item.get('vcard_updated')) {
|
||||
@ -3167,7 +3147,6 @@
|
||||
});
|
||||
}
|
||||
this.$el.hide().html(roster_markup);
|
||||
|
||||
this.model.fetch({add: true}); // Get the cached roster items from localstorage
|
||||
},
|
||||
|
||||
|
1
main.js
1
main.js
@ -8,6 +8,7 @@ config = {
|
||||
"underscore": "components/underscore/underscore",
|
||||
"backbone": "components/backbone/backbone",
|
||||
"backbone.localStorage": "components/backbone.localStorage/backbone.localStorage",
|
||||
"backbone.overview": "components/backbone.overview/backbone.overview",
|
||||
"text": 'components/requirejs-text/text',
|
||||
"tpl": 'components/requirejs-tpl-jcbrand/tpl',
|
||||
"converse-templates": "src/templates",
|
||||
|
@ -3,6 +3,7 @@ define("converse-dependencies", [
|
||||
"moment",
|
||||
"locales",
|
||||
"backbone.localStorage",
|
||||
"backbone.overview",
|
||||
"jquery.tinysort",
|
||||
"jquery.browser",
|
||||
"strophe",
|
||||
|
@ -2,6 +2,7 @@ define("converse-dependencies", [
|
||||
"moment",
|
||||
"locales",
|
||||
"backbone.localStorage",
|
||||
"backbone.overview",
|
||||
"jquery.tinysort",
|
||||
"jquery.browser",
|
||||
"strophe",
|
||||
|
Loading…
Reference in New Issue
Block a user