Cull dead code
Most of this no longer needed because of templating and list views.
This commit is contained in:
parent
9082781e09
commit
dc957415c2
4 changed files with 0 additions and 77 deletions
|
@ -43,7 +43,6 @@ var Whisper = Whisper || {};
|
|||
if (!this.messageCollection) {
|
||||
this.messageCollection = new Whisper.MessageCollection([], {threadId: this.id});
|
||||
}
|
||||
this.messageCollection.fetch();
|
||||
return this.messageCollection;
|
||||
},
|
||||
});
|
||||
|
|
|
@ -11,7 +11,6 @@ var Whisper = Whisper || {};
|
|||
|
||||
events: {
|
||||
'select .conversation': 'select',
|
||||
'deselect': 'deselect'
|
||||
},
|
||||
|
||||
select: function(e) {
|
||||
|
@ -20,10 +19,5 @@ var Whisper = Whisper || {};
|
|||
target.addClass('selected').trigger('open');
|
||||
return false;
|
||||
},
|
||||
|
||||
deselect: function() {
|
||||
this.$el.find('.selected').removeClass('selected').trigger('close');
|
||||
this.$el.find('.conversation').show();
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -3,32 +3,6 @@ var Whisper = Whisper || {};
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var destroyer = Backbone.View.extend({
|
||||
tagName: 'button',
|
||||
className: 'btn btn-square btn-sm destroy',
|
||||
events: {
|
||||
'click': 'destroy'
|
||||
},
|
||||
initialize: function() {
|
||||
this.$el.html('×');
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
this.model.messages().each(function(message) { message.destroy(); });
|
||||
this.model.set('active', false);
|
||||
this.model.save();
|
||||
this.model.trigger('destroy');
|
||||
}
|
||||
});
|
||||
|
||||
var menu = Backbone.View.extend({
|
||||
tagName: 'ul',
|
||||
className: 'menu',
|
||||
initialize: function() {
|
||||
this.$el.html("<li>delete</li>");
|
||||
}
|
||||
});
|
||||
|
||||
Whisper.ConversationView = Backbone.View.extend({
|
||||
tagName: 'li',
|
||||
className: 'conversation',
|
||||
|
@ -42,18 +16,9 @@ var Whisper = Whisper || {};
|
|||
Mustache.parse(this.template);
|
||||
|
||||
this.listenTo(this.model, 'change', this.render); // auto update
|
||||
this.listenTo(this.model, 'message', this.addMessage); // auto update
|
||||
this.listenTo(this.model, 'destroy', this.remove); // auto update
|
||||
this.listenTo(Whisper.Messages, 'reset', this.addAllMessages); // auto update
|
||||
|
||||
this.$el.addClass('closed');
|
||||
this.$destroy = (new destroyer({model: this.model})).$el;
|
||||
|
||||
this.$image = $('<div class="image">');
|
||||
this.$name = $('<span class="name">');
|
||||
this.$header = $('<div class="header">').append(this.$image, this.$name);
|
||||
|
||||
this.$el.append(this.$header, this.$collapsable);
|
||||
},
|
||||
|
||||
sendMessage: function(e) {
|
||||
|
@ -67,37 +32,11 @@ var Whisper = Whisper || {};
|
|||
this.$el.remove();
|
||||
},
|
||||
|
||||
close: function() {
|
||||
if (!this.$el.hasClass('closed')) {
|
||||
this.$el.addClass('closed');
|
||||
}
|
||||
},
|
||||
|
||||
open: function(e) {
|
||||
this.$el.siblings().addClass('closed');
|
||||
this.$el.removeClass('closed');
|
||||
var v = new Whisper.MessageListView({collection: this.model.messages()});
|
||||
v.render();
|
||||
},
|
||||
|
||||
toggle: function() {
|
||||
if (this.$el.hasClass('closed')) {
|
||||
this.open();
|
||||
} else {
|
||||
this.close();
|
||||
}
|
||||
},
|
||||
|
||||
addMessage: function (message) {
|
||||
var view = new Whisper.MessageView({ model: message });
|
||||
this.$messages.append(view.render().el);
|
||||
},
|
||||
|
||||
addAllMessages: function () {
|
||||
this.model.messages().each(this.addMessage, this);
|
||||
this.render();
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(
|
||||
Mustache.render(this.template, {
|
||||
|
|
|
@ -3,15 +3,6 @@ var Whisper = Whisper || {};
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
var Destroyer = Backbone.View.extend({
|
||||
tagName: 'button',
|
||||
className: 'btn btn-square btn-sm',
|
||||
initialize: function() {
|
||||
this.$el.html('×');
|
||||
this.listenTo(this.$el, 'click', this.model.destroy);
|
||||
}
|
||||
});
|
||||
|
||||
Whisper.MessageView = Backbone.View.extend({
|
||||
tagName: "li",
|
||||
className: "message",
|
||||
|
|
Loading…
Reference in a new issue