You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sonarr/src/UI/AddSeries/Existing/AddExistingSeriesCollection...

60 lines
1.8 KiB

10 years ago
'use strict';
11 years ago
define(
[
'marionette',
'AddSeries/AddSeriesView',
11 years ago
'AddSeries/Existing/UnmappedFolderCollection'
], function (Marionette, AddSeriesView, UnmappedFolderCollection) {
11 years ago
return Marionette.CompositeView.extend({
11 years ago
itemView : AddSeriesView,
itemViewContainer: '.x-loading-folders',
template : 'AddSeries/Existing/AddExistingSeriesCollectionViewTemplate',
ui: {
loadingFolders: '.x-loading-folders'
},
11 years ago
initialize: function () {
this.collection = new UnmappedFolderCollection();
this.collection.importItems(this.model);
},
showCollection: function () {
this._showAndSearch(0);
},
appendHtml: function(collectionView, itemView, index){
collectionView.ui.loadingFolders.before(itemView.el);
},
11 years ago
_showAndSearch: function (index) {
var self = this;
11 years ago
var model = this.collection.at(index);
11 years ago
if (model) {
var currentIndex = index;
var folderName = model.get('folder').name;
11 years ago
this.addItemView(model, this.getItemView(), index);
this.children.findByModel(model)
.search({term: folderName})
.always(function () {
if (!self.isClosed) {
self._showAndSearch(currentIndex + 1);
}
});
11 years ago
}
else {
this.ui.loadingFolders.hide();
}
},
itemViewOptions: {
isExisting: true
11 years ago
}
});
});