Clean up inbox/compose view rendering and swapping

Templatize the inbox view and use the same pattern for in-window view
switching as is now used with the conversation/message detail views.
This means doing more with markup and less jquery manipulation of
individual subelements of the inbox view.
This commit is contained in:
lilia
2015-03-09 14:21:06 -07:00
parent fd6e2954f7
commit a72ea7966d
4 changed files with 59 additions and 57 deletions

View File

@@ -101,7 +101,19 @@
'select .new-contact': 'addNewRecipient',
'select .contacts': 'addRecipient',
'remove .recipient': 'removeRecipient',
'click .create': 'create'
'click .create': 'create',
'click .back': 'goBack',
'keyup': 'keyup'
},
keyup: function(e) {
if (e.keyCode === 27) {
this.goBack();
}
},
goBack: function() {
this.trigger('back');
},
initNewContact: function() {
@@ -180,12 +192,12 @@
type: 'private'
});
conversation.fetch().then(function() {
this.$el.trigger('open', { modelId: conversation.id });
this.trigger('open', { modelId: conversation.id });
}.bind(this)).fail(function() {
var saved = conversation.save(); // false or indexedDBRequest
if (saved) {
saved.then(function() {
this.$el.trigger('open', { modelId: conversation.id });
this.trigger('open', { modelId: conversation.id });
}.bind(this));
}
}.bind(this));
@@ -210,7 +222,7 @@
var id = getString(groupId);
var group = new Whisper.Conversation(attributes);
group.save({ id: id, groupId: id }).then(function() {
this.$el.trigger('open', {modelId: id});
this.trigger('open', {modelId: id});
}.bind(this));
}.bind(this));
}.bind(this));