95% done with hiding existing movies

This commit is contained in:
Tim Turner
2017-01-14 23:04:31 -05:00
parent 8c8c7a99e3
commit 7c5f2ca54e
9 changed files with 66 additions and 12 deletions

View File

@@ -1,12 +1,21 @@
var Marionette = require('marionette');
var SearchResultView = require('./SearchResultView');
var vent = require('vent');
module.exports = Marionette.CollectionView.extend({
itemView : SearchResultView,
initialize : function(options) {
this.showExisting = true;
this.isExisting = options.isExisting;
this.showing = 1;
vent.on(vent.Commands.ShowExistingCommand, this._onExistingToggle.bind(this));
},
_onExistingToggle : function(data) {
this.showExisting = data.showExisting;
this.render();
},
showAll : function() {
@@ -34,8 +43,17 @@ module.exports = Marionette.CollectionView.extend({
},
appendHtml : function(collectionView, itemView, index) {
if (!this.isExisting || index < this.showing || index === 0) {
collectionView.$el.append(itemView.el);
if(this.isExisting) {
if(this.showExisting) {
if (index < this.showing || index === 0) {
collectionView.$el.append(itemView.el);
}
}
} else if(!this.isExisting) {
if (index < this.showing || index === 0) {
collectionView.$el.append(itemView.el);
}
}
}
});