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