|
|
@ -5,10 +5,11 @@ define(
|
|
|
|
'marionette',
|
|
|
|
'marionette',
|
|
|
|
'AddSeries/AddSeriesCollection',
|
|
|
|
'AddSeries/AddSeriesCollection',
|
|
|
|
'AddSeries/SearchResultCollectionView',
|
|
|
|
'AddSeries/SearchResultCollectionView',
|
|
|
|
|
|
|
|
'AddSeries/EmptyView',
|
|
|
|
'AddSeries/NotFoundView',
|
|
|
|
'AddSeries/NotFoundView',
|
|
|
|
'Shared/LoadingView',
|
|
|
|
'Shared/LoadingView',
|
|
|
|
'underscore'
|
|
|
|
'underscore'
|
|
|
|
], function (vent, Marionette, AddSeriesCollection, SearchResultCollectionView, NotFoundView, LoadingView, _) {
|
|
|
|
], function (vent, Marionette, AddSeriesCollection, SearchResultCollectionView, EmptyView, NotFoundView, LoadingView, _) {
|
|
|
|
return Marionette.Layout.extend({
|
|
|
|
return Marionette.Layout.extend({
|
|
|
|
template: 'AddSeries/AddSeriesViewTemplate',
|
|
|
|
template: 'AddSeries/AddSeriesViewTemplate',
|
|
|
|
|
|
|
|
|
|
|
@ -64,13 +65,14 @@ define(
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
self.searchResult.close();
|
|
|
|
|
|
|
|
self._abortExistingSearch();
|
|
|
|
self._abortExistingSearch();
|
|
|
|
self.throttledSearch({
|
|
|
|
self.throttledSearch({
|
|
|
|
term: self.ui.seriesSearch.val()
|
|
|
|
term: self.ui.seriesSearch.val()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._clearResults();
|
|
|
|
|
|
|
|
|
|
|
|
if (this.isExisting) {
|
|
|
|
if (this.isExisting) {
|
|
|
|
this.ui.searchBar.hide();
|
|
|
|
this.ui.searchBar.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -104,7 +106,7 @@ define(
|
|
|
|
|
|
|
|
|
|
|
|
else if (!this.isExisting) {
|
|
|
|
else if (!this.isExisting) {
|
|
|
|
this.collection.reset();
|
|
|
|
this.collection.reset();
|
|
|
|
this.searchResult.close();
|
|
|
|
this._clearResults();
|
|
|
|
this.ui.seriesSearch.val('');
|
|
|
|
this.ui.seriesSearch.val('');
|
|
|
|
this.ui.seriesSearch.focus();
|
|
|
|
this.ui.seriesSearch.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -119,6 +121,15 @@ define(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_clearResults: function () {
|
|
|
|
|
|
|
|
if (!this.isExisting) {
|
|
|
|
|
|
|
|
this.searchResult.show(new EmptyView());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
this.searchResult.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_showResults: function () {
|
|
|
|
_showResults: function () {
|
|
|
|
if (!this.isClosed) {
|
|
|
|
if (!this.isClosed) {
|
|
|
|
|
|
|
|
|
|
|
@ -139,6 +150,9 @@ define(
|
|
|
|
console.log('aborting previous pending search request.');
|
|
|
|
console.log('aborting previous pending search request.');
|
|
|
|
this.currentSearchPromise.abort();
|
|
|
|
this.currentSearchPromise.abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
this._clearResults();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|