2013-06-21 01:43:58 +00:00
|
|
|
|
'use strict';
|
|
|
|
|
define(
|
|
|
|
|
[
|
|
|
|
|
'marionette',
|
2013-06-22 00:48:23 +00:00
|
|
|
|
'AddSeries/SearchResultView',
|
|
|
|
|
'AddSeries/Collection'
|
|
|
|
|
|
|
|
|
|
], function (Marionette, SearchResultView, SearchResultCollection) {
|
2013-06-21 01:43:58 +00:00
|
|
|
|
|
|
|
|
|
return Marionette.CollectionView.extend({
|
|
|
|
|
|
2013-06-22 00:48:23 +00:00
|
|
|
|
itemView: SearchResultView,
|
|
|
|
|
|
|
|
|
|
initialize: function (options) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.isExisting = options.isExisting;
|
|
|
|
|
this.fullResult = options.fullResult;
|
|
|
|
|
|
|
|
|
|
this.listenTo(this.fullResult, 'sync', this._processResultCollection);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
showAll: function () {
|
|
|
|
|
|
|
|
|
|
this.showingAll = true;
|
|
|
|
|
this.fullResult.each(function (searchResult) {
|
|
|
|
|
this.collection.add(searchResult);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.render();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_processResultCollection: function () {
|
|
|
|
|
if (!this.showingAll && this.isExisting) {
|
|
|
|
|
this.collection = new SearchResultCollection();
|
|
|
|
|
this.collection.add(this.fullResult.shift());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
this.collection = this.fullResult;
|
|
|
|
|
}
|
2013-06-21 01:43:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-22 00:48:23 +00:00
|
|
|
|
|
2013-06-21 01:43:58 +00:00
|
|
|
|
});
|
|
|
|
|
});
|