Commit fc631e7f authored by JC Brand's avatar JC Brand

Minor refactoring

parent 27c59cfe
......@@ -386,7 +386,6 @@
});
_converse.BookmarkView = Backbone.VDOMView.extend({
initialize () {
this.model.on('destroy', this.remove.bind(this));
},
......@@ -422,6 +421,8 @@
initialize () {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments);
this.toggleBookmarksList = _.debounce(this._toggleBookmarksList, 600, {'leading': true});
this.model.on('remove', this.hideListIfEmpty, this);
_converse.chatboxes.on('add', this.renderBookmarkListElement, this);
_converse.chatboxes.on('remove', this.renderBookmarkListElement, this);
......@@ -444,12 +445,17 @@
'label_bookmarks': __('Bookmarks'),
'_converse': _converse
});
this.hideListIfEmpty();
this.insertIntoControlBox();
return this;
},
insertIntoControlBox () {
const controlboxview = _converse.chatboxviews.get('controlbox');
if (!_.isUndefined(controlboxview)) {
const chatrooms_el = controlboxview.el.querySelector('#chatrooms');
chatrooms_el.insertAdjacentElement('afterbegin', this.el);
}
return this;
},
removeBookmark: _converse.removeBookmarkViaEvent,
......@@ -473,7 +479,7 @@
}
},
toggleBookmarksList (ev) {
_toggleBookmarksList (ev) {
if (ev && ev.preventDefault) { ev.preventDefault(); }
if (u.hasClass('icon-opened', ev.target)) {
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