mirror of
https://github.com/Sonarr/Sonarr
synced 2024-12-25 17:27:18 +00:00
removed unneeded js libraries.
This commit is contained in:
parent
bd2c56df20
commit
b7c569d30d
8 changed files with 0 additions and 4189 deletions
|
@ -27,7 +27,6 @@ module.exports = function (grunt) {
|
|||
'UI/JsLibraries/require.js' : 'http://raw.github.com/jrburke/requirejs/master/require.js',
|
||||
'UI/JsLibraries/sugar.js' : 'http://raw.github.com/andrewplummer/Sugar/master/release/sugar-full.development.js',
|
||||
'UI/JsLibraries/lodash.underscore.js' : 'http://raw.github.com/bestiejs/lodash/master/dist/lodash.underscore.js',
|
||||
'UI/JsLibraries/lunr.js' : 'http://raw.github.com/olivernn/lunr.js/master/lunr.js',
|
||||
|
||||
'UI/JsLibraries/messenger.js' : 'http://raw.github.com/HubSpot/messenger/master/build/js/messenger.js',
|
||||
'UI/Content/Messenger/messenger.css' : 'http://raw.github.com/HubSpot/messenger/master/build/css/messenger.css',
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="backbone.backgrid.filter.js" type="javaScript">
|
||||
<properties>
|
||||
<sourceFilesUrls>
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/jquery.backstretch.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/lodash.underscore.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/jquery.signalR.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.modelbinder.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/fullcalendar.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.marionette.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/jquery.knob.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.mutators.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/lunr.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/bootstrap.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.debug.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.relational.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/handlebars.helpers.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/jquery.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.backgrid.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/sugar.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.shortcuts.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/handlebars.runtime.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.backgrid.paginator.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.backgrid.filter.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.deep.model.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.collectionbinder.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/underscore.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/messenger.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.marionette.viewswapper.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.pageable.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/require.js" />
|
||||
</sourceFilesUrls>
|
||||
</properties>
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/jquery.backstretch.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/lodash.underscore.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/jquery.signalR.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.modelbinder.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/fullcalendar.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.marionette.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/jquery.knob.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.mutators.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/lunr.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/bootstrap.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.debug.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.relational.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/jquery.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/handlebars.helpers.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.backgrid.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/sugar.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.shortcuts.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/handlebars.runtime.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.backgrid.paginator.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.backgrid.filter.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.collectionbinder.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.deep.model.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/underscore.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/messenger.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.marionette.viewswapper.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.pageable.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/require.js" />
|
||||
</CLASSES>
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -1,47 +0,0 @@
|
|||
<component name="libraryTable">
|
||||
<library name="libraries" type="javaScript">
|
||||
<properties>
|
||||
<sourceFilesUrls>
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/bootstrap.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.debug.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/jquery.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/sugar.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.shortcuts.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/handlebars.runtime.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.modelbinder.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/fullcalendar.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.collectionbinder.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/underscore.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.marionette.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.marionette.viewswapper.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/require.js" />
|
||||
<item url="file://$PROJECT_DIR$/JsLibraries/backbone.mutators.js" />
|
||||
</sourceFilesUrls>
|
||||
</properties>
|
||||
<CLASSES>
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/bootstrapSwitch.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/toastr-1.1.5.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/jquery.tablesorter.pager.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/jquery.tablesorter.bootstrap.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/jquery.tablesorter.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/bootstrap.slider.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/bootstrap.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.debug.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/jquery.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/sugar.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.shortcuts.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/handlebars.runtime.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.modelbinder.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.collectionbinder.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/fullcalendar.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/underscore.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.marionette.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.marionette.viewswapper.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/backbone.mutators.js" />
|
||||
<root url="file://$PROJECT_DIR$/JsLibraries/require.js" />
|
||||
</CLASSES>
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
|
@ -1,284 +0,0 @@
|
|||
// Backbone.CollectionBinder v1.0.0
|
||||
// (c) 2013 Bart Wood
|
||||
// Distributed Under MIT License
|
||||
|
||||
(function(){
|
||||
|
||||
if(!Backbone){
|
||||
throw 'Please include Backbone.js before Backbone.ModelBinder.js';
|
||||
}
|
||||
|
||||
if(!Backbone.ModelBinder){
|
||||
throw 'Please include Backbone.ModelBinder.js before Backbone.CollectionBinder.js';
|
||||
}
|
||||
|
||||
Backbone.CollectionBinder = function(elManagerFactory, options){
|
||||
_.bindAll(this);
|
||||
this._elManagers = {};
|
||||
|
||||
this._elManagerFactory = elManagerFactory;
|
||||
if(!this._elManagerFactory) throw 'elManagerFactory must be defined.';
|
||||
|
||||
// Let the factory just use the trigger function on the view binder
|
||||
this._elManagerFactory.trigger = this.trigger;
|
||||
|
||||
this._options = options || {};
|
||||
};
|
||||
|
||||
Backbone.CollectionBinder.VERSION = '1.0.0';
|
||||
|
||||
_.extend(Backbone.CollectionBinder.prototype, Backbone.Events, {
|
||||
bind: function(collection, parentEl){
|
||||
this.unbind();
|
||||
|
||||
if(!collection) throw 'collection must be defined';
|
||||
if(!parentEl) throw 'parentEl must be defined';
|
||||
|
||||
this._collection = collection;
|
||||
this._elManagerFactory.setParentEl(parentEl);
|
||||
|
||||
this._onCollectionReset();
|
||||
|
||||
this._collection.on('add', this._onCollectionAdd, this);
|
||||
this._collection.on('remove', this._onCollectionRemove, this);
|
||||
this._collection.on('reset', this._onCollectionReset, this);
|
||||
|
||||
},
|
||||
|
||||
unbind: function(){
|
||||
if(this._collection !== undefined){
|
||||
this._collection.off('add', this._onCollectionAdd);
|
||||
this._collection.off('remove', this._onCollectionRemove);
|
||||
this._collection.off('reset', this._onCollectionReset);
|
||||
}
|
||||
|
||||
this._removeAllElManagers();
|
||||
},
|
||||
|
||||
getManagerForEl: function(el){
|
||||
var i, elManager, elManagers = _.values(this._elManagers);
|
||||
|
||||
for(i = 0; i < elManagers.length; i++){
|
||||
elManager = elManagers[i];
|
||||
|
||||
if(elManager.isElContained(el)){
|
||||
return elManager;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
|
||||
getManagerForModel: function(model){
|
||||
var i, elManager, elManagers = _.values(this._elManagers);
|
||||
|
||||
for(i = 0; i < elManagers.length; i++){
|
||||
elManager = elManagers[i];
|
||||
|
||||
if(elManager.getModel() === model){
|
||||
return elManager;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
|
||||
_onCollectionAdd: function(model){
|
||||
this._elManagers[model.cid] = this._elManagerFactory.makeElManager(model);
|
||||
this._elManagers[model.cid].createEl();
|
||||
|
||||
if(this._options['autoSort']){
|
||||
this.sortRootEls();
|
||||
}
|
||||
},
|
||||
|
||||
_onCollectionRemove: function(model){
|
||||
this._removeElManager(model);
|
||||
},
|
||||
|
||||
_onCollectionReset: function(){
|
||||
this._removeAllElManagers();
|
||||
|
||||
this._collection.each(function(model){
|
||||
this._onCollectionAdd(model);
|
||||
}, this);
|
||||
|
||||
this.trigger('elsReset', this._collection);
|
||||
},
|
||||
|
||||
_removeAllElManagers: function(){
|
||||
_.each(this._elManagers, function(elManager){
|
||||
elManager.removeEl();
|
||||
delete this._elManagers[elManager._model.cid];
|
||||
}, this);
|
||||
|
||||
delete this._elManagers;
|
||||
this._elManagers = {};
|
||||
},
|
||||
|
||||
_removeElManager: function(model){
|
||||
if(this._elManagers[model.cid] !== undefined){
|
||||
this._elManagers[model.cid].removeEl();
|
||||
delete this._elManagers[model.cid];
|
||||
}
|
||||
},
|
||||
|
||||
sortRootEls: function(){
|
||||
this._collection.each(function(model, modelIndex){
|
||||
var modelElManager = this.getManagerForModel(model);
|
||||
if(modelElManager){
|
||||
var modelEl = modelElManager.getEl();
|
||||
var currentRootEls = $(this._elManagerFactory.getParentEl()).children();
|
||||
|
||||
if(currentRootEls[modelIndex] !== modelEl[0]){
|
||||
modelEl.detach();
|
||||
modelEl.insertBefore(currentRootEls[modelIndex]);
|
||||
}
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
});
|
||||
|
||||
// The ElManagerFactory is used for els that are just html templates
|
||||
// elHtml - how the model's html will be rendered. Must have a single root element (div,span).
|
||||
// bindings (optional) - either a string which is the binding attribute (name, id, data-name, etc.) or a normal bindings hash
|
||||
Backbone.CollectionBinder.ElManagerFactory = function(elHtml, bindings){
|
||||
_.bindAll(this);
|
||||
|
||||
this._elHtml = elHtml;
|
||||
this._bindings = bindings;
|
||||
|
||||
if(! _.isString(this._elHtml)) throw 'elHtml must be a valid html string';
|
||||
};
|
||||
|
||||
_.extend(Backbone.CollectionBinder.ElManagerFactory.prototype, {
|
||||
setParentEl: function(parentEl){
|
||||
this._parentEl = parentEl;
|
||||
},
|
||||
|
||||
getParentEl: function(){
|
||||
return this._parentEl;
|
||||
},
|
||||
|
||||
makeElManager: function(model){
|
||||
|
||||
var elManager = {
|
||||
_model: model,
|
||||
|
||||
createEl: function(){
|
||||
|
||||
this._el = $(this._elHtml);
|
||||
$(this._parentEl).append(this._el);
|
||||
|
||||
if(this._bindings){
|
||||
if(_.isString(this._bindings)){
|
||||
this._modelBinder = new Backbone.ModelBinder();
|
||||
this._modelBinder.bind(this._model, this._el, Backbone.ModelBinder.createDefaultBindings(this._el, this._bindings));
|
||||
}
|
||||
else if(_.isObject(this._bindings)){
|
||||
this._modelBinder = new Backbone.ModelBinder();
|
||||
this._modelBinder.bind(this._model, this._el, this._bindings);
|
||||
}
|
||||
else {
|
||||
throw 'Unsupported bindings type, please use a boolean or a bindings hash';
|
||||
}
|
||||
}
|
||||
|
||||
this.trigger('elCreated', this._model, this._el);
|
||||
},
|
||||
|
||||
removeEl: function(){
|
||||
if(this._modelBinder !== undefined){
|
||||
this._modelBinder.unbind();
|
||||
}
|
||||
|
||||
this._el.remove();
|
||||
this.trigger('elRemoved', this._model, this._el);
|
||||
},
|
||||
|
||||
isElContained: function(findEl){
|
||||
return this._el === findEl || $(this._el).has(findEl).length > 0;
|
||||
},
|
||||
|
||||
getModel: function(){
|
||||
return this._model;
|
||||
},
|
||||
|
||||
getEl: function(){
|
||||
return this._el;
|
||||
}
|
||||
};
|
||||
|
||||
_.extend(elManager, this);
|
||||
return elManager;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// The ViewManagerFactory is used for els that are created and owned by backbone views.
|
||||
// There is no bindings option because the view made by the viewCreator should take care of any binding
|
||||
// viewCreator - a callback that will create backbone view instances for a model passed to the callback
|
||||
Backbone.CollectionBinder.ViewManagerFactory = function(viewCreator){
|
||||
_.bindAll(this);
|
||||
this._viewCreator = viewCreator;
|
||||
|
||||
if(!_.isFunction(this._viewCreator)) throw 'viewCreator must be a valid function that accepts a model and returns a backbone view';
|
||||
};
|
||||
|
||||
_.extend(Backbone.CollectionBinder.ViewManagerFactory.prototype, {
|
||||
setParentEl: function(parentEl){
|
||||
this._parentEl = parentEl;
|
||||
},
|
||||
|
||||
getParentEl: function(){
|
||||
return this._parentEl;
|
||||
},
|
||||
|
||||
makeElManager: function(model){
|
||||
var elManager = {
|
||||
|
||||
_model: model,
|
||||
|
||||
createEl: function(){
|
||||
this._view = this._viewCreator(model);
|
||||
$(this._parentEl).append(this._view.render(this._model).el);
|
||||
|
||||
this.trigger('elCreated', this._model, this._view);
|
||||
},
|
||||
|
||||
removeEl: function(){
|
||||
if(this._view.close !== undefined){
|
||||
this._view.close();
|
||||
}
|
||||
else {
|
||||
this._view.$el.remove();
|
||||
console.log('warning, you should implement a close() function for your view, you might end up with zombies');
|
||||
}
|
||||
|
||||
this.trigger('elRemoved', this._model, this._view);
|
||||
},
|
||||
|
||||
isElContained: function(findEl){
|
||||
return this._view.el === findEl || this._view.$el.has(findEl).length > 0;
|
||||
},
|
||||
|
||||
getModel: function(){
|
||||
return this._model;
|
||||
},
|
||||
|
||||
getView: function(){
|
||||
return this._view;
|
||||
},
|
||||
|
||||
getEl: function(){
|
||||
return this._view.$el;
|
||||
}
|
||||
};
|
||||
|
||||
_.extend(elManager, this);
|
||||
|
||||
return elManager;
|
||||
}
|
||||
});
|
||||
|
||||
}).call(this);
|
|
@ -1,131 +0,0 @@
|
|||
(function () {
|
||||
var __bind = function (fn, me) { return function () { return fn.apply(me, arguments); }; };
|
||||
|
||||
window.Backbone.Debug = (function () {
|
||||
|
||||
function Debug() {
|
||||
this._hookPrototype = __bind(this._hookPrototype, this);
|
||||
this._hookMethod = __bind(this._hookMethod, this);
|
||||
this._logSync = __bind(this._logSync, this);
|
||||
this._logEvent = __bind(this._logEvent, this);
|
||||
this._saveObjects = __bind(this._saveObjects, this);
|
||||
this._hookSync = __bind(this._hookSync, this);
|
||||
this._hookEvents = __bind(this._hookEvents, this);
|
||||
this._trackObjects = __bind(this._trackObjects, this);
|
||||
this.off = __bind(this.off, this);
|
||||
this.on = __bind(this.on, this);
|
||||
this.routers = __bind(this.routers, this);
|
||||
this.views = __bind(this.views, this);
|
||||
this.models = __bind(this.models, this);
|
||||
this.collections = __bind(this.collections, this); this._options = {
|
||||
'log:events': true,
|
||||
'log:sync': true
|
||||
};
|
||||
this._objects = {
|
||||
Collection: {},
|
||||
Model: {},
|
||||
View: {},
|
||||
Router: {}
|
||||
};
|
||||
this._trackObjects();
|
||||
this._hookEvents();
|
||||
this._hookSync();
|
||||
}
|
||||
|
||||
Debug.prototype.collections = function () {
|
||||
return this._objects.Collection;
|
||||
};
|
||||
|
||||
Debug.prototype.models = function () {
|
||||
return this._objects.Model;
|
||||
};
|
||||
|
||||
Debug.prototype.views = function () {
|
||||
return this._objects.View;
|
||||
};
|
||||
|
||||
Debug.prototype.routers = function () {
|
||||
return this._objects.Router;
|
||||
};
|
||||
|
||||
Debug.prototype.on = function (option) {
|
||||
if (option != null) {
|
||||
return this._options[option] = true;
|
||||
} else {
|
||||
this._options['log:events'] = true;
|
||||
return this._options['log:sync'] = true;
|
||||
}
|
||||
};
|
||||
|
||||
Debug.prototype.off = function (option) {
|
||||
if (option != null) {
|
||||
return this._options[option] = false;
|
||||
} else {
|
||||
this._options['log:events'] = false;
|
||||
return this._options['log:sync'] = false;
|
||||
}
|
||||
};
|
||||
|
||||
Debug.prototype._trackObjects = function () {
|
||||
this._hookPrototype('Collection', 'constructor', this._saveObjects);
|
||||
this._hookPrototype('Model', 'constructor', this._saveObjects);
|
||||
this._hookPrototype('View', 'constructor', this._saveObjects);
|
||||
return this._hookPrototype('Router', 'constructor', this._saveObjects);
|
||||
};
|
||||
|
||||
Debug.prototype._hookEvents = function () {
|
||||
this._hookPrototype('Collection', 'trigger', this._logEvent);
|
||||
this._hookPrototype('Model', 'trigger', this._logEvent);
|
||||
this._hookPrototype('View', 'trigger', this._logEvent);
|
||||
return this._hookPrototype('Router', 'trigger', this._logEvent);
|
||||
};
|
||||
|
||||
Debug.prototype._hookSync = function () {
|
||||
return this._hookMethod('sync', this._logSync);
|
||||
};
|
||||
|
||||
Debug.prototype._saveObjects = function (type, method, object) {
|
||||
return this._objects[type][object.constructor.name + ':' + object.cid] = object;
|
||||
};
|
||||
|
||||
Debug.prototype._logEvent = function (parent_object, method, object, args) {
|
||||
if (this._options['log:events']) {
|
||||
return console.log("" + args[0] + " - ", object);
|
||||
}
|
||||
};
|
||||
|
||||
Debug.prototype._logSync = function (method, object, args) {
|
||||
if (this._options['log:sync'] === true) {
|
||||
return console.log("sync - " + args[0], args[1]);
|
||||
}
|
||||
};
|
||||
|
||||
Debug.prototype._hookMethod = function (method, action) {
|
||||
var original;
|
||||
original = window.Backbone[method];
|
||||
return window.Backbone[method] = function () {
|
||||
var ret;
|
||||
ret = original.apply(this, arguments);
|
||||
action(method, this, arguments);
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
|
||||
Debug.prototype._hookPrototype = function (object, method, action) {
|
||||
var original;
|
||||
original = window.Backbone[object].prototype[method];
|
||||
return window.Backbone[object].prototype[method] = function () {
|
||||
var ret;
|
||||
ret = original.apply(this, arguments);
|
||||
action(object, method, this, arguments);
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
|
||||
return Debug;
|
||||
|
||||
})();
|
||||
|
||||
window.Backbone.debug = new Backbone.Debug();
|
||||
|
||||
}).call(this);
|
|
@ -1,212 +0,0 @@
|
|||
https://github.com/marionettejs/backbone.marionette/blob/viewswap/docs/marionette.viewswapper.md
|
||||
|
||||
// View Swapper
|
||||
// ------------
|
||||
//
|
||||
// Switch out views based on events that are triggered
|
||||
// by the currently displayed view. Enables easy "edit in
|
||||
// place" features, "loading" screens, and more.
|
||||
|
||||
Marionette.ViewSwapper = Marionette.View.extend({
|
||||
constructor: function (options) {
|
||||
this._swapperViews = {};
|
||||
this._swapperBindings = new Marionette.EventBinder();
|
||||
this._currentViewBindings = new Marionette.EventBinder();
|
||||
|
||||
Marionette.View.prototype.constructor.apply(this, arguments);
|
||||
|
||||
this.views = Marionette.getOption(this, "views");
|
||||
this.swapOn = Marionette.getOption(this, "swapOn");
|
||||
this.initialView = Marionette.getOption(this, "initialView");
|
||||
|
||||
this._setupViewEvents("swapper", this, this._swapperBindings);
|
||||
},
|
||||
|
||||
// Render the current view. If no current view is set, it
|
||||
// will render the `initialView` that was configured.
|
||||
render: function () {
|
||||
// set up the initial view to display, on first render
|
||||
if (!this.currentView) {
|
||||
var initialViewName = Marionette.getOption(this, "initialView");
|
||||
this._swapView(initialViewName);
|
||||
}
|
||||
|
||||
// render and show the new view
|
||||
this.currentView.render();
|
||||
this.$el.append(this.currentView.$el);
|
||||
|
||||
// setup a callback for the showView call to recieve
|
||||
var done = _.bind(function () {
|
||||
// trigger show/onShow on the previous view
|
||||
if (this.currentView) {
|
||||
Marionette.triggerMethod.call(this.currentView, "show");
|
||||
Marionette.triggerMethod.call(this, "swap:in", this.currentView);
|
||||
}
|
||||
}, this);
|
||||
|
||||
// show the view, passing it the done callback
|
||||
this.showView(this.currentView, done);
|
||||
},
|
||||
|
||||
// Show a view that is being swapped in. Override this method to
|
||||
// set up your own custom fade in / show method
|
||||
showView: function (view, done) {
|
||||
view.$el.show();
|
||||
done();
|
||||
},
|
||||
|
||||
// Hide a view that is being swapped out. Override this method to
|
||||
// set up your own custom fade out / hide method
|
||||
hideView: function (view, done) {
|
||||
view.$el.hide();
|
||||
done();
|
||||
},
|
||||
|
||||
// Ensure the views that were configured for this view swapper get closed
|
||||
close: function () {
|
||||
|
||||
// Close all of the configured views that we are swapping between
|
||||
_.each(this.views, function (view, name) {
|
||||
view.close();
|
||||
});
|
||||
|
||||
// unbind all the events, and clean up any decorator views
|
||||
this._swapperViews = {};
|
||||
this._currentViewBindings.unbindAll();
|
||||
this._swapperBindings.unbindAll();
|
||||
|
||||
// Close the base view that we extended from
|
||||
Marionette.View.prototype.close.apply(this, arguments);
|
||||
},
|
||||
|
||||
// Get a view by name, throwing an exception if the view instance
|
||||
// is not found.
|
||||
_getView: function (viewName) {
|
||||
var originalView, error, views;
|
||||
var swapperView = this._swapperViews[viewName];
|
||||
|
||||
// Do not allow the name "swapper" to be used as a target view
|
||||
// or initial view. This is reserved for the ViewSwapper instance,
|
||||
// when configuring `swapOn` events
|
||||
if (viewName === "swapper") {
|
||||
error = new Error("Cannot display 'swapper' as a view.");
|
||||
error.name = "InvalidViewName";
|
||||
throw error;
|
||||
}
|
||||
|
||||
// Do we have a view with the specified name?
|
||||
if (!swapperView) {
|
||||
originalView = this.views[viewName];
|
||||
|
||||
// No view, so throw an exception
|
||||
if (!originalView) {
|
||||
error = new Error("Cannot show view in ViewSwapper. View '" + viewName + "' not found.");
|
||||
error.name = "ViewNotFoundError";
|
||||
throw error;
|
||||
}
|
||||
|
||||
// Found the view, so build a Decorator around it
|
||||
swapperView = this._buildSwapperView(originalView, viewName);
|
||||
this._swapperViews[viewName] = swapperView;
|
||||
}
|
||||
|
||||
return swapperView;
|
||||
},
|
||||
|
||||
// Decorate the configured view with information that the view swapper
|
||||
// needs, to keep track of the view's current state.
|
||||
_buildSwapperView: function (originalView, viewName) {
|
||||
var swapperView = Marionette.createObject(originalView);
|
||||
_.extend(swapperView, {
|
||||
|
||||
viewName: viewName,
|
||||
originalView: originalView,
|
||||
|
||||
// Prevent the underlying view from being rendered more than once
|
||||
render: function () {
|
||||
var value;
|
||||
|
||||
if (this._hasBeenRendered) {
|
||||
return this;
|
||||
} else {
|
||||
|
||||
// prevent any more rendering
|
||||
this._hasBeenRendered = true;
|
||||
|
||||
// do the render
|
||||
value = originalView.render.apply(originalView, arguments);
|
||||
|
||||
// trigger render/onRender
|
||||
Marionette.triggerMethod.call(this, "render");
|
||||
|
||||
// return whatever was sent back to us
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return swapperView;
|
||||
},
|
||||
|
||||
// Set up the event handlers for the individual views, so that the
|
||||
// swapping can happen when a view event is triggered
|
||||
_setupViewEvents: function (viewName, view, bindings) {
|
||||
if (!this.swapOn || !this.swapOn[viewName]) { return; }
|
||||
var that = this;
|
||||
|
||||
// default to current view bindings, unless otherwise specified
|
||||
if (!bindings) {
|
||||
bindings = this._currentViewBindings;
|
||||
}
|
||||
|
||||
// close the previous event bindings
|
||||
bindings.unbindAll();
|
||||
|
||||
// set up the new view's event bindings
|
||||
_.each(this.swapOn[viewName], function (targetViewName, eventName) {
|
||||
|
||||
bindings.bindTo(view, eventName, function () {
|
||||
that._swapView(targetViewName);
|
||||
});
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
// Do the swapping of the views to the new view, by name
|
||||
_swapView: function (viewName) {
|
||||
|
||||
// only swap views if the target view is not the same
|
||||
// as the current view
|
||||
var view = this._getView(viewName);
|
||||
if (view === this.currentView) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Provide a callback function that will switch over to
|
||||
// the new view, when called
|
||||
var done = _.bind(function () {
|
||||
|
||||
// trigger hide/onHide on the previous view
|
||||
if (this.currentView) {
|
||||
Marionette.triggerMethod.call(this.currentView, "hide");
|
||||
Marionette.triggerMethod.call(this, "swap:out", this.currentView);
|
||||
}
|
||||
|
||||
// get the next view, configure it's events and render it
|
||||
this._setupViewEvents(viewName, view);
|
||||
this.currentView = view;
|
||||
this.render();
|
||||
|
||||
}, this);
|
||||
|
||||
if (this.currentView) {
|
||||
// if we have a current view, hide it so that the new
|
||||
// view can be show in it's place
|
||||
this.hideView(this.currentView, done);
|
||||
} else {
|
||||
// no current view, so just switch to the new view
|
||||
done();
|
||||
}
|
||||
}
|
||||
});
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue