2013-01-24 20:48:44 +00:00
|
|
|
|
/// <reference path="../../app.js" />
|
|
|
|
|
/// <reference path="RootDirModel.js" />
|
|
|
|
|
/// <reference path="RootDirCollection.js" />
|
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.RootDirItemView = Backbone.Marionette.ItemView.extend({
|
|
|
|
|
|
|
|
|
|
template: "AddSeries/RootDir/RootDirItemTemplate",
|
2013-01-25 00:02:53 +00:00
|
|
|
|
tagName: 'tr',
|
|
|
|
|
|
|
|
|
|
events: {
|
|
|
|
|
'click #remove-dir': 'removeDir',
|
|
|
|
|
},
|
2013-01-24 20:48:44 +00:00
|
|
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
|
NzbDrone.ModelBinder.bind(this.model, this.el);
|
2013-01-25 00:02:53 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
removeDir: function () {
|
|
|
|
|
this.model.destroy({ wait: true });
|
2013-01-25 01:22:14 +00:00
|
|
|
|
this.model.collection.remove(this.model);
|
2013-01-25 00:02:53 +00:00
|
|
|
|
},
|
2013-01-24 20:48:44 +00:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.RootDirListView = Backbone.Marionette.CollectionView.extend({
|
|
|
|
|
itemView: NzbDrone.AddSeries.RootDirItemView,
|
2013-01-25 00:02:53 +00:00
|
|
|
|
|
|
|
|
|
tagName: 'table',
|
|
|
|
|
className: 'table table-hover',
|
2013-01-24 20:48:44 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({
|
|
|
|
|
template: "AddSeries/RootDir/RootDirTemplate",
|
2013-01-25 00:02:53 +00:00
|
|
|
|
route: "series/add/rootdir",
|
2013-01-24 20:48:44 +00:00
|
|
|
|
|
|
|
|
|
ui: {
|
|
|
|
|
pathInput: '.path input'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
regions: {
|
|
|
|
|
currentDirs: "#current-dirs",
|
|
|
|
|
},
|
|
|
|
|
|
2013-01-25 00:02:53 +00:00
|
|
|
|
events: {
|
|
|
|
|
'click #add-dir': 'addDir',
|
|
|
|
|
},
|
|
|
|
|
|
2013-01-25 17:54:45 +00:00
|
|
|
|
shortcuts: {
|
|
|
|
|
'enter': 'addDir'
|
|
|
|
|
},
|
|
|
|
|
|
2013-01-25 00:02:53 +00:00
|
|
|
|
|
2013-01-24 20:48:44 +00:00
|
|
|
|
collection: new NzbDrone.AddSeries.RootDirCollection(),
|
|
|
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
|
var self = this;
|
|
|
|
|
|
2013-01-25 00:02:53 +00:00
|
|
|
|
//NzbDrone.Router.navigate(this.route, { trigger: true });
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
this.ui.seriesSearch
|
|
|
|
|
.data('timeout', null)
|
|
|
|
|
.keyup(function () {
|
|
|
|
|
clearTimeout(self.$el.data('timeout'));
|
|
|
|
|
self.$el.data('timeout', setTimeout(self.search, 500, self));
|
|
|
|
|
});
|
|
|
|
|
*/
|
2013-01-24 20:48:44 +00:00
|
|
|
|
|
|
|
|
|
this.currentDirs.show(new NzbDrone.AddSeries.RootDirListView({ collection: this.collection }));
|
2013-01-25 00:02:53 +00:00
|
|
|
|
|
|
|
|
|
this.collection.fetch();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addDir: function () {
|
|
|
|
|
var newDir = new NzbDrone.AddSeries.RootDirModel(
|
|
|
|
|
{
|
|
|
|
|
Path: this.ui.pathInput.val()
|
|
|
|
|
});
|
|
|
|
|
|
2013-01-29 02:00:35 +00:00
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
this.collection.create(newDir, {
|
|
|
|
|
wait: true, success: function () {
|
|
|
|
|
self.collection.fetch();
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-01-24 20:48:44 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
search: function (context) {
|
|
|
|
|
|
|
|
|
|
var term = context.ui.seriesSearch.val();
|
|
|
|
|
|
|
|
|
|
if (term == "") {
|
|
|
|
|
context.collection.reset();
|
|
|
|
|
} else {
|
|
|
|
|
console.log(term);
|
|
|
|
|
context.collection.fetch({ data: $.param({ term: term }) });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
});
|