This repository has been archived by the owner on Sep 23, 2020. It is now read-only.
/
scaleApp.min.js
1 lines (1 loc) · 7.79 KB
/
scaleApp.min.js
1
((function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E=Object.prototype.hasOwnProperty,F=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(b in this&&this[b]===a)return b;return-1};a=function(){function a(a){this.channels={},a&&this.installTo(a)}return a.prototype.subscribe=function(b,c,d){var e,f,g,h,i,j,k,l,m,n;d==null&&(d=this),(j=this.channels)[b]==null&&(j[b]=[]),h=this;if(b instanceof Array){m=[];for(k=0,l=b.length;k<l;k++)e=b[k],m.push(this.subscribe(e,c,d));return m}if(typeof b=="object"){n=[];for(f in b)i=b[f],n.push(this.subscribe(f,i,c));return n}return g={context:d,callback:c},{attach:function(){return h.channels[b].push(g),this},detach:function(){return a._rm(h,b,g.callback),this}}.attach()},a.prototype.unsubscribe=function(b,c){var d;switch(typeof b){case"string":typeof c=="function"&&a._rm(this,b,c),typeof c=="undefined"&&a._rm(this,b);break;case"function":for(d in this.channels)a._rm(this,d,b);break;case"undefined":for(d in this.channels)a._rm(this,d);break;case"object":for(d in this.channels)a._rm(this,d,null,b)}return this},a.prototype.publish=function(a,b,c){var d,e,f,g,h,i,j;if(this.channels[a]!=null){j=this.channels[a];for(h=0,i=j.length;h<i;h++){f=j[h];if(c!==!0&&typeof b=="object"){if(b instanceof Array)d=function(){var a,c,d;d=[];for(a=0,c=b.length;a<c;a++)g=b[a],d.push(g);return d}();else{d={};for(e in b)g=b[e],d[e]=g}try{f.callback.apply(f.context,[d,a])}catch(k){typeof console!="undefined"&&console!==null&&typeof console.error=="function"&&console.error(k)}}else try{f.callback.apply(f.context,[b,a])}catch(k){typeof console!="undefined"&&console!==null&&typeof console.error=="function"&&console.error(k)}}}return this},a.prototype.installTo=function(a){var b,c;if(typeof a=="object")for(b in this)c=this[b],a[b]=c;return this},a._rm=function(a,b,c,d){var e;return a.channels[b]=function(){var f,g,h,i;h=a.channels[b],i=[];for(f=0,g=h.length;f<g;f++)e=h[f],(c!=null?e.callback!==c:d!=null?e.context!==d:e.context!==a)&&i.push(e);return i}()},a}(),typeof exports!="undefined"&&exports!==null&&(exports.Mediator=a),b=function(){function a(a,b,c){this.core=a,this.instanceId=b,this.options=c!=null?c:{};if(this.core==null)throw new Error("core was not defined");if(b==null)throw new Error("no id was specified");if(typeof b!="string")throw new Error("id is not a string")}return a}(),typeof exports!="undefined"&&exports!==null&&(exports.Sandbox=b),typeof require=="function"&&(a=require("./Mediator").Mediator,b=require("./Sandbox").Sandbox),c="0.3.4",p={},k={},o=new a,s={},j=function(a){return typeof console!="undefined"&&console!==null?typeof console.error=="function"?console.error(a.message):void 0:void 0},A=function(a){var b;a==null&&(a=8),b="";while(b.length<a)b+=Math.random().toString(36).substr(2);return b.substr(0,a)},r={_always:[]},q=function(a,b){var c;if(typeof a!="function")throw new Error("expect a function as parameter");c={context:this,callback:a};if(typeof b=="string")return r[b]==null&&(r[b]=[]),r[b].push(c);if(b==null)return r._always.push(c)},h=function(a,c,d){var e,g,h,i,j,l,m,n,q,t,u,v,w,x,y,z,A,B,C,D;c==null&&(c=a),m=p[a];if(k[c]!=null)return k[c];i={},B=m.options;for(l in B)w=B[l],i[l]=w;if(d)for(l in d)w=d[l],i[l]=w;u=new b(f,c,i),o.installTo(u);for(g in s){q=s[g];if(q.sandbox==null)continue;t=new q.sandbox(u);for(j in t){if(!E.call(t,j))continue;v=t[j],u[j]=v}}h=new m.creator(u),h.options=i,h.id=c,k[c]=h,C=[c,"_always"];for(x=0,z=C.length;x<z;x++){n=C[x];if(r[n]!=null){D=r[n];for(y=0,A=D.length;y<A;y++)e=D[y],e.callback.apply(e.context)}}return h},d=function(a,b,c){var d;if(typeof a!="string")throw new Error("moudule ID has to be a string");if(typeof b!="function")throw new Error("creator has to be a constructor function");if(typeof c!="object")throw new Error("option parameter has to be an object");d=new b;if(typeof d!="object")throw new Error("creator has to return an object");if(typeof d.init!="function")throw new Error("module has to have an init function");if(typeof d.destroy!="function")throw new Error("module has to have a destroy function");if(p[a]!=null)throw new Error("module "+a+" was already registered");return p[a]={creator:b,options:c,id:a},!0},t=function(a,b,c){c==null&&(c={});try{return d(a,b,c)}catch(e){return j(new Error("could not register module: "+e.message)),!1}},B=function(a){return p[a]!=null?(delete p[a],!0):!1},C=function(){var a,b;b=[];for(a in p)b.push(B(a));return b},w=function(a,b){var c;b==null&&(b={});try{if(typeof a!="string")throw new Error("module ID has to be a string");if(typeof b!="object")throw new Error("second parameter has to be an object");if(p[a]==null)throw new Error("module does not exist");c=h(a,b.instanceId,b.options);if(c.running===!0)throw new Error("module was already started");return c.init(c.options,function(a){return typeof b.callback=="function"?b.callback(a):void 0}),c.running=!0,!0}catch(d){return j(d),typeof b.callback=="function"&&b.callback(new Error("could not start module: "+d.message)),!1}},y=function(a,b){var c;return(c=k[a])?(o.unsubscribe(c),c.destroy(b),delete k[a],!0):!1},i=function(a,b,c){var d,f,g,h,i,j;f=a.length,g=[],d=function(){return f--,e(f,g,c)};for(i=0,j=a.length;i<j;i++){h=a[i];if(!!b(h,d))continue;g.push("'"+h+"'"),d()}return g.length===0},e=function(a,b,c){if(a===0)return b.length>0?typeof c=="function"?c(new Error("errors occoured in the following modules: "+b)):void 0:typeof c=="function"?c():void 0},x=function(a,b){var c,d,e,f,g,h,j;if(a instanceof Array)f=a,a=b,b=null,h=function(){var a,b,d;d=[];for(a=0,b=f.length;a<b;a++)c=f[a],p[c]!=null&&d.push(c);return d}(),h.length!==f.length&&(d=function(){var a,b,d;d=[];for(a=0,b=f.length;a<b;a++)c=f[a],F.call(h,c)>=0||d.push("'"+c+"'");return d}(),e=new Error("these modules don't exist: "+d));else switch(typeof a){case"undefined":case"function":f=h=function(){var a;a=[];for(c in p)a.push(c);return a}();break;default:f=h=[]}return h.length===(j=f.length)&&j===0?(typeof a=="function"&&a(null),!0):(g=function(a,b){var c,d,e,f;e={},d=p[a].options;for(c in d){if(!E.call(d,c))continue;f=d[c],f&&(e[c]=f)}return e.callback=function(a){return typeof d.callback=="function"&&d.callback(a),b()},w(a,e)},i(h,g,function(b){return a(b||e)})&&e==null)},z=function(a){var b;return i(function(){var a;a=[];for(b in k)a.push(b);return a}(),function(a,b){return y(a,b)},a)},g=["VERSION","register","unregister","registerPlugin","start","stop","startAll","stopAll","publish","subscribe","unsubscribe","Mediator","Sandbox","unregisterAll","uniqueId","lsModules","lsInstances"],v=["core","instanceId","options","publish","subscribe","unsubscribe"],n=function(){var a,b,c;c=[];for(a in p)b=p[a],c.push(a);return c},m=function(){var a,b,c;c=[];for(a in k)b=k[a],c.push(a);return c},u=function(a){var c,d,e,h;try{if(typeof a!="object")throw new Error("plugin has to be an object");if(typeof a.id!="string")throw new Error("plugin has no id");if(typeof a.sandbox=="function"){for(c in new a.sandbox(new b(f,"")))if(F.call(v,c)>=0)throw new Error("plugin uses reserved keyword");e=a.sandbox.prototype;for(c in e)d=e[c],b.prototype[c]=d}if(typeof a.core=="object"){for(c in a.core)if(F.call(g,c)>=0)throw new Error("plugin uses reserved keyword");h=a.core;for(c in h)d=h[c],f[c]=d,typeof exports!="undefined"&&exports!==null&&(exports[c]=d)}return typeof a.onInstantiate=="function"&&q(a.onInstantiate),s[a.id]=a,!0}catch(i){return j(i),!1}},f={VERSION:c,register:t,unregister:B,unregisterAll:C,registerPlugin:u,start:w,stop:y,startAll:x,stopAll:z,uniqueId:A,lsInstances:m,lsModules:n,Mediator:a,Sandbox:b,subscribe:function(){return o.subscribe.apply(o,arguments)},unsubscribe:function(){return o.unsubscribe.apply(o,arguments)},publish:function(){return o.publish.apply(o,arguments)}};if(typeof exports!="undefined"&&exports!==null&&typeof module!="undefined"&&module!==null)for(l in f)D=f[l],exports[l]=D;typeof window!="undefined"&&window!==null&&(window.scaleApp=f)})).call(this);