sonarr-repo-only/NzbDrone.Web/Scripts/backbone.marionette.min.js

13 lines
18 KiB
JavaScript
Raw Normal View History

2012-11-07 00:41:34 +00:00
/*!
* Backbone.Marionette, v1.0.0-beta4
* Copyright (c)2012 Derick Bailey, Muted Solutions, LLC.
* Distributed under MIT license
* http://github.com/marionettejs/backbone.marionette
*/
/*!
* Includes Wreqr
* https://github.com/marionettejs/backbone.wreqr/
* Includes EventBinder
* https://github.com/marionettejs/backbone.eventbinder/
*/
Backbone.EventBinder=function(e,t){"use strict";function r(e){return e.jquery?n.jquery:n["default"]}var n={"default":{bindTo:function(e,t,n,r){r=r||this,e.on(t,n,r);var i={type:"default",obj:e,eventName:t,callback:n,context:r};return i},unbindFrom:function(e){e.obj.off(e.eventName,e.callback,e.context)}},jquery:{bindTo:function(e,n,r,i){i=i||this,r=t(r).bind(i),e.on(n,r);var s={type:"jquery",obj:e,eventName:n,callback:r,context:i};return s},unbindFrom:function(e){e.obj.off(e.eventName,e.callback)}}},i=function(){this._eventBindings=[]};return i.extend=e.View.extend,t.extend(i.prototype,{bindTo:function(){var e=arguments[0],t=r(e),n=t.bindTo.apply(this,arguments);return this._eventBindings.push(n),n},unbindFrom:function(e){n[e.type].unbindFrom.apply(this,arguments),this._eventBindings=t.reject(this._eventBindings,function(t){return t===e})},unbindAll:function(){var e=t.map(this._eventBindings,t.identity);t.each(e,this.unbindFrom,this)}}),i}(Backbone,_),Backbone.Wreqr=function(e,t,n){"option strict";var r={};return r.Handlers=function(e,t){var n=function(){"use strict";this._handlers={}};return n.extend=e.Model.extend,t.extend(n.prototype,{addHandler:function(e,t,n){var r={callback:t,context:n};this._handlers[e]=r},getHandler:function(e){var t=this._handlers[e];if(!t)throw new Error("Handler not found for '"+e+"'");return function(){return t.callback.apply(t.context,arguments)}},removeHandler:function(e){delete this._handlers[e]},removeAllHandlers:function(){this._handlers={}}}),n}(e,n),r.Commands=function(e){return e.Handlers.extend({execute:function(e,t){this.getHandler(e)(t)}})}(r),r.RequestResponse=function(e){return e.Handlers.extend({request:function(e,t){return this.getHandler(e)(t)}})}(r),r.EventAggregator=function(e,t){var n=function(){};return n.extend=e.Model.extend,t.extend(n.prototype,e.Events),n}(e,n),r}(Backbone,Backbone.Marionette,_),Backbone.Marionette=Marionette=function(e,t,n){var r={},i=Array.prototype.slice;return r.extend=e.Model.extend,r.getOption=function(e,t){if(!e||!t)return;var n;return e.options&&e.options[t]?n=e.options[t]:n=e[t],n},r.createObject=function(){function t(){}var e;return typeof Object.create=="function"?e=Object.create:e=function(e){t.prototype=e;var n=new t;return t.prototype=null,n},e}(),r.triggerMethod=function(){var e=Array.prototype.slice.apply(arguments),n=e[0],r=n.split(":"),i,s,o="on";for(var u=0;u<r.length;u++)i=r[u],s=i.charAt(0).toUpperCase(),o+=s+i.slice(1);this.trigger.apply(this,arguments),t.isFunction(this[o])&&(e.shift(),this[o].apply(this,e))},r.EventBinder=e.EventBinder.extend({augment:function(e){var n=new r.EventBinder;e.eventBinder=n,e.bindTo=t.bind(n.bindTo,n),e.unbindFrom=t.bind(n.unbindFrom,n),e.unbindAll=t.bind(n.unbindAll,n)}}),r.addEventBinder=function(e){var n=new r.EventBinder;e.eventBinder=n,e.bindTo=t.bind(n.bindTo,n),e.unbindFrom=t.bind(n.unbindFrom,n),e.unbindAll=t.bind(n.unbindAll,n)},r.EventAggregator=e.Wreqr.EventAggregator.extend({constructor:function(){r.addEventBinder(this),e.Wreqr.EventAggregator.prototype.constructor.apply(this,arguments)}}),r.Callbacks=function(){this._deferred=n.Deferred(),this._callbacks=[]},t.extend(r.Callbacks.prototype,{add:function(e,t){this._callbacks.push({cb:e,ctx:t}),this._deferred.done(function(n,r){t&&(n=t),e.call(n,r)})},run:function(e,t){this._deferred.resolve(t,e)},reset:function(){var e=this,r=this._callbacks;this._deferred=n.Deferred(),this._callbacks=[],t.each(r,function(t){e.add(t.cb,t.ctx)})}}),r.TemplateCache=function(e){this.templateId=e},t.extend(r.TemplateCache,{templateCaches:{},get:function(e){var t=this,n=this.templateCaches[e];return n||(n=new r.TemplateCache(e),this.templateCaches[e]=n),n.load()},clear:function(){var e,t=arguments.length;if(t>0)for(e=0;e<t;e++)delete this.templateCaches[arguments[e]];else this.templateCaches={}}}),t.extend(r.TemplateCache.prototype,{load:function(){var e=this;if(this.compiledTemplate)return this.compiledTemplate;var t=this.loadTemplate(this.templateId);return this.compiledTemplate=this.compileTemplate(t),this.compiledTemplate},loadTemplate:function(e){var t=n(