diff --git a/common/static/js/vendor/backbone-associations-min.js b/common/static/js/vendor/backbone-associations-min.js index a45bad4c55..77d398d962 100644 --- a/common/static/js/vendor/backbone-associations-min.js +++ b/common/static/js/vendor/backbone-associations-min.js @@ -1,7 +1,11 @@ -(function(){var f,h,q,l,p,o,s;"undefined"!==typeof require?(f=require("underscore"),h=require("backbone"),exports=module.exports=h):(f=this._,h=this.Backbone);q=h.Model;l=h.Collection;p=q.prototype;s=/[\.\[\]]+/g;h.Many="Many";h.One="One";o=h.AssociatedModel=q.extend({relations:void 0,_proxyCalls:void 0,get:function(b){var a=p.get.call(this,b);return a?a:this.getAttr.apply(this,arguments)},set:function(b,a,d){var c,k,e,i,g=this;if(f.isObject(b)||b==null){c=b;d=a}else{c={};c[b]=a}if(!c)return this; -for(k in c){e||(e={});if(k.match(s)){b=r(k);a=f.initial(b);b=b[b.length-1];a=this.get(a);if(a instanceof o){a=e[a.cid]||(e[a.cid]={model:a,data:{}});a.data[b]=c[k]}}else{a=e[this.cid]||(e[this.cid]={model:this,data:{}});a.data[k]=c[k]}}if(e)for(i in e){a=e[i];this.setAttr.call(a.model,a.data,d)||(g=false)}else return this.setAttr.call(this,c,d);return g},setAttr:function(b,a){var d;a||(a={});if(a.unset)for(d in b)b[d]=void 0;this.relations&&f.each(this.relations,function(c){var d=c.key,e=c.relatedModel, -i=c.collectionType,g,j,n,m;if(b[d]){g=f.result(b,d);e&&f.isString(e)&&(e=eval(e));i&&f.isString(i)&&(i=eval(i));j=c.options?f.extend({},c.options,a):a;if(c.type===h.Many){if(i&&!i.prototype instanceof l)throw Error("collectionType must inherit from Backbone.Collection");if(g instanceof l)n=g;else{n=i?new i:this._createCollection(e);n.add(g,j)}b[d]=n}else if(c.type===h.One&&e){n=g instanceof o?g:new e(g);b[d]=n}if((m=n)&&!m._proxyCallback){m._proxyCallback=function(){return this._bubbleEvent.call(this, -d,m,arguments)};m.on("all",m._proxyCallback,this)}}},this);return p.set.call(this,b,a)},_bubbleEvent:function(b,a,d){var c=d[0].split(":"),k=c[0],e=d[1],i=-1,g=a._proxyCalls,j;f.size(c)>1&&(j=c[1]);if(a instanceof l&&"change"===k&&e){var h=r(j),m=f.initial(h);(c=a.find(function(a){if(e===a)return true;if(a){var b=a.get(m);if((b instanceof o||b instanceof l)&&e===b)return true;b=a.get(h);return(b instanceof o||b instanceof l)&&e===b}return false}))&&(i=a.indexOf(c))}j=b+(i!==-1?"["+i+"]":"")+(j?"."+ -j:"");d[0]=k+":"+j;if(g){if(i=f.find(g,function(a,b){return j.indexOf(b,j.length-b.length)!==-1}))return this}else g=a._proxyCalls={};g[j]=true;if("change"===k){this._previousAttributes[b]=a._previousAttributes;this.changed[b]=a}this.trigger.apply(this,d);j&&g&&delete g[j];return this},_createCollection:function(b){var a=b;f.isString(a)&&(a=eval(a));if(a&&a.prototype instanceof o){b=new l;b.model=a}else throw Error("type must inherit from Backbone.AssociatedModel");return b},toJSON:function(b){var a, -d;if(!this.visited){this.visited=true;a=p.toJSON.apply(this,arguments);this.relations&&f.each(this.relations,function(c){var h=this.attributes[c.key];if(h){d=h.toJSON(b);a[c.key]=f.isArray(d)?f.compact(d):d}},this);delete this.visited}return a},clone:function(){return new this.constructor(this.toJSON())},getAttr:function(b){var a=this,b=r(b),d,c;if(!(f.size(b)<1)){for(c=0;c0)f.parents=g.difference(f.parents,[this])}},this);return r.set.call(this,a,c)},_bubbleEvent:function(a,c,d){var b=d[0].split(":"),n=b[0],f=d[0]=="nested-change",j=d[1],k=d[2],i=-1,h=c._proxyCalls,e,q=g.indexOf(z,n)!==-1;if(!f){g.size(b)>1&&(e= +b[1]);g.indexOf(B,n)!==-1&&(k=j);if(c instanceof m&&q&&j){var l=x(e),p=g.initial(l);(b=c.find(function(a){if(j===a)return true;if(!a)return false;var b=a.get(p);if((b instanceof o||b instanceof m)&&j===b)return true;b=a.get(l);if((b instanceof o||b instanceof m)&&j===b||b instanceof m&&k&&k===b)return true}))&&(i=c.indexOf(b))}e=a+(i!==-1&&(n==="change"||e)?"["+i+"]":"")+(e?"."+e:"");if(/\[\*\]/g.test(e))return this;b=e.replace(/\[\d+\]/g,"[*]");i=[];i.push.apply(i,d);i[0]=n+":"+e;h=c._proxyCalls= +h||{};if(this._isEventAvailable.call(this,h,e))return this;h[e]=true;if("change"===n){this._previousAttributes[a]=c._previousAttributes;this.changed[a]=c}this.trigger.apply(this,i);"change"===n&&this.get(e)!=d[2]&&this.trigger.apply(this,["nested-change",e,d[1]]);h&&e&&delete h[e];if(e!==b){i[0]=n+":"+b;this.trigger.apply(this,i)}return this}},_isEventAvailable:function(a,c){return g.find(a,function(a,b){return c.indexOf(b,c.length-b.length)!==-1})},_createCollection:function(a){var c=a;g.isString(c)&& +(c=t(c));if(c&&c.prototype instanceof o){a=new m;a.model=c}else throw Error("type must inherit from Backbone.AssociatedModel");return a},_processPendingEvents:function(){if(!this.visited){this.visited=true;this._deferEvents=false;g.each(this._pendingEvents,function(a){a.c.trigger.apply(a.c,a.a)});this._pendingEvents=[];g.each(this.relations,function(a){(a=this.attributes[a.key])&&a._processPendingEvents()},this);delete this.visited}},trigger:function(a){if(this._deferEvents){this._pendingEvents=this._pendingEvents|| +[];this._pendingEvents.push({c:this,a:arguments})}else r.trigger.apply(this,arguments)},toJSON:function(a){var c,d;if(!this.visited){this.visited=true;c=r.toJSON.apply(this,arguments);this.relations&&g.each(this.relations,function(b){var h=this.attributes[b.key];if(h){d=h.toJSON(a);c[b.key]=g.isArray(d)?g.compact(d):d}},this);delete this.visited}return c},clone:function(){return new this.constructor(this.toJSON())},_getAttr:function(a){var c=this,a=x(a),d,b;if(!(g.size(a)<1)){for(b=0;b