2019-09-17 13:19:54 -04:00
|
|
|
!function(a){var b="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global;if("function"==typeof define&&define.amd)define(["underscore","jquery","exports"],function(c,d,e){b.Backbone=a(b,e,c,d)});else if("undefined"!=typeof exports){var c,d=require("underscore");try{c=require("jquery")}catch(e){}a(b,exports,d,c)}else b.Backbone=a(b,{},b._,b.jQuery||b.Zepto||b.ender||b.$)}(function(a,b,c,d){var e=a.Backbone,f=Array.prototype.slice;b.VERSION="1.4.0",b.$=d,b.noConflict=function(){return a.Backbone=e,this},b.emulateHTTP=!1,b.emulateJSON=!1;var g,h=b.Events={},i=/\s+/,j=function(a,b,d,e,f){var g,h=0;if(d&&"object"==typeof d){void 0!==e&&"context"in f&&void 0===f.context&&(f.context=e);for(g=c.keys(d);h<g.length;h++)b=j(a,b,g[h],d[g[h]],f)}else if(d&&i.test(d))for(g=d.split(i);h<g.length;h++)b=a(b,g[h],e,f);else b=a(b,d,e,f);return b};h.on=function(a,b,c){if(this._events=j(k,this._events||{},a,b,{context:c,ctx:this,listening:g}),g){var d=this._listeners||(this._listeners={});d[g.id]=g,g.interop=!1}return this},h.listenTo=function(a,b,d){if(!a)return this;var e=a._listenId||(a._listenId=c.uniqueId("l")),f=this._listeningTo||(this._listeningTo={}),h=g=f[e];h||(this._listenId||(this._listenId=c.uniqueId("l")),h=g=f[e]=new q(this,a));var i=l(a,b,d,this);if(g=void 0,i)throw i;return h.interop&&h.on(b,d),this};var k=function(a,b,c,d){if(c){var e=a[b]||(a[b]=[]),f=d.context,g=d.ctx,h=d.listening;h&&h.count++,e.push({callback:c,context:f,ctx:f||g,listening:h})}return a},l=function(a,b,c,d){try{a.on(b,c,d)}catch(e){return e}};h.off=function(a,b,c){return this._events?(this._events=j(m,this._events,a,b,{context:c,listeners:this._listeners}),this):this},h.stopListening=function(a,b,d){var e=this._listeningTo;if(!e)return this;for(var f=a?[a._listenId]:c.keys(e),g=0;g<f.length;g++){var h=e[f[g]];if(!h)break;h.obj.off(b,d,this),h.interop&&h.off(b,d)}return c.isEmpty(e)&&(this._listeningTo=void 0),this};var m=function(a,b,d,e){if(a){var f,g=e.context,h=e.listeners,i=0;if(b||g||d){for(f=b?[b]:c.keys(a);i<f.length;i++){b=f[i];var j=a[b];if(!j)break;for(var k=[],l=0;l<j.length;l++){var m=j[l];if(d&&d!==m.callback&&d!==m.callback._callback||g&&g!==m.context)k.push(m);else{var n=m.listening;n&&n.off(b,d)}}k.length?a[b]=k:delete a[b]}return a}for(f=c.keys(h);i<f.length;i++)h[f[i]].cleanup()}};h.once=function(a,b,c){var d=j(n,{},a,b,this.off.bind(this));return"string"==typeof a&&null==c&&(b=void 0),this.on(d,b,c)},h.listenToOnce=function(a,b,c){var d=j(n,{},b,c,this.stopListening.bind(this,a));return this.listenTo(a,d)};var n=function(a,b,d,e){if(d){var f=a[b]=c.once(function(){e(b,f),d.apply(this,arguments)});f._callback=d}return a};h.trigger=function(a){if(!this._events)return this;for(var b=Math.max(0,arguments.length-1),c=Array(b),d=0;d<b;d++)c[d]=arguments[d+1];return j(o,this._events,a,void 0,c),this};var o=function(a,b,c,d){if(a){var e=a[b],f=a.all;e&&f&&(f=f.slice()),e&&p(e,d),f&&p(f,[b].concat(d))}return a},p=function(a,b){var c,d=-1,e=a.length,f=b[0],g=b[1],h=b[2];switch(b.length){case 0:for(;++d<e;)(c=a[d]).callback.call(c.ctx);return;case 1:for(;++d<e;)(c=a[d]).callback.call(c.ctx,f);return;case 2:for(;++d<e;)(c=a[d]).callback.call(c.ctx,f,g);return;case 3:for(;++d<e;)(c=a[d]).callback.call(c.ctx,f,g,h);return;default:for(;++d<e;)(c=a[d]).callback.apply(c.ctx,b);return}},q=function(a,b){this.id=a._listenId,this.listener=a,this.obj=b,this.interop=!0,this.count=0,this._events=void 0};q.prototype.on=h.on,q.prototype.off=function(a,b){var c;this.interop?(this._events=j(m,this._events,a,b,{context:void 0,listeners:void 0}),c=!this._events):(this.count--,c=0===this.count),c&&this.cleanup()},q.prototype.cleanup=function(){delete this.listener._listeningTo[this.obj._listenId],this.interop||delete this.obj._listeners[this.id]},h.bind=h.on,h.unbind=h.off,c.extend(b,h);var r=b.Model=function(a,b){var d=a||{};b||(b={}),this.preinitialize.apply(this,arguments),this.cid=c.uniqueId(this.cidPrefix),this.attributes={},b.collection&&(this.collection=b.collection),b.parse&&(d=this.parse(d,b)||{});var e=c.r
|