mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 21:13:28 -07:00
removed backbone from VS solution,
renamed NzbDrone.Backbone to UI
This commit is contained in:
parent
c7776f74e1
commit
663160c06a
230 changed files with 57 additions and 386 deletions
60
UI/AddSeries/New/AddNewSeriesView.js
Normal file
60
UI/AddSeries/New/AddNewSeriesView.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
"use strict";
|
||||
define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'AddSeries/New/SearchResultView', 'Shared/SpinnerView'], function () {
|
||||
NzbDrone.AddSeries.New.AddNewSeriesView = Backbone.Marionette.Layout.extend({
|
||||
template: 'AddSeries/New/AddNewSeriesTemplate',
|
||||
route: 'Series/add/new',
|
||||
|
||||
ui: {
|
||||
seriesSearch: '.search input'
|
||||
},
|
||||
|
||||
regions: {
|
||||
searchResult: '#search-result'
|
||||
},
|
||||
|
||||
collection: new NzbDrone.AddSeries.SearchResultCollection(),
|
||||
|
||||
onRender: function () {
|
||||
console.log('binding auto complete');
|
||||
var self = this;
|
||||
|
||||
this.ui.seriesSearch
|
||||
.data('timeout', null)
|
||||
.keyup(function () {
|
||||
window.clearTimeout(self.$el.data('timeout'));
|
||||
self.$el.data('timeout', window.setTimeout(self.search, 500, self));
|
||||
});
|
||||
|
||||
this.resultView = new NzbDrone.AddSeries.SearchResultView({ collection: this.collection });
|
||||
},
|
||||
|
||||
search: function (context) {
|
||||
|
||||
context.abortExistingRequest();
|
||||
|
||||
var term = context.ui.seriesSearch.val();
|
||||
context.collection.reset();
|
||||
|
||||
if (term === '') {
|
||||
context.searchResult.close();
|
||||
} else {
|
||||
context.searchResult.show(new NzbDrone.Shared.SpinnerView());
|
||||
|
||||
context.currentSearchRequest = context.collection.fetch({
|
||||
data: { term: term },
|
||||
success: function () {
|
||||
context.searchResult.show(context.resultView);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
abortExistingRequest: function () {
|
||||
if (this.currentSearchRequest && this.currentSearchRequest.readyState > 0 && this.currentSearchRequest.readyState < 4) {
|
||||
console.log('aborting previous pending search request.');
|
||||
this.currentSearchRequest.abort();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue