Get rid of Layout global
Instead, trigger and listen for events on the conversation collection object.
This commit is contained in:
parent
a835887459
commit
d1c5b6da7a
4 changed files with 9 additions and 5 deletions
|
@ -22,7 +22,7 @@
|
|||
if (textsecure.storage.getUnencrypted("number_id") === undefined) {
|
||||
window.location = '/options.html';
|
||||
} else {
|
||||
Whisper.Layout = new Whisper.InboxView({el: document});
|
||||
new Whisper.InboxView({el: document});
|
||||
textsecure.storage.putUnencrypted("unreadCount", 0);
|
||||
extension.navigator.setBadgeText("");
|
||||
}
|
||||
|
|
|
@ -20,14 +20,14 @@ var Whisper = Whisper || {};
|
|||
},
|
||||
|
||||
open: function(e) {
|
||||
$('.conversation').trigger('close'); // detach any existing conversation views
|
||||
this.$el.addClass('selected');
|
||||
|
||||
if (!this.view) {
|
||||
this.view = new Whisper.ConversationView({ model: this.model });
|
||||
} else {
|
||||
this.view.delegateEvents();
|
||||
}
|
||||
this.view.render();
|
||||
this.$el.addClass('selected');
|
||||
this.model.collection.trigger('selected', this.view);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
|
|
@ -57,7 +57,6 @@
|
|||
},
|
||||
|
||||
render: function() {
|
||||
Whisper.Layout.setContent(this.$el.show());
|
||||
this.view.scrollToBottom();
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,11 @@
|
|||
}.bind(this));
|
||||
}.bind(this));
|
||||
|
||||
this.conversations.on('selected', function(view) {
|
||||
$('.conversation').hide().trigger('close'); // detach any existing conversation views
|
||||
this.setContent(view.$el.show());
|
||||
view.render();
|
||||
}, this);
|
||||
},
|
||||
events: {
|
||||
'click #new-message': 'new_message',
|
||||
|
|
Loading…
Reference in a new issue