diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index ca7bfbfae..00f032de3 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -187,6 +187,7 @@ + diff --git a/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesTemplate.html b/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesTemplate.html index bd64011d2..218317bb1 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesTemplate.html +++ b/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesTemplate.html @@ -3,4 +3,6 @@ +
+
diff --git a/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesView.js b/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesView.js index efc9477f3..ac39d12f2 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesView.js +++ b/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/AddNewSeriesView.js @@ -1,27 +1,68 @@ /// /// -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 }) }); }, }); \ No newline at end of file diff --git a/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/SearchResultTemplate.html b/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/SearchResultTemplate.html new file mode 100644 index 000000000..ea2685331 --- /dev/null +++ b/NzbDrone.Web/_backboneApp/AddSeries/AddNewSeries/SearchResultTemplate.html @@ -0,0 +1,3 @@ +
+

result

+
diff --git a/NzbDrone.Web/_backboneApp/AddSeries/SeriesSearchModel.js b/NzbDrone.Web/_backboneApp/AddSeries/SeriesSearchModel.js index 42c95ccc3..2455f703f 100644 --- a/NzbDrone.Web/_backboneApp/AddSeries/SeriesSearchModel.js +++ b/NzbDrone.Web/_backboneApp/AddSeries/SeriesSearchModel.js @@ -1,10 +1,11 @@ /// -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" });