moved most of addseries to use require.js

pull/4/head
Keivan Beigi 11 years ago committed by kay.one
parent 5e26596623
commit 52d815b1d4

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram />

@ -204,12 +204,14 @@
<Content Include="_backboneApp\AddSeries\Existing\ImportSeriesView.js" />
<Content Include="_backboneApp\AddSeries\Existing\UnmappedFolderModel.js" />
<Content Include="_backboneApp\AddSeries\Existing\RootFolderCompositeViewTemplate.html" />
<Content Include="_backboneApp\AddSeries\RootFolders\RootDirTemplate.html" />
<Content Include="_backboneApp\AddSeries\RootFolders\RootDirView.js" />
<Content Include="_backboneApp\AddSeries\RootFolders\RootDirItemTemplate.html" />
<Content Include="_backboneApp\AddSeries\RootFolders\RootDirModel.js" />
<Content Include="_backboneApp\AddSeries\RootFolders\RootDirCollection.js" />
<Content Include="_backboneApp\AddSeries\RootFolders\RootFolderTemplate.html" />
<Content Include="_backboneApp\AddSeries\RootFolders\RootFolderView.js" />
<Content Include="_backboneApp\AddSeries\RootFolders\RootFolderItemTemplate.html" />
<Content Include="_backboneApp\AddSeries\RootFolders\RootFolderModel.js" />
<Content Include="_backboneApp\AddSeries\RootFolders\RootFolderCollection.js" />
<Content Include="_backboneApp\Content\jquery.dataTables.bootstrap.css" />
<Content Include="_backboneApp\JsLibraries\jquery.js" />
<Content Include="_backboneApp\Routing.js" />
<Content Include="_backboneApp\JsLibraries\backbone.modelbinder.js" />
<Content Include="_backboneApp\AddSeries\New\AddNewSeriesTemplate.html" />
<Content Include="_backboneApp\AddSeries\New\AddNewSeriesView.js" />
@ -220,6 +222,7 @@
<Content Include="_backboneApp\JsLibraries\jquery.dataTables.extensions.js" />
<Content Include="_backboneApp\JsLibraries\jquery.dataTables-1.10.0-dev.js" />
<Content Include="_backboneApp\JsLibraries\jquery.dataTables.bootstrap.pagination.js" />
<Content Include="_backboneApp\JsLibraries\require-jquery.js" />
<Content Include="_backboneApp\Quality\qualityProfileModel.js" />
<Content Include="_backboneApp\Quality\qualityProfileCollection.js" />
<Content Include="_backboneApp\Quality\qualityTypeModel.js" />
@ -432,11 +435,11 @@
<Content Include="_backboneApp\Shared\SpinnerTemplate.html" />
<Content Include="_backboneApp\Shared\SpinnerView.js" />
<Content Include="Eloquera.config" />
<Content Include="ClassDiagram1.cd" />
<None Include="_backboneApp\JsLibraries\jquery-1.8.2.intellisense.js" />
<Content Include="_backboneApp\JsLibraries\backbone.collectionbinder.js" />
<Content Include="_backboneApp\JsLibraries\backbone.debug.js" />
<Content Include="_backboneApp\JsLibraries\handlebars.js" />
<Content Include="_backboneApp\JsLibraries\jquery.js" />
<Content Include="_backboneApp\JsLibraries\jquery-ui-1.9.0.js" />
<Content Include="_backboneApp\JsLibraries\backbone.marionette.viewswapper.js" />
<Content Include="_backboneApp\JsLibraries\sugar.js" />

@ -4,12 +4,10 @@
@using Cassette.Scripts
@using Cassette.Stylesheets
@using NzbDrone.Web
@using NzbDrone.Web.Backbone.NzbDrone
@using NzbDrone.Web.Helpers
@{
Bundles.Reference<StylesheetBundle>(CassetteBundleConfiguration.BASE_STYLE);
Bundles.Reference<ScriptBundle>(CassetteBundleConfiguration.NZBDRONE);
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@ -45,7 +43,7 @@
</div>
<div id="logo" class="row">
<div class="span18 offset2">
Single page
Single page
</div>
</div>
<div id="content" class="row">
@ -65,9 +63,7 @@
<div id="footer-region" class="span20"></div>
</div>
</div>
@Bundles.RenderScripts()
<script type="text/javascript">
NzbDrone.start();
</script>
<script data-main="/_backboneApp/app" src="/_backboneApp/JsLibraries/require-jquery.js"></script>
<script src="/_backboneApp/Routing.js"></script>
</body>
</html>

@ -1,111 +1,111 @@
/// <reference path="../app.js" />
/// <reference path="New/AddNewSeriesView.js" />
/// <reference path="RootFolders/RootDirView.js" />
/// <reference path="../Quality/qualityProfileCollection.js" />
/// <reference path="../Shared/SpinnerView.js" />
/// <reference path="Existing/ImportSeriesView.js" />
NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
template: 'AddSeries/addSeriesLayoutTemplate',
regions: {
addNew: '#add-new',
importExisting: '#import-existing',
rootFolders: '#root-folders'
},
ui: {
addNewTab: '.x-add-new-tab',
importExistingTab: '.x-import-existing-tab',
rootFoldersTab: '.x-root-folders-tab'
},
events: {
'click .x-add-new-tab': 'showAddNew',
'click .x-import-existing-tab': 'showImport',
'click .x-root-folders-tab': 'showRootFolders'
},
showAddNew: function (e) {
if (e) {
e.preventDefault();
}
this.ui.addNewTab.tab('show');
NzbDrone.Router.navigate('series/add/new');
},
showImport: function (e) {
if (e) {
e.preventDefault();
}
this.ui.importExistingTab.tab('show');
NzbDrone.Router.navigate('series/add/import');
},
showRootFolders: function (e) {
if (e) {
e.preventDefault();
}
this.ui.rootFoldersTab.tab('show');
NzbDrone.Router.navigate('series/add/rootfolders');
},
rootFolderCollection: new NzbDrone.AddSeries.RootDirCollection(),
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
initialize: function (context, action, query) {
if (action) {
this.action = action.toLowerCase();
}
if (query) {
this.query = query.toLowerCase();
}
},
onRender: function () {
this.qualityProfileCollection.fetch();
this.rootFolderCollection.fetch();
this.addNew.show(new NzbDrone.AddSeries.AddNewSeriesView({ rootFolders: this.rootFolderCollection, qualityProfiles: this.qualityProfileCollection }));
this.importExisting.show(new NzbDrone.AddSeries.Existing.ImportSeriesView({ collection: this.rootFolderCollection, quality: this.qualityProfileCollection }));
this.rootFolders.show(new NzbDrone.AddSeries.RootDirView({ collection: this.rootFolderCollection }));
this.listenTo(this.rootFolderCollection, 'add', this.evaluateActions, this);
this.listenTo(this.rootFolderCollection, 'remove', this.evaluateActions, this);
this.listenTo(this.rootFolderCollection, 'reset', this.evaluateActions, this);
},
onShow: function () {
switch (this.action) {
case 'import':
this.showImport();
break;
case 'rootfolders':
this.showRootFolders();
break;
default:
this.showAddNew();
}
},
evaluateActions: function () {
if (this.rootFolderCollection.length === 0) {
this.ui.addNewTab.hide();
this.ui.importExistingTab.hide();
this.showRootFolders();
} else {
this.ui.addNewTab.show();
this.ui.importExistingTab.show();
}
},
});
define([
'app',
'AddSeries/RootFolders/RootFolderView',
'AddSeries/RootFolders/RootFolderCollection',
'AddSeries/New/AddNewSeriesView',
'AddSeries/Existing/ImportSeriesView',
'Quality/QualityProfileCollection'
],
function () {
NzbDrone.AddSeries.AddSeriesLayout = Backbone.Marionette.Layout.extend({
template: 'AddSeries/addSeriesLayoutTemplate',
regions: {
addNew: '#add-new',
importExisting: '#import-existing',
rootFolders: '#root-folders'
},
ui: {
addNewTab: '.x-add-new-tab',
importExistingTab: '.x-import-existing-tab',
rootFoldersTab: '.x-root-folders-tab'
},
events: {
'click .x-add-new-tab': 'showAddNew',
'click .x-import-existing-tab': 'showImport',
'click .x-root-folders-tab': 'showRootFolders'
},
showAddNew: function (e) {
if (e) {
e.preventDefault();
}
this.ui.addNewTab.tab('show');
NzbDrone.Router.navigate('series/add/new');
},
showImport: function (e) {
if (e) {
e.preventDefault();
}
this.ui.importExistingTab.tab('show');
NzbDrone.Router.navigate('series/add/import');
},
showRootFolders: function (e) {
if (e) {
e.preventDefault();
}
this.ui.rootFoldersTab.tab('show');
NzbDrone.Router.navigate('series/add/rootfolders');
},
rootFolderCollection: new NzbDrone.AddSeries.RootFolders.RootFolderCollection(),
qualityProfileCollection: new NzbDrone.Quality.QualityProfileCollection(),
initialize: function (context, action, query) {
if (action) {
this.action = action.toLowerCase();
}
if (query) {
this.query = query.toLowerCase();
}
},
onRender: function () {
this.qualityProfileCollection.fetch();
this.rootFolderCollection.fetch();
this.addNew.show(new NzbDrone.AddSeries.New.AddNewSeriesView({ rootFolders: this.rootFolderCollection, qualityProfiles: this.qualityProfileCollection }));
this.importExisting.show(new NzbDrone.AddSeries.Existing.ImportSeriesView({ collection: this.rootFolderCollection, quality: this.qualityProfileCollection }));
this.rootFolders.show(new NzbDrone.AddSeries.RootDirView({ collection: this.rootFolderCollection }));
this.listenTo(this.rootFolderCollection, 'add', this.evaluateActions, this);
this.listenTo(this.rootFolderCollection, 'remove', this.evaluateActions, this);
this.listenTo(this.rootFolderCollection, 'reset', this.evaluateActions, this);
},
onShow: function () {
switch (this.action) {
case 'import':
this.showImport();
break;
case 'rootfolders':
this.showRootFolders();
break;
default:
this.showAddNew();
}
},
evaluateActions: function () {
if (this.rootFolderCollection.length === 0) {
this.ui.addNewTab.hide();
this.ui.importExistingTab.hide();
this.showRootFolders();
} else {
this.ui.addNewTab.show();
this.ui.importExistingTab.show();
}
},
});
});

@ -1,154 +1,149 @@
'use strict';
/// <reference path="../../app.js" />
/// <reference path="UnmappedFolderModel.js" />
/// <reference path="../../Series/SeriesModel.js" />
/// <reference path="../SearchResultCollection.js" />
define(['app', 'AddSeries/Existing/UnmappedFolderModel', 'AddSeries/SearchResultCollection', 'Series/SeriesModel'], function () {
NzbDrone.AddSeries.Existing.FolderMatchResultView = Backbone.Marionette.ItemView.extend({
template: 'AddSeries/Existing/FolderMatchResultViewTemplatate',
events: {
'click .x-btn-add': 'addSeries'
},
NzbDrone.AddSeries.Existing.FolderMatchResultView = Backbone.Marionette.ItemView.extend({
template: 'AddSeries/Existing/FolderMatchResultViewTemplatate',
addSeries: function () {
events: {
'click .x-btn-add': 'addSeries'
},
var seriesId = this.model.get('id');
var title = this.model.get('seriesName');
var quality = this.options.qualityProfile.val();
var path = this.options.rootFolder + "\\" + title;
addSeries: function () {
var model = new NzbDrone.Series.SeriesModel({
seriesId: seriesId,
title: title,
qualityProfileId: quality,
path: path
});
var seriesId = this.model.get('id');
var title = this.model.get('seriesName');
var quality = this.options.qualityProfile.val();
var path = this.options.rootFolder + "\\" + title;
var self = this;
var model = new NzbDrone.Series.SeriesModel({
seriesId: seriesId,
title: title,
qualityProfileId: quality,
path: path
});
model.save(undefined, {
success: function () {
var notificationModel = new NzbDrone.Shared.NotificationModel({
title: 'Added',
message: title,
level: 'success'
});
var self = this;
NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(notificationModel);
self.close();
}
});
}
});
model.save(undefined, {
success: function () {
var notificationModel = new NzbDrone.Shared.NotificationModel({
title: 'Added',
message: title,
level: 'success'
});
NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView = Backbone.Marionette.CompositeView.extend({
template: 'AddSeries/Existing/UnmappedFolderCompositeViewTemplatate',
itemViewContainer: '.x-folder-name-match-results',
itemView: NzbDrone.AddSeries.Existing.FolderMatchResultView,
NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(notificationModel);
self.close();
}
});
}
events: {
'click .x-btn-search': 'search'
},
});
ui: {
searchButton: '.x-btn-search',
searchText: '.x-txt-search',
profileList: '.x-lst-quality-profile'
},
NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView = Backbone.Marionette.CompositeView.extend({
initialize: function () {
this.collection = new NzbDrone.AddSeries.SearchResultCollection();
},
template: 'AddSeries/Existing/UnmappedFolderCompositeViewTemplatate',
itemViewContainer: '.x-folder-name-match-results',
itemView: NzbDrone.AddSeries.Existing.FolderMatchResultView,
search: function () {
events: {
'click .x-btn-search': 'search'
},
var icon = this.ui.searchButton.find('icon');
ui: {
searchButton: '.x-btn-search',
searchText: '.x-txt-search',
profileList: '.x-lst-quality-profile'
},
icon.removeClass('icon-search').addClass('icon-spin icon-spinner disabled');
initialize: function () {
this.collection = new NzbDrone.AddSeries.SearchResultCollection();
},
var self = this;
search: function () {
this.collection.fetch({
data: $.param({ term: this.ui.searchText.val() }),
success: function (model) {
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
var icon = this.ui.searchButton.find('icon');
},
fail: function () {
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
}
});
},
icon.removeClass('icon-search').addClass('icon-spin icon-spinner disabled');
itemViewOptions: function () {
return {
qualityProfile: this.ui.profileList,
rootFolder: this.model.get('rootFolder')
};
}
var self = this;
this.collection.fetch({
data: $.param({ term: this.ui.searchText.val() }),
success: function (model) {
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
},
fail: function () {
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
}
});
},
});
itemViewOptions: function () {
return {
qualityProfile: this.ui.profileList,
rootFolder: this.model.get('rootFolder')
};
}
NzbDrone.AddSeries.Existing.RootFolderCompositeView = Backbone.Marionette.CompositeView.extend({
template: "AddSeries/Existing/RootFolderCompositeViewTemplate",
itemViewContainer: ".x-existing-folder-container",
itemView: NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView,
initialize: function () {
});
if (!this.model) {
throw "model is required.";
}
NzbDrone.AddSeries.Existing.RootFolderCompositeView = Backbone.Marionette.CompositeView.extend({
if (!this.options.quality) {
throw "quality collection is required.";
}
template: "AddSeries/Existing/RootFolderCompositeViewTemplate",
itemViewContainer: ".x-existing-folder-container",
itemView: NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView,
this.collection = new NzbDrone.AddSeries.Existing.UnmappedFolderCollection();
this.refreshItems();
this.listenTo(this.options.quality, 'reset', this.refreshItems, this);
},
initialize: function () {
refreshItems: function () {
this.collection.importItems(this.model, this.options.quality);
if (!this.model) {
throw "model is required.";
}
},
if (!this.options.quality) {
throw "quality collection is required.";
}
this.collection = new NzbDrone.AddSeries.Existing.UnmappedFolderCollection();
this.refreshItems();
this.listenTo(this.options.quality, 'reset', this.refreshItems, this);
},
refreshItems: function () {
this.collection.importItems(this.model, this.options.quality);
});
},
NzbDrone.AddSeries.Existing.ImportSeriesView = Backbone.Marionette.CollectionView.extend({
itemView: NzbDrone.AddSeries.Existing.RootFolderCompositeView,
});
NzbDrone.AddSeries.Existing.ImportSeriesView = Backbone.Marionette.CollectionView.extend({
initialize: function () {
itemView: NzbDrone.AddSeries.Existing.RootFolderCompositeView,
if (!this.collection) {
throw "root folder collection is required.";
}
if (!this.options.quality) {
throw "quality collection is required.";
}
this.itemViewOptions = {
quality: this.options.quality
};
}
initialize: function () {
if (!this.collection) {
throw "root folder collection is required.";
}
if (!this.options.quality) {
throw "quality collection is required.";
}
this.itemViewOptions = {
quality: this.options.quality
};
}
});
});

@ -1,34 +1,35 @@
'use strict';
/// <reference path="../../app.js" />
NzbDrone.AddSeries.Existing.UnmappedFolderModel = Backbone.Model.extend({
define(['app'], function () {
});
NzbDrone.AddSeries.Existing.UnmappedFolderCollection = Backbone.Collection.extend({
model: NzbDrone.AddSeries.Existing.UnmappedFolderModel,
NzbDrone.AddSeries.Existing.UnmappedFolderModel = Backbone.Model.extend({
importItems: function (rootFolderModel, quality) {
});
if (!rootFolderModel) {
throw "folder array is required";
}
NzbDrone.AddSeries.Existing.UnmappedFolderCollection = Backbone.Collection.extend({
model: NzbDrone.AddSeries.Existing.UnmappedFolderModel,
if (!quality) {
throw "quality is required";
}
this.reset();
importItems: function (rootFolderModel, quality) {
var qualityCollection = quality;
var rootFolder = rootFolderModel.get('path');
if (!rootFolderModel) {
throw "folder array is required";
}
_.each(rootFolderModel.get('unmappedFolders'), function (folder) {
this.push(new NzbDrone.AddSeries.Existing.UnmappedFolderModel({rootFolder:rootFolder, folder: folder, quality: qualityCollection }));
}, this);
}
});
if (!quality) {
throw "quality is required";
}
this.reset();
var qualityCollection = quality;
var rootFolder = rootFolderModel.get('path');
_.each(rootFolderModel.get('unmappedFolders'), function (folder) {
this.push(new NzbDrone.AddSeries.Existing.UnmappedFolderModel({ rootFolder: rootFolder, folder: folder, quality: qualityCollection }));
}, this);
}
});
});

@ -1,84 +1,83 @@
'use strict;'
/// <reference path="../../app.js" />
/// <reference path="SearchResultView.js" />
define(['app', 'AddSeries/New/SearchResultView'], function () {
NzbDrone.AddSeries.AddNewSeriesView = Backbone.Marionette.Layout.extend({
template: 'AddSeries/New/AddNewSeriesTemplate',
route: 'Series/add/new',
NzbDrone.AddSeries.New.AddNewSeriesView = Backbone.Marionette.Layout.extend({
template: 'AddSeries/New/AddNewSeriesTemplate',
route: 'Series/add/new',
ui: {
seriesSearch: '.search input'
},
ui: {
seriesSearch: '.search input'
},
regions: {
searchResult: '#search-result',
},
regions: {
searchResult: '#search-result',
},
collection: new NzbDrone.AddSeries.SearchResultCollection(),
collection: new NzbDrone.AddSeries.SearchResultCollection(),
initialize: function (options) {
if (options.rootFolders === undefined) {
throw 'rootFolder arg. is required.';
}
initialize: function (options) {
if (options.rootFolders === undefined) {
throw 'rootFolder arg. is required.';
}
if (options.qualityProfiles === undefined) {
throw 'qualityProfiles arg. is required.';
}
if (options.qualityProfiles === undefined) {
throw 'qualityProfiles arg. is required.';
}
this.rootFoldersCollection = options.rootFolders;
this.qualityProfileCollection = options.qualityProfiles;
},
this.rootFoldersCollection = options.rootFolders;
this.qualityProfileCollection = options.qualityProfiles;
},
onRender: function () {
console.log('binding auto complete');
var self = this;
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.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.show(new NzbDrone.Shared.SpinnerView());
context.currentSearchRequest = context.collection.fetch({
data: $.param({ term: term }),
success: function (model) {
context.resultUpdated(model, context);
}
});
this.resultView = new NzbDrone.AddSeries.SearchResultView({ collection: this.collection });
},
} else {
context.searchResult.close();
}
},
search: function (context) {
abortExistingRequest : function () {
if (this.currentSearchRequest && this.currentSearchRequest.readyState > 0 && this.currentSearchRequest.readyState < 4) {
console.log('aborting previous pending search request.');
this.currentSearchRequest.abort();
}
},
context.abortExistingRequest();
var term = context.ui.seriesSearch.val();
context.collection.reset();
if (term !== '') {
context.searchResult.show(new NzbDrone.Shared.SpinnerView());
resultUpdated: function (options, context) {
_.each(options.models, function (model) {
model.set('rootFolders', context.rootFoldersCollection);
model.set('qualityProfiles', context.qualityProfileCollection);
});
context.currentSearchRequest = context.collection.fetch({
data: $.param({ term: term }),
success: function (model) {
context.resultUpdated(model, context);
}
});
context.searchResult.show(context.resultView);
}
});
} else {
context.searchResult.close();
}
},
abortExistingRequest: function () {
if (this.currentSearchRequest && this.currentSearchRequest.readyState > 0 && this.currentSearchRequest.readyState < 4) {
console.log('aborting previous pending search request.');
this.currentSearchRequest.abort();
}
},
resultUpdated: function (options, context) {
_.each(options.models, function (model) {
model.set('rootFolders', context.rootFoldersCollection);
model.set('qualityProfiles', context.qualityProfileCollection);
});
context.searchResult.show(context.resultView);
}
});
});

@ -1,71 +1,69 @@
'use strict';
/*global NzbDrone, Backbone*/
/// <reference path="../../app.js" />
/// <reference path="../SearchResultModel.js" />
/// <reference path="../../Series/SeriesModel.js" />
/// <reference path="../SearchResultCollection.js" />
NzbDrone.AddSeries.SearchItemView = Backbone.Marionette.ItemView.extend({
template: "AddSeries/New/SearchResultTemplate",
className: 'search-item',
ui: {
qualityProfile: '.x-quality-profile',
rootFolder: '.x-root-folder',
addButton: '.x-add'
},
events: {
'click .x-add': 'add'
},
onRender: function () {
this.listenTo(this.model, 'change', this.render);
},
add: function () {
var seriesId = this.model.get('id');
var title = this.model.get('seriesName');
var quality = this.ui.qualityProfile.val();
var rootFolderId = this.ui.rootFolder.val();
//Todo: This wiil create an invalid path on linux...
var rootPath = this.model.get('rootFolders').get(rootFolderId).get('path');
var path = rootPath + "\\" + title;
var model = new NzbDrone.Series.SeriesModel({
seriesId: seriesId,
title: title,
qualityProfileId: quality,
path: path
});
var self = this;
model.save(undefined, {
success: function () {
var notificationModel = new NzbDrone.Shared.NotificationModel({
title: 'Added',
message: title,
level: 'success'
});
NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(notificationModel);
self.close();
}
});
}
});
NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend({
define(['app', 'AddSeries/SearchResultCollection', 'AddSeries/SearchResultModel', 'Series/SeriesModel'], function () {
NzbDrone.AddSeries.New.SearchItemView = Backbone.Marionette.ItemView.extend({
template: "AddSeries/New/SearchResultTemplate",
className: 'search-item',
ui: {
qualityProfile: '.x-quality-profile',
rootFolder: '.x-root-folder',
addButton: '.x-add'
},
events: {
'click .x-add': 'add'
},
onRender: function () {
this.listenTo(this.model, 'change', this.render);
},
add: function () {
var seriesId = this.model.get('id');
var title = this.model.get('seriesName');
var quality = this.ui.qualityProfile.val();
var rootFolderId = this.ui.rootFolder.val();
//Todo: This wiil create an invalid path on linux...
var rootPath = this.model.get('rootFolders').get(rootFolderId).get('path');
var path = rootPath + "\\" + title;
var model = new NzbDrone.Series.SeriesModel({
seriesId: seriesId,
title: title,
qualityProfileId: quality,
path: path
});
var self = this;
model.save(undefined, {
success: function () {
var notificationModel = new NzbDrone.Shared.NotificationModel({
title: 'Added',
message: title,
level: 'success'
});
NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(notificationModel);
self.close();
}
});
}
});
NzbDrone.AddSeries.SearchResultView = Backbone.Marionette.CollectionView.extend({
itemView: NzbDrone.AddSeries.SearchItemView,
itemView: NzbDrone.AddSeries.SearchItemView,
className: 'accordion',
className: 'accordion',
initialize: function () {
this.listenTo(this.collection, 'reset', this.render);
}
initialize: function () {
this.listenTo(this.collection, 'reset', this.render);
}
});
});

@ -1,8 +0,0 @@
/// <reference path="../../app.js" />
/// <reference path="RootDirModel.js" />
NzbDrone.AddSeries.RootDirCollection = Backbone.Collection.extend({
url: NzbDrone.Constants.ApiRoot + '/rootdir',
model: NzbDrone.AddSeries.RootDirModel,
});

@ -1,13 +0,0 @@
/// <reference path="../../app.js" />
NzbDrone.AddSeries.RootDirModel = Backbone.Model.extend({
mutators: {
freeSpaceString: function () {
return this.get('freeSpace').bytes(2) + " Free";
}
},
defaults: {
freeSpace: 0,
}
});

@ -1,90 +0,0 @@
'use strict;'
/// <reference path="../../app.js" />
/// <reference path="RootDirModel.js" />
/// <reference path="RootDirCollection.js" />
/// <reference path="../../Shared/AutoComplete.js" />
NzbDrone.AddSeries.RootDirItemView = Backbone.Marionette.ItemView.extend({
template: 'AddSeries/RootFolders/RootDirItemTemplate',
tagName: 'tr',
events: {
'click .x-remove': 'removeFolder',
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
removeFolder: function () {
this.model.destroy({ wait: true });
this.model.collection.remove(this.model);
},
});
NzbDrone.AddSeries.RootDirListView = Backbone.Marionette.CollectionView.extend({
itemView: NzbDrone.AddSeries.RootDirItemView,
tagName: 'table',
className: 'table table-hover',
});
NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({
template: 'AddSeries/RootFolders/RootDirTemplate',
route: 'series/add/rootdir',
ui: {
pathInput: '.x-path input'
},
regions: {
currentDirs: '#current-dirs',
},
events: {
'click .x-add': 'addFolder',
},
collection: new NzbDrone.AddSeries.RootDirCollection(),
onRender: function () {
this.currentDirs.show(new NzbDrone.AddSeries.RootDirListView({ collection: this.collection }));
this.collection.fetch();
this.ui.pathInput.folderAutoComplete();
},
addFolder: function () {
var newDir = new NzbDrone.AddSeries.RootDirModel(
{
Path: this.ui.pathInput.val()
});
var self = this;
this.collection.create(newDir, {
wait: true, success: function () {
self.collection.fetch();
}
});
},
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 }) });
}
},
});

@ -0,0 +1,10 @@
define(['app', 'AddSeries/RootFolders/RootFolderModel'], function () {
NzbDrone.AddSeries.RootFolders.RootFolderCollection = Backbone.Collection.extend({
url: NzbDrone.Constants.ApiRoot + '/rootdir',
model: NzbDrone.AddSeries.RootFolders.RootFolderModel,
});
});

@ -0,0 +1,13 @@
define(['app'], function () {
NzbDrone.AddSeries.RootFolders.RootFolderModel = Backbone.Model.extend({
mutators: {
freeSpaceString: function () {
return this.get('freeSpace').bytes(2) + " Free";
}
},
defaults: {
freeSpace: 0,
}
});
});

@ -0,0 +1,91 @@
'use strict;'
define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'Shared/AutoComplete'], function () {
NzbDrone.AddSeries.RootFolderItemView = Backbone.Marionette.ItemView.extend({
template: 'AddSeries/RootFolders/RootFolderItemTemplate',
tagName: 'tr',
events: {
'click .x-remove': 'removeFolder',
},
onRender: function () {
NzbDrone.ModelBinder.bind(this.model, this.el);
},
removeFolder: function () {
this.model.destroy({ wait: true });
this.model.collection.remove(this.model);
},
});
NzbDrone.AddSeries.RootDirListView = Backbone.Marionette.CollectionView.extend({
itemView: NzbDrone.AddSeries.RootFolderItemView,
tagName: 'table',
className: 'table table-hover',
});
NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({
template: 'AddSeries/RootFolders/RootFolderTemplate',
route: 'series/add/rootdir',
ui: {
pathInput: '.x-path input'
},
regions: {
currentDirs: '#current-dirs',
},
events: {
'click .x-add': 'addFolder',
},
collection: new NzbDrone.AddSeries.RootFolders.RootFolderCollection(),
onRender: function () {
this.currentDirs.show(new NzbDrone.AddSeries.RootDirListView({ collection: this.collection }));
this.collection.fetch();
this.ui.pathInput.folderAutoComplete();
},
addFolder: function () {
var newDir = new NzbDrone.AddSeries.RootFolders.RootFolderModel(
{
Path: this.ui.pathInput.val()
});
var self = this;
this.collection.create(newDir, {
wait: true, success: function () {
self.collection.fetch();
}
});
},
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 }) });
}
},
});
});

@ -1,10 +1,10 @@
/// <reference path="../app.js" />
/// <reference path="SearchResultModel.js" />
"use strict";
"use strict";
define(['app', 'AddSeries/SearchResultModel'], function () {
NzbDrone.AddSeries.SearchResultCollection = Backbone.Collection.extend({
url: NzbDrone.Constants.ApiRoot + '/series/lookup',
model: NzbDrone.AddSeries.SearchResultModel
});
});
NzbDrone.AddSeries.SearchResultCollection = Backbone.Collection.extend({
url: NzbDrone.Constants.ApiRoot + '/series/lookup',
model: NzbDrone.AddSeries.SearchResultModel
});

@ -1,23 +1,25 @@
/// <reference path="../app.js" />
/// <reference path="RootFolders/RootDirCollection.js" />
/// <reference path="../Quality/qualityProfileCollection.js" />
NzbDrone.AddSeries.SearchResultModel = Backbone.Model.extend({
mutators: {
seriesYear: function () {
var date = Date.utc.create(this.get('firstAired')).format('({yyyy})');
define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'Quality/QualityProfileCollection'], function () {
//don't append year, if the series name already has the name appended.
if (this.get('seriesName').endsWith(date)) {
return "";
} else {
return date;
NzbDrone.AddSeries.SearchResultModel = Backbone.Model.extend({
mutators: {
seriesYear: function () {
var date = Date.utc.create(this.get('firstAired')).format('({yyyy})');
//don't append year, if the series name already has the name appended.
if (this.get('seriesName').endsWith(date)) {
return "";
} else {
return date;
}
}
},
defaults: {
qualityProfiles: new NzbDrone.Quality.QualityProfileCollection(),
rootFolders: new NzbDrone.AddSeries.RootFolders.RootFolderModel()
}
},
defaults: {
qualityProfiles: new NzbDrone.Quality.QualityProfileCollection(),
rootFolders: new NzbDrone.AddSeries.RootDirCollection()
}
});
});

@ -8,7 +8,7 @@ namespace NzbDrone.Web.Backbone.NzbDrone
public class CassetteBundleConfiguration : IConfiguration<BundleCollection>
{
public const string BASE_STYLE = "BASE_STYLE";
public const string NZBDRONE = "NZBDRONE";
//public const string NZBDRONE = "NZBDRONE";
internal const string FONTS = "FONTS";
private const string APP_PATH = "_backboneApp";
@ -17,7 +17,7 @@ namespace NzbDrone.Web.Backbone.NzbDrone
{
bundles.AddUrlWithAlias<StylesheetBundle>("//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,400,600,300'", FONTS);
bundles.AddPerIndividualFile<ScriptBundle>(APP_PATH);
//bundles.AddPerIndividualFile<ScriptBundle>(APP_PATH);
bundles.Add<StylesheetBundle>(BASE_STYLE, new[]{
APP_PATH + "\\Content\\Bootstrap\\bootstrap.less",
@ -28,15 +28,17 @@ namespace NzbDrone.Web.Backbone.NzbDrone
},
bundle => bundle.AddReference("/" + FONTS));
bundles.Add<ScriptBundle>("~/_backboneApp/JsLibraries/backbone.js");
/* bundles.Add<ScriptBundle>("~/_backboneApp/JsLibraries/backbone.js");
bundles.Add<ScriptBundle>(NZBDRONE, new[]{
APP_PATH + "\\app.js",
APP_PATH + "\\routing.js",
APP_PATH + "\\Series\\Index\\IndexLayout.js",
APP_PATH + "\\AddSeries\\AddSeriesLayout.js",
APP_PATH + "\\Shared\\NotificationView.js",
});
});*/
/* bundles.Add<ScriptBundle>(NZBDRONE, new[]{

@ -1,34 +1,36 @@
/// <reference path="handlebars.js" />

define(['underscore', 'marionette', 'handlebars', 'jquery'], function (_, Marionette, Handlebars, $) {
_.extend(Marionette.TemplateCache.prototype, {
_.extend(Marionette.TemplateCache.prototype, {
loadTemplate: function (templateId) {
loadTemplate: function (templateId) {
var template;
var template;
console.log("Loading template '" + templateId + "'");
console.log("Loading template '" + templateId + "'");
$.ajax({
url: '_backboneApp//' + templateId + '.html',
cache: false,
async: false
$.ajax({
url: '_backboneApp//' + templateId + '.html',
cache:false,
async: false
}).done(function (data) {
template = data;
}).done(function (data) {
template = data;
}).fail(function (data) {
console.log("couldn't load template " + this.templateId + " Error: " + data.statusText);
template = "<div class='alert alert-error'>Couldn't load template '" + templateId + "'. Status: " + data.statusText + "</div>";
});
}).fail(function (data) {
console.log("couldn't load template " + this.templateId + " Error: " + data.statusText);
template = "<div class='alert alert-error'>Couldn't load template '" + templateId + "'. Status: " + data.statusText + "</div>";
});
return template;
}
});
return template;
}
});
_.extend(Marionette.TemplateCache.prototype, {
_.extend(Marionette.TemplateCache.prototype, {
compileTemplate: function (rawTemplate) {
return Handlebars.compile(rawTemplate);
}
});
});
compileTemplate: function (rawTemplate) {
return Handlebars.compile(rawTemplate);
}
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,7 +1,8 @@
/// <reference path="../app.js" />
/// <reference path="qualityProfileModel.js" />
define(['app', 'Quality/QualityProfileModel'], function () {
NzbDrone.Quality.QualityProfileCollection = Backbone.Collection.extend({
model: NzbDrone.Quality.QualityProfileModel,
url: NzbDrone.Constants.ApiRoot + '/qualityprofiles'
});
NzbDrone.Quality.QualityProfileCollection = Backbone.Collection.extend({
model: NzbDrone.Quality.QualityProfileModel,
url: NzbDrone.Constants.ApiRoot + '/qualityprofiles'
});
});

@ -1,47 +1,48 @@
/// <reference path="../app.js" />
NzbDrone.Quality.QualityProfileModel = Backbone.Model.extend({
initialize: function () {
this.validators = {};
this.validators.name = function (value) {
return value.length > 0 ? { isValid: true } : { isValid: false, message: 'You must enter a name' };
};
//this.validators.allowed = function (value) {
// return value.length > 0 ? { isValid: true } : { isValid: false, message: 'You must have allowed qualities' };
//};
//Todo: Cutoff should be something that is allowed (double check)
this.validators.cutoff = function (value) {
return value !== null ? { isValid: true } : { isValid: false, message: 'You must have a valid cutoff' };
};
},
validateItem: function (key) {
return (this.validators[key]) ? this.validators[key](this.get(key)) : { isValid: true };
},
// TODO: Implement Backbone's standard validate() method instead.
validateAll: function () {
var messages = {};
for (var key in this.validators) {
if (this.validators.hasOwnProperty(key)) {
var check = this.validators[key](this.get(key));
if (check.isValid === false) {
messages[key] = check.message;
define(['app'], function () {
NzbDrone.Quality.QualityProfileModel = Backbone.Model.extend({
initialize: function () {
this.validators = {};
this.validators.name = function (value) {
return value.length > 0 ? { isValid: true } : { isValid: false, message: 'You must enter a name' };
};
//this.validators.allowed = function (value) {
// return value.length > 0 ? { isValid: true } : { isValid: false, message: 'You must have allowed qualities' };
//};
//Todo: Cutoff should be something that is allowed (double check)
this.validators.cutoff = function (value) {
return value !== null ? { isValid: true } : { isValid: false, message: 'You must have a valid cutoff' };
};
},
validateItem: function (key) {
return (this.validators[key]) ? this.validators[key](this.get(key)) : { isValid: true };
},
// TODO: Implement Backbone's standard validate() method instead.
validateAll: function () {
var messages = {};
for (var key in this.validators) {
if (this.validators.hasOwnProperty(key)) {
var check = this.validators[key](this.get(key));
if (check.isValid === false) {
messages[key] = check.message;
}
}
}
}
return _.size(messages) > 0 ? { isValid: false, messages: messages } : { isValid: true };
},
return _.size(messages) > 0 ? { isValid: false, messages: messages } : { isValid: true };
},
defaults: {
Id: null,
Name: '',
//allowed: {},
Cutoff: null
}
});
});
defaults: {
Id: null,
Name: '',
//allowed: {},
Cutoff: null
}
});

@ -0,0 +1,38 @@
require(['app', 'AddSeries/AddSeriesLayout'], function () {
NzbDrone.Controller = Backbone.Marionette.Controller.extend({
addSeries: function (action, query) {
NzbDrone.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout(this, action, query));
},
series: function (action, query) {
NzbDrone.mainRegion.show(new NzbDrone.Series.IndexLayout(this, action, query));
},
notFound: function () {
alert('route not found');
}
});
NzbDrone.Router = Backbone.Marionette.AppRouter.extend({
controller: new NzbDrone.Controller(),
appRoutes: {
'series': 'series',
'series/index': 'series',
'series/add': 'addSeries',
'series/add/:action(/:query)': 'addSeries',
':whatever': 'notFound'
}
});
NzbDrone.addInitializer(function () {
NzbDrone.Router = new NzbDrone.Router();
Backbone.history.start();
});
});

@ -1,6 +1,6 @@
'use strict';
/*global NzbDrone, Backbone*/
/// <reference path="../app.js" />
/// <reference path="SeriesModel.js" />
NzbDrone.Series.DeleteSeriesView = Backbone.Marionette.ItemView.extend({

@ -1,6 +1,6 @@
'use strict';
/*global NzbDrone, Backbone*/
/// <reference path="../app.js" />
/// <reference path="SeriesModel.js" />
/// <reference path="DeleteSeriesView.js" />
/// <reference path="../Quality/qualityProfileCollection.js" />

@ -1,5 +1,5 @@
'use strict;'
/// <reference path="../../app.js" />
/// <reference path="../SeriesCollection.js" />
/// <reference path="SeriesItemView.js" />
/// <reference path="../../JsLibraries/jquery.dataTables.bootstrap.pagination.js" />

@ -1,6 +1,6 @@
'use strict';
/*global NzbDrone, Backbone*/
/// <reference path="../../app.js" />
/// <reference path="../SeriesModel.js" />
/// <reference path="../SeriesCollection.js" />
/// <reference path="../EditSeriesView.js" />

@ -1,4 +1,4 @@
/// <reference path="../app.js" />

/// <reference path="SeriesModel.js" />
NzbDrone.Series.SeriesCollection = Backbone.Collection.extend({

@ -1,48 +1,43 @@
NzbDrone.Series.SeriesModel = Backbone.Model.extend({
url: NzbDrone.Constants.ApiRoot + '/series',
mutators: {
bestDateString: function () {
var dateSource = this.get('nextAiring');
define(['app'], function () {
if (!dateSource) return '';
var date = Date.create(dateSource);
NzbDrone.Series.SeriesModel = Backbone.Model.extend({
url: NzbDrone.Constants.ApiRoot + '/series',
if (date.isYesterday()) return 'Yesterday';
if (date.isToday()) return 'Today';
if (date.isTomorrow()) return 'Tomorrow';
if (date.isToday()) return 'Today';
if (date.isBefore(Date.create().addDays(7))) return date.format('{Weekday}');
mutators: {
bestDateString: function () {
var dateSource = this.get('nextAiring');
return date.format('{MM}/{dd}/{yyyy}');
},
formatedDateString: function () {
var dateSource = this.get('nextAiring');
if (!dateSource) return '';
if (!dateSource) return '';
var date = Date.create(dateSource);
var date = Date.create(dateSource);
if (date.isYesterday()) return 'Yesterday';
if (date.isToday()) return 'Today';
if (date.isTomorrow()) return 'Tomorrow';
if (date.isToday()) return 'Today';
if (date.isBefore(Date.create().addDays(7))) return date.format('{Weekday}');
return date.format('{Weekday} {Month} {dd}, {yyyy} {12hr}:{mm} {TT}');
},
percentOfEpisodes: function () {
var episodeCount = this.get('episodeCount');
var episodeFileCount = this.get('episodeFileCount');
return date.format('{MM}/{dd}/{yyyy}');
},
percentOfEpisodes: function () {
var episodeCount = this.get('episodeCount');
var episodeFileCount = this.get('episodeFileCount');
var percent = 100;
var percent = 100;
if (episodeCount > 0)
percent = episodeFileCount / episodeCount * 100;
if (episodeCount > 0)
percent = episodeFileCount / episodeCount * 100;
return percent;
}
},
return percent;
defaults: {
episodeFileCount: 0,
episodeCount: 0
}
},
});
defaults: {
episodeFileCount: 0,
episodeCount: 0
}
});
});

@ -1,16 +1,20 @@
$.fn.folderAutoComplete = function () {
$(this).typeahead({
source: function (query, process) {
$.ajax({
url: '/api/directories',
dataType: "json",
type: "POST",
data: { query: query },
success: function (data) {
process(data);
}
});
},
minLength: 3
});
}
define(['bootstrap'], function () {
$.fn.folderAutoComplete = function () {
$(this).typeahead({
source: function (query, process) {
$.ajax({
url: '/api/directories',
dataType: "json",
type: "POST",
data: { query: query },
success: function (data) {
process(data);
}
});
},
minLength: 3
});
};
});

@ -1,24 +1,28 @@
ModalRegion = Backbone.Marionette.Region.extend({
el: "#modal-region",
define('modalRegion', ['Marionette'], function (Marionette) {
return Marionette.Region.extend({
el: "#modal-region",
constructor: function () {
_.bindAll(this);
Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
this.on("show", this.showModal, this);
},
constructor: function () {
_.bindAll(this);
Backbone.Marionette.Region.prototype.constructor.apply(this, arguments);
this.on("show", this.showModal, this);
},
getEl: function (selector) {
var $el = $(selector);
$el.on("hidden", this.close);
return $el;
},
getEl: function (selector) {
var $el = $(selector);
$el.on("hidden", this.close);
return $el;
},
showModal: function (view) {
view.on("close", this.hideModal, this);
this.$el.modal('show');
},
hideModal: function () {
this.$el.modal('hide');
}
});
});
showModal: function (view) {
view.on("close", this.hideModal, this);
this.$el.modal('show');
},
hideModal: function () {
this.$el.modal('hide');
}
});

@ -1,4 +1,5 @@
/// <reference path="../app.js" />

NzbDrone.Shared.NotificationModel = Backbone.Model.extend({
mutators: {

@ -1,4 +1,4 @@
/// <reference path="../app.js" />

/// <reference path="NotificationModel.js" />
NzbDrone.Shared.NotificationItemView = Backbone.Marionette.ItemView.extend({

@ -1,6 +1,4 @@
/// <reference path="../app.js" />
NzbDrone.Shared.SpinnerView = Backbone.Marionette.ItemView.extend({
NzbDrone.Shared.SpinnerView = Backbone.Marionette.ItemView.extend({
template: 'Shared/SpinnerTemplate',
className: 'nz-spinner row',

@ -1,97 +1,85 @@
/// <reference path="JsLibraries/jquery.js" />
/// <reference path="JsLibraries/underscore.js" />
/// <reference path="JsLibraries/sugar.js" />
/// <reference path="JsLibraries/backbone.js" />
/// <reference path="JsLibraries/handlebars.js" />
/// <reference path="JsLibraries/backbone.modelbinder.js" />
/// <reference path="JsLibraries/backbone.mutators.js" />
/// <reference path="JsLibraries/backbone.shortcuts.js" />
/// <reference path="JsLibraries/backbone.marionette.js" />
/// <reference path="JsLibraries/backbone.marionette.extend.js" />
/// <reference path="JsLibraries/backbone.marionette.viewswapper.js" />
/// <reference path="JsLibraries/backbone.modelbinder.js" />
/// <reference path="JsLibraries/bootstrap.js" />
/// <reference path="Shared/ModalRegion.js" />
if (typeof console === undefined) {
window.console = { log: function () { } };
}
NzbDrone = new Backbone.Marionette.Application();
NzbDrone.Series = {};
NzbDrone.Series.Index = {};
NzbDrone.AddSeries = {};
NzbDrone.AddSeries.New = {};
NzbDrone.AddSeries.Existing = {};
NzbDrone.AddSeries.RootFolders = {};
NzbDrone.Quality = {};
NzbDrone.Shared = {};
/*
_.templateSettings = {
interpolate: /\{\{([\s\S]+?)\}\}/g
};
*/
NzbDrone.ModelBinder = new Backbone.ModelBinder();
NzbDrone.Constants = {
ApiRoot: '/api'
};
NzbDrone.Events = {
DisplayInMainRegion: 'DisplayInMainRegion'
};
NzbDrone.Controller = Backbone.Marionette.Controller.extend({
addSeries: function (action, query) {
NzbDrone.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout(this, action, query));
require.config({
paths: {
'backbone': 'JsLibraries/backbone',
'underscore': 'JsLibraries/underscore',
'marionette': 'JsLibraries/backbone.marionette',
'handlebars': 'JsLibraries/handlebars',
'bootstrap': 'JsLibraries/bootstrap',
},
series: function (action, query) {
NzbDrone.mainRegion.show(new NzbDrone.Series.IndexLayout(this, action, query));
},
notFound: function () {
alert('route not found');
shim: {
bootstrap: {
deps: ["jquery"],
},
underscore: {
exports: '_'
},
backbone: {
deps: ["underscore", "jquery"],
exports: "Backbone"
},
marionette: {
deps: ["backbone"],
exports: "Marionette"
},
handlebars: {
exports: "Handlebars"
}
}
});
NzbDrone.Router = Backbone.Marionette.AppRouter.extend({
define('app', ['jquery', 'JsLibraries/backbone.modelbinder', 'marionette', 'handlebars', 'JsLibraries/backbone.marionette.extend'],
function (jquery, modelBinder, marionette, handlebars) {
controller: new NzbDrone.Controller(),
// "someMethod" must exist at controller.someMethod
appRoutes: {
'series': 'series',
'series/index': 'series',
'series/add': 'addSeries',
'series/add/:action(/:query)': 'addSeries',
':whatever': 'notFound'
}
});
NzbDrone.addInitializer(function (options) {
window.$ = jquery;
window.jquery = jquery;
console.log('starting application');
window.Backbone.ModelBinder = modelBinder;
window.Backbone.Marionette = marionette;
window.Handlebars = handlebars;
NzbDrone.registerHelpers();
window.NzbDrone = new Backbone.Marionette.Application();
window.NzbDrone.Series = {};
window.NzbDrone.Series.Index = {};
window.NzbDrone.AddSeries = {};
window.NzbDrone.AddSeries.New = {};
window.NzbDrone.AddSeries.Existing = {};
window.NzbDrone.AddSeries.RootFolders = {};
window.NzbDrone.Quality = {};
window.NzbDrone.Shared = {};
NzbDrone.addRegions({
mainRegion: '#main-region',
notificationRegion: '#notification-region',
modalRegion: ModalRegion
});
window.NzbDrone.Constants = {
ApiRoot: '/api'
};
NzbDrone.Router = new NzbDrone.Router();
Backbone.history.start();
});
NzbDrone.registerHelpers = function() {
Handlebars.registerHelper("formatStatus", function (status, monitored) {
if (!monitored) return '<i class="icon-pause grid-icon" title="Not Monitored"></i>';
if (status === 'Continuing') return '<i class="icon-play grid-icon" title="Continuing"></i>';
window.NzbDrone.addInitializer(function (options) {
console.log('starting application');
NzbDrone.ModelBinder = new Backbone.ModelBinder();
return '<i class="icon-stop grid-icon" title="Ended"></i>';
//TODO: move this out of here
Handlebars.registerHelper("formatStatus", function (status, monitored) {
if (!monitored) return '<i class="icon-pause grid-icon" title="Not Monitored"></i>';
if (status === 'Continuing') return '<i class="icon-play grid-icon" title="Continuing"></i>';
return '<i class="icon-stop grid-icon" title="Ended"></i>';
});
NzbDrone.addRegions({
mainRegion: '#main-region',
notificationRegion: '#notification-region',
modalRegion: '#modal-region'
});
});
window.NzbDrone.start();
});
}

@ -2,6 +2,7 @@
<FileVersion>1</FileVersion>
<AutoEnableOnStartup>False</AutoEnableOnStartup>
<AllowParallelTestExecution>true</AllowParallelTestExecution>
<AllowTestsToRunInParallelWithThemselves>true</AllowTestsToRunInParallelWithThemselves>
<FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>
<FrameworkUtilisationTypeForGallio>Disabled</FrameworkUtilisationTypeForGallio>
<FrameworkUtilisationTypeForMSpec>Disabled</FrameworkUtilisationTypeForMSpec>

@ -1,4 +1,5 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/JavaScriptNaming/UserRules/=JS_005FPARAMETER/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb"&gt;&lt;ExtraRule Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/Environment/Editor/MatchingBraceHighlighting/Position/@EntryValue">BOTH_SIDES</s:String>
<s:String x:Key="/Default/Environment/Editor/MatchingBraceHighlighting/Style/@EntryValue">OUTLINE</s:String>
<s:Boolean x:Key="/Default/Environment/InjectedLayers/FileInjectedLayer/=5C7F3FB135E52A44B9447C48B2EEEE92/@KeyIndexDefined">True</s:Boolean>

Loading…
Cancel
Save