Fix list_view.js and message_view.js whitespace
This commit is contained in:
parent
61581bae7f
commit
1c589f2fad
2 changed files with 55 additions and 54 deletions
|
@ -28,11 +28,10 @@ var Whisper = Whisper || {};
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.listenTo(this.collection, 'add', this.addOne);
|
this.listenTo(this.collection, 'add', this.addOne);
|
||||||
this.listenTo(this.collection, 'reset', this.addAll);
|
this.listenTo(this.collection, 'reset', this.addAll);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
addOne: function(model) {
|
addOne: function(model) {
|
||||||
if (this.itemView) {
|
if (this.itemView) {
|
||||||
var view = new this.itemView({model: model});
|
var view = new this.itemView({model: model});
|
||||||
this.$el.append(view.render().el);
|
this.$el.append(view.render().el);
|
||||||
this.$el.trigger('add');
|
this.$el.trigger('add');
|
||||||
|
|
|
@ -14,35 +14,35 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
window.Whisper = window.Whisper || {};
|
window.Whisper = window.Whisper || {};
|
||||||
|
|
||||||
var ErrorView = Backbone.View.extend({
|
var ErrorView = Backbone.View.extend({
|
||||||
className: 'error',
|
className: 'error',
|
||||||
events: {
|
events: {
|
||||||
'click' : 'replay'
|
'click' : 'replay'
|
||||||
},
|
},
|
||||||
replay: function() {
|
replay: function() {
|
||||||
new window.textsecure.ReplayableError(this.model).replay();
|
new window.textsecure.ReplayableError(this.model).replay();
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
this.$el.text(this.model.message);
|
this.$el.text(this.model.message);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var ContentMessageView = Backbone.View.extend({
|
var ContentMessageView = Backbone.View.extend({
|
||||||
tagName: 'div',
|
tagName: 'div',
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.template = $('#message').html();
|
this.template = $('#message').html();
|
||||||
Mustache.parse(this.template);
|
Mustache.parse(this.template);
|
||||||
},
|
},
|
||||||
className: function() {
|
className: function() {
|
||||||
if (this.model.get('delivered')) { return 'delivered'; }
|
if (this.model.get('delivered')) { return 'delivered'; }
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
this.$el.html(
|
this.$el.html(
|
||||||
Mustache.render(this.template, {
|
Mustache.render(this.template, {
|
||||||
message: this.model.get('body'),
|
message: this.model.get('body'),
|
||||||
|
@ -53,7 +53,9 @@
|
||||||
|
|
||||||
this.$el.find('.attachments').append(
|
this.$el.find('.attachments').append(
|
||||||
this.model.get('attachments').map(function(attachment) {
|
this.model.get('attachments').map(function(attachment) {
|
||||||
return new Whisper.AttachmentView({model: attachment}).render().el;
|
return new Whisper.AttachmentView({
|
||||||
|
model: attachment
|
||||||
|
}).render().el;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -65,36 +67,36 @@
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Whisper.MessageView = Backbone.View.extend({
|
|
||||||
tagName: "li",
|
|
||||||
className: function() {
|
|
||||||
return ["entry", this.model.get('type')].join(' ');
|
|
||||||
},
|
|
||||||
initialize: function() {
|
|
||||||
if (this.model.isEndSession()) {
|
|
||||||
this.view = new Whisper.EndSessionView();
|
|
||||||
} else if (this.model.isGroupUpdate()) {
|
|
||||||
this.view = new Whisper.GroupUpdateView({
|
|
||||||
model: this.model.get('group_update')
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.view = new ContentMessageView({model: this.model});
|
|
||||||
}
|
}
|
||||||
this.$el.append(this.view.el);
|
});
|
||||||
|
|
||||||
this.listenTo(this.model, 'change', this.render); // auto update
|
Whisper.MessageView = Backbone.View.extend({
|
||||||
this.listenTo(this.model, 'destroy', this.remove); // auto update
|
tagName: "li",
|
||||||
|
className: function() {
|
||||||
|
return ["entry", this.model.get('type')].join(' ');
|
||||||
|
},
|
||||||
|
initialize: function() {
|
||||||
|
if (this.model.isEndSession()) {
|
||||||
|
this.view = new Whisper.EndSessionView();
|
||||||
|
} else if (this.model.isGroupUpdate()) {
|
||||||
|
this.view = new Whisper.GroupUpdateView({
|
||||||
|
model: this.model.get('group_update')
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.view = new ContentMessageView({model: this.model});
|
||||||
|
}
|
||||||
|
this.$el.append(this.view.el);
|
||||||
|
|
||||||
},
|
this.listenTo(this.model, 'change', this.render); // auto update
|
||||||
|
this.listenTo(this.model, 'destroy', this.remove); // auto update
|
||||||
|
|
||||||
render: function() {
|
},
|
||||||
this.view.render();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
render: function() {
|
||||||
|
this.view.render();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue