mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-14 11:23:42 +02:00
updated backbone to 0.9.10
updated marionette 1.0.0-rc5
This commit is contained in:
parent
eab6abc8c9
commit
78d007791f
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
// Backbone.Marionette, v1.0.0-rc3
|
||||
// Backbone.Marionette, v1.0.0-rc5
|
||||
// Copyright (c)2013 Derick Bailey, Muted Solutions, LLC.
|
||||
// Distributed under MIT license
|
||||
// http://github.com/marionettejs/backbone.marionette
|
||||
@ -207,12 +207,12 @@ Backbone.ChildViewContainer = (function (Backbone, _) {
|
||||
return Container;
|
||||
})(Backbone, _);
|
||||
|
||||
// Backbone.Wreqr, v0.2.0
|
||||
// Copyright (c)2012 Derick Bailey, Muted Solutions, LLC.
|
||||
// Backbone.Wreqr, v0.1.1
|
||||
// Copyright (c)2013 Derick Bailey, Muted Solutions, LLC.
|
||||
// Distributed under MIT license
|
||||
// http://github.com/marionettejs/backbone.wreqr
|
||||
Backbone.Wreqr = (function (Backbone, Marionette, _) {
|
||||
"option strict";
|
||||
"use strict";
|
||||
var Wreqr = {};
|
||||
|
||||
// Handlers
|
||||
@ -220,13 +220,12 @@ Backbone.Wreqr = (function (Backbone, Marionette, _) {
|
||||
// A registry of functions to call, given a name
|
||||
|
||||
Wreqr.Handlers = (function (Backbone, _) {
|
||||
"option strict";
|
||||
"use strict";
|
||||
|
||||
// Constructor
|
||||
// -----------
|
||||
|
||||
var Handlers = function () {
|
||||
"use strict";
|
||||
this._handlers = {};
|
||||
};
|
||||
|
||||
@ -284,7 +283,7 @@ Backbone.Wreqr = (function (Backbone, Marionette, _) {
|
||||
// A simple command pattern implementation. Register a command
|
||||
// handler and execute it.
|
||||
Wreqr.Commands = (function (Wreqr) {
|
||||
"option strict";
|
||||
"use strict";
|
||||
|
||||
return Wreqr.Handlers.extend({
|
||||
execute: function () {
|
||||
@ -303,7 +302,7 @@ Backbone.Wreqr = (function (Backbone, Marionette, _) {
|
||||
// A simple request/response implementation. Register a
|
||||
// request handler, and return a response from it
|
||||
Wreqr.RequestResponse = (function (Wreqr) {
|
||||
"option strict";
|
||||
"use strict";
|
||||
|
||||
return Wreqr.Handlers.extend({
|
||||
request: function () {
|
||||
@ -322,32 +321,16 @@ Backbone.Wreqr = (function (Backbone, Marionette, _) {
|
||||
// of an application through event-driven architecture.
|
||||
|
||||
Wreqr.EventAggregator = (function (Backbone, _) {
|
||||
"use strict";
|
||||
var EA = function () { };
|
||||
|
||||
// Grab a reference to the original listenTo
|
||||
var listenTo = Backbone.Events.listenTo;
|
||||
// Copy the `extend` function used by Backbone's classes
|
||||
EA.extend = Backbone.Model.extend;
|
||||
|
||||
// Create a version of listenTo that allows contexting binding
|
||||
function contextBoundListenTo(obj, evtSource, events, callback, context) {
|
||||
context = context || obj;
|
||||
return listenTo.call(obj, evtSource, events, _.bind(callback, context));
|
||||
}
|
||||
// Copy the basic Backbone.Events on to the event aggregator
|
||||
_.extend(EA.prototype, Backbone.Events);
|
||||
|
||||
// Define the EventAggregator
|
||||
function EventAggregator() { }
|
||||
|
||||
// Mix Backbone.Events in to it
|
||||
_.extend(EventAggregator.prototype, Backbone.Events, {
|
||||
// Override the listenTo so that we can have a version that
|
||||
// correctly binds context
|
||||
listenTo: function (evtSource, events, callback, context) {
|
||||
return contextBoundListenTo(this, evtSource, events, callback, context);
|
||||
}
|
||||
});
|
||||
|
||||
// Allow it to be extended
|
||||
EventAggregator.extend = Backbone.Model.extend;
|
||||
|
||||
return EventAggregator;
|
||||
return EA;
|
||||
})(Backbone, _);
|
||||
|
||||
|
||||
@ -381,7 +364,7 @@ var Marionette = (function (Backbone, _, $) {
|
||||
if (!target || !optionName) { return; }
|
||||
var value;
|
||||
|
||||
if (target.options && target.options[optionName]) {
|
||||
if (target.options && (optionName in target.options) && (target.options[optionName] !== undefined)) {
|
||||
value = target.options[optionName];
|
||||
} else {
|
||||
value = target[optionName];
|
||||
@ -509,56 +492,6 @@ var Marionette = (function (Backbone, _, $) {
|
||||
})();
|
||||
|
||||
|
||||
// addEventBinder
|
||||
// --------------
|
||||
//
|
||||
// Mixes in Backbone.Events to the target object, if it is not present
|
||||
// already. Also adjusts the listenTo method to accept a 4th parameter
|
||||
// for the callback context.
|
||||
|
||||
(function (Backbone, Marionette, _) {
|
||||
|
||||
// grab a reference to the original listenTo
|
||||
var listenTo = Backbone.Events.listenTo;
|
||||
|
||||
// Fix the listenTo method on the target object, allowing the 4th
|
||||
// context parameter to be specified
|
||||
Marionette.addEventBinder = function (target) {
|
||||
// If the target is not already extending Backbone.Events,
|
||||
// then extend that on to it first
|
||||
if (!target.on && !target.off && !target.listenTo && !target.stopListening) {
|
||||
_.extend(target, Backbone.Events);
|
||||
}
|
||||
|
||||
// Override the built-in listenTo method to make sure we
|
||||
// account for context
|
||||
target.listenTo = function (evtSource, events, callback, context) {
|
||||
context = context || this;
|
||||
return listenTo.call(this, evtSource, events, _.bind(callback, context));
|
||||
};
|
||||
};
|
||||
|
||||
})(Backbone, Marionette, _);
|
||||
|
||||
|
||||
// Event Aggregator
|
||||
// ----------------
|
||||
// A pub-sub object that can be used to decouple various parts
|
||||
// of an application through event-driven architecture.
|
||||
//
|
||||
// Extends [Backbone.Wreqr.EventAggregator](https://github.com/marionettejs/backbone.wreqr)
|
||||
// and mixes in an EventBinder from [Backbone.EventBinder](https://github.com/marionettejs/backbone.eventbinder).
|
||||
Marionette.EventAggregator = Backbone.Wreqr.EventAggregator.extend({
|
||||
|
||||
constructor: function () {
|
||||
Marionette.addEventBinder(this);
|
||||
|
||||
var args = Array.prototype.slice.apply(arguments);
|
||||
Backbone.Wreqr.EventAggregator.prototype.constructor.apply(this, args);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Marionette.bindEntityEvents & unbindEntityEvents
|
||||
// ---------------------------
|
||||
//
|
||||
@ -707,8 +640,6 @@ var Marionette = (function (Backbone, _, $) {
|
||||
this.triggerMethod = Marionette.triggerMethod;
|
||||
this.options = options || {};
|
||||
|
||||
Marionette.addEventBinder(this);
|
||||
|
||||
if (_.isFunction(this.initialize)) {
|
||||
this.initialize(this.options);
|
||||
}
|
||||
@ -737,8 +668,6 @@ var Marionette = (function (Backbone, _, $) {
|
||||
Marionette.Region = function (options) {
|
||||
this.options = options || {};
|
||||
|
||||
Marionette.addEventBinder(this);
|
||||
|
||||
this.el = Marionette.getOption(this, "el");
|
||||
|
||||
if (!this.el) {
|
||||
@ -953,7 +882,7 @@ var Marionette = (function (Backbone, _, $) {
|
||||
// and know whether or not it has been loaded
|
||||
_.extend(Marionette.TemplateCache.prototype, {
|
||||
|
||||
// Internal method to load the template asynchronously.
|
||||
// Internal method to load the template
|
||||
load: function () {
|
||||
var that = this;
|
||||
|
||||
@ -970,12 +899,12 @@ var Marionette = (function (Backbone, _, $) {
|
||||
},
|
||||
|
||||
// Load a template from the DOM, by default. Override
|
||||
// this method to provide your own template retrieval,
|
||||
// such as asynchronous loading from a server.
|
||||
// this method to provide your own template retrieval
|
||||
// For asynchronous loading with AMD/RequireJS, consider
|
||||
// using a template-loader plugin as described here:
|
||||
// https://github.com/marionettejs/backbone.marionette/wiki/Using-marionette-with-requirejs
|
||||
loadTemplate: function (templateId) {
|
||||
|
||||
var templateEl = $(templateId);
|
||||
var template = templateEl.html();
|
||||
var template = $(templateId).html();
|
||||
|
||||
if (!template || template.length === 0) {
|
||||
var msg = "Could not find template: '" + templateId + "'";
|
||||
@ -984,7 +913,6 @@ var Marionette = (function (Backbone, _, $) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
templateEl.remove();
|
||||
return template;
|
||||
},
|
||||
|
||||
@ -1026,7 +954,6 @@ var Marionette = (function (Backbone, _, $) {
|
||||
|
||||
constructor: function () {
|
||||
_.bindAll(this, "render");
|
||||
Marionette.addEventBinder(this);
|
||||
|
||||
var args = Array.prototype.slice.apply(arguments);
|
||||
Backbone.View.prototype.constructor.apply(this, args);
|
||||
@ -1091,7 +1018,7 @@ var Marionette = (function (Backbone, _, $) {
|
||||
};
|
||||
|
||||
// trigger the event
|
||||
that.trigger(value, args);
|
||||
that.triggerMethod(value, args);
|
||||
};
|
||||
|
||||
});
|
||||
@ -1401,15 +1328,15 @@ var Marionette = (function (Backbone, _, $) {
|
||||
// remove and/or close it later
|
||||
this.children.add(view);
|
||||
|
||||
// Render it and show it
|
||||
this.renderItemView(view, index);
|
||||
|
||||
// call the "show" method if the collection view
|
||||
// has already been shown
|
||||
if (this._isShown) {
|
||||
Marionette.triggerMethod.call(view, "show");
|
||||
}
|
||||
|
||||
// Render it and show it
|
||||
var renderResult = this.renderItemView(view, index);
|
||||
|
||||
// this view was added
|
||||
this.triggerMethod("after:item:added", view);
|
||||
},
|
||||
@ -1447,6 +1374,7 @@ var Marionette = (function (Backbone, _, $) {
|
||||
removeItemView: function (item) {
|
||||
var view = this.children.findByModel(item);
|
||||
this.removeChildView(view);
|
||||
this.checkEmpty();
|
||||
},
|
||||
|
||||
// Remove the child view and close it
|
||||
@ -1464,13 +1392,16 @@ var Marionette = (function (Backbone, _, $) {
|
||||
this.children.remove(view);
|
||||
}
|
||||
|
||||
this.triggerMethod("item:removed", view);
|
||||
},
|
||||
|
||||
// helper to show the empty view if the collection is empty
|
||||
checkEmpty: function () {
|
||||
// check if we're empty now, and if we are, show the
|
||||
// empty view
|
||||
if (!this.collection || this.collection.length === 0) {
|
||||
this.showEmptyView();
|
||||
}
|
||||
|
||||
this.triggerMethod("item:removed", view);
|
||||
},
|
||||
|
||||
// Append the HTML to the collection's `el`.
|
||||
@ -1505,9 +1436,7 @@ var Marionette = (function (Backbone, _, $) {
|
||||
this.children.each(function (child) {
|
||||
this.removeChildView(child);
|
||||
}, this);
|
||||
|
||||
// re-initialize to clean up after ourselves
|
||||
this._initChildViewStorage();
|
||||
this.checkEmpty();
|
||||
}
|
||||
});
|
||||
|
||||
@ -1845,14 +1774,13 @@ var Marionette = (function (Backbone, _, $) {
|
||||
// event aggregator as `app.vent`
|
||||
Marionette.Application = function (options) {
|
||||
this.initCallbacks = new Marionette.Callbacks();
|
||||
this.vent = new Marionette.EventAggregator();
|
||||
this.vent = new Backbone.Wreqr.EventAggregator();
|
||||
this.commands = new Backbone.Wreqr.Commands();
|
||||
this.reqres = new Backbone.Wreqr.RequestResponse();
|
||||
this.submodules = {};
|
||||
|
||||
_.extend(this, options);
|
||||
|
||||
Marionette.addEventBinder(this);
|
||||
this.triggerMethod = Marionette.triggerMethod;
|
||||
};
|
||||
|
||||
@ -1939,8 +1867,6 @@ var Marionette = (function (Backbone, _, $) {
|
||||
this.app = app;
|
||||
this.startWithParent = true;
|
||||
|
||||
// extend this module with an event binder
|
||||
Marionette.addEventBinder(this);
|
||||
this.triggerMethod = Marionette.triggerMethod;
|
||||
};
|
||||
|
||||
@ -2001,7 +1927,7 @@ var Marionette = (function (Backbone, _, $) {
|
||||
_.each(this.submodules, function (mod) { mod.stop(); });
|
||||
|
||||
// run the finalizers
|
||||
this._finalizerCallbacks.run();
|
||||
this._finalizerCallbacks.run(undefined, this);
|
||||
|
||||
// reset the initializers and finalizers
|
||||
this._initializerCallbacks.reset();
|
||||
|
Loading…
Reference in New Issue
Block a user