forked from stealjs/steal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
steal.production.js
27 lines (27 loc) · 13.3 KB
/
steal.production.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(function(){function c(){var a=x(arguments);q.push.apply(q,a);c.after(a);return c}function G(a,b,d,c,e){n[d.shift()].require(a,b,function(){d.length?G(a,b,d,c,e):c.apply(this,arguments)},e)}function o(a,b,d){return d?function(){return a.apply(this,b.apply(this,arguments))}:function(){b.apply(this,arguments);return a.apply(this,arguments)}}function p(a,b,d){return d?function(){return b.apply(this,[a.apply(this,arguments)].concat(x(arguments)))}:function(){var d=a.apply(this,arguments);b.apply(this,
arguments);return d}}function E(a,b){var d=a[b];if(!a[b].callbacks)a[b]=function(){var b=arguments.callee,c;c=d.apply(a,arguments);var f=b.callbacks,j=f.length;b.called=true;for(b=0;b<j;b++)f[b].called();return c},a[b].callbacks=[];return a[b]}function H(a,b){this.obj=a;this.meth=b;E(a,b);this.calls=0}function s(){var a=x(arguments),b=a[a.length-1];typeof b==="function"&&(a[a.length-1]={fn:b},a.push("fn"));for(var b=a.pop(),d=a.pop(),b=new H(d,b),d=0;d<a.length;d+=2)b.add(a[d],a[d+1]);b.go()}var h=
function(){return this}.call(null),g=h.document,I=function(){var a=g.createElement("script");a.type="text/javascript";return a},t=function(){var a=g.documentElement,b=g.getElementsByTagName("head")[0];b||(b=g.createElement("head"),a.insertBefore(b,a.firstChild));t=function(){return b};return b},k=function(a,b){for(var d in b)a[d]=b[d];return a},l=function(a,b){for(var d=0,c=a.length;d<c;d++)b.call(a[d],d,a[d]);return a},x=function(a){var b=[];l(a,function(a,c){b[a]=c});return b},J=g&&function(){var a=
I();a.setAttribute("onerror","return;");return typeof a.onerror==="function"?true:"onerror"in a}(),K=false,u=function(){},y=h.steal,F=typeof y=="object"?y:{};c.File=function(a){if(this.constructor!=c.File)return new c.File(a);this.path=typeof a=="string"?a:a.path};var f=c.File,L;f.cur=function(a){if(a!==void 0)L=f(a);else return L||f("")};k(f.prototype,{clean:function(){return this.path.match(/([^\?#]*)/)[1]},ext:function(){var a=this.clean().match(/\.([\w\d]+)$/);return a?a[1]:""},dir:function(){var a=
this.clean(),b=a.lastIndexOf("/"),b=b!=-1?a.substring(0,b):"";return/^(https?:\/|file:\/)$/.test(b)?a:b},filename:function(){var a=this.clean(),b=a.lastIndexOf("/"),b=b!=-1?a.substring(b+1,a.length):a;return/^(https?:\/|file:\/)$/.test(b)?a:b},domain:function(){var a=this.path.match(/^(?:https?:\/\/)([^\/]*)/);return a?a[1]:null},join:function(a){return f(a).joinFrom(this.path)},joinFrom:function(a,b){var d=f(a);if(this.protocol()){var i=this.domain(),d=d.domain();return i&&i==d?this.toReferenceFromSameDomain(a):
this.path}else if(a===c.pageUrl().dir()&&!b)return this.path;else if(this.isLocalAbsolute())return(d.domain()?d.protocol()+"//"+d.domain():"")+this.path;else{if(a==="")return this.path.replace(/\/$/,"");var i=a.split("/"),d=this.path.split("/"),e=d[0];for(a.match(/\/$/)&&i.pop();e==".."&&d.length>0;){if(!i.pop())break;d.shift();e=d[0]}return i.concat(d).join("/")}},relative:function(){return this.path.match(/^(https?:|file:|\/)/)===null},afterDomain:function(){return this.path.match(/https?:\/\/[^\/]*(.*)/)[1]},
toReferenceFromSameDomain:function(a){for(var b=this.path.split("/"),a=a.split("/"),d="";b.length>0&&a.length>0&&b[0]==a[0];)b.shift(),a.shift();l(a,function(){d+="../"});return d+b.join("/")},isCrossDomain:function(){return this.isLocalAbsolute()?false:this.domain()!=f(h.location.href).domain()},isLocalAbsolute:function(){return this.path.indexOf("/")===0},protocol:function(){var a=this.path.match(/^(https?:|file:)/);return a&&a[0]},getAbsolutePath:function(){var a=f.cur().dir(),b=f(a);return b.relative()?
b.joinFrom(c.root.path,true):a},normalize:function(){var a=f.cur().dir(),b=this.path;if(/^\/\//.test(this.path))b=this.path.substr(2);else if(/^\.\//.test(this.path))this.path=this.path.substr(2),b=this.joinFrom(a),this.path="./"+this.path;else if(!/^[^\.|\/]/.test(this.path)&&(this.relative()||f.cur().isCrossDomain()&&!this.protocol()))b=this.joinFrom(a);return b}});var q=[],U=0,r={};c.p={make:function(a){var b=new c.p.init(a),d=b.options.rootSrc;b.unique&&d&&(!r[d]&&!r[d+".js"]?r[d]=b:(b=r[d],k(b.options,
typeof a==="string"?{}:a)));return b},init:function(a){this.dependencies=[];this.id=++U;if(a)if(typeof a=="function"){var b=f.cur().path;this.options={fn:function(){f.cur(b);a(c.send||h.jQuery||c)},rootSrc:b,orig:a,type:"fn"};this.waits=true;this.unique=false}else this.orig=a,this.options=c.makeOptions(k({},typeof a=="string"?{src:a}:a)),this.waits=this.options.waits||false,this.unique=true;else this.options={},this.waits=false,this.pack="production.js"},complete:function(){this.completed=true},loaded:function(a){var b,
d,a=a&&a.src||this.options.src;f.cur(this.options.rootSrc);this.isLoaded=true;K&&a&&(b=m[a]);b||(b=q.slice(0),q=[]);if(b.length){var i=this,e,h=c.options.env=="production",j=[],g=function(a,b,d,i){var e=[d,i];l(a,function(a,d){e.unshift(d,b)});s.apply(c,e)},k=function(a,b,d,c){l(d,function(d,i){s(a,b,i,c)})};l(b.reverse(),function(a,b){if(!h||!b.ignore)d=c.p.make(b),i.dependencies.unshift(d),d.waits===false?j.push(d):(e?(g(j.length?j.concat(d):[d],"complete",e,"load"),k(d,"complete",j.length?j:[e],
"load")):(g(j.length?j.concat(d):[d],"complete",i,"complete"),j.length&&k(d,"complete",j,"load")),e=d,j=[])});j.length?(e?g(j,"complete",e,"load"):g(j,"complete",i,"complete"),l(j.reverse(),function(){this.load()})):e?e.load():i.complete()}else this.complete()},load:function(){if(!this.loading&&!this.isLoaded){this.loading=true;var a=this;c.require(this.options,this.orig,function(b){a.loaded(b)},function(){clearTimeout(a.completeTimeout);throw"steal.js : "+a.options.src+" not completed";})}}};c.p.init.prototype=
c.p;var M;k(c,{root:f(""),rootUrl:function(a){if(a!==void 0){c.root=f(a);var b=c.pageUrl(),a=b.join(a);f.cur(b.toReferenceFromSameDomain(a));return c}else return c.root.path},extend:k,pageUrl:function(a){return a?(M=f(f(a).clean()),c):M||f("")},cur:function(a){return a===void 0?f.cur():(f.cur(a),c)},isRhino:h.load&&h.readUrl&&h.readFile,options:{env:"development",loadProduction:true},add:function(a){r[a.rootSrc]=a},makeOptions:function(a){if(!f(a.src).ext())a.src.indexOf(".")==0||a.src.indexOf("/")==
0?a.src+=".js":a.src=a.src+"/"+f(a.src).filename()+".js";var b=c.File(a.src).normalize(),d=c.File(a.src).protocol();k(a,{originalSrc:a.src,rootSrc:b,src:c.root.join(b),protocol:d||(g?location.protocol:"file:")});a.originalSrc=a.src;return a},then:function(){var a=typeof arguments[0]=="function"?arguments:[function(){}].concat(x(arguments));return c.apply(h,a)},bind:function(a,b){v[a]||(v[a]=[]);var d=c.events[a];d&&d.add&&(b=d.add(b));b&&v[a].push(b);return c},one:function(a,b){c.bind(a,function(){b.apply(this,
arguments);c.unbind(a,arguments.callee)});return c},events:{},unbind:function(a,b){for(var d=v[a]||[],c=0;c<d.length;)b===d[c]?d.splice(c,1):c++},trigger:function(a,b){l(v[a]||[],function(a,c){c(b)})},loading:function(){useInteractive=false;l(arguments,function(a,b){c.p.make(b).loading=true})},loaded:function(a){a=c.p.make(a);a.loading=true;a.loaded();return c}});var v={},u=o(u,function(){c.pageUrl(h.location?h.location.href:"")}),n={};c.type=function(a,b){var d=a.split(" ");if(!b)return n[d.shift()].require;
n[d.shift()]={require:b,convert:d}};c.p.load=o(c.p.load,function(){var a=this.options;if(!a.type){var b=f(a.src).ext();!b&&!n[b]&&(b="js");a.type=b}if(!n[a.type])throw"steal.js - type "+a.type+" has not been loaded.";b=n[a.type].convert;a.buildType=b.length?b[b.length-1]:a.type});c.require=function(a,b,d,c){var e=n[a.type];e.convert.length?(e=e.convert.slice(0),e.unshift("text",a.type)):e=[a.type];G(a,b,e,d,c)};var N=function(a){a.onreadystatechange=a.onload=a.onerror=null;t().removeChild(a)},z,V=
/loaded|complete/;c.type("js",function(a,b,d,c){var e=I();a.text?e.text=a.text:(b=function(){if(!e.readyState||V.test(e.readyState))N(e),d(e)},e.attachEvent?e.attachEvent("onreadystatechange",b):e.onload=b,J&&c&&a.protocol!=="file:"&&(e.attachEvent?e.attachEvent("onerror",c):e.onerror=c),e.src=a.src,e.onSuccess=d);z=e;t().insertBefore(e,t().firstChild);a.text&&(d(),N(e))});c.type("fn",function(a,b,d){d(a.fn())});c.type("text",function(a,b,d,i){c.request(a,function(b){a.text=b;d(b)},i)});var w=0,W=
g&&g.createStyleSheet,O,P;c.type("css",function(a,b,d){if(a.text)b=g.createElement("style"),b.type="text/css",b.styleSheet?b.styleSheet.cssText=a.text:(a=g.createTextNode(a.text),b.childNodes.length>0?b.firstChild.nodeValue!==a.nodeValue&&b.replaceChild(a,b.firstChild):b.appendChild(a));else{if(W){w==0?(O=document.createStyleSheet(a.src),P=a,w++):(a=f(a.src).joinFrom(f(P.src).dir()),O.addImport(a),w++,w==30&&(w=0));d();return}a=a||{};b=g.createElement("link");b.rel=a.rel||"stylesheet";b.href=a.src;
b.type="text/css"}t().appendChild(b);d()});(function(){if(F.types)for(var a in F.types)c.type(a,F.types[a])})();var X=function(){return h.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest};c.request=function(a,b,d){var c=new X,e=a.contentType||"application/x-www-form-urlencoded; charset=utf-8",f=function(){c=g=f=null},g=function(){c.readyState===4&&(c.status===500||c.status===404||c.status===2||c.status===0&&c.responseText===""?d&&d():b(c.responseText),f())};c.open("GET",a.src,
a.async===false?false:true);c.setRequestHeader("Content-type",e);c.overrideMimeType&&c.overrideMimeType(e);c.onreadystatechange=function(){g()};try{c.send(null)}catch(h){console.error(h),d&&d(),f()}};var Q=function(a){var b,d;for(b in c.mappings)if(d=c.mappings[b],d.test.test(a))return a.replace(b,d.path);return a};f.prototype.mapJoin=function(a){a=Q(a);return f(a).joinFrom(this.path)};c.makeOptions=p(c.makeOptions,function(a){a.src=c.root.join(a.rootSrc=Q(a.rootSrc))});c.mappings={};c.map=function(a,
b){if(typeof a=="string")c.mappings[a]={test:RegExp("^("+a+")([/.]|$)"),path:b};else for(var d in a)c.map(d,a[d]);return this};var A;k(c,{after:function(){if(!A){var a=A=new c.p.init,b=function(){c.trigger("start",a);s(a,"complete",function(){c.trigger("end",a)});a.loaded()};h.setTimeout?setTimeout(b,0):b()}},_before:o,_after:p});c.p.complete=o(c.p.complete,function(){this===A&&(A=null)});(function(){var a=false,b,d=false;c.p.loaded=o(c.p.loaded,function(){var c=typeof jQuery!=="undefined"?jQuery:
null;c&&"readyWait"in c&&!a&&(b=c,c.readyWait+=1,a=true)});c.bind("end",function(){a&&!d&&(b.ready(true),d=true)})})();c.p.load=p(c.p.load,function(){if(h.document&&!this.completed&&!this.completeTimeout&&(this.options.protocol=="file:"||!J)){var a=this;this.completeTimeout=setTimeout(function(){throw"steal.js : "+a.options.src+" not completed";},5E3)}});c.p.complete=p(c.p.complete,function(){this.completeTimeout&&clearTimeout(this.completeTimeout)});k(H.prototype,{called:function(){this.calls--;
this.go()},add:function(a,b){var c=E(a,b);c.called||(c.callbacks.push(this),this.calls++)},go:function(){if(this.calls===0)this.obj[this.meth]()}});c.isRhino&&typeof console=="undefined"&&(console={log:function(){print.apply(null,arguments)}});var B={load:function(){},end:function(){}},C=false;(function(a,b,c){a.addEventListener?a.addEventListener(b,c,false):a.attachEvent?a.attachEvent("on"+b,c):c()})(h,"load",function(){B.load()});c.one("end",function(a){B.end();C=a;c.trigger("done",C)});s(B,"load",
B,"end",function(){c.trigger("ready");c.isReady=true});c.events.done={add:function(a){return C?(a(C),false):a}};c.p.make=p(c.p.make,function(a){a.options.has&&(a.isLoaded?a.loadHas():c.loading.apply(c,a.options.has));return a},true);c.p.loaded=o(c.p.loaded,function(){this.options.has&&this.loadHas()});c.p.loadHas=function(){var a,b,d=f.cur();for(b=0;b<this.options.has.length;b++)f.cur(d),a=c.p.make(this.options.has[b]),E(a,"complete"),a.loaded()};var D,m={},R=function(){var a,b,c=g.getElementsByTagName("script");
for(a=c.length-1;a>-1&&(b=c[a]);a--)if(b.readyState==="interactive")return b},S=function(){var a;return D&&D.readyState==="interactive"?D:(a=R())?a:z&&z.readyState=="interactive"?z:null};if(K=g&&!!R())c.after=p(c.after,function(){var a=S();if(a&&a.src&&!/steal\.(production\.)*js/.test(a.src)){var b=a.src;m[b]||(m[b]=[]);b&&(m[b].push.apply(m[b],q),q=[],D=a)}}),c.loaded=o(c.loaded,function(a){var a=r[a].options.src,b=S().src;m[a]=m[b];m[b]=null});var T=/steal\.(production\.)?js.*/;c.getScriptOptions=
function(a){var b;if(!(b=a))a:{if(g){b=g.getElementsByTagName("script");for(var a=0,d=b.length;a<d;a++){var f=b[a].src;if(f&&T.test(f)){b=b[a];break a}}}b=void 0}a=b;b={};if(a){a=a.src;d=a.replace(T,"");b.rootUrl=/steal\/$/.test(d)?d.substr(0,d.length-6):d+"../";if(/steal\.production\.js/.test(a))b.env="production";if(a.indexOf("?")!==-1){a=a.split("?")[1];a=a.split(",");if(a[0])b.startFile=a[0];if(a[1]&&c.options.env!="production")b.env=a[1]}}return b};u=p(u,function(){var a=c.options;k(a,c.getScriptOptions());
typeof y=="object"&&k(a,y);var b=h.location&&decodeURIComponent(h.location.search);b&&b.replace(/steal\[([^\]]+)\]=([^&]+)/g,function(b,c,e){b=e.split(",");b.length>1&&(e=b);a[c]=e});c.rootUrl(a.rootUrl);if(a.startFile.indexOf(".")=="-1")a.startFile=a.startFile+"/"+a.startFile.match(/[^\/]+$/)[0]+".js";if(!a.logLevel)a.logLevel=0;if(!a.production&&a.startFile)a.production=f(a.startFile).dir()+"/production.js";a.production&&(a.production+=a.production.indexOf(".js")==-1?".js":"");l(a.loaded||[],function(a,
b){c.loaded(b)});if(a.env=="production"&&a.loadProduction)a.production&&c({src:a.production,force:true});else{b=[];a.loadDev!==false&&b.push({src:"steal/dev/dev.js",ignore:true});if(a.startFiles){if(typeof a.startFiles==="string")a.startFiles=[a.startFiles];b.push.apply(b,a.startFiles)}a.startFile&&b.push(a.startFile);b.length&&c.apply(null,b)}});c.when=s;h.steal=c;u()})();