mirror of https://github.com/lidarr/Lidarr
added add series search model/collections
This commit is contained in:
parent
d110cf2633
commit
c247406d67
|
@ -187,6 +187,7 @@
|
|||
<Compile Include="App_Start\MiniProfiler.cs" />
|
||||
<Content Include="_backboneApp\AddSeries\AddNewSeries\AddNewSeriesTemplate.html" />
|
||||
<Content Include="_backboneApp\AddSeries\AddNewSeries\AddNewSeriesView.js" />
|
||||
<Content Include="_backboneApp\AddSeries\AddNewSeries\SearchResultTemplate.html" />
|
||||
<Content Include="_backboneApp\AddSeries\SeriesSearchModel.js" />
|
||||
<Content Include="_backboneApp\Content\Intelisense\bootstrap.css" />
|
||||
<Content Include="_backboneApp\JsLibraries\backbone.marionette.extend.js" />
|
||||
|
|
|
@ -3,4 +3,6 @@
|
|||
<i class="add-on icon-search"></i>
|
||||
<input type="text" class="span10" placeholder="Start typing the name of series you want to add ...">
|
||||
</div>
|
||||
<div id="search-result">
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,27 +1,68 @@
|
|||
/// <reference path="../../app.js" />
|
||||
/// <reference path="../SeriesSearchModel.js" />
|
||||
|
||||
NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.ItemView.extend({
|
||||
NzbDrone.AddSeries.SearchItemView = Backbone.Marionette.ItemView.extend({
|
||||
|
||||
tagName: 'li',
|
||||
template: "AddSeries/AddNewSeries/SearchResultTemplate",
|
||||
itemView: NzbDrone.AddSeries.SearchResultModel,
|
||||
|
||||
|
||||
initialize: function () {
|
||||
|
||||
this.collection = new NzbDrone.AddSeries.SearchResultCollection();
|
||||
this.bindTo(this.collection, 'reset', this.render);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend({
|
||||
|
||||
tagName: 'ul',
|
||||
className: 'result',
|
||||
itemView: NzbDrone.AddSeries.SearchResultModel,
|
||||
|
||||
collection : new NzbDrone.AddSeries.SearchResultCollection(),
|
||||
|
||||
initialize: function () {
|
||||
//this.collection = new NzbDrone.AddSeries.SearchResultCollection();
|
||||
this.listenTo(this.collection, 'reset', this.render);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({
|
||||
template: "AddSeries/AddNewSeries/AddNewSeriesTemplate",
|
||||
|
||||
ui: {
|
||||
seriesSearch: '.search input'
|
||||
},
|
||||
|
||||
onRender: function() {
|
||||
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() {
|
||||
.keyup(function () {
|
||||
clearTimeout(self.$el.data('timeout'));
|
||||
self.$el.data('timeout', setTimeout(self.search, 500, self));
|
||||
});
|
||||
|
||||
this.searchResult.show(new NzbDrone.AddSeries.SearchResultView());
|
||||
},
|
||||
|
||||
search: function (context) {
|
||||
|
||||
search: function(context) {
|
||||
console.log(context.ui.seriesSearch.val());
|
||||
var term = context.ui.seriesSearch.val();
|
||||
console.log(term);
|
||||
context.collection.fetch({ data: $.param({ term: term }) });
|
||||
},
|
||||
});
|
|
@ -0,0 +1,3 @@
|
|||
<div>
|
||||
<h3>result</h3>
|
||||
</div>
|
|
@ -1,10 +1,11 @@
|
|||
/// <reference path="../app.js" />
|
||||
|
||||
NzbDrone.AddSeries.SeriesSearchResultModel = Backbone.Model.extend({
|
||||
NzbDrone.AddSeries.SearchResultModel = Backbone.Model.extend({
|
||||
|
||||
});
|
||||
|
||||
NzbDrone.AddSeries.SeriesSearchResultCollection = Backbone.Collection.extend({
|
||||
|
||||
NzbDrone.AddSeries.SearchResultCollection = Backbone.Collection.extend({
|
||||
model: NzbDrone.AddSeries.SearchResultModel,
|
||||
url: "http://localhost/api/v1/series/lookup"
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue