UI dependency graph cleanup

pull/2/head
kayone 11 years ago
parent 86ea33b638
commit 4948d0608b

@ -155,6 +155,25 @@ module.exports = function (grunt) {
}
},
requirejs: {
compile:{
options: {
mainConfigFile: "_output/UI/app.js",
fileExclusionRegExp: /^.*\.(?!js$)[^.]+$/,
preserveLicenseComments: true,
dir: "rjs/",
optimize: 'none',
removeCombined: true,
inlineText: false,
modules: [{
name: 'app',
exclude: ['JsLibraries/jquery']
}],
}
}
},
watch: {
options: {
nospawn: false,
@ -213,6 +232,7 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-notify');
grunt.loadNpmTasks('grunt-curl');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.registerTask('package', ['clean:output', 'copy', 'less', 'handlebars']);
grunt.registerTask('default', ['package', 'watch']);

@ -22,6 +22,7 @@
"grunt-contrib-copy": "*",
"grunt-curl": "*",
"grunt-notify": "*",
"grunt-contrib-clean": "*"
"grunt-contrib-clean": "*",
"grunt-contrib-requirejs": "*"
}
}

@ -1,7 +1,8 @@
'use strict';
define(
[
'app',
'vent',
'AppLayout',
'marionette',
'AddSeries/RootFolders/Layout',
'AddSeries/Existing/AddExistingSeriesCollectionView',
@ -9,7 +10,8 @@ define(
'Quality/QualityProfileCollection',
'AddSeries/RootFolders/Collection',
'Series/SeriesCollection'
], function (App,
], function (vent,
AppLayout,
Marionette,
RootFolderLayout,
ExistingSeriesCollectionView,
@ -43,7 +45,7 @@ define(
},
_folderSelected: function (options) {
App.vent.trigger(App.Commands.CloseModalCommand);
vent.trigger(vent.Commands.CloseModalCommand);
this.workspace.show(new ExistingSeriesCollectionView({model: options.model}));
},
@ -51,7 +53,7 @@ define(
_importSeries: function () {
this.rootFolderLayout = new RootFolderLayout();
this.rootFolderLayout.on('folderSelected', this._folderSelected, this);
App.modalRegion.show(this.rootFolderLayout);
AppLayout.modalRegion.show(this.rootFolderLayout);
},
_addSeries: function () {

@ -1,14 +1,14 @@
'use strict';
define(
[
'app',
'vent',
'marionette',
'AddSeries/AddSeriesCollection',
'AddSeries/SearchResultCollectionView',
'AddSeries/NotFoundView',
'Shared/LoadingView',
'underscore'
], function (App, Marionette, AddSeriesCollection, SearchResultCollectionView, NotFoundView, LoadingView, _) {
], function (vent, Marionette, AddSeriesCollection, SearchResultCollectionView, NotFoundView, LoadingView, _) {
return Marionette.Layout.extend({
template: 'AddSeries/AddSeriesViewTemplate',
@ -41,7 +41,7 @@ define(
this.className = 'new-series';
}
this.listenTo(App.vent, App.Events.SeriesAdded, this._onSeriesAdded);
this.listenTo(vent, vent.Events.SeriesAdded, this._onSeriesAdded);
this.listenTo(this.collection, 'sync', this._showResults);
this.resultCollectionView = new SearchResultCollectionView({

@ -20,4 +20,4 @@
<div class="btn btn-block text-center new-series-loadmore x-load-more" style="display: none;">
<i class="icon-angle-down"/>
more
</div>{{debug}}
</div>

@ -5,4 +5,3 @@
<a href="https://github.com/NzbDrone/NzbDrone/wiki/FAQ#why-cant-i-add-a-new-show-to-nzbdrone-its-on-thetvdb">Why can't I find my show?</a>
</div>
{{debug}}

@ -1,7 +1,8 @@
'use strict';
define(
[
'app',
'vent',
'AppLayout',
'underscore',
'marionette',
'Quality/QualityProfileCollection',
@ -12,7 +13,7 @@ define(
'Shared/Messenger',
'Mixins/AsValidatedView',
'jquery.dotdotdot'
], function (App, _, Marionette, QualityProfiles, RootFolders, RootFolderLayout, SeriesCollection, Config, Messenger, AsValidatedView) {
], function (vent, AppLayout, _, Marionette, QualityProfiles, RootFolders, RootFolderLayout, SeriesCollection, Config, Messenger, AsValidatedView) {
var view = Marionette.ItemView.extend({
@ -41,7 +42,7 @@ define(
this.templateHelpers = {};
this._configureTemplateHelpers();
this.listenTo(App.vent, Config.Events.ConfigUpdatedEvent, this._onConfigUpdated);
this.listenTo(vent, Config.Events.ConfigUpdatedEvent, this._onConfigUpdated);
this.listenTo(this.model, 'change', this.render);
this.listenTo(RootFolders, 'all', this.render);
@ -105,7 +106,7 @@ define(
_rootFolderChanged: function () {
var rootFolderValue = this.ui.rootFolder.val();
if (rootFolderValue === 'addNew') {
App.modalRegion.show(this.rootFolderLayout);
AppLayout.modalRegion.show(this.rootFolderLayout);
}
else {
Config.setValue(Config.Keys.DefaultRootFolderId, rootFolderValue);
@ -113,7 +114,7 @@ define(
},
_setRootFolder: function (options) {
App.vent.trigger(App.Commands.CloseModalCommand);
vent.trigger(vent.Commands.CloseModalCommand);
this.ui.rootFolder.val(options.model.id);
this._rootFolderChanged();
},
@ -145,7 +146,7 @@ define(
message: 'Added: ' + self.model.get('title')
});
App.vent.trigger(App.Events.SeriesAdded, { series: self.model });
vent.trigger(vent.Events.SeriesAdded, { series: self.model });
});
promise.fail(function () {

@ -0,0 +1,23 @@
define(
[
'marionette',
'Shared/Modal/ModalRegion'
], function (Marionette, ModalRegion) {
'use strict';
var Layout = Marionette.Layout.extend({
regions: {
navbarRegion: '#nav-region',
mainRegion : '#main-region'
},
initialize: function () {
this.addRegions({
modalRegion: ModalRegion
});
}
});
return new Layout({el: 'body'});
});

@ -2,12 +2,12 @@
define(
[
'app',
'vent',
'marionette',
'moment',
'Calendar/Collection',
'fullcalendar'
], function (App, Marionette, Moment, CalendarCollection) {
], function (vent, Marionette, Moment, CalendarCollection) {
var _instance;
@ -38,7 +38,7 @@ define(
$(element).children('.fc-event-inner').addClass(event.statusLevel);
},
eventClick : function (event) {
App.vent.trigger(App.Commands.ShowEpisodeDetails, {episode: event.model});
vent.trigger(vent.Commands.ShowEpisodeDetails, {episode: event.model});
}
});
@ -108,7 +108,7 @@ define(
var test = currentTime.startOf('day').format('LLLL');
if (end.isBefore(currentTime.startOf('day'))) {
statusLevel += ' past'
statusLevel += ' past';
}
return statusLevel;

@ -2,10 +2,10 @@
define(
[
'app',
'vent',
'marionette',
'moment'
], function (App, Marionette, Moment) {
], function (vent, Marionette, Moment) {
return Marionette.ItemView.extend({
template: 'Calendar/UpcomingItemViewTemplate',
tagName : 'div',
@ -21,11 +21,11 @@ define(
this.model.set({
end: end.toISOString()
})
});
},
_showEpisodeDetails: function () {
App.vent.trigger(App.Commands.ShowEpisodeDetails, {episode: this.model});
vent.trigger(vent.Commands.ShowEpisodeDetails, {episode: this.model});
}
});
});

@ -12,8 +12,8 @@ define(
tagName : 'select',
events: {
'change': 'save',
'blur': 'close',
'change' : 'save',
'blur' : 'close',
'keydown': 'close'
},
@ -45,12 +45,12 @@ define(
save: function (e) {
var model = this.model;
var column = this.column;
var selected = parseInt(this.$el.val());
var selected = parseInt(this.$el.val(), 10);
var quality = _.find(this.schema.get('available'), { 'id': selected });
var newQuality = {
proper: false,
proper : false,
quality: quality
};

@ -2,10 +2,11 @@
define(
[
'app',
'vent',
'marionette',
'Cells/NzbDroneCell',
'Commands/CommandController'
], function (App, NzbDroneCell, CommandController) {
], function (vent, Marionette, NzbDroneCell, CommandController) {
return NzbDroneCell.extend({
className: 'episode-actions-cell',
@ -48,7 +49,7 @@ define(
},
_manualSearch: function () {
App.vent.trigger(App.Commands.ShowEpisodeDetails, { episode: this.cellValue, hideSeriesLink: true, openingTab: 'search' });
vent.trigger(vent.Commands.ShowEpisodeDetails, { episode: this.cellValue, hideSeriesLink: true, openingTab: 'search' });
}
});
});

@ -2,13 +2,13 @@
define(
[
'app',
'reqres',
'underscore',
'Cells/NzbDroneCell',
'History/Queue/QueueCollection',
'moment',
'Shared/FormatHelpers'
], function (App, _, NzbDroneCell, QueueCollection, Moment, FormatHelpers) {
], function (Reqres, _, NzbDroneCell, QueueCollection, Moment, FormatHelpers) {
return NzbDroneCell.extend({
className: 'episode-status-cell',
@ -33,7 +33,7 @@ define(
var hasFile = this.model.get('hasFile');
if (hasFile) {
var episodeFile = App.request(App.Reqres.GetEpisodeFileById, this.model.get('episodeFileId'));
var episodeFile = Reqres.request(reqres.Requests.GetEpisodeFileById, this.model.get('episodeFileId'));
this.listenTo(episodeFile, 'change', this._refresh);

@ -2,9 +2,9 @@
define(
[
'app',
'vent',
'Cells/NzbDroneCell'
], function (App, NzbDroneCell) {
], function (vent, NzbDroneCell) {
return NzbDroneCell.extend({
className: 'episode-title-cell',
@ -27,7 +27,7 @@ define(
_showDetails: function () {
var hideSeriesLink = this.column.get('hideSeriesLink');
App.vent.trigger(App.Commands.ShowEpisodeDetails, { episode: this.cellValue, hideSeriesLink: hideSeriesLink });
vent.trigger(vent.Commands.ShowEpisodeDetails, { episode: this.cellValue, hideSeriesLink: hideSeriesLink });
}
});
});

@ -2,9 +2,9 @@
define(
[
'app',
'vent',
'Cells/NzbDroneCell'
], function (App, NzbDroneCell) {
], function (vent, NzbDroneCell) {
return NzbDroneCell.extend({
className: 'series-actions-cell',
@ -27,11 +27,11 @@ define(
},
_editSeries: function () {
App.vent.trigger(App.Commands.EditSeriesCommand, {series:this.model});
vent.trigger(vent.Commands.EditSeriesCommand, {series:this.model});
},
_removeSeries: function () {
App.vent.trigger(App.Commands.DeleteSeriesCommand, {series:this.model});
vent.trigger(vent.Commands.DeleteSeriesCommand, {series:this.model});
}
});
});

@ -1,12 +1,16 @@
'use strict';
define(
[
'app',
'vent',
'Commands/CommandModel',
'Commands/CommandCollection',
'Commands/CommandMessengerCollectionView',
'underscore',
'jQuery/jquery.spin'
], function (App, CommandModel, CommandCollection, _) {
], function (vent, CommandModel, CommandCollection, CommandMessengerCollectionView, _) {
CommandMessengerCollectionView.render();
var singleton = function () {
@ -33,11 +37,18 @@ define(
this._bindToCommandModel.call(this, existingCommand, options);
}
CommandCollection.bind('add sync', function (model) {
CommandCollection.bind('add', function (model) {
if (model.isSameCommand(options.command)) {
self._bindToCommandModel.call(self, model, options);
}
});
CommandCollection.bind('add sync', function () {
var command = CommandCollection.findCommand(options.command);
if (command) {
self._bindToCommandModel.call(self, command, options);
}
});
},
_bindToCommandModel: function bindToCommand(model, options) {
@ -52,7 +63,7 @@ define(
options.element.stopSpin();
if (model.isComplete()) {
App.vent.trigger(App.Events.CommandComplete, { command: model, model: options.model });
vent.trigger(vent.Events.CommandComplete, { command: model, model: options.model });
}
}
});

@ -1,15 +1,14 @@
'use strict';
define(
[
'app',
'marionette',
'Commands/CommandCollection',
'Commands/CommandMessengerItemView'
], function (App, Marionette, commandCollection, CommandMessengerItemView) {
], function (Marionette, commandCollection, CommandMessengerItemView) {
var CollectionView = Marionette.CollectionView.extend({
itemView : CommandMessengerItemView
itemView: CommandMessengerItemView
});
new CollectionView({collection: commandCollection});
return new CollectionView({collection: commandCollection});
});

@ -1,10 +1,9 @@
'use strict';
define(
[
'app',
'marionette',
'Shared/Messenger'
], function (App, Marionette, Messenger) {
], function ( Marionette, Messenger) {
return Marionette.ItemView.extend({

@ -1,8 +1,8 @@
'use strict';
define(
[
'app'
], function (App) {
'vent'
], function (vent) {
return {
Events: {
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
@ -36,7 +36,7 @@ define(
}
localStorage.setItem(key, value);
App.vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value});
vent.trigger(this.Events.ConfigUpdatedEvent, {key: key, value: value});
}
};

@ -1,118 +1,77 @@
'use strict';
define(
[
'app',
'Shared/NzbDroneController',
'AppLayout',
'marionette',
'History/HistoryLayout',
'Settings/SettingsLayout',
'AddSeries/AddSeriesLayout',
'Series/Index/SeriesIndexLayout',
'Series/Details/SeriesDetailsLayout',
'Series/SeriesCollection',
'Missing/MissingLayout',
'Calendar/CalendarLayout',
'Release/Layout',
'System/SystemLayout',
'SeasonPass/SeasonPassLayout',
'System/Update/UpdateLayout',
'Shared/NotFoundView',
'Shared/Modal/Region'
], function (App,
'System/Update/UpdateLayout'
], function (NzbDroneController,
AppLayout,
Marionette,
HistoryLayout,
SettingsLayout,
AddSeriesLayout,
SeriesIndexLayout,
SeriesDetailsLayout,
SeriesCollection,
MissingLayout,
CalendarLayout,
ReleaseLayout,
SystemLayout,
SeasonPassLayout,
UpdateLayout,
NotFoundView) {
return Marionette.Controller.extend({
series: function () {
this._setTitle('NzbDrone');
App.mainRegion.show(new SeriesIndexLayout());
},
seriesDetails: function (query) {
var series = SeriesCollection.where({titleSlug: query});
if (series.length !== 0) {
var targetSeries = series[0];
this._setTitle(targetSeries.get('title'));
App.mainRegion.show(new SeriesDetailsLayout({ model: targetSeries }));
}
else {
this.notFound();
}
},
UpdateLayout) {
return NzbDroneController.extend({
addSeries: function (action) {
this._setTitle('Add Series');
App.mainRegion.show(new AddSeriesLayout({action: action}));
this.setTitle('Add Series');
AppLayout.mainRegion.show(new AddSeriesLayout({action: action}));
},
calendar: function () {
this._setTitle('Calendar');
App.mainRegion.show(new CalendarLayout());
this.setTitle('Calendar');
AppLayout.mainRegion.show(new CalendarLayout());
},
settings: function (action) {
this._setTitle('Settings');
App.mainRegion.show(new SettingsLayout({ action: action }));
this.setTitle('Settings');
AppLayout.mainRegion.show(new SettingsLayout({ action: action }));
},
missing: function () {
this._setTitle('Missing');
this.setTitle('Missing');
App.mainRegion.show(new MissingLayout());
AppLayout.mainRegion.show(new MissingLayout());
},
history: function (action) {
this._setTitle('History');
this.setTitle('History');
App.mainRegion.show(new HistoryLayout({ action: action }));
AppLayout.mainRegion.show(new HistoryLayout({ action: action }));
},
rss: function () {
this._setTitle('RSS');
App.mainRegion.show(new ReleaseLayout());
this.setTitle('RSS');
AppLayout.mainRegion.show(new ReleaseLayout());
},
system: function (action) {
this._setTitle('System');
App.mainRegion.show(new SystemLayout({ action: action }));
this.setTitle('System');
AppLayout.mainRegion.show(new SystemLayout({ action: action }));
},
seasonPass: function () {
this._setTitle('Season Pass');
App.mainRegion.show(new SeasonPassLayout());
this.setTitle('Season Pass');
AppLayout.mainRegion.show(new SeasonPassLayout());
},
update: function () {
this._setTitle('Updates');
App.mainRegion.show(new UpdateLayout());
},
notFound: function () {
this._setTitle('Not Found');
App.mainRegion.show(new NotFoundView(this));
},
_setTitle: function (title) {
//$('#title-region').html(title);
if (title.toLocaleLowerCase() === 'nzbdrone') {
window.document.title = 'NzbDrone';
}
else {
window.document.title = title + ' - NzbDrone';
}
this.setTitle('Updates');
AppLayout.mainRegion.show(new UpdateLayout());
}
});
});

@ -1,7 +1,6 @@
'use strict';
define(
[
'app',
'marionette',
'backgrid',
'History/HistoryCollection',
@ -10,7 +9,7 @@ define(
'Cells/RelativeDateCell',
'Episode/Activity/NoActivityView',
'Shared/LoadingView'
], function (App, Marionette, Backgrid, HistoryCollection, EventTypeCell, QualityCell, RelativeDateCell, NoActivityView, LoadingView) {
], function (Marionette, Backgrid, HistoryCollection, EventTypeCell, QualityCell, RelativeDateCell, NoActivityView, LoadingView) {
return Marionette.Layout.extend({
template: 'Episode/Activity/EpisodeActivityLayoutTemplate',

@ -1,9 +1,8 @@
'use strict';
define(
[
'app',
'marionette'
], function (App, Marionette) {
], function (Marionette) {
return Marionette.ItemView.extend({
template: 'Episode/Search/ButtonsViewTemplate'

@ -1,7 +1,7 @@
'use strict';
define(
[
'app',
'vent',
'marionette',
'Episode/Search/ButtonsView',
'Episode/Search/ManualLayout',
@ -9,7 +9,7 @@ define(
'Series/SeriesCollection',
'Commands/CommandController',
'Shared/LoadingView'
], function (App, Marionette, ButtonsView, ManualSearchLayout, ReleaseCollection, SeriesCollection,CommandController, LoadingView) {
], function (vent, Marionette, ButtonsView, ManualSearchLayout, ReleaseCollection, SeriesCollection,CommandController, LoadingView) {
return Marionette.Layout.extend({
template: 'Episode/Search/EpisodeSearchLayoutTemplate',
@ -50,7 +50,7 @@ define(
episodeIds: [ this.model.get('id') ]
});
App.vent.trigger(App.Commands.CloseModalCommand);
vent.trigger(vent.Commands.CloseModalCommand);
},
_searchManual: function (e) {

@ -1,7 +1,7 @@
'use strict';
define(
[
'app',
'reqres',
'marionette',
'backgrid',
'Series/EpisodeFileModel',
@ -10,7 +10,7 @@ define(
'Cells/QualityCell',
'Episode/Summary/NoFileView',
'Shared/LoadingView'
], function (App, Marionette, Backgrid, EpisodeFileModel, EpisodeFileCollection, FileSizeCell, QualityCell, NoFileView, LoadingView) {
], function (reqres, Marionette, Backgrid, EpisodeFileModel, EpisodeFileCollection, FileSizeCell, QualityCell, NoFileView, LoadingView) {
return Marionette.Layout.extend({
template: 'Episode/Summary/EpisodeSummaryLayoutTemplate',
@ -55,8 +55,8 @@ define(
if (this.model.get('hasFile')) {
var episodeFileId = this.model.get('episodeFileId');
if (App.reqres.hasHandler(App.Reqres.GetEpisodeFileById)) {
var episodeFile = App.request(App.Reqres.GetEpisodeFileById, episodeFileId);
if (reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) {
var episodeFile = reqres.request(reqres.Requests.GetEpisodeFileById, episodeFileId);
var episodeFileCollection = new EpisodeFileCollection(episodeFile, { seriesId: this.model.get('seriesId') });
this._showTable(episodeFileCollection);
}

@ -1,22 +1,18 @@
'use strict';
define(
[
'app',
'marionette',
'backbone',
'backgrid',
'History/Table/HistoryTableLayout',
'History/Queue/QueueLayout'
], function (App,
Marionette,
Backgrid,
HistoryTableLayout,
QueueLayout) {
], function (Marionette, Backbone, Backgrid, HistoryTableLayout, QueueLayout) {
return Marionette.Layout.extend({
template: 'History/HistoryLayoutTemplate',
regions: {
history: '#history',
queueRegion : '#queue'
history : '#history',
queueRegion: '#queue'
},
ui: {
@ -25,8 +21,8 @@ define(
},
events: {
'click .x-history-tab' : '_showHistory',
'click .x-queue-tab' : '_showQueue'
'click .x-history-tab': '_showHistory',
'click .x-queue-tab' : '_showQueue'
},
initialize: function (options) {
@ -45,10 +41,8 @@ define(
}
},
_navigate:function(route){
require(['Router'], function(){
App.Router.navigate(route);
});
_navigate: function (route) {
Backbone.history.navigate(route);
},
_showHistory: function (e) {

@ -2,9 +2,9 @@
define(
[
'app',
'vent',
'Cells/NzbDroneCell'
], function (App, NzbDroneCell) {
], function (vent, NzbDroneCell) {
return NzbDroneCell.extend({
className: 'history-details-cell',
@ -21,7 +21,7 @@ define(
},
_showDetails: function () {
App.vent.trigger(App.Commands.ShowHistoryDetails, { history: this.model });
vent.trigger(vent.Commands.ShowHistoryDetails, { history: this.model });
}
});
});

@ -0,0 +1,416 @@
/**
* @license xrayquire 0.0.0 Copyright (c) 2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/requirejs/xrayquire for details
*/
/*jslint nomen: true */
/*global requirejs, console, window */
/**
* Put a script tag in the HTML that references this script right after the
* script tag for require.js.
*/
var xrayquire;
(function () {
'use strict';
var contexts = {},
config = typeof xrayquire === 'undefined' ? {} : xrayquire,
s = requirejs.s,
oldNewContext = s.newContext,
tokenRegExp = /\{(\w+)\}/g,
standardDeps = {
require: true,
exports: true,
module: true
},
prop;
function each(ary, func) {
if (ary) {
var i;
for (i = 0; i < ary.length; i += 1) {
if (ary[i] && func(ary[i], i, ary)) {
break;
}
}
}
}
/**
* Cycles over properties in an object and calls a function for each
* property value. If the function returns a truthy value, then the
* iteration is stopped.
*/
function eachProp(obj, func) {
var prop;
for (prop in obj) {
if (obj.hasOwnProperty(prop)) {
if (func(obj[prop], prop)) {
break;
}
}
}
}
function hasProp(obj, prop) {
return obj.hasOwnProperty(prop);
}
/**
* Simple function to mix in properties from source into target,
* but only if target does not already have a property of the same name.
* This is not robust in IE for transferring methods that match
* Object.prototype names, but the uses of mixin here seem unlikely to
* trigger a problem related to that.
*/
function mixin(target, source, force, deepStringMixin) {
if (source) {
eachProp(source, function (value, prop) {
if (force || !hasProp(target, prop)) {
if (deepStringMixin && typeof value !== 'string') {
if (!target[prop]) {
target[prop] = {};
}
mixin(target[prop], value, force, deepStringMixin);
} else {
target[prop] = value;
}
}
});
}
return target;
}
function isRequire(id) {
return id.indexOf('_@r') !== -1;
}
function formatId(id) {
//If the ID is for a require call, make it prettier.
return isRequire(id) ? 'require()' : id;
}
function formatUrl(url) {
return !url || isRequire(url) ? '' : url;
}
function getX(context) {
if (!context.xray) {
context.xray = {
traced: {},
traceOrder: [],
mixedCases: {}
};
}
return context.xray;
}
function modContext(context) {
var oldLoad = context.load,
modProto = context.Module.prototype,
oldModuleEnable = modProto.enable,
xray = getX(context),
traced = xray.traced,
mixedCases = xray.mixedCases;
function trackModule(mod) {
var id = mod.map.id,
traceData;
//If an intermediate module from a plugin, do not
//track it
if (mod.map.prefix && id.indexOf('_unnormalized') !== -1) {
return;
}
//Cycle through the dependencies now, wire this up here
//instead of context.load so that we get a recording of
//modules as they are encountered, and not as they
//are fetched/loaded, since things could fall over between
//now and then.
if (!traced[id] || !traced[id].deps || !traced[id].deps.length) {
each(mod.depMaps, function (dep) {
var depId = dep.id,
lowerId = depId.toLowerCase();
if (mixedCases[lowerId] && depId !== mixedCases[lowerId].id) {
console.error('Mixed case modules may conflict: ' +
formatId(mixedCases[lowerId].refId) +
' asked for: "' +
mixedCases[lowerId].id +
'" and ' +
formatId(id) +
' asked for: "' +
depId +
'"');
} else {
mixedCases[lowerId] = {
refId: id,
id: depId
};
}
});
traceData = {
map: mod.map,
deps: mod.depMaps
};
//Only add this to the order if not previously added.
if (!traced[id]) {
xray.traceOrder.push(id);
}
//Set the data again in case this enable has the
//real dependencies. Some first calls of enable do
//not have the dependencies known yet.
traced[id] = traceData;
}
}
modProto.enable = function () {
var result = oldModuleEnable.apply(this, arguments);
trackModule(this);
return result;
};
//Collect any modules that are already in process
eachProp(context.registry, function (mod) {
if (mod.enabled) {
trackModule(mod);
}
});
return context;
}
//Mod any existing contexts.
eachProp(requirejs.s.contexts, function (context) {
modContext(context);
});
//Apply mods to any new context.
s.newContext = function (name) {
return modContext(oldNewContext);
};
requirejs.onResourceLoad = function (context, map, deps) {
var id = map.id;
if (typeof context.defined[id] === 'undefined') {
//May be a problem with a circular dependency.
//console.error(id + ' has undefined module value, may be part ' +
// 'of a bad circular reference');
}
};
function sortTraceOrder(traceOrder) {
//Sort the traceOrder, but do it by lowercase comparisons,
//to keep 'something' and 'Something' next to each other.
traceOrder.sort(function (a, b) {
return a.toLowerCase() > b.toLowerCase() ? 1 : -1;
});
}
function htmlEscape(id) {
return (id || '')
.replace('<', '&lt;')
.replace('>', '&gt;')
.replace('&', '&amp;')
.replace('"', '&quot;');
}
function template(contents, data) {
return contents.replace(tokenRegExp, function (match, token) {
var result = data[token];
//Just use empty string for null or undefined
if (result === null || result === undefined) {
result = '';
}
return result;
});
}
function findCycle(mod, traced, masterVisited, visited) {
var id = mod.map.id,
depArray = mod.deps,
foundModule;
//Do not bother with require calls or standard deps,
//or things that are already listed in a cycle
if (isRequire(id) || masterVisited[id] || standardDeps[id]) {
return;
}
//Found the cycle.
if (visited[id]) {
return {
mod: mod,
visited: visited
};
}
visited[id] = true;
//Trace through the dependencies.
each(depArray, function (depMap) {
var depId = depMap.id,
depMod = traced[depId];
if (!depMod) {
return;
}
//mixin visited to a new object for each dependency, so that
//sibling dependencies in this object to not generate a
//false positive match on a cycle. Ideally an Object.create
//type of prototype delegation would be used here, but
//optimizing for file size vs. execution speed since hopefully
//the trees are small for circular dependency scans relative
//to the full app perf.
return (foundModule = findCycle(depMod, traced, masterVisited, mixin({}, visited)));
});
return foundModule;
}
function showHtml(html) {
//Convert to URL encoded data
html = encodeURIComponent(html);
//Display the HTML
window.open('data:text/html;charset=utf-8,' + html, '_blank');
}
/**
* Public API
*/
xrayquire = {
treeHtml: '<!DOCTYPE html>\n<html>\n<head>\n<title>Module Dependencies</title>\n<style>\nbody {\n font-family: \"Inconsolata\",Andale Mono,Monaco,Monospace;\n color: green;\n}\n\na {\n color: #2E87DD;\n text-decoration: none;\n}\n\na:hover {\n text-decoration: underline;\n}\n\n.mod {\n background-color: #FAFAFA;\n border: 1px solid #E6E6E6;\n border-radius: 5px 5px 5px 5px;\n box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);\n font-size: 13px;\n line-height: 18px;\n margin: 7px 0 21px;\n overflow: auto;\n padding: 5px 10px;\n}\n\n.url {\n font-size: smaller;\n color: grey;\n}\n\nli.standard {\n color: grey;\n}\n\n</style>\n</head>\n<body>\n{content}\n</body>\n</html>\n',
treeDepItemHtml: '<li><a href=\"#mod-{htmlId}\">{id}</a></li>',
treeDepItemNoLinkHtml: '<li class=\"standard\">{id}</li>',
treeItemHtml: '<div class=\"mod\" id=\"mod-{htmlId}\">\n <span class=\"id\">{id}</span>\n <span class=\"url\">{url}</span>\n <ul class=\"deps\">\n {depItems}\n </ul>\n</div>\n',
makeHtmlId: function (id) {
return encodeURIComponent(id);
},
makeTemplateData: function (mod) {
return {
htmlId: xrayquire.makeHtmlId(mod.id),
id: htmlEscape(formatId(mod.id)),
url: htmlEscape(formatUrl(mod.url))
};
},
showTree: function (contextName) {
var context = requirejs.s.contexts[contextName || '_'],
xray = getX(context),
traced = xray.traced,
html = '';
sortTraceOrder(xray.traceOrder);
//Generate the HTML
each(xray.traceOrder, function (id) {
var mod = traced[id],
templateData = xrayquire.makeTemplateData(mod.map);
//Do not bother if this is a require() call with no
//dependencies
if (isRequire(mod.map.id) && (!mod.deps || !mod.deps.length)) {
return;
}
templateData.depItems = '';
each(mod.deps, function (dep) {
var depHtmlTemplate = standardDeps[dep.id] ?
xrayquire.treeDepItemNoLinkHtml :
xrayquire.treeDepItemHtml;
templateData.depItems += template(depHtmlTemplate,
xrayquire.makeTemplateData(dep));
});
html += template(xrayquire.treeItemHtml, templateData);
});
//Put the HTML in a full HTML document.
html = template(xrayquire.treeHtml, {
content: html
});
showHtml(html);
},
getCycles: function (contextName) {
var context = requirejs.s.contexts[contextName || '_'],
cycles = {},
xray = getX(context),
traced = xray.traced,
masterVisited = {},
foundCycle = false;
sortTraceOrder(xray.traceOrder);
each(xray.traceOrder, function (id) {
var mod = traced[id],
cycleInfo = findCycle(mod, traced, masterVisited, {});
if (cycleInfo) {
foundCycle = true;
mod = cycleInfo.mod;
mixin(masterVisited, cycleInfo.visited);
cycles[mod.map.id] = {
visited: cycleInfo.visited
};
}
});
return foundCycle ? cycles : null;
},
cycleHtml: '<!DOCTYPE html>\n<html>\n<head>\n<title>Module Cycles</title>\n<style>\nbody {\n font-family: \"Inconsolata\",Andale Mono,Monaco,Monospace;\n color: green;\n}\n\na {\n color: #2E87DD;\n text-decoration: none;\n}\n\na:hover {\n text-decoration: underline;\n}\n\n.mod {\n background-color: #FAFAFA;\n border: 1px solid #E6E6E6;\n border-radius: 5px 5px 5px 5px;\n box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);\n font-size: 13px;\n line-height: 18px;\n margin: 7px 0 21px;\n overflow: auto;\n padding: 5px 10px;\n}\n\n</style>\n</head>\n<body>\n{content}\n</body>\n</html>\n',
cycleEntryHtml: '<div class=\"mod\">\n <span class=\"id\">{id}</span>\n <ul class=\"chain\">\n {chain}\n </ul>\n</div>\n',
cycleChainEntryHtml: '<li>{id}</li>',
showCycles: function (contextName) {
var cycles = xrayquire.getCycles(contextName),
html = '';
if (cycles) {
eachProp(cycles, function (cycle, id) {
var chainHtml = '';
eachProp(cycle.visited, function (value, cycleId) {
if (cycleId !== id) {
chainHtml += template(xrayquire.cycleChainEntryHtml, {
id: cycleId
});
}
});
html += template(xrayquire.cycleEntryHtml, {
id: id,
chain: chainHtml
});
});
} else {
html = 'No cycles found';
}
html = template(xrayquire.cycleHtml, {
content: html
});
showHtml(html);
}
};
}());

@ -1,4 +1,4 @@
'use strict';
'use strict';
define(function () {

@ -1,26 +0,0 @@
/*
'use strict';
(function () {
var _originalRegionClose = Marionette.Region.prototype.close;
*/
/*
Marionette.Region.prototype.open = function (view) {
var self = this;
self.$el.html(view.el);
//self.$el.fadeIn(100);
};*//*
Marionette.Region.prototype.close = function () {
*/
/* this.$el.fadeOut(200, function () {
_originalRegionClose.apply(this, arguments);
});*//*
};
}());
*/

@ -1,10 +1,11 @@
'use strict';
define(
[
'vent',
'underscore',
'backbone',
'signalR'
], function (_, Backbone) {
], function (vent, _, Backbone) {
_.extend(Backbone.Collection.prototype, {
bindSignalR: function () {
@ -25,12 +26,7 @@ define(
console.log(options.action + ': {0}}'.format(options.resource));
};
require(
[
'app'
], function (app) {
collection.listenTo(app.vent, 'server:' + collection.url.replace('/api/', ''), processMessage);
});
collection.listenTo(vent, 'server:' + collection.url.replace('/api/', ''), processMessage);
return this;
},

@ -1,9 +1,9 @@
'use strict';
define(
[
'app',
'backbone',
'Series/SeriesCollection'
], function (App, SeriesCollection) {
], function (Backbone, SeriesCollection) {
$(document).on('keydown', function (e){
if ($(e.target).is('input')) {
return;
@ -29,7 +29,7 @@ define(
var series = SeriesCollection.findWhere({ title: item });
this.$element.blur();
App.Router.navigate('/series/{0}'.format(series.get('titleSlug')), { trigger: true });
Backbone.history.navigate('/series/{0}'.format(series.get('titleSlug')), { trigger: true });
}
});
};

@ -1,47 +0,0 @@
'use strict';
define(
[
'app',
'backbone',
'Shared/Messenger',
'Mixins/backbone.signalr.mixin'
], function (App, Backbone, Messenger) {
var ProgressMessageCollection = Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/progressmessage',
model: Backbone.Model,
initialize: function(){
}
});
var collection = new ProgressMessageCollection();//.bindSignalR();
/* collection.signalRconnection.received(function (message) {
var type = getMessengerType(message.status);
var hideAfter = type === 'info' ? 60 :5;
Messenger.show({
id : message.commandId,
message : message.message,
type : type,
hideAfter: hideAfter
});
});*/
var getMessengerType = function (status) {
switch (status) {
case 'completed':
return 'success';
case 'failed':
return 'error';
default:
return 'info';
}
};
return collection;
});

@ -2,9 +2,8 @@
define(
[
'app',
'Settings/SettingsModelBase'
], function (App, ModelBase) {
], function (ModelBase) {
return ModelBase.extend({
baseInitialize: ModelBase.prototype.initialize,

@ -0,0 +1,25 @@
define(function () {
'use strict';
return {
load: function (name, parentRequire, onload, config) {
if(config.isBuild){
return onload();
}
var resource = name.split('!')[0];
var url = window.NzbDrone.ApiRoot + '/' + resource;
$.ajax({
url: url
}).done(function (data) {
onload(data);
}).error(function (xhr, status, error) {
onload.error({
xhr : xhr,
status: status,
error : error});
});
}
};
});

@ -1,38 +1,16 @@
'use strict';
require(
define(
[
'app',
'backbone',
'marionette',
'Controller',
'Series/SeriesCollection',
'ProgressMessaging/ProgressMessageCollection',
'Commands/CommandMessengerCollectionView',
'History/Queue/QueueCollection',
'Navbar/NavbarView',
'jQuery/RouteBinder',
'jquery'
], function (App,
Backbone,
Marionette,
Controller,
SeriesCollection,
ProgressMessageCollection,
CommandMessengerCollectionView,
QueueCollection,
NavbarView,
RouterBinder,
$) {
'Controller'
], function (Marionette, Controller) {
var Router = Marionette.AppRouter.extend({
return Marionette.AppRouter.extend({
controller: new Controller(),
appRoutes : {
'' : 'series',
'series' : 'series',
'addseries' : 'addSeries',
'addseries/:action(/:query)': 'addSeries',
'series/:query' : 'seriesDetails',
'calendar' : 'calendar',
'settings' : 'settings',
'settings/:action(/:query)' : 'settings',
@ -43,23 +21,8 @@ require(
'system' : 'system',
'system/:action' : 'system',
'seasonpass' : 'seasonPass',
':whatever' : 'notFound'
':whatever' : 'showNotFound'
}
});
App.addInitializer(function () {
App.Router = new Router();
SeriesCollection.fetch().done(function () {
Backbone.history.start({ pushState: true });
RouterBinder.bind(App.Router);
App.navbarRegion.show(new NavbarView());
$('body').addClass('started');
});
});
return App.Router;
});

@ -45,7 +45,7 @@ define(
},
_seasonSelected: function () {
var seasonNumber = parseInt(this.ui.seasonSelect.val());
var seasonNumber = parseInt(this.ui.seasonSelect.val(), 10);
if (seasonNumber === -1 || isNaN(seasonNumber)) {
return;
@ -112,19 +112,18 @@ define(
var element;
if (e.target.localName === 'i') {
seasonNumber = parseInt($(e.target).parent('td').attr('data-season-number'));
seasonNumber = parseInt($(e.target).parent('td').attr('data-season-number'), 10);
element = $(e.target);
}
else {
seasonNumber = parseInt($(e.target).attr('data-season-number'));
seasonNumber = parseInt($(e.target).attr('data-season-number'), 10);
element = $(e.target).children('i');
}
this.model.setSeasonMonitored(seasonNumber);
var savePromise =this.model.save()
.always(this.render.bind(this));
var savePromise = this.model.save().always(this.render.bind(this));
element.spinForPromise(savePromise);
},

@ -1,9 +1,9 @@
'use strict';
define(
[
'app',
'vent',
'marionette'
], function (App, Marionette) {
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Series/Delete/DeleteSeriesTemplate',
@ -24,8 +24,8 @@ define(
data: { 'deleteFiles': deleteFiles },
wait: true
}).done(function () {
App.vent.trigger(App.Events.SeriesDeleted, { series: self.model });
App.vent.trigger(App.Commands.CloseModalCommand);
vent.trigger(vent.Events.SeriesDeleted, { series: self.model });
vent.trigger(vent.Commands.CloseModalCommand);
});
}
});

@ -2,8 +2,9 @@
define(
[
'marionette',
'Series/Details/SeasonLayout'
], function (Marionette, SeasonLayout) {
'Series/Details/SeasonLayout',
'underscore'
], function (Marionette, SeasonLayout, _) {
return Marionette.CollectionView.extend({
itemView: SeasonLayout,
@ -26,16 +27,15 @@ define(
},
onEpisodeGrabbed: function (message) {
if (message.episode.series.id != this.episodeCollection.seriesId) {
if (message.episode.series.id !== this.episodeCollection.seriesId) {
return;
}
var self = this;
_.each(message.episode.episodes, function (episode){
_.each(message.episode.episodes, function (episode) {
var ep = self.episodeCollection.get(episode.id);
ep.set('downloading', true);
console.debug(episode.title);
});
this.render();

@ -1,7 +1,7 @@
'use strict';
define(
[
'app',
'vent',
'marionette',
'backgrid',
'Cells/ToggleCell',
@ -10,8 +10,9 @@ define(
'Cells/EpisodeStatusCell',
'Cells/EpisodeActionsCell',
'Commands/CommandController',
'moment'
], function (App, Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, EpisodeActionsCell, CommandController, Moment) {
'moment',
'underscore'
], function (vent, Marionette, Backgrid, ToggleCell, EpisodeTitleCell, RelativeDateCell, EpisodeStatusCell, EpisodeActionsCell, CommandController, Moment,_) {
return Marionette.Layout.extend({
template: 'Series/Details/SeasonLayoutTemplate',
@ -173,7 +174,7 @@ define(
_afterRename: function () {
App.vent.trigger(App.Events.SeasonRenamed, { series: this.series, seasonNumber: this.model.get('seasonNumber') });
vent.trigger(vent.Events.SeasonRenamed, { series: this.series, seasonNumber: this.model.get('seasonNumber') });
},
_showEpisodes: function () {

@ -1,8 +1,10 @@
'use strict';
define(
[
'app',
'vent',
'reqres',
'marionette',
'backbone',
'Series/EpisodeCollection',
'Series/EpisodeFileCollection',
'Series/SeasonCollection',
@ -10,9 +12,10 @@ define(
'Series/Details/InfoView',
'Commands/CommandController',
'Shared/LoadingView',
'underscore',
'backstrech',
'Mixins/backbone.signalr.mixin'
], function (App, Marionette, EpisodeCollection, EpisodeFileCollection, SeasonCollection, SeasonCollectionView, InfoView, CommandController, LoadingView) {
], function (vent,reqres, Marionette, Backbone, EpisodeCollection, EpisodeFileCollection, SeasonCollection, SeasonCollectionView, InfoView, CommandController, LoadingView, _) {
return Marionette.Layout.extend({
itemViewContainer: '.x-series-seasons',
@ -42,10 +45,10 @@ define(
initialize: function () {
this.listenTo(this.model, 'change:monitored', this._setMonitoredState);
this.listenTo(App.vent, App.Events.SeriesDeleted, this._onSeriesDeleted);
this.listenTo(App.vent, App.Events.SeasonRenamed, this._onSeasonRenamed);
this.listenTo(vent, vent.Events.SeriesDeleted, this._onSeriesDeleted);
this.listenTo(vent, vent.Events.SeasonRenamed, this._onSeasonRenamed);
App.vent.on(App.Events.CommandComplete, this._commandComplete, this);
vent.on(vent.Events.CommandComplete, this._commandComplete, this);
},
onShow: function () {
@ -105,7 +108,7 @@ define(
}
$('body').removeClass('backdrop');
App.reqres.removeHandler(App.Reqres.GetEpisodeFileById);
reqres.removeHandler(reqres.Requests.GetEpisodeFileById);
},
_toggleMonitored: function () {
@ -132,7 +135,7 @@ define(
},
_editSeries: function () {
App.vent.trigger(App.Commands.EditSeriesCommand, {series: this.model});
vent.trigger(vent.Commands.EditSeriesCommand, {series: this.model});
},
_refreshSeries: function () {
@ -145,7 +148,7 @@ define(
_onSeriesDeleted: function (event) {
if (this.model.get('id') === event.series.get('id')) {
App.Router.navigate('/', { trigger: true });
Backbone.history.navigate('/', { trigger: true });
}
},
@ -180,7 +183,7 @@ define(
series : self.model
});
App.reqres.setHandler(App.Reqres.GetEpisodeFileById, function (episodeFileId) {
reqres.setHandler(reqres.Requests.GetEpisodeFileById, function (episodeFileId) {
return self.episodeFileCollection.get(episodeFileId);
});

@ -1,13 +1,13 @@
'use strict';
define(
[
'app',
'vent',
'marionette',
'Quality/QualityProfileCollection',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'Mixins/AutoComplete'
], function (App, Marionette, QualityProfiles, AsModelBoundView, AsValidatedView) {
], function (vent, Marionette, QualityProfiles, AsModelBoundView, AsValidatedView) {
var view = Marionette.ItemView.extend({
template: 'Series/Edit/EditSeriesViewTemplate',
@ -36,7 +36,7 @@ define(
this.model.save().done(function () {
self.trigger('saved');
App.vent.trigger(App.Commands.CloseModalCommand);
vent.trigger(vent.Commands.CloseModalCommand);
});
},
@ -45,7 +45,7 @@ define(
},
_removeSeries: function () {
App.vent.trigger(App.Commands.DeleteSeriesCommand, {series:this.model});
vent.trigger(vent.Commands.DeleteSeriesCommand, {series:this.model});
}
});

@ -1,9 +0,0 @@
'use strict';
define(
[
'marionette'
], function (Marionette) {
return Marionette.CompositeView.extend({
template: 'Series/Index/EmptySeriesIndexTemplate'
});
});

@ -2,9 +2,9 @@
define(
[
'app',
'marionette',
], function (App, Marionette) {
'vent',
'marionette'
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Series/Index/List/ItemTemplate',
@ -18,11 +18,11 @@ define(
},
editSeries: function () {
App.vent.trigger(App.Commands.EditSeriesCommand, {series: this.model});
vent.trigger(vent.Commands.EditSeriesCommand, {series: this.model});
},
removeSeries: function () {
App.vent.trigger(App.Commands.DeleteSeriesCommand, {series: this.model});
vent.trigger(vent.Commands.DeleteSeriesCommand, {series: this.model});
}
});
});

@ -2,9 +2,9 @@
define(
[
'app',
'vent',
'marionette'
], function (App, Marionette) {
], function (vent, Marionette) {
return Marionette.ItemView.extend({
tagName : 'li',
@ -25,11 +25,11 @@ define(
editSeries: function () {
App.vent.trigger(App.Commands.EditSeriesCommand, {series:this.model});
vent.trigger(vent.Commands.EditSeriesCommand, {series:this.model});
},
removeSeries: function () {
App.vent.trigger(App.Commands.DeleteSeriesCommand, {series:this.model});
vent.trigger(vent.Commands.DeleteSeriesCommand, {series:this.model});
},
posterHoverAction: function () {

@ -2,8 +2,9 @@
define(
[
'backbone',
'Series/SeriesModel'
], function (Backbone, SeriesModel) {
'Series/SeriesModel',
'api!series'
], function (Backbone, SeriesModel, SeriesData) {
var Collection = Backbone.Collection.extend({
url : window.NzbDrone.ApiRoot + '/series',
model: SeriesModel,
@ -18,6 +19,6 @@ define(
}
});
var collection = new Collection();
var collection = new Collection(SeriesData);
return collection;
});

@ -0,0 +1,40 @@
'use strict';
define(
[
'Shared/NzbDroneController',
'AppLayout',
'Series/SeriesCollection',
'Series/Index/SeriesIndexLayout',
'Series/Details/SeriesDetailsLayout'
], function (NzbDroneController, AppLayout, SeriesCollection, SeriesIndexLayout, SeriesDetailsLayout) {
return NzbDroneController.extend({
initialize: function () {
this.route('', this.series);
this.route('series', this.series);
this.route('series/:query', this.seriesDetails);
},
series: function () {
this.setTitle('NzbDrone');
AppLayout.mainRegion.show(new SeriesIndexLayout());
},
seriesDetails: function (query) {
var series = SeriesCollection.where({titleSlug: query});
if (series.length !== 0) {
var targetSeries = series[0];
this.setTitle(targetSeries.get('title'));
AppLayout.mainRegion.show(new SeriesDetailsLayout({ model: targetSeries }));
}
else {
this.showNotFound();
}
}
});
});

@ -2,7 +2,6 @@
define(
[
'backbone',
'underscore'
], function (Backbone, _) {
return Backbone.Model.extend({

@ -1,10 +1,13 @@
'use strict';
define(['app',
'marionette',
'Settings/Indexers/ItemView',
'Settings/Indexers/EditView',
'Settings/Indexers/Collection'],
function (App, Marionette, IndexerItemView, IndexerEditView, IndexerCollection) {
define(
[
'AppLayout',
'marionette',
'Settings/Indexers/ItemView',
'Settings/Indexers/EditView',
'Settings/Indexers/Collection',
'underscore'
], function (AppLayout, Marionette, IndexerItemView, IndexerEditView, IndexerCollection, _) {
return Marionette.CompositeView.extend({
itemView : IndexerItemView,
itemViewContainer: '#x-indexers',
@ -18,7 +21,7 @@ define(['app',
'click .x-add-card': '_openSchemaModal'
},
appendHtml: function(collectionView, itemView, index){
appendHtml: function (collectionView, itemView, index) {
collectionView.ui.addCard.parent('li').before(itemView.el);
},
@ -33,13 +36,13 @@ define(['app',
var model = _.first(collection.models);
model.set({
id: undefined,
name: '',
id : undefined,
name : '',
enable: true
});
var view = new IndexerEditView({ model: model, indexerCollection: self.collection});
App.modalRegion.show(view);
AppLayout.modalRegion.show(view);
}
});
}

@ -1,19 +0,0 @@
'use strict';
define(['app', 'marionette'], function (App, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/DeleteTemplate',
events: {
'click .x-confirm-delete': '_removeIndexer'
},
_removeIndexer: function () {
this.model.destroy({
wait : true,
success: function () {
App.vent.trigger(App.Commands.CloseModalCommand);
}
});
}
});
});

@ -2,16 +2,17 @@
define(
[
'app',
'vent',
'marionette',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function (App, Marionette, AsModelBoundView, AsValidatedView) {
'Mixins/AsValidatedView',
'underscore'
], function (vent, Marionette, AsModelBoundView, AsValidatedView, _) {
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/EditTemplate',
ui : {
ui: {
activity: '.x-activity'
},
@ -33,7 +34,7 @@ define(
if (promise) {
promise.done(function () {
self.indexerCollection.add(self.model, { merge: true });
App.vent.trigger(App.Commands.CloseModalCommand);
vent.trigger(vent.Commands.CloseModalCommand);
});
promise.fail(function () {

@ -2,12 +2,12 @@
define(
[
'app',
'AppLayout',
'marionette',
'Settings/Notifications/DeleteView',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function (App, Marionette, DeleteView, AsModelBoundView, AsValidatedView) {
], function (AppLayout, Marionette, DeleteView, AsModelBoundView, AsValidatedView) {
var view = Marionette.ItemView.extend({
template: 'Settings/Indexers/ItemTemplate',
@ -19,7 +19,7 @@ define(
_deleteIndexer: function () {
var view = new DeleteView({ model: this.model});
App.modalRegion.show(view);
AppLayout.modalRegion.show(view);
}
});

@ -1,4 +1,4 @@
'use strict';
'use strict';
define(
[
'marionette',

@ -1,10 +1,10 @@
'use strict';
define([
'app',
'AppLayout',
'marionette',
'Settings/Notifications/EditView'
], function (App, Marionette, EditView) {
], function (AppLayout, Marionette, EditView) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/AddItemTemplate',
@ -31,7 +31,7 @@ define([
});
var editView = new EditView({ model: this.model, notificationCollection: this.notificationCollection });
App.modalRegion.show(editView);
AppLayout.modalRegion.show(editView);
}
});
});

@ -1,10 +1,9 @@
'use strict';
define([
'app',
'marionette',
'Settings/Notifications/ItemView',
'Settings/Notifications/SchemaModal'
], function (App, Marionette, NotificationItemView, SchemaModal) {
], function (Marionette, NotificationItemView, SchemaModal) {
return Marionette.CompositeView.extend({
itemView : NotificationItemView,
itemViewContainer: '.notifications',

@ -1,19 +1,23 @@
'use strict';
define(['app', 'marionette'], function (App, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/DeleteTemplate',
define(
[
'vent',
'marionette'
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/DeleteTemplate',
events: {
'click .x-confirm-delete': '_removeNotification'
},
events: {
'click .x-confirm-delete': '_removeNotification'
},
_removeNotification: function () {
this.model.destroy({
wait : true,
success: function () {
App.vent.trigger(App.Commands.CloseModalCommand);
}
});
}
_removeNotification: function () {
this.model.destroy({
wait : true,
success: function () {
vent.trigger(vent.Commands.CloseModalCommand);
}
});
}
});
});
});

@ -1,92 +1,93 @@
'use strict';
define([
'app',
'marionette',
'Settings/Notifications/Model',
'Settings/Notifications/DeleteView',
'Shared/Messenger',
'Commands/CommandController',
'Mixins/AsModelBoundView',
'Form/FormBuilder'
], function (App, Marionette, NotificationModel, DeleteView, Messenger, CommandController, AsModelBoundView) {
var model = Marionette.ItemView.extend({
template: 'Settings/Notifications/EditTemplate',
events: {
'click .x-save' : '_saveNotification',
'click .x-save-and-add' : '_saveAndAddNotification',
'click .x-delete' : '_deleteNotification',
'click .x-back' : '_back',
'click .x-test' : '_test'
},
ui: {
testButton: '.x-test',
testIcon : '.x-test-icon'
},
initialize: function (options) {
this.notificationCollection = options.notificationCollection;
},
_saveNotification: function () {
var self = this;
var promise = this.model.saveSettings();
if (promise) {
promise.done(function () {
self.notificationCollection.add(self.model, { merge: true });
App.vent.trigger(App.Commands.CloseModalCommand);
});
define(
[
'vent',
'AppLayout',
'marionette',
'Settings/Notifications/DeleteView',
'Commands/CommandController',
'Mixins/AsModelBoundView',
'Form/FormBuilder',
'underscore'
], function (vent, AppLayout, Marionette, DeleteView, CommandController, AsModelBoundView, _) {
var model = Marionette.ItemView.extend({
template: 'Settings/Notifications/EditTemplate',
events: {
'click .x-save' : '_saveNotification',
'click .x-save-and-add': '_saveAndAddNotification',
'click .x-delete' : '_deleteNotification',
'click .x-back' : '_back',
'click .x-test' : '_test'
},
ui: {
testButton: '.x-test',
testIcon : '.x-test-icon'
},
initialize: function (options) {
this.notificationCollection = options.notificationCollection;
},
_saveNotification: function () {
var self = this;
var promise = this.model.saveSettings();
if (promise) {
promise.done(function () {
self.notificationCollection.add(self.model, { merge: true });
vent.trigger(vent.Commands.CloseModalCommand);
});
}
},
_saveAndAddNotification: function () {
var self = this;
var promise = this.model.saveSettings();
if (promise) {
promise.done(function () {
self.notificationCollection.add(self.model, { merge: true });
require('Settings/Notifications/SchemaModal').open(self.notificationCollection);
});
}
},
_deleteNotification: function () {
var view = new DeleteView({ model: this.model });
AppLayout.modalRegion.show(view);
},
_back: function () {
require('Settings/Notifications/SchemaModal').open(this.notificationCollection);
},
_test: function () {
var testCommand = this.model.get('testCommand');
if (testCommand) {
this.idle = false;
var properties = {};
_.each(this.model.get('fields'), function (field) {
properties[field.name] = field.value;
});
CommandController.Execute(testCommand, properties);
}
},
_testOnAlways: function () {
if (!this.isClosed) {
this.idle = true;
}
}
},
});
_saveAndAddNotification: function () {
var self = this;
var promise = this.model.saveSettings();
if (promise) {
promise.done(function () {
self.notificationCollection.add(self.model, { merge: true });
require('Settings/Notifications/SchemaModal').open(self.notificationCollection);
});
}
},
_deleteNotification: function () {
var view = new DeleteView({ model: this.model });
App.modalRegion.show(view);
},
_back: function () {
require('Settings/Notifications/SchemaModal').open(this.notificationCollection);
},
_test: function () {
var testCommand = this.model.get('testCommand');
if (testCommand) {
this.idle = false;
var properties = {};
_.each(this.model.get('fields'), function (field) {
properties[field.name] = field.value;
});
CommandController.Execute(testCommand, properties);
}
},
_testOnAlways: function () {
if (!this.isClosed) {
this.idle = true;
}
}
return AsModelBoundView.call(model);
});
return AsModelBoundView.call(model);
});

@ -1,12 +1,12 @@
'use strict';
define([
'app',
'AppLayout',
'marionette',
'Settings/Notifications/EditView',
'Settings/Notifications/DeleteView'
], function (App, Marionette, EditView, DeleteView) {
], function (AppLayout, Marionette, EditView, DeleteView) {
return Marionette.ItemView.extend({
template: 'Settings/Notifications/ItemTemplate',
@ -23,12 +23,12 @@ define([
_editNotification: function () {
var view = new EditView({ model: this.model, notificationCollection: this.model.collection});
App.modalRegion.show(view);
AppLayout.modalRegion.show(view);
},
_deleteNotification: function () {
var view = new DeleteView({ model: this.model});
App.modalRegion.show(view);
AppLayout.modalRegion.show(view);
}
});
});

@ -1,9 +1,9 @@
'use strict';
define([
'app',
'AppLayout',
'Settings/Notifications/Collection',
'Settings/Notifications/AddView'
], function (App, NotificationCollection, AddSelectionNotificationView) {
], function (AppLayout, NotificationCollection, AddSelectionNotificationView) {
return ({
open: function (collection) {
@ -13,7 +13,7 @@ define([
schemaCollection.url = '/api/notification';
var view = new AddSelectionNotificationView({ collection: schemaCollection, notificationCollection: collection});
App.modalRegion.show(view);
AppLayout.modalRegion.show(view);
}
});
});

@ -1,18 +1,22 @@
'use strict';
define(['app', 'handlebars'], function (App,Handlebars) {
Handlebars.registerHelper('allowedLabeler', function () {
var ret = '';
var cutoff = this.cutoff;
_.each(this.allowed, function (allowed) {
if (allowed.id === cutoff.id) {
ret += '<span class="label label-info" title="Cutoff">' + allowed.name + '</span> ';
}
define(
[
'handlebars',
'underscore'
], function (Handlebars, _) {
Handlebars.registerHelper('allowedLabeler', function () {
var ret = '';
var cutoff = this.cutoff;
_.each(this.allowed, function (allowed) {
if (allowed.id === cutoff.id) {
ret += '<span class="label label-info" title="Cutoff">' + allowed.name + '</span> ';
}
else {
ret += '<span class="label">' + allowed.name + '</span> ';
}
});
else {
ret += '<span class="label">' + allowed.name + '</span> ';
}
});
return new Handlebars.SafeString(ret);
return new Handlebars.SafeString(ret);
});
});
});

@ -1,9 +1,9 @@
'use strict';
define(
[
'app',
'vent',
'marionette'
], function (App, Marionette) {
], function (vent, Marionette) {
return Marionette.ItemView.extend({
template: 'Settings/Quality/Profile/DeleteTemplate',
@ -17,7 +17,7 @@ define(
this.model.destroy({
wait: true
}).done(function () {
App.vent.trigger(App.Commands.CloseModalCommand);
vent.trigger(vent.Commands.CloseModalCommand);
});
}
});

@ -1,11 +1,13 @@
'use strict';
define(
[
'app',
'vent',
'marionette',
'backbone',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function (App, Marionette, AsModelBoundView, AsValidatedView) {
'Mixins/AsValidatedView',
'underscore'
], function (vent, Marionette, Backbone, AsModelBoundView, AsValidatedView, _) {
var view = Marionette.ItemView.extend({
template: 'Settings/Quality/Profile/EditQualityProfileTemplate',
@ -61,7 +63,7 @@ define(
_saveQualityProfile: function () {
var self = this;
var cutoff = _.findWhere(this.model.get('allowed'), { id: parseInt(this.ui.cutoff.val())});
var cutoff = _.findWhere(this.model.get('allowed'), { id: parseInt(this.ui.cutoff.val(), 10)});
this.model.set('cutoff', cutoff);
var promise = this.model.save();
@ -69,7 +71,7 @@ define(
if (promise) {
promise.done(function () {
self.profileCollection.add(self.model, { merge: true });
App.vent.trigger(App.Commands.CloseModalCommand);
vent.trigger(vent.Commands.CloseModalCommand);
});
}
}

@ -1,11 +1,12 @@
'use strict';
define(['app',
define(['AppLayout',
'marionette',
'Settings/Quality/Profile/QualityProfileView',
'Settings/Quality/Profile/EditQualityProfileView',
'Settings/Quality/Profile/QualityProfileSchemaCollection'
], function (App, Marionette, QualityProfileView, EditProfileView, ProfileCollection) {
'Settings/Quality/Profile/QualityProfileSchemaCollection',
'underscore'
], function (AppLayout, Marionette, QualityProfileView, EditProfileView, ProfileCollection, _) {
return Marionette.CompositeView.extend({
itemView : QualityProfileView,
@ -35,7 +36,7 @@ define(['app',
model.collection = self.collection;
var view = new EditProfileView({ model: model, profileCollection: self.collection});
App.modalRegion.show(view);
AppLayout.modalRegion.show(view);
}
});
}

@ -2,16 +2,15 @@
define(
[
'app',
'AppLayout',
'marionette',
'Settings/Quality/Profile/EditQualityProfileView',
'Settings/Quality/Profile/DeleteView',
'Series/SeriesCollection',
'Mixins/AsModelBoundView',
'Settings/Quality/Profile/AllowedLabeler',
'bootstrap',
], function (App, Marionette, EditProfileView, DeleteProfileView, SeriesCollection, AsModelBoundView) {
'bootstrap'
], function (AppLayout, Marionette, EditProfileView, DeleteProfileView, SeriesCollection, AsModelBoundView) {
var view = Marionette.ItemView.extend({
template: 'Settings/Quality/Profile/QualityProfileTemplate',
@ -29,12 +28,12 @@ define(
initialize: function () {
this.listenTo(this.model, 'sync', this.render);
this.listenTo(SeriesCollection, 'all', this._updateDisableStatus)
this.listenTo(SeriesCollection, 'all', this._updateDisableStatus);
},
_editProfile: function () {
var view = new EditProfileView({ model: this.model, profileCollection: this.model.collection });
App.modalRegion.show(view);
AppLayout.modalRegion.show(view);
},
_deleteProfile: function () {
@ -43,7 +42,7 @@ define(
}
var view = new DeleteProfileView({ model: this.model });
App.modalRegion.show(view);
AppLayout.modalRegion.show(view);
},
onRender: function () {

@ -1,55 +1,61 @@
'use strict';
define(['marionette', 'Mixins/AsModelBoundView', 'filesize', 'jquery.knob' ], function (Marionette, AsModelBoundView, Filesize) {
var view = Marionette.ItemView.extend({
template : 'Settings/Quality/Size/QualitySizeTemplate',
tagName : 'li',
ui: {
knob : '.x-knob',
thirtyMinuteSize: '.x-size-thirty',
sixtyMinuteSize : '.x-size-sixty'
},
events: {
'change .x-knob': '_changeMaxSize'
},
initialize: function (options) {
this.qualityProfileCollection = options.qualityProfiles;
this.filesize = Filesize;
},
onRender: function () {
this.ui.knob.knob({
min : 0,
max : 200,
step : 1,
cursor : 25,
width : 150,
stopper : true,
displayInput : false
});
this._changeMaxSize();
},
_changeMaxSize: function () {
var maxSize = this.model.get('maxSize');
var bytes = maxSize * 1024 * 1024;
var thirty = Filesize(bytes * 30, 1, false);
var sixty = Filesize(bytes * 60, 1, false);
if (parseInt(maxSize) === 0) {
thirty = 'No Limit';
sixty = 'No Limit';
define(
[
'marionette',
'Mixins/AsModelBoundView',
'filesize',
'jquery.knob'
], function (Marionette, AsModelBoundView, Filesize) {
var view = Marionette.ItemView.extend({
template: 'Settings/Quality/Size/QualitySizeTemplate',
tagName : 'li',
ui: {
knob : '.x-knob',
thirtyMinuteSize: '.x-size-thirty',
sixtyMinuteSize : '.x-size-sixty'
},
events: {
'change .x-knob': '_changeMaxSize'
},
initialize: function (options) {
this.qualityProfileCollection = options.qualityProfiles;
this.filesize = Filesize;
},
onRender: function () {
this.ui.knob.knob({
min : 0,
max : 200,
step : 1,
cursor : 25,
width : 150,
stopper : true,
displayInput: false
});
this._changeMaxSize();
},
_changeMaxSize: function () {
var maxSize = this.model.get('maxSize');
var bytes = maxSize * 1024 * 1024;
var thirty = Filesize(bytes * 30, 1, false);
var sixty = Filesize(bytes * 60, 1, false);
if (parseInt(maxSize, 10) === 0) {
thirty = 'No Limit';
sixty = 'No Limit';
}
this.ui.thirtyMinuteSize.html(thirty);
this.ui.sixtyMinuteSize.html(sixty);
}
});
this.ui.thirtyMinuteSize.html(thirty);
this.ui.sixtyMinuteSize.html(sixty);
}
return AsModelBoundView.call(view);
});
return AsModelBoundView.call(view);
});

@ -1,8 +1,9 @@
'use strict';
'use strict';
define(
[
'app',
'vent',
'marionette',
'backbone',
'Settings/SettingsModel',
'Settings/General/GeneralSettingsModel',
'Settings/MediaManagement/Naming/Model',
@ -16,8 +17,9 @@ define(
'Settings/General/GeneralView',
'Shared/LoadingView',
'Config'
], function (App,
], function (vent,
Marionette,
Backbone,
SettingsModel,
GeneralSettingsModel,
NamingModel,
@ -87,6 +89,8 @@ define(
this.indexerSettings.fetch(),
this.notificationSettings.fetch()
).done(function () {
if(!self.isClosed)
{
self.loading.$el.hide();
self.mediaManagement.show(new MediaManagementLayout({ settings: self.settings, namingSettings: self.namingSettings }));
self.quality.show(new QualityLayout({ settings: self.settings }));
@ -94,6 +98,7 @@ define(
self.downloadClient.show(new DownloadClientLayout({ model: self.settings }));
self.notifications.show(new NotificationCollectionView({ collection: self.notificationSettings }));
self.general.show(new GeneralView({ model: self.generalSettings }));
}
});
this._setAdvancedSettingsState();
@ -179,13 +184,11 @@ define(
},
_navigate:function(route){
require(['Router'], function(){
App.Router.navigate(route);
});
Backbone.history.navigate(route, {trigger:true});
},
_save: function () {
App.vent.trigger(App.Commands.SaveSettings);
vent.trigger(vent.Commands.SaveSettings);
},
_setAdvancedSettingsState: function () {

@ -1,9 +1,11 @@
'use strict';
define(['app',
'Settings/SettingsModelBase'], function (App, SettingsModelBase) {
return SettingsModelBase.extend({
url : window.NzbDrone.ApiRoot + '/settings',
successMessage: 'Settings saved',
errorMessage : 'Failed to save settings'
'use strict';
define(
[
'Settings/SettingsModelBase'
], function (SettingsModelBase) {
return SettingsModelBase.extend({
url : window.NzbDrone.ApiRoot + '/settings',
successMessage: 'Settings saved',
errorMessage : 'Failed to save settings'
});
});
});

@ -1,34 +1,36 @@
'use strict';
define(['app',
'backbone.deepmodel',
'Mixins/AsChangeTrackingModel',
'Shared/Messenger'], function (App, DeepModel, AsChangeTrackingModel, Messenger) {
var model = DeepModel.DeepModel.extend({
define(
[
'vent',
'backbone.deepmodel',
'Mixins/AsChangeTrackingModel',
'Shared/Messenger'
], function (vent, DeepModel, AsChangeTrackingModel, Messenger) {
var model = DeepModel.DeepModel.extend({
initialize: function () {
this.listenTo(App.vent, App.Commands.SaveSettings, this.saveSettings);
},
initialize: function () {
this.listenTo(vent, vent.Commands.SaveSettings, this.saveSettings);
},
saveSettings: function () {
saveSettings: function () {
if (!this.isSaved) {
if (!this.isSaved) {
var savePromise = this.save();
var savePromise = this.save();
Messenger.monitor(
{
promise : savePromise,
successMessage: this.successMessage,
errorMessage : this.errorMessage
});
Messenger.monitor({
promise : savePromise,
successMessage: this.successMessage,
errorMessage : this.errorMessage
});
return savePromise;
return savePromise;
}
return undefined;
}
return undefined;
}
});
return AsChangeTrackingModel.call(model);
});
return AsChangeTrackingModel.call(model);
});

@ -1,2 +0,0 @@
&copy; Copyright 2013 NzbDrone
<p>v{{version}} ({{ShortDate buildTime}})</p>

@ -1,12 +0,0 @@
'use strict';
define(
[
'marionette',
'System/StatusModel'
], function (Marionette, StatusModel) {
return Marionette.ItemView.extend({
template: 'Shared/Footer/Template',
model : StatusModel
});
});

@ -1,48 +1,47 @@
'use strict';
define(
[
'app',
'vent',
'AppLayout',
'marionette',
'Series/Edit/EditSeriesView',
'Series/Delete/DeleteSeriesView',
'Episode/EpisodeDetailsLayout',
'History/Details/HistoryDetailsView'
], function (App, Marionette, EditSeriesView, DeleteSeriesView, EpisodeDetailsLayout, HistoryDetailsView) {
], function (vent, AppLayout, Marionette, EditSeriesView, DeleteSeriesView, EpisodeDetailsLayout, HistoryDetailsView) {
var router = Marionette.AppRouter.extend({
return Marionette.AppRouter.extend({
initialize: function () {
App.vent.on(App.Commands.CloseModalCommand, this._closeModal, this);
App.vent.on(App.Commands.EditSeriesCommand, this._editSeries, this);
App.vent.on(App.Commands.DeleteSeriesCommand, this._deleteSeries, this);
App.vent.on(App.Commands.ShowEpisodeDetails, this._showEpisode, this);
App.vent.on(App.Commands.ShowHistoryDetails, this._showHistory, this);
vent.on(vent.Commands.CloseModalCommand, this._closeModal, this);
vent.on(vent.Commands.EditSeriesCommand, this._editSeries, this);
vent.on(vent.Commands.DeleteSeriesCommand, this._deleteSeries, this);
vent.on(vent.Commands.ShowEpisodeDetails, this._showEpisode, this);
vent.on(vent.Commands.ShowHistoryDetails, this._showHistory, this);
},
_closeModal: function () {
App.modalRegion.closeModal();
AppLayout.modalRegion.closeModal();
},
_editSeries: function (options) {
var view = new EditSeriesView({ model: options.series });
App.modalRegion.show(view);
AppLayout.modalRegion.show(view);
},
_deleteSeries: function (options) {
var view = new DeleteSeriesView({ model: options.series });
App.modalRegion.show(view);
AppLayout.modalRegion.show(view);
},
_showEpisode: function (options) {
var view = new EpisodeDetailsLayout({ model: options.episode, hideSeriesLink: options.hideSeriesLink, openingTab: options.openingTab });
App.modalRegion.show(view);
AppLayout.modalRegion.show(view);
},
_showHistory: function (options) {
var view = new HistoryDetailsView({ model: options.history });
App.modalRegion.show(view);
AppLayout.modalRegion.show(view);
}
});
return new router();
});

@ -1,11 +1,11 @@
'use strict';
define(
[
'app',
'$',
'jquery',
'backbone',
'marionette',
'bootstrap'
], function (app, $, Marionette) {
], function ($,Backbone, Marionette) {
var region = Marionette.Region.extend({
el: '#modal-region',
@ -39,17 +39,5 @@ define(
});
require(
[
'Shared/Modal/Controller'
], function () {
app.addInitializer(function () {
app.addRegions({
modalRegion: region
});
});
});
return region;
});

@ -1,3 +1,3 @@
<div>
<img src="/content/images/404.png" style="height:400px; margin-top: 50px"/>
<img src="/Content/Images/404.png" style="height:400px; margin-top: 50px"/>
</div>

@ -0,0 +1,25 @@
'use strict';
define(
[
'AppLayout',
'marionette',
'Shared/NotFoundView'
], function (AppLayout, Marionette, NotFoundView) {
return Marionette.AppRouter.extend({
showNotFound: function () {
this.setTitle('Not Found');
AppLayout.mainRegion.show(new NotFoundView(this));
},
setTitle: function (title) {
if (title.toLocaleLowerCase() === 'nzbdrone') {
window.document.title = 'NzbDrone';
}
else {
window.document.title = title + ' - NzbDrone';
}
}
});
});

@ -1,9 +1,9 @@
'use strict';
define(
[
'app',
'vent',
'signalR'
], function () {
], function (vent) {
return {
appInitializer: function () {
@ -31,12 +31,7 @@ define(
});
this.signalRconnection.received(function (message) {
require(
[
'app'
], function (app) {
app.vent.trigger('server:' + message.name, message.body);
});
vent.trigger('server:' + message.name, message.body);
});
this.signalRconnection.start({ transport:

@ -1,11 +1,11 @@
'use strict';
define(
[
'app',
'backbone',
'marionette',
'underscore',
'Commands/CommandController'
], function (App, Marionette, _, CommandController) {
], function (Backbone, Marionette, _, CommandController) {
return Marionette.ItemView.extend({
template : 'Shared/Toolbar/ButtonTemplate',
@ -61,13 +61,7 @@ define(
invokeRoute: function () {
var route = this.model.get('route');
if (route) {
require(
[
'Router'
], function () {
App.Router.navigate(route, {trigger: true});
});
Backbone.history.navigate(route, {trigger: true});
}
},

@ -2,9 +2,8 @@
define(
[
'app',
'marionette'
], function (App, Marionette) {
], function (Marionette) {
return Marionette.ItemView.extend({
template: 'System/Logs/Files/ContentsViewTemplate'
});

@ -1,7 +1,7 @@
'use strict';
define(
[
'app',
'vent',
'marionette',
'backgrid',
'System/Logs/Files/FilenameCell',
@ -13,7 +13,7 @@ define(
'System/Logs/Files/ContentsModel',
'Shared/Toolbar/ToolbarLayout',
'Shared/LoadingView'
], function (App,
], function (vent,
Marionette,
Backgrid,
FilenameCell,
@ -57,11 +57,12 @@ define(
initialize: function () {
this.collection = new LogFileCollection();
App.vent.on(App.Commands.ShowLogFile, this._fetchLogFileContents, this);
App.vent.on(App.Events.CommandComplete, this._commandComplete, this);
vent.on(vent.Commands.ShowLogFile, this._fetchLogFileContents, this);
vent.on(vent.Events.CommandComplete, this._commandComplete, this);
this.listenTo(this.collection, 'sync', this._collectionSynced);
this.collection.fetch();
},
onShow: function () {

@ -1,9 +1,9 @@
'use strict';
define(
[
'app',
'vent',
'backgrid'
], function (App, Backgrid) {
], function (vent, Backgrid) {
return Backgrid.Row.extend({
className: 'log-file-row',
@ -13,7 +13,7 @@ define(
},
_showContents: function () {
App.vent.trigger(App.Commands.ShowLogFile, { model: this.model });
vent.trigger(vent.Commands.ShowLogFile, { model: this.model });
}
});
});

@ -1,7 +1,7 @@
'use strict';
define(
[
'app',
'vent',
'marionette',
'backgrid',
'System/Logs/Table/LogTimeCell',
@ -10,7 +10,7 @@ define(
'System/Logs/LogsCollection',
'Shared/Toolbar/ToolbarLayout',
'Shared/LoadingView'
], function (App, Marionette, Backgrid, LogTimeCell, LogLevelCell, GridPager, LogCollection, ToolbarLayout, LoadingView) {
], function (vent, Marionette, Backgrid, LogTimeCell, LogLevelCell, GridPager, LogCollection, ToolbarLayout, LoadingView) {
return Marionette.Layout.extend({
template: 'System/Logs/Table/LogsTableLayoutTemplate',
@ -59,7 +59,7 @@ define(
this.collection = new LogCollection();
this.collectionPromise = this.collection.fetch();
App.vent.on(App.Events.CommandComplete, this._commandComplete, this);
vent.on(vent.Events.CommandComplete, this._commandComplete, this);
},
onRender: function () {

@ -1,12 +1,12 @@
'use strict';
define(
[
'app',
'backbone',
'marionette',
'System/About/AboutView',
'System/Logs/LogsLayout',
'System/Update/UpdateLayout'
], function (App,
], function (Backbone,
Marionette,
AboutView,
LogsLayout,
@ -52,9 +52,7 @@ define(
},
_navigate:function(route){
require(['Router'], function(){
App.Router.navigate(route);
});
Backbone.history.navigate(route);
},
_showAbout: function (e) {

@ -2,9 +2,8 @@
define(
[
'app',
'marionette'
], function (App, Marionette) {
], function (Marionette) {
return Marionette.ItemView.extend({
template: 'System/Update/UpdateItemViewTemplate',

@ -1,8 +1,5 @@
'use strict';
require.config({
urlArgs: 'v=' + window.NzbDrone.ServerStatus.version,
paths: {
'backbone' : 'JsLibraries/backbone',
'moment' : 'JsLibraries/moment',
@ -16,23 +13,24 @@ require.config({
'backbone.modelbinder': 'JsLibraries/backbone.modelbinder',
'backgrid' : 'JsLibraries/backbone.backgrid',
'backgrid.paginator' : 'JsLibraries/backbone.backgrid.paginator',
'backgrid.selectall' : 'JsLibraries/backbone.backgrid.selectall',
'backgrid.selectall' : 'JsLibraries/backbone.backgrid.selectall',
'fullcalendar' : 'JsLibraries/fullcalendar',
'backstrech' : 'JsLibraries/jquery.backstretch',
'$' : 'JsLibraries/jquery',
'underscore' : 'JsLibraries/lodash.underscore',
'marionette' : 'JsLibraries/backbone.marionette',
'signalR' : 'JsLibraries/jquery.signalR',
'jquery.knob' : 'JsLibraries/jquery.knob',
'jquery.dotdotdot' : 'JsLibraries/jquery.dotdotdot',
'libs' : 'JsLibraries/'
'jquery' : 'JsLibraries/jquery',
'libs' : 'JsLibraries/',
'api': 'Require/require.api'
},
shim: {
$: {
exports: '$',
jquery: {
exports: 'jQuery',
deps :
[
'Mixins/jquery.ajax'
@ -53,28 +51,33 @@ require.config({
signalR: {
deps:
[
'$'
'jquery'
]
},
bootstrap: {
deps:
[
'$'
]
'jquery'
],
init: function ($) {
$('body').tooltip({
selector: '[title]'
});
}
},
backstrech: {
deps:
[
'$'
'jquery'
]
},
underscore: {
deps :
[
'$'
'jquery'
],
exports: '_'
},
@ -83,7 +86,7 @@ require.config({
deps :
[
'underscore',
'$'
'jquery'
],
exports: 'Backbone'
},
@ -123,14 +126,14 @@ require.config({
'jquery.knob': {
deps:
[
'$'
'jquery'
]
},
'jquery.dotdotdot': {
deps:
[
'$'
'jquery'
]
},
@ -190,55 +193,44 @@ require.config({
}
});
require.config({
urlArgs: 'v=' + window.NzbDrone.ServerStatus.version
});
define(
[
'backbone',
'marionette',
'jQuery/RouteBinder',
'Shared/SignalRBroadcaster',
'Navbar/NavbarView',
'AppLayout',
'Series/SeriesController',
'Router',
'Shared/Modal/Controller',
'Instrumentation/StringFormat'
], function (Marionette, SignalRBroadcaster) {
], function (Backbone, Marionette, RouteBinder, SignalRBroadcaster, NavbarView, AppLayout, SeriesController, Router, ModalController) {
var app = new Marionette.Application();
new SeriesController();
new ModalController();
new Router();
app.Events = {
SeriesAdded : 'series:added',
SeriesDeleted : 'series:deleted',
SeasonRenamed : 'season:renamed',
CommandComplete: 'command:complete'
};
app.Commands = {
EditSeriesCommand : 'EditSeriesCommand',
DeleteSeriesCommand : 'DeleteSeriesCommand',
CloseModalCommand : 'CloseModalCommand',
ShowEpisodeDetails : 'ShowEpisodeDetails',
ShowHistoryDetails : 'ShowHistoryDetails',
SaveSettings : 'saveSettings',
ShowLogFile : 'showLogFile'
};
app.Reqres = {
GetEpisodeFileById: 'GetEpisodeFileById'
};
var app = new Marionette.Application();
app.addInitializer(function () {
console.log('starting application');
});
app.addInitializer(SignalRBroadcaster.appInitializer, { app: app });
app.addInitializer(SignalRBroadcaster.appInitializer, {
app: app
});
app.addRegions({
navbarRegion: '#nav-region',
mainRegion : '#main-region',
footerRegion: '#footer-region'
app.addInitializer(function () {
Backbone.history.start({ pushState: true });
RouteBinder.bind();
AppLayout.navbarRegion.show(new NavbarView());
$('body').addClass('started');
});
app.start();
window.require(
[
'Router',
'jQuery/TooltipBinder'
]);
return app;
});

@ -74,4 +74,5 @@
<script src="/ServerStatus.js"></script>
<script data-main="/app" src="/JsLibraries/require.js"></script>
<script src="/JsLibraries/xrayquire.js"></script>
</html>

@ -1,18 +1,18 @@
'use strict';
define(function () {
define(['backbone'],function (Backbone) {
//This module will automatically route all relative links through backbone router rather than
//causing links to reload pages.
var routeBinder = {
bind: function (router) {
bind: function () {
var self = this;
$(document).on('click', 'a[href]', function (event) {
self._handleClick(event, router);
self._handleClick(event);
});
},
_handleClick: function (event, router) {
_handleClick: function (event) {
var $target = $(event.target);
//check if tab nav
@ -41,7 +41,7 @@ define(function () {
if (!href.startsWith('http')) {
router.navigate(href, { trigger: true });
Backbone.history.navigate(href, { trigger: true });
}
else {

@ -1,10 +0,0 @@
'use strict';
define(
[
'bootstrap'
], function () {
$('body').tooltip({
selector: '[title]'
});
});

@ -0,0 +1,14 @@
define(
[
'marionette',
'backbone'
], function (Marionette, Backbone) {
'use strict';
var reqres = new Backbone.Wreqr.RequestResponse();
reqres.Requests = {
GetEpisodeFileById: 'GetEpisodeFileById'
};
return reqres;
});

@ -0,0 +1,28 @@
define(
[
'marionette',
'backbone'
], function (Marionette, Backbone) {
'use strict';
var vent = new Backbone.Wreqr.EventAggregator();
vent.Events = {
SeriesAdded : 'series:added',
SeriesDeleted : 'series:deleted',
SeasonRenamed : 'season:renamed',
CommandComplete: 'command:complete'
};
vent.Commands = {
EditSeriesCommand : 'EditSeriesCommand',
DeleteSeriesCommand: 'DeleteSeriesCommand',
CloseModalCommand : 'CloseModalCommand',
ShowEpisodeDetails : 'ShowEpisodeDetails',
ShowHistoryDetails : 'ShowHistoryDetails',
SaveSettings : 'saveSettings',
ShowLogFile : 'showLogFile'
};
return vent;
});
Loading…
Cancel
Save