mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
DRY up a common view pattern
Define a Whisper.View base class that automatically parses and renders templates and attributes defined by the subclass. This saves us a good number of lines of code as well as some marginal memory overhead, since we are no longer saving per-instance copies of template strings.
This commit is contained in:
@@ -18,16 +18,13 @@
|
||||
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
Whisper.NewGroupUpdateView = Backbone.View.extend({
|
||||
Whisper.NewGroupUpdateView = Whisper.View.extend({
|
||||
tagName: "div",
|
||||
className: "new-group-update-form",
|
||||
template: $('#new-group-update-form').html(),
|
||||
initialize: function(options) {
|
||||
if (this.$el.html().length === 0) {
|
||||
this.template = $('#new-group-update-form').html();
|
||||
Mustache.parse(this.template);
|
||||
this.$el.html(
|
||||
Mustache.render(this.template, this.model.attributes)
|
||||
);
|
||||
this.render();
|
||||
}
|
||||
this.avatarInput = new Whisper.FileInputView({
|
||||
el: this.$el.find('.group-avatar')
|
||||
|
||||
Reference in New Issue
Block a user