Commit fc631e7f authored by JC Brand's avatar JC Brand

Minor refactoring

parent 27c59cfe
...@@ -386,7 +386,6 @@ ...@@ -386,7 +386,6 @@
}); });
_converse.BookmarkView = Backbone.VDOMView.extend({ _converse.BookmarkView = Backbone.VDOMView.extend({
initialize () { initialize () {
this.model.on('destroy', this.remove.bind(this)); this.model.on('destroy', this.remove.bind(this));
}, },
...@@ -422,6 +421,8 @@ ...@@ -422,6 +421,8 @@
initialize () { initialize () {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments); Backbone.OrderedListView.prototype.initialize.apply(this, arguments);
this.toggleBookmarksList = _.debounce(this._toggleBookmarksList, 600, {'leading': true});
this.model.on('remove', this.hideListIfEmpty, this); this.model.on('remove', this.hideListIfEmpty, this);
_converse.chatboxes.on('add', this.renderBookmarkListElement, this); _converse.chatboxes.on('add', this.renderBookmarkListElement, this);
_converse.chatboxes.on('remove', this.renderBookmarkListElement, this); _converse.chatboxes.on('remove', this.renderBookmarkListElement, this);
...@@ -444,12 +445,17 @@ ...@@ -444,12 +445,17 @@
'label_bookmarks': __('Bookmarks'), 'label_bookmarks': __('Bookmarks'),
'_converse': _converse '_converse': _converse
}); });
this.hideListIfEmpty();
this.insertIntoControlBox();
return this;
},
insertIntoControlBox () {
const controlboxview = _converse.chatboxviews.get('controlbox'); const controlboxview = _converse.chatboxviews.get('controlbox');
if (!_.isUndefined(controlboxview)) { if (!_.isUndefined(controlboxview)) {
const chatrooms_el = controlboxview.el.querySelector('#chatrooms'); const chatrooms_el = controlboxview.el.querySelector('#chatrooms');
chatrooms_el.insertAdjacentElement('afterbegin', this.el); chatrooms_el.insertAdjacentElement('afterbegin', this.el);
} }
return this;
}, },
removeBookmark: _converse.removeBookmarkViaEvent, removeBookmark: _converse.removeBookmarkViaEvent,
...@@ -473,7 +479,7 @@ ...@@ -473,7 +479,7 @@
} }
}, },
toggleBookmarksList (ev) { _toggleBookmarksList (ev) {
if (ev && ev.preventDefault) { ev.preventDefault(); } if (ev && ev.preventDefault) { ev.preventDefault(); }
if (u.hasClass('icon-opened', ev.target)) { if (u.hasClass('icon-opened', ev.target)) {
u.slideIn(this.el.querySelector('.bookmarks')); u.slideIn(this.el.querySelector('.bookmarks'));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment