mirror of
https://github.com/Radarr/Radarr.git
synced 2024-11-09 04:22:30 +01:00
almost all js files are loaded using require.js
This commit is contained in:
parent
aed7b95245
commit
2407e33ea2
@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
define(['app', 'AddSeries/RootFolders/RootFolderModel'], function () {
|
||||
define(['app', 'AddSeries/RootFolders/RootFolderModel','mixins/backbone.signalr.mixin'], function () {
|
||||
|
||||
var rootFolderCollection = Backbone.Collection.extend({
|
||||
url : NzbDrone.Constants.ApiRoot + '/rootfolder',
|
||||
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
define(['app', 'Calendar/Collection'], function () {
|
||||
define(['app', 'Calendar/Collection','fullcalendar'], function () {
|
||||
NzbDrone.Calendar.CalendarView = Backbone.Marionette.ItemView.extend({
|
||||
initialize : function () {
|
||||
this.collection = new NzbDrone.Calendar.Collection();
|
||||
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
define(['app' ], function () {
|
||||
define(['app','backgrid' ], function () {
|
||||
NzbDrone.Cells.EpisodeStatusCell = Backgrid.Cell.extend({
|
||||
|
||||
className: 'episode-status-cell',
|
||||
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
define(['app', 'Shared/FormatHelpers'], function () {
|
||||
define(['app', 'Shared/FormatHelpers','backgrid'], function () {
|
||||
NzbDrone.Cells.FileSizeCell = Backgrid.Cell.extend({
|
||||
|
||||
className: "file-size-cell",
|
||||
|
@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
define(['app'], function () {
|
||||
define(['app','backgrid'], function () {
|
||||
NzbDrone.Cells.IndexerCell = Backgrid.Cell.extend({
|
||||
|
||||
class : 'indexer-cell',
|
||||
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
define(['app'], function () {
|
||||
define(['app','backgrid'], function () {
|
||||
NzbDrone.Cells.NzbDroneCell = Backgrid.Cell.extend({
|
||||
|
||||
_originalInit: Backgrid.Cell.prototype.initialize,
|
||||
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
define(['app', 'History/Model'], function () {
|
||||
NzbDrone.History.Collection = Backbone.PageableCollection.extend({
|
||||
define(['app', 'History/Model', 'backbone.pageable'], function (App, HistoryModel, PageableCollection) {
|
||||
NzbDrone.History.Collection = PageableCollection.extend({
|
||||
url : NzbDrone.Constants.ApiRoot + '/history',
|
||||
model : NzbDrone.History.Model,
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
"use strict";
|
||||
define(['app','backgrid'], function () {
|
||||
NzbDrone.Missing.Row = Backgrid.Row.extend({
|
||||
events: {
|
||||
'click .x-search': 'search'
|
||||
@ -7,3 +9,6 @@ NzbDrone.Missing.Row = Backgrid.Row.extend({
|
||||
window.alert('Episode Search');
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Missing.Row;
|
||||
});
|
||||
|
@ -78,35 +78,12 @@
|
||||
</body>
|
||||
<script src="/JsLibraries/jquery.js"></script>
|
||||
<script src="/JsLibraries/messenger.js"></script>
|
||||
<script src="/Instrumentation/StringFormat.js"></script>
|
||||
<script src="/Instrumentation/ErrorHandler.js"></script>
|
||||
<script src="/JsLibraries/jquery.signalR.js"></script>
|
||||
<script src="/JsLibraries/bootstrap.js"></script>
|
||||
<script src="/JsLibraries/bootstrap.slider.js"></script>
|
||||
<script src="/JsLibraries/underscore.js"></script>
|
||||
<script src="/JsLibraries/handlebars.runtime.js"></script>
|
||||
<script src="/JsLibraries/backbone.js"></script>
|
||||
<script src="/JsLibraries/backbone.modelbinder.js"></script>
|
||||
<script src="/JsLibraries/backbone.deep.model.js"></script>
|
||||
<script src="/JsLibraries/backbone.mutators.js"></script>
|
||||
<script src="/JsLibraries/backbone.mutators.deep.model.js"></script>
|
||||
<script src="/JsLibraries/backbone.marionette.js"></script>
|
||||
<script src="/JsLibraries/backbone.pageable.js"></script>
|
||||
<script src="/JsLibraries/lunr.js"></script>
|
||||
<!--<script src="/JsLibraries/backbone.backgrid.js"></script>
|
||||
<script src="/JsLibraries/backbone.backgrid.filter.js"></script>-->
|
||||
<script src="/JsLibraries/jquery.backstretch.js"></script>
|
||||
<script src="/JsLibraries/sugar.js"></script>
|
||||
<script src="/JsLibraries/fullcalendar.js"></script>
|
||||
|
||||
<script src="/templates.js"></script>
|
||||
|
||||
<script src="/Mixins/backbone.marionette.templates.js"></script>
|
||||
<script src="/Mixins/backbone.marionette.region.mixin.js"></script>
|
||||
<script src="/Mixins/backbone.ajax.js"></script>
|
||||
<script src="/Mixins/backbone.modelbinder.mixin.js"></script>
|
||||
<script src="/Mixins/backbone.signalr.mixin.js"></script>
|
||||
|
||||
<script data-main="/app" src="/JsLibraries/require.js"></script>
|
||||
<script src="/Routing.js"></script>
|
||||
</html>
|
||||
|
@ -1,124 +1,3 @@
|
||||
/*jshint expr:true eqnull:true */
|
||||
/**
|
||||
*
|
||||
* Backbone.DeepModel v0.10.4
|
||||
*
|
||||
* Copyright (c) 2013 Charles Davison, Pow Media Ltd
|
||||
*
|
||||
* https://github.com/powmedia/backbone-deep-model
|
||||
* Licensed under the MIT License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Underscore mixins for deep objects
|
||||
*
|
||||
* Based on https://gist.github.com/echong/3861963
|
||||
*/
|
||||
(function() {
|
||||
var arrays, basicObjects, deepClone, deepExtend, deepExtendCouple, isBasicObject,
|
||||
__slice = [].slice;
|
||||
|
||||
deepClone = function(obj) {
|
||||
var func, isArr;
|
||||
if (!_.isObject(obj) || _.isFunction(obj)) {
|
||||
return obj;
|
||||
}
|
||||
if (obj instanceof Backbone.Collection || obj instanceof Backbone.Model) {
|
||||
return obj;
|
||||
}
|
||||
if (_.isDate(obj)) {
|
||||
return new Date(obj.getTime());
|
||||
}
|
||||
if (_.isRegExp(obj)) {
|
||||
return new RegExp(obj.source, obj.toString().replace(/.*\//, ""));
|
||||
}
|
||||
isArr = _.isArray(obj || _.isArguments(obj));
|
||||
func = function(memo, value, key) {
|
||||
if (isArr) {
|
||||
memo.push(deepClone(value));
|
||||
} else {
|
||||
memo[key] = deepClone(value);
|
||||
}
|
||||
return memo;
|
||||
};
|
||||
return _.reduce(obj, func, isArr ? [] : {});
|
||||
};
|
||||
|
||||
isBasicObject = function(object) {
|
||||
if (object == null) return false;
|
||||
return (object.prototype === {}.prototype || object.prototype === Object.prototype) && _.isObject(object) && !_.isArray(object) && !_.isFunction(object) && !_.isDate(object) && !_.isRegExp(object) && !_.isArguments(object);
|
||||
};
|
||||
|
||||
basicObjects = function(object) {
|
||||
return _.filter(_.keys(object), function(key) {
|
||||
return isBasicObject(object[key]);
|
||||
});
|
||||
};
|
||||
|
||||
arrays = function(object) {
|
||||
return _.filter(_.keys(object), function(key) {
|
||||
return _.isArray(object[key]);
|
||||
});
|
||||
};
|
||||
|
||||
deepExtendCouple = function(destination, source, maxDepth) {
|
||||
var combine, recurse, sharedArrayKey, sharedArrayKeys, sharedObjectKey, sharedObjectKeys, _i, _j, _len, _len1;
|
||||
if (maxDepth == null) {
|
||||
maxDepth = 20;
|
||||
}
|
||||
if (maxDepth <= 0) {
|
||||
console.warn('_.deepExtend(): Maximum depth of recursion hit.');
|
||||
return _.extend(destination, source);
|
||||
}
|
||||
sharedObjectKeys = _.intersection(basicObjects(destination), basicObjects(source));
|
||||
recurse = function(key) {
|
||||
return source[key] = deepExtendCouple(destination[key], source[key], maxDepth - 1);
|
||||
};
|
||||
for (_i = 0, _len = sharedObjectKeys.length; _i < _len; _i++) {
|
||||
sharedObjectKey = sharedObjectKeys[_i];
|
||||
recurse(sharedObjectKey);
|
||||
}
|
||||
sharedArrayKeys = _.intersection(arrays(destination), arrays(source));
|
||||
combine = function(key) {
|
||||
return source[key] = _.union(destination[key], source[key]);
|
||||
};
|
||||
for (_j = 0, _len1 = sharedArrayKeys.length; _j < _len1; _j++) {
|
||||
sharedArrayKey = sharedArrayKeys[_j];
|
||||
combine(sharedArrayKey);
|
||||
}
|
||||
return _.extend(destination, source);
|
||||
};
|
||||
|
||||
deepExtend = function() {
|
||||
var finalObj, maxDepth, objects, _i;
|
||||
objects = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), maxDepth = arguments[_i++];
|
||||
if (!_.isNumber(maxDepth)) {
|
||||
objects.push(maxDepth);
|
||||
maxDepth = 20;
|
||||
}
|
||||
if (objects.length <= 1) {
|
||||
return objects[0];
|
||||
}
|
||||
if (maxDepth <= 0) {
|
||||
return _.extend.apply(this, objects);
|
||||
}
|
||||
finalObj = objects.shift();
|
||||
while (objects.length > 0) {
|
||||
finalObj = deepExtendCouple(finalObj, deepClone(objects.shift()), maxDepth);
|
||||
}
|
||||
return finalObj;
|
||||
};
|
||||
|
||||
_.mixin({
|
||||
deepClone: deepClone,
|
||||
isBasicObject: isBasicObject,
|
||||
basicObjects: basicObjects,
|
||||
arrays: arrays,
|
||||
deepExtend: deepExtend
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
|
||||
/**
|
||||
* Main source
|
||||
*/
|
||||
@ -329,11 +208,15 @@
|
||||
|
||||
//<custom code>
|
||||
var separator = DeepModel.keyPathSeparator;
|
||||
var alreadyTriggered = {}; // * @restorer
|
||||
|
||||
for (var i = 0, l = changes.length; i < l; i++) {
|
||||
var key = changes[i];
|
||||
|
||||
if (!alreadyTriggered.hasOwnProperty(key) || !alreadyTriggered[key]) { // * @restorer
|
||||
alreadyTriggered[key] = true; // * @restorer
|
||||
this.trigger('change:' + key, this, getNested(current, key), options);
|
||||
} // * @restorer
|
||||
|
||||
var fields = key.split(separator);
|
||||
|
||||
@ -342,7 +225,17 @@
|
||||
var parentKey = _.first(fields, n).join(separator),
|
||||
wildcardKey = parentKey + separator + '*';
|
||||
|
||||
if (!alreadyTriggered.hasOwnProperty(wildcardKey) || !alreadyTriggered[wildcardKey]) { // * @restorer
|
||||
alreadyTriggered[wildcardKey] = true; // * @restorer
|
||||
this.trigger('change:' + wildcardKey, this, getNested(current, parentKey), options);
|
||||
} // * @restorer
|
||||
|
||||
// + @restorer
|
||||
if (!alreadyTriggered.hasOwnProperty(parentKey) || !alreadyTriggered[parentKey]) {
|
||||
alreadyTriggered[parentKey] = true;
|
||||
this.trigger('change:' + parentKey, this, getNested(current, parentKey), options);
|
||||
}
|
||||
// - @restorer
|
||||
}
|
||||
//</custom code>
|
||||
}
|
||||
@ -435,4 +328,3 @@
|
||||
return Backbone;
|
||||
|
||||
}));
|
||||
|
||||
|
@ -1,211 +0,0 @@
|
||||
/*! Backbone.Mutators - v0.4.0
|
||||
------------------------------
|
||||
Build @ 2013-05-01
|
||||
Documentation and Full License Available at:
|
||||
http://asciidisco.github.com/Backbone.Mutators/index.html
|
||||
git://github.com/asciidisco/Backbone.Mutators.git
|
||||
Copyright (c) 2013 Sebastian Golasch <public@asciidisco.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.*/
|
||||
(function (root, factory, undef) {
|
||||
'use strict';
|
||||
|
||||
if (typeof exports === 'object') {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like enviroments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory(require('underscore'), require('Backbone'));
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['underscore', 'backbone'], function (_, Backbone) {
|
||||
// Check if we use the AMD branch of Back
|
||||
_ = _ === undef ? root._ : _;
|
||||
Backbone = Backbone === undef ? root.Backbone : Backbone;
|
||||
return (root.returnExportsGlobal = factory(_, Backbone, root));
|
||||
});
|
||||
} else {
|
||||
// Browser globals
|
||||
root.returnExportsGlobal = factory(root._, root.Backbone);
|
||||
}
|
||||
|
||||
// Usage:
|
||||
//
|
||||
// Note: This plugin is UMD compatible, you can use it in node, amd and vanilla js envs
|
||||
//
|
||||
// Vanilla JS:
|
||||
// <script src="underscore.js"></script>
|
||||
// <script src="backbone.js"></script>
|
||||
// <script src="backbone.mutators.js"></script>
|
||||
//
|
||||
// Node:
|
||||
// var _ = require('underscore');
|
||||
// var Backbone = require('backbone');
|
||||
// var Mutators = require('backbone.mutators');
|
||||
//
|
||||
//
|
||||
// AMD:
|
||||
// define(['underscore', 'backbone', 'backbone.mutators'], function (_, Backbone, Mutators) {
|
||||
// // insert sample from below
|
||||
// return User;
|
||||
// });
|
||||
//
|
||||
// var User = Backbone.Model.extend({
|
||||
// mutators: {
|
||||
// fullname: function () {
|
||||
// return this.firstname + ' ' + this.lastname;
|
||||
// }
|
||||
// },
|
||||
//
|
||||
// defaults: {
|
||||
// firstname: 'Sebastian',
|
||||
// lastname: 'Golasch'
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// var user = new User();
|
||||
// user.get('fullname') // returns 'Sebastian Golasch'
|
||||
// user.toJSON() // return '{firstname: 'Sebastian', lastname: 'Golasch', fullname: 'Sebastian Golasch'}'
|
||||
|
||||
}(this, function (_, Backbone, root, undef) {
|
||||
'use strict';
|
||||
|
||||
// check if we use the amd branch of backbone and underscore
|
||||
Backbone = Backbone === undef ? root.Backbone : Backbone;
|
||||
_ = _ === undef ? root._ : _;
|
||||
|
||||
// extend backbones model prototype with the mutator functionality
|
||||
var Mutator = function () {},
|
||||
oldGet = Backbone.DeepModel.prototype.get,
|
||||
oldSet = Backbone.DeepModel.prototype.set,
|
||||
oldToJson = Backbone.DeepModel.prototype.toJSON;
|
||||
|
||||
// This is necessary to ensure that Models declared without the mutators object do not throw and error
|
||||
Mutator.prototype.mutators = {};
|
||||
|
||||
// override get functionality to fetch the mutator props
|
||||
Mutator.prototype.get = function (attr) {
|
||||
var isMutator = this.mutators !== undef;
|
||||
|
||||
// check if we have a getter mutation
|
||||
if (isMutator === true && _.isFunction(this.mutators[attr]) === true) {
|
||||
return this.mutators[attr].call(this);
|
||||
}
|
||||
|
||||
// check if we have a deeper nested getter mutation
|
||||
if (isMutator === true && _.isObject(this.mutators[attr]) === true && _.isFunction(this.mutators[attr].get) === true) {
|
||||
return this.mutators[attr].get.call(this);
|
||||
}
|
||||
|
||||
return oldGet.call(this, attr);
|
||||
};
|
||||
|
||||
// override set functionality to set the mutator props
|
||||
Mutator.prototype.set = function (key, value, options) {
|
||||
var isMutator = this.mutators !== undef,
|
||||
ret = null,
|
||||
attrs = null;
|
||||
|
||||
// seamleassly stolen from backbone core
|
||||
// check if the setter action is triggered
|
||||
// using key <-> value or object
|
||||
if (_.isObject(key) || key === null) {
|
||||
attrs = key;
|
||||
options = value;
|
||||
} else {
|
||||
attrs = {};
|
||||
attrs[key] = value;
|
||||
}
|
||||
|
||||
// check if we have a deeper nested setter mutation
|
||||
if (isMutator === true && _.isObject(this.mutators[key]) === true) {
|
||||
|
||||
// check if we need to set a single value
|
||||
if (_.isFunction(this.mutators[key].set) === true) {
|
||||
ret = this.mutators[key].set.call(this, key, attrs[key], options, _.bind(oldSet, this));
|
||||
} else if(_.isFunction(this.mutators[key])){
|
||||
ret = this.mutators[key].call(this, key, attrs[key], options, _.bind(oldSet, this));
|
||||
}
|
||||
}
|
||||
|
||||
if (_.isObject(attrs)) {
|
||||
_.each(attrs, _.bind(function (attr, attrKey) {
|
||||
var cur_ret = null;
|
||||
if (isMutator === true && _.isObject(this.mutators[attrKey]) === true) {
|
||||
// check if we need to set a single value
|
||||
|
||||
var meth = this.mutators[attrKey];
|
||||
if(_.isFunction(meth.set)){
|
||||
meth = meth.set;
|
||||
}
|
||||
|
||||
if(_.isFunction(meth)){
|
||||
if (options === undef || (_.isObject(options) === true && options.silent !== true && (options.mutators !== undef && options.mutators.silent !== true))) {
|
||||
this.trigger('mutators:set:' + attrKey);
|
||||
}
|
||||
cur_ret = meth.call(this, attrKey, attr, options, _.bind(oldSet, this));
|
||||
}
|
||||
|
||||
}
|
||||
if (cur_ret === null) {
|
||||
cur_ret = _.bind(oldSet, this)(attrKey, attr, options);
|
||||
}
|
||||
|
||||
if (ret !== false) { ret = cur_ret; }
|
||||
|
||||
}, this));
|
||||
}
|
||||
|
||||
//validation purposes
|
||||
if (ret !== null) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return oldSet.call(this, key, value, options);
|
||||
};
|
||||
|
||||
// override toJSON functionality to serialize mutator properties
|
||||
Mutator.prototype.toJSON = function () {
|
||||
// fetch ye olde values
|
||||
var attr = oldToJson.call(this);
|
||||
// iterate over all mutators (if there are some)
|
||||
_.each(this.mutators, _.bind(function (mutator, name) {
|
||||
// check if we have some getter mutations
|
||||
if (_.isObject(this.mutators[name]) === true && _.isFunction(this.mutators[name].get)) {
|
||||
attr[name] = _.bind(this.mutators[name].get, this)();
|
||||
} else {
|
||||
attr[name] = _.bind(this.mutators[name], this)();
|
||||
}
|
||||
}, this));
|
||||
|
||||
return attr;
|
||||
};
|
||||
|
||||
// override get functionality to get HTML-escaped the mutator props
|
||||
Mutator.prototype.escape = function (attr){
|
||||
var val = this.get(attr);
|
||||
return _.escape(val == null ? '' : '' + val);
|
||||
};
|
||||
|
||||
// extend the models prototype
|
||||
_.extend(Backbone.DeepModel.prototype, Mutator.prototype);
|
||||
|
||||
// make mutators globally available under the Backbone namespace
|
||||
Backbone.Mutators = Mutator;
|
||||
return Mutator;
|
||||
}));
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
define(['app', 'Logs/Model'], function () {
|
||||
NzbDrone.Logs.Collection = Backbone.PageableCollection.extend({
|
||||
define(['app', 'Logs/Model', 'backbone.pageable'], function (app, SeriesModel, PagableCollection) {
|
||||
NzbDrone.Logs.Collection = PagableCollection.extend({
|
||||
url : NzbDrone.Constants.ApiRoot + '/log',
|
||||
model: NzbDrone.Logs.Model,
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
define(['app', 'Series/EpisodeModel'], function () {
|
||||
NzbDrone.Missing.Collection = Backbone.PageableCollection.extend({
|
||||
define(['app', 'Series/EpisodeModel', 'backbone.pageable'], function (app, EpisodeModel, PagableCollection) {
|
||||
NzbDrone.Missing.Collection = PagableCollection.extend({
|
||||
url : NzbDrone.Constants.ApiRoot + '/missing',
|
||||
model: NzbDrone.Series.EpisodeModel,
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
"use strict";
|
||||
define(['app','backgrid'], function () {
|
||||
|
||||
NzbDrone.Missing.Row = Backgrid.Row.extend({
|
||||
events: {
|
||||
'click .x-search': 'search'
|
||||
@ -7,3 +10,7 @@ NzbDrone.Missing.Row = Backgrid.Row.extend({
|
||||
window.alert('Episode Search');
|
||||
}
|
||||
});
|
||||
return NzbDrone.Mixins.Row;
|
||||
|
||||
});
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
(function () {
|
||||
define(['app'], function () {
|
||||
|
||||
NzbDrone.Mixins.SaveIfChangedModel = {
|
||||
// originalInitialize: this.initialize,
|
||||
@ -26,4 +26,6 @@
|
||||
}
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
||||
return NzbDrone.Missing.SaveIfChangedModel;
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
//try to add ajax data as query string to DELETE calls.
|
||||
"use strict";
|
||||
(function () {
|
||||
define(['jquery'], function () {
|
||||
|
||||
var original = Backbone.ajax;
|
||||
|
||||
@ -20,4 +20,4 @@
|
||||
|
||||
return original.apply(this, arguments);
|
||||
};
|
||||
}());
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
define(['app', 'marionette'], function (App, Marionette) {
|
||||
Marionette.TemplateCache.get = function (templateId) {
|
||||
|
||||
var templateKey = templateId.toLowerCase();
|
||||
@ -22,3 +23,4 @@ Marionette.TemplateCache.get = function (templateId) {
|
||||
}
|
||||
};
|
||||
};
|
||||
});
|
||||
|
@ -1,4 +1,5 @@
|
||||
"use strict";
|
||||
define(['app', 'signalR'], function () {
|
||||
|
||||
_.extend(Backbone.Collection.prototype, {BindSignalR: function (options) {
|
||||
|
||||
@ -43,6 +44,6 @@ _.extend(Backbone.Collection.prototype, {BindSignalR: function (options) {
|
||||
|
||||
return this;
|
||||
}});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
109
UI/Mixins/underscore.mixin.deepExtend.js
Normal file
109
UI/Mixins/underscore.mixin.deepExtend.js
Normal file
@ -0,0 +1,109 @@
|
||||
/**
|
||||
* Underscore mixins for deep objects
|
||||
*
|
||||
* Based on https://gist.github.com/echong/3861963
|
||||
*/
|
||||
(function() {
|
||||
var arrays, basicObjects, deepClone, deepExtend, deepExtendCouple, isBasicObject,
|
||||
__slice = [].slice;
|
||||
|
||||
deepClone = function(obj) {
|
||||
var func, isArr;
|
||||
if (!_.isObject(obj) || _.isFunction(obj)) {
|
||||
return obj;
|
||||
}
|
||||
if (obj instanceof Backbone.Collection || obj instanceof Backbone.Model) {
|
||||
return obj;
|
||||
}
|
||||
if (_.isDate(obj)) {
|
||||
return new Date(obj.getTime());
|
||||
}
|
||||
if (_.isRegExp(obj)) {
|
||||
return new RegExp(obj.source, obj.toString().replace(/.*\//, ""));
|
||||
}
|
||||
isArr = _.isArray(obj || _.isArguments(obj));
|
||||
func = function(memo, value, key) {
|
||||
if (isArr) {
|
||||
memo.push(deepClone(value));
|
||||
} else {
|
||||
memo[key] = deepClone(value);
|
||||
}
|
||||
return memo;
|
||||
};
|
||||
return _.reduce(obj, func, isArr ? [] : {});
|
||||
};
|
||||
|
||||
isBasicObject = function(object) {
|
||||
if (object == null) return false;
|
||||
return (object.prototype === {}.prototype || object.prototype === Object.prototype) && _.isObject(object) && !_.isArray(object) && !_.isFunction(object) && !_.isDate(object) && !_.isRegExp(object) && !_.isArguments(object);
|
||||
};
|
||||
|
||||
basicObjects = function(object) {
|
||||
return _.filter(_.keys(object), function(key) {
|
||||
return isBasicObject(object[key]);
|
||||
});
|
||||
};
|
||||
|
||||
arrays = function(object) {
|
||||
return _.filter(_.keys(object), function(key) {
|
||||
return _.isArray(object[key]);
|
||||
});
|
||||
};
|
||||
|
||||
deepExtendCouple = function(destination, source, maxDepth) {
|
||||
var combine, recurse, sharedArrayKey, sharedArrayKeys, sharedObjectKey, sharedObjectKeys, _i, _j, _len, _len1;
|
||||
if (maxDepth == null) {
|
||||
maxDepth = 20;
|
||||
}
|
||||
if (maxDepth <= 0) {
|
||||
console.warn('_.deepExtend(): Maximum depth of recursion hit.');
|
||||
return _.extend(destination, source);
|
||||
}
|
||||
sharedObjectKeys = _.intersection(basicObjects(destination), basicObjects(source));
|
||||
recurse = function(key) {
|
||||
return source[key] = deepExtendCouple(destination[key], source[key], maxDepth - 1);
|
||||
};
|
||||
for (_i = 0, _len = sharedObjectKeys.length; _i < _len; _i++) {
|
||||
sharedObjectKey = sharedObjectKeys[_i];
|
||||
recurse(sharedObjectKey);
|
||||
}
|
||||
sharedArrayKeys = _.intersection(arrays(destination), arrays(source));
|
||||
combine = function(key) {
|
||||
return source[key] = _.union(destination[key], source[key]);
|
||||
};
|
||||
for (_j = 0, _len1 = sharedArrayKeys.length; _j < _len1; _j++) {
|
||||
sharedArrayKey = sharedArrayKeys[_j];
|
||||
combine(sharedArrayKey);
|
||||
}
|
||||
return _.extend(destination, source);
|
||||
};
|
||||
|
||||
deepExtend = function() {
|
||||
var finalObj, maxDepth, objects, _i;
|
||||
objects = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), maxDepth = arguments[_i++];
|
||||
if (!_.isNumber(maxDepth)) {
|
||||
objects.push(maxDepth);
|
||||
maxDepth = 20;
|
||||
}
|
||||
if (objects.length <= 1) {
|
||||
return objects[0];
|
||||
}
|
||||
if (maxDepth <= 0) {
|
||||
return _.extend.apply(this, objects);
|
||||
}
|
||||
finalObj = objects.shift();
|
||||
while (objects.length > 0) {
|
||||
finalObj = deepExtendCouple(finalObj, deepClone(objects.shift()), maxDepth);
|
||||
}
|
||||
return finalObj;
|
||||
};
|
||||
|
||||
_.mixin({
|
||||
deepClone: deepClone,
|
||||
isBasicObject: isBasicObject,
|
||||
basicObjects: basicObjects,
|
||||
arrays: arrays,
|
||||
deepExtend: deepExtend
|
||||
});
|
||||
|
||||
}).call(this);
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
define(['app'], function () {
|
||||
NzbDrone.Quality.QualityProfileModel = Backbone.DeepModel.extend({
|
||||
define(['app', 'backbone.deepmodel'], function (App, DeepModel) {
|
||||
NzbDrone.Quality.QualityProfileModel = DeepModel.DeepModel.extend({
|
||||
|
||||
defaults: {
|
||||
id : null,
|
||||
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
define(['app', 'Release/Model'], function () {
|
||||
NzbDrone.Release.Collection = Backbone.PageableCollection.extend({
|
||||
define(['app', 'Release/Model', 'backbone.pageable'], function (app, SeriesModel, PagableCollection) {
|
||||
NzbDrone.Release.Collection = PagableCollection.extend({
|
||||
url : NzbDrone.Constants.ApiRoot + '/release',
|
||||
model: NzbDrone.Release.Model,
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
define(['app'], function () {
|
||||
NzbDrone.Release.DownloadReportCell = Backgrid.Cell.extend({
|
||||
|
||||
className: "download-report-cell",
|
||||
@ -25,3 +27,7 @@ NzbDrone.Release.DownloadReportCell = Backgrid.Cell.extend({
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return NzbDrone.Release.DownloadReportCell;
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
define(['app', 'Series/Details/SeasonCollectionView', 'Shared/LoadingView'], function () {
|
||||
define(['app', 'Series/Details/SeasonCollectionView', 'Shared/LoadingView','backstrech'], function () {
|
||||
NzbDrone.Series.Details.SeriesDetailsLayout = Backbone.Marionette.Layout.extend({
|
||||
|
||||
itemViewContainer: '.x-series-seasons',
|
||||
|
@ -1,4 +1,5 @@
|
||||
"use strict";
|
||||
define(['app','backgrid'], function () {
|
||||
NzbDrone.Series.Index.Table.Row = Backgrid.Row.extend({
|
||||
events: {
|
||||
'click .x-edit' : 'editSeries',
|
||||
@ -15,3 +16,7 @@ NzbDrone.Series.Index.Table.Row = Backgrid.Row.extend({
|
||||
NzbDrone.modalRegion.show(view);
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Series.Table.Row;
|
||||
});
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
"use strict";
|
||||
define(['app','backgrid'], function () {
|
||||
Backgrid.SeriesStatusCell = Backgrid.Cell.extend({
|
||||
className: "series-status-cell",
|
||||
|
||||
@ -21,3 +22,6 @@ Backgrid.SeriesStatusCell = Backgrid.Cell.extend({
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
return Backgrid.SeriesStatusCell;
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
define(['app', 'Series/SeasonModel'], function () {
|
||||
NzbDrone.Series.SeasonCollection = Backbone.PageableCollection.extend({
|
||||
define(['app', 'Series/SeasonModel', 'backbone.pageable'], function (App, SeasonModel, PageAbleCollection) {
|
||||
NzbDrone.Series.SeasonCollection = PageAbleCollection.extend({
|
||||
url : NzbDrone.Constants.ApiRoot + '/season',
|
||||
model: NzbDrone.Series.SeasonModel,
|
||||
|
||||
|
@ -82,4 +82,6 @@ define(['app', 'Quality/QualityProfileCollection'], function (app, qualityProfil
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Series.SeriesModel;
|
||||
|
||||
});
|
||||
|
@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
define([
|
||||
'app', 'Settings/SettingsModel'
|
||||
'app', 'Settings/SettingsModel','bootstrap'
|
||||
|
||||
], function () {
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
"use strict";
|
||||
define(['app',
|
||||
'Mixins/SaveIfChangedModel'], function () {
|
||||
NzbDrone.Settings.Indexers.Model = Backbone.DeepModel.extend({
|
||||
'Mixins/SaveIfChangedModel',
|
||||
'backbone.deepmodel'], function (App, SaveIfChangedModel, DeepModel) {
|
||||
NzbDrone.Settings.Indexers.Model = DeepModel.DeepModel.extend({
|
||||
});
|
||||
|
||||
_.extend(NzbDrone.Settings.Indexers.Model.prototype, NzbDrone.Mixins.SaveIfChangedModel);
|
||||
|
@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
define(['app'], function () {
|
||||
NzbDrone.Settings.Notifications.Model = Backbone.DeepModel.extend({
|
||||
define(['app', 'backbone.deepmodel'], function (App, DeepModel) {
|
||||
NzbDrone.Settings.Notifications.Model = DeepModel.DeepModel.extend({
|
||||
});
|
||||
});
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
define([
|
||||
'app',
|
||||
'Quality/QualitySizeCollection'
|
||||
'Quality/QualitySizeCollection',
|
||||
'bootstrap.slider'
|
||||
|
||||
], function () {
|
||||
|
||||
|
@ -1,15 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
Backgrid.Column.prototype.defaults = {
|
||||
name : undefined,
|
||||
label : undefined,
|
||||
sortable : true,
|
||||
editable : false,
|
||||
renderable: true,
|
||||
formatter : undefined,
|
||||
cell : undefined,
|
||||
headerCell: 'nzbDrone'
|
||||
};
|
||||
define(['app','backgrid'], function () {
|
||||
|
||||
|
||||
Backgrid.NzbDroneHeaderCell = Backgrid.HeaderCell.extend({
|
||||
@ -104,3 +95,6 @@ Backgrid.NzbDroneHeaderCell = Backgrid.HeaderCell.extend({
|
||||
return 'descending';
|
||||
}
|
||||
});
|
||||
|
||||
return Backgrid.NzbDroneHeaderCell;
|
||||
});
|
||||
|
@ -1,20 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
Backgrid.Column.prototype.defaults = {
|
||||
name : undefined,
|
||||
label : undefined,
|
||||
sortable : true,
|
||||
editable : false,
|
||||
renderable: true,
|
||||
formatter : undefined,
|
||||
cell : undefined,
|
||||
headerCell: 'nzbDrone'
|
||||
};
|
||||
|
||||
|
||||
define([
|
||||
'app',
|
||||
'JsLibraries/backbone.backgrid.paginator'
|
||||
'backgrid',
|
||||
'backgrid.paginator'
|
||||
], function () {
|
||||
|
||||
NzbDrone.Shared.Grid.Pager = Backgrid.Extension.Paginator.extend({
|
||||
@ -153,4 +141,6 @@ define([
|
||||
return this;
|
||||
}
|
||||
});
|
||||
|
||||
return NzbDrone.Shared.Grid.Pager;
|
||||
});
|
||||
|
@ -1,6 +1,5 @@
|
||||
"use strict";
|
||||
define(function () {
|
||||
|
||||
define(['marionette'], function () {
|
||||
return Backbone.Marionette.Region.extend({
|
||||
el: "#modal-region",
|
||||
|
||||
|
85
UI/app.js
85
UI/app.js
@ -3,42 +3,109 @@ require.config({
|
||||
|
||||
paths: {
|
||||
'backbone' : 'JsLibraries/backbone',
|
||||
'bootstrap' : 'JsLibraries/bootstrap',
|
||||
'bootstrap.slider' : 'JsLibraries/bootstrap.slider',
|
||||
'backbone.mutators' : 'JsLibraries/backbone.mutators',
|
||||
'backbone.deepmodel': 'JsLibraries/backbone.deep.model',
|
||||
'backbone.pageable' : 'JsLibraries/backbone.pageable',
|
||||
'backgrid' : 'JsLibraries/backbone.backgrid',
|
||||
'backgrid.paginator': 'JsLibraries/backbone.backgrid.paginator',
|
||||
'fullcalendar' : 'JsLibraries/fullcalendar',
|
||||
'backstrech' : 'JsLibraries/jquery.backstretch',
|
||||
'$' : 'JsLibraries/jquery',
|
||||
'underscore' : 'JsLibraries/underscore',
|
||||
'marionette' : 'JsLibraries/backbone.marionette',
|
||||
'handlebars' : 'JsLibraries/handlebars',
|
||||
'signalR' : 'JsLibraries/jquery.signalR',
|
||||
'libs' : 'JsLibraries/'
|
||||
},
|
||||
|
||||
shim: {
|
||||
underscore: {
|
||||
exports: '_'
|
||||
|
||||
$: {
|
||||
exports: '$'
|
||||
},
|
||||
|
||||
bootstrap: {
|
||||
deps: ['$']
|
||||
},
|
||||
|
||||
'bootstrap.slider': {
|
||||
deps: ['$']
|
||||
},
|
||||
|
||||
backstrech: {
|
||||
deps: ['$']
|
||||
},
|
||||
|
||||
'underscore': {
|
||||
dep : ['$'],
|
||||
exports: '_',
|
||||
init : function () {
|
||||
require(['mixins/underscore.mixin.deepExtend']);
|
||||
}
|
||||
},
|
||||
|
||||
backbone: {
|
||||
deps : ['underscore', '$'],
|
||||
exports: 'Backbone'
|
||||
exports: 'Backbone',
|
||||
init : function () {
|
||||
require(['libs/backbone.mutators']);
|
||||
}
|
||||
},
|
||||
|
||||
marionette: {
|
||||
deps : ['backbone'],
|
||||
exports: 'Marionette'
|
||||
exports: 'Marionette',
|
||||
init : function () {
|
||||
require(['mixins/backbone.marionette.templates']);
|
||||
}
|
||||
},
|
||||
|
||||
handlebars: {
|
||||
exports: 'Handlebars'
|
||||
},
|
||||
|
||||
backbone_backgrid :{
|
||||
exports: 'backgrid'
|
||||
signalR: {
|
||||
dep: ['$']
|
||||
},
|
||||
|
||||
'backbone.pageable': {
|
||||
dep : ['backbone'],
|
||||
init: function () {
|
||||
console.log(this);
|
||||
}
|
||||
},
|
||||
|
||||
backgrid : {
|
||||
deps: ['backbone', 'libs/backbone.backgrid', 'libs/backbone.backgrid.paginator']
|
||||
deps: ['backbone'],
|
||||
init: function () {
|
||||
Backgrid.Column.prototype.defaults = {
|
||||
name : undefined,
|
||||
label : undefined,
|
||||
sortable : true,
|
||||
editable : false,
|
||||
renderable: true,
|
||||
formatter : undefined,
|
||||
cell : undefined,
|
||||
headerCell: 'nzbDrone'
|
||||
};
|
||||
}
|
||||
},
|
||||
'backgrid.paginator': {
|
||||
deps: ['backgrid']
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
define(['backbone','backgrid'], function (ModalRegion) {
|
||||
define([
|
||||
'marionette',
|
||||
'shared/modal/region',
|
||||
'Instrumentation/StringFormat',
|
||||
'Instrumentation/ErrorHandler'
|
||||
], function (Marionette, ModalRegion) {
|
||||
|
||||
window.NzbDrone = new Backbone.Marionette.Application();
|
||||
window.NzbDrone = new Marionette.Application();
|
||||
window.NzbDrone.Config = {};
|
||||
window.NzbDrone.Form = {};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user