Remember the state of the minimized chats toggle
This commit is contained in:
parent
30a6e6cb58
commit
0d3977d3d4
42
converse.js
42
converse.js
@ -454,7 +454,7 @@
|
|||||||
this.initStatus = function (callback) {
|
this.initStatus = function (callback) {
|
||||||
this.xmppstatus = new this.XMPPStatus();
|
this.xmppstatus = new this.XMPPStatus();
|
||||||
var id = b64_sha1('converse.xmppstatus-'+this.bare_jid);
|
var id = b64_sha1('converse.xmppstatus-'+this.bare_jid);
|
||||||
this.xmppstatus.id = id; // This appears to be necessary for backbone.localStorage
|
this.xmppstatus.id = id; // Appears to be necessary for backbone.localStorage
|
||||||
this.xmppstatus.localStorage = new Backbone.LocalStorage(id);
|
this.xmppstatus.localStorage = new Backbone.LocalStorage(id);
|
||||||
this.xmppstatus.fetch({success: callback, error: callback});
|
this.xmppstatus.fetch({success: callback, error: callback});
|
||||||
};
|
};
|
||||||
@ -2689,10 +2689,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.toggleview = new converse.MinimizedChatsToggleView({
|
this.initToggle();
|
||||||
model: new converse.MinimizedChatsToggle()
|
|
||||||
});
|
|
||||||
|
|
||||||
this.model.on("add", function (item) {
|
this.model.on("add", function (item) {
|
||||||
if (item.get('minimized')) {
|
if (item.get('minimized')) {
|
||||||
this.addChat(item);
|
this.addChat(item);
|
||||||
@ -2702,6 +2699,16 @@
|
|||||||
this.model.on("change:minimized", this.onChanged, this);
|
this.model.on("change:minimized", this.onChanged, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
initToggle: function () {
|
||||||
|
this.toggleview = new converse.MinimizedChatsToggleView({
|
||||||
|
model: new converse.MinimizedChatsToggle()
|
||||||
|
});
|
||||||
|
var id = b64_sha1('converse.minchatstoggle'+this.bare_jid);
|
||||||
|
this.toggleview.model.id = id; // Appears to be necessary for backbone.localStorage
|
||||||
|
this.toggleview.model.localStorage = new Backbone.LocalStorage(id);
|
||||||
|
this.toggleview.model.fetch({success: callback, error: callback});
|
||||||
|
},
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
if (this.keys().length === 0) {
|
if (this.keys().length === 0) {
|
||||||
this.$el.hide('fast');
|
this.$el.hide('fast');
|
||||||
@ -2711,8 +2718,11 @@
|
|||||||
return this.$el;
|
return this.$el;
|
||||||
},
|
},
|
||||||
|
|
||||||
toggle: function () {
|
toggle: function (ev) {
|
||||||
this.toggleview.model.set({'visible': !this.toggleview.model.get('visible')})
|
if (ev && ev.preventDefault) {
|
||||||
|
ev.preventDefault();
|
||||||
|
}
|
||||||
|
this.toggleview.model.save({'collapsed': !this.toggleview.model.get('collapsed')})
|
||||||
this.$('.minimized-chats-flyout').toggle();
|
this.$('.minimized-chats-flyout').toggle();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -2744,12 +2754,9 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.MinimizedChatsToggle = Backbone.Model.extend({
|
this.MinimizedChatsToggle = Backbone.Model.extend({
|
||||||
localStorage: new Backbone.LocalStorage(
|
|
||||||
b64_sha1('converse.minimized-chats-toggle'+converse.bare_jid)),
|
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.set({
|
this.set({
|
||||||
'visible': this.get('visible') || false,
|
'collapsed': this.get('collapsed') || false,
|
||||||
'num_minimized': 0
|
'num_minimized': 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2760,13 +2767,18 @@
|
|||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.model.on('change:num_minimized', this.render, this);
|
this.model.on('change:num_minimized', this.render, this);
|
||||||
|
this.$flyout = this.$el.siblings('.minimized-chats-flyout');
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
this.$el.html(converse.templates.toggle_chats({
|
this.$el.html(converse.templates.toggle_chats(
|
||||||
'Minimized': __('Minimized'),
|
_.extend(this.model.toJSON(), {'Minimized': __('Minimized')})
|
||||||
'num_minimized': this.model.get('num_minimized')
|
));
|
||||||
}));
|
if (this.model.get('collapsed')) {
|
||||||
|
this.$flyout.hide();
|
||||||
|
} else {
|
||||||
|
this.$flyout.show();
|
||||||
|
}
|
||||||
return this.$el;
|
return this.$el;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
<div id="minimized-chats">
|
<div id="minimized-chats">
|
||||||
<a id="toggle-minimized-chats" href="#">
|
<a id="toggle-minimized-chats" href="#"></a>
|
||||||
<span>Minimized <span id="minimized-count">(0)</span>
|
|
||||||
<span class="unread-message-count" href="#">0</span>
|
|
||||||
</a>
|
|
||||||
<div class="minimized-chats-flyout"></div>
|
<div class="minimized-chats-flyout"></div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user