forked from stealjs/steal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
steal.production.js
29 lines (29 loc) · 14.2 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
28
29
(function(g,$){function d(){var a=n(arguments);a.length&&(r.push.apply(r,a),d.after(a));return d}function N(a,b,c,e){o[b.shift()].require(a,function(){b.length?N(a,b,c,e):c.apply(this,arguments)},e)}function t(a,b,c){return c?function(){return a.apply(this,b.apply(this,arguments))}:function(){b.apply(this,arguments);return a.apply(this,arguments)}}function p(a,b,c){return c?function(){return b.apply(this,[a.apply(this,arguments)].concat(n(arguments)))}:function(){var c=a.apply(this,arguments);b.apply(this,
arguments);return c}}var i=g.document,O=i&&i.documentElement,l=function(a,b){var c,e;if("number"==typeof a.length){c=0;for(e=a.length;c<e;c++)b.call(a[c],c,a[c],a)}else for(c in a)b.call(a[c],c,a[c],a);return a},u=function(a){return"string"==typeof a},v=function(a){return"function"==typeof a},F=function(){},G=function(){var a=i.createElement("script");a.type="text/javascript";return a},w=function(){var a=i.getElementsByTagName("head")[0];a||(a=i.createElement("head"),O.insertBefore(a,O.firstChild));
w=function(){return a};return a},h=function(a,b){b&&l(b,function(c){a[c]=b[c]});return a},n=function(a,b){var c=[];l(a,function(a,d){c.push(b?u(b)?d[b]:b.call(d,d):d)});return c},m;if(m=i)m=G(),m.onerror=F,m=v(m.onerror)||"onerror"in m;var P=m,x=!1;i&&G();m=F;var y="object"==typeof g.steal?g.steal:{},B=function(a){y.suffix&&(a=-1<(a+"").indexOf("?")?a+"&"+y.suffix:a+"?"+y.suffix);return a},j=function(a){if(!(this instanceof j))return new j;this.doneFuncs=[];this.failFuncs=[];this.resultArgs=null;
this.status="";a&&a.call(this,this)};j.when=function(){var a=n(arguments);if(2>a.length){var b=a[0];return b&&v(b.isResolved)&&v(b.isRejected)?b:j().resolve(b)}var c=j(),e=0,d=[];l(a,function(b,f){f.done(function(){d[b]=2>arguments.length?arguments[0]:arguments;++e==a.length&&c.resolve.apply(c,d)}).fail(function(){c.reject(arguments)})});return c};var s=function(a,b){return function(c){var e=this.resultArgs=1<arguments.length?arguments[1]:[];return this.exec(c,this[a],e,b)}},Q=function(a,b){return function(){var c=
this;l(arguments,function(e,d,f){d&&(d.constructor===Array?f.callee.apply(c,d):(c.status===b&&d.apply(this,this.resultArgs||[]),c[a].push(d)))});return this}};h(j.prototype,{resolveWith:s("doneFuncs","rs"),rejectWith:s("failFuncs","rj"),done:Q("doneFuncs","rs"),fail:Q("failFuncs","rj"),always:function(){var a=n(arguments);a.length&&a[0]&&this.done(a[0]).fail(a[0]);return this},then:function(){var a=n(arguments);1<a.length&&a[1]&&this.fail(a[1]);a.length&&a[0]&&this.done(a[0]);return this},isResolved:function(){return"rs"===
this.status},isRejected:function(){return"rj"===this.status},reject:function(){return this.rejectWith(this,arguments)},resolve:function(){return this.resolveWith(this,arguments)},exec:function(a,b,c,e){if(""!==this.status)return this;this.status=e;l(b,function(b,e){e.apply(a,c)});return this}});var R=function(a,b,c,e){a=n(a,b);return j.when.apply(j,a).then(function(){if(v(c[e]))c[e]();else c[e].resolve()})},f=function(a){if(this.constructor!==f)return new f(a);h(this,f.parse(""+a))},H;h(f,{root:function(a){if(a!==
$){H=f(a);var b=f.page,a=b.join(a);f.cur=a.pathTo(b);d.root=H;return d}return H||f("")},parse:function(a){var b=a.split("?"),a=b.shift(),b=b.join("").split("#"),a=a.split("://"),b={query:b.shift(),fragment:b.join("#")};a[1]?(b.protocol=a.shift(),a=a[0].split("/"),b.host=a.shift(),b.path="/"+a.join("/")):b.path=a[0];return b}});f.page=f(g.location&&location.href);f.cur=f();h(f.prototype,{dir:function(){var a=this.path.split("/");a.pop();return f(this.domain()+a.join("/"))},filename:function(){return this.path.split("/").pop()},
ext:function(){var a=this.filename();return~a.indexOf(".")?a.split(".").pop():""},domain:function(){return this.protocol?this.protocol+"://"+this.host:""},isCrossDomain:function(a){var a=f(a||g.location.href),b=this.domain(),a=a.domain();return b&&a&&b!=a||"file"===this.protocol||b&&!a},isRelativeToDomain:function(){return!this.path.indexOf("/")},hash:function(){return this.fragment?"#"+this.fragment:""},search:function(){return this.query?"?"+this.query:""},add:function(a){return this.join(a)+""},
join:function(a){a=f(a);if(a.isCrossDomain(this))return a;if(a.isRelativeToDomain())return f(this.domain()+a);var b=this.path?this.path.split("/"):[],c=a.path.split("/"),e=c[0];for(this.path.match(/\/$/)&&b.pop();".."==e&&b.length&&b.pop();)c.shift(),e=c[0];return h(f(this.domain()+b.concat(c).join("/")),{query:a.query})},normalize:function(){var a=f.cur.dir(),b=this.path;b.indexOf("//")?b.indexOf("./")?this.isRelative()&&(b=a.join(this.domain()+b)):b=a.join(b.substr(2)):b=f(b.substr(2));b.query=
this.query;return b},isRelative:function(){return/^[\.|\/]/.test(this.path)},pathTo:function(a){for(var a=f(a),a=a.path.split("/"),b=this.path.split("/"),c=[];a.length&&b.length&&a[0]==b[0];)a.shift(),b.shift();l(b,function(){c.push("../")});return f(c.join("")+a.join("/"))},mapJoin:function(a){return this.join(f(a).insertMapping())},addJS:function(){this.ext()||(this.isRelative()||(this.path+="/"+this.filename()),this.path+=".js");return this}});f.prototype.toString=function(){return this.domain()+
this.path+this.search()+this.hash()};d.File=d.URI=f;var r=[],aa=0;h(d,{each:l,extend:h,Deferred:j,isRhino:g.load&&g.readUrl&&g.readFile,options:{env:"development",loadProduction:!0,needs:{less:"steal/less/less.js",coffee:"steal/coffee/coffee.js"},logLevel:0},add:function(a){steals[a.rootSrc]=a},makeOptions:function(a){var b=a.src=f(a.src);a.type||(b=a.src=b.addJS());var c=f(b).normalize();h(a,{originalSrc:b,rootSrc:c,src:f.root().join(c)});a.originalSrc=a.src;return a},then:function(){var a=n(arguments);
"string"===typeof a[0]&&(a[0]={src:a[0]});"object"===typeof a[0]&&(a[0].waits=!0);return d.apply(g,a)},bind:function(a,b){z[a]||(z[a]=[]);var c=d.events[a];c&&c.add&&(b=c.add(b));b&&z[a].push(b);return d},one:function(a,b){return d.bind(a,function(){b.apply(this,arguments);d.unbind(a,arguments.callee)})},events:{},unbind:function(a,b){for(var c=z[a]||[],e=0;e<c.length;)b===c[e]?c.splice(e,1):e++},trigger:function(a,b){l(n(z[a]||[]),function(a,e){e(b)})},has:function(){x=!1;l(arguments,function(a,
b){var c=k.make(b);c.loading=c.executing=!0})},preexecuted:function(){},executed:function(a){a=k.make(a);a.loading=a.executing=!0;d.preexecuted(a);a.executed();return d},type:function(a,b){var c=a.split(" ");if(!b)return o[c.shift()].require;o[c.shift()]={require:b,convert:c}},types:{}});var A={},k=function(a){this.dependencies=[];this.id=++aa;if(a)if(v(a)){var b=f.cur;this.options={fn:function(){f.cur=b;return a(d.send||g.jQuery||d)},rootSrc:b,orig:a,type:"fn"};this.waits=!0;this.unique=!1}else this.orig=
a,this.options=d.makeOptions(h({},u(a)?{src:a}:a)),this.waits=this.options.waits||!1,this.unique=!0;else this.options={},this.waits=!1;this.loaded=j();this.run=j();this.completed=j()};k.make=function(a){var b=new k(a),c=b.options.rootSrc;b.unique&&c&&(!A[c]&&!A[c+".js"]?A[c]=b:(b=A[c],u(a)||(l(["src","rootSrc","originalSrc"],function(b,c){delete a[c]}),h(b.options,a))));return b};h(k.prototype,{complete:function(){this.completed.resolve()},executed:function(a){var b,a=a&&a.src||this.options.src,c=
this.options.rootSrc;this.options.rootSrc&&(f.cur=f(c));this.run.resolve();x&&a&&(b=q[a]);b||(b=r.slice(0),r=[]);if(b.length){var e=this,g="production"==d.options.env,i=[];l(b.reverse(),function(a,b){if(!g||!b.ignore){var c=k.make(b);if(I[c.options.rootSrc]&&c.options.type!=="fn"){d.has(c.options.rootSrc);c=k.make(I[c.options.rootSrc])}i.push(c);l(c.options.needs||[],function(a,b){i.push(k.make(function(){}),k.make(b))})}});var h=[],j=[],m=[],n=!0;l(i.reverse(),function(a,b){e.dependencies.unshift(b);
if(b.waits&&j.length){h=h.concat(j);j=[];n=false}R(h,"completed",b,"execute");b.waitedOn=b.waitedOn?b.waitedOn.concat(h):h.slice(0);j.push(b);n&&m.push(b);b.load()});h=h.concat(j);R(h,"completed",e,"completed");l(m,function(a,b){b.execute()})}else this.complete()},load:function(){!this.loading&&!this.loaded.isResolved()&&(this.loading=!0,this.loaded.resolve())},execute:function(){var a=this;a.loaded.isResolved()||a.loaded.resolve();a.executing||(a.executing=!0,d.require(a.options,function(b){a.executed(b)},
function(){var b=a.options.abort,c=a.options.error;c&&c.call(a.options);g.clearTimeout&&g.clearTimeout(a.completeTimeout);if(!1===b)a.executed();else throw"steal.js : "+a.options.src+" not completed";}))}});var z={},o=d.types;k.prototype.execute=t(k.prototype.execute,function(){var a=this.options;if(!a.type){var b=f(a.src).ext();!b&&!o[b]&&(b="js");a.type=b}if(!o[a.type]&&"development"==d.options.env)throw"steal.js - type "+a.type+" has not been loaded.";if(o[a.type]||"production"!=d.options.env)b=
o[a.type].convert,a.buildType=b.length?b[b.length-1]:a.type});d.require=function(a,b,c){var e=o[a.type];e.convert.length?(e=e.convert.slice(0),e.unshift("text",a.type)):e=[a.type];N(a,e,b,c)};var C,ba=/^loade|c|u/,J=0,ca=i&&i.createStyleSheet,S,T;l(h({js:function(a,b,c){var e=G(),d=function(){if(!e.readyState||ba.test(e.readyState))e.onreadystatechange=e.onload=e.onerror=null,setTimeout(function(){w().removeChild(e)},1),b(e)};a.text?e.text=a.text:(e.onload=e.onreadystatechange=d,P&&(c&&"file"!==a.src.protocol)&&
(e.onerror=c),e.src=a.src=B(a.src),e.onSuccess=b);C=e;w().insertBefore(e,w().firstChild);a.text&&d()},fn:function(a,b){var c;a.skipCallbacks||(c=a.fn());b(c)},text:function(a,b,c){d.request(a,function(c){a.text=c;b(c)},c)},css:function(a,b){if(a.text){var c=i.createElement("style");c.type="text/css";if(c.styleSheet)c.styleSheet.cssText=a.text;else{var e=i.createTextNode(a.text);c.childNodes.length?c.firstChild.nodeValue!==e.nodeValue&&c.replaceChild(e,c.firstChild):c.appendChild(e)}}else{if(ca){J++?
(c=""+f(f(T.src).dir()).pathTo(a.src),S.addImport(B(c)),30==J&&(J=0)):(S=i.createStyleSheet(B(a.src)),T=a);b();return}a=a||{};c=i.createElement("link");c.rel=a.rel||"stylesheet";c.href=B(a.src);c.type="text/css"}w().appendChild(c);b()}},y.types||{}),d.type);var da=function(){return g.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest};d.request=function(a,b,c){var e=new da,d=a.contentType||"application/x-www-form-urlencoded; charset=utf-8",f=function(){e=g=f=null},g=function(){var a;
e&&4===e.readyState&&(a=e.status,500===a||404===a||2===a||0>e.status||!a&&""===e.responseText?c&&c(e.status):b(e.responseText),f())};e.open("GET",a.src+"",!1!==a.async);e.setRequestHeader("Content-type",d);e.overrideMimeType&&e.overrideMimeType(d);e.onreadystatechange=g;try{e.send(null)}catch(h){f&&(console.error(h),c&&c(),f())}};var K=[],I={};d.packages=function(a){return arguments.length?("string"==typeof a?K.push.apply(K,arguments):I=a,this):K};d.makeOptions=p(d.makeOptions,function(a){a.ext=a.src.ext();
d.options.needs[a.ext]&&(a.needs||(a.needs=[]),a.needs.push(d.options.needs[a.ext]))});f.prototype.insertMapping=function(){var a=""+this,b,c;for(b in d.mappings)if(c=d.mappings[b],c.test.test(a))return a.replace(b,c.path);return f(a)};var L=!1;h(d,{makeOptions:p(d.makeOptions,function(a){a.src=f.root().join(a.rootSrc=f(a.rootSrc).insertMapping())}),mappings:{},map:function(a,b){u(a)?d.mappings[a]={test:RegExp("^(/?"+a+")([/.]|$)"),path:b}:l(a,d.map);return this},after:function(){if(!L){var a=L=new k,
b=function(){d.trigger("start",a);a.completed.then(function(){L=null;d.trigger("end",a)});a.executed()};g.setTimeout?setTimeout(b,0):b()}},_before:t,_after:p});var M=!1,U,V=!1;k.prototype.executed=t(k.prototype.executed,function(){var a=g.jQuery;a&&"readyWait"in a&&!M&&(U=a,a.readyWait+=1,M=!0)});d.bind("end",function(){M&&!V&&(U.ready(!0),V=!0)});h(k.prototype,{load:p(k.prototype.load,function(){var a=this;if(i&&!a.completed&&!a.completeTimeout&&!d.isRhino&&("file"==a.options.src.protocol||!P))a.completeTimeout=
setTimeout(function(){throw"steal.js : "+a.options.src+" not completed";},5E3)}),complete:p(k.prototype.complete,function(){this.completeTimeout&&clearTimeout(this.completeTimeout)}),executed:t(k.prototype.executed,function(){this.options.has&&this.loadHas()}),loadHas:function(){var a=f.cur;"js"!=this.options.buildType&&l(this.options.has,function(b,c){f.cur=f(a);d.executed(c)})}});k.make=p(k.make,function(a){a.options.has&&(a.run.isResolved()?a.loadHas():d.has.apply(d,a.options.has));return a},!0);
var W=j(),X=j(),D=!1,s=function(){W.resolve()};g.addEventListener?g.addEventListener("load",s,!1):g.attachEvent?g.attachEvent("onload",s):s();d.one("end",function(a){X.resolve();D=a;d.trigger("done",D)});j.when(W,X).then(function(){d.trigger("ready");d.isReady=!0});d.events.done={add:function(a){return D?(a(D),!1):a}};var E,q={},Y=function(){for(var a=i.getElementsByTagName("script"),b=a.length;b--;)if("interactive"===a[b].readyState)return a[b]},Z=function(){return E&&"interactive"===E.readyState||
(E=Y())?E:C&&"interactive"==C.readyState?C:null};if(x=i&&!!Y())d.after=p(d.after,function(){if(x){var a=Z();a&&(a.src&&!/steal\.(production|production\.[a-zA-Z0-9\-\.\_]*)*js/.test(a.src))&&(a=a.src,q[a]||(q[a]=[]),a&&(q[a].push.apply(q[a],r),r=[]))}}),d.preexecuted=t(d.preexecuted,function(a){if(x){var a=a.options.src,b=Z().src;q[a]=q[b];q[b]=null}});var ea=/steal\.(production\.)?js.*/;d.getScriptOptions=function(a){var b={},c,e;if(!a)if(i){var a=i.getElementsByTagName("script"),d;l(a,function(a,
b){ea.test(b.src)&&(d=b)});a=d}else a=void 0;if(a){c=a.src.split("?");a=c.shift();c=c.join("?");c=c.split(",");-1<a.indexOf("steal.production")&&(b.env="production");if(e=c[0])-1==e.indexOf(".js")&&(e+="/"+e.split("/").pop()+".js"),b.startFile=e;if(c=c[1])b.env=c;c=a.split("/");c.pop();"steal"==c[c.length-1]&&c.pop();b.rootUrl=c.join("/")}return b};m=p(m,function(){var a=d.options;h(a,d.getScriptOptions());h(a,y);var b=g.location&&decodeURIComponent(g.location.search);b&&b.replace(/steal\[([^\]]+)\]=([^&]+)/g,
function(b,c,d){a[c]=~d.indexOf(",")?d.split(","):d});f.root(a.rootUrl);a.startFile&&(a.startFile=""+f(a.startFile).addJS(),a.production||(a.production=f(a.startFile).dir()+"/production.js"));l(a.executed||[],function(a,b){d.executed(b)});b=[];a.startFiles&&(b.push.apply(b,u(a.startFiles)?[a.startFiles]:a.startFiles),a.startFiles=b.slice(0));try{(a.instrument||!a.browser&&g.top&&g.top.opener&&g.top.opener.steal&&g.top.opener.steal.instrument)&&b.push(F,{src:"steal/instrument",waits:!0})}catch(c){}"production"==
a.env&&a.loadProduction&&a.production?d({src:a.production,force:!0}):(!1!==a.loadDev&&b.unshift({src:"steal/dev/dev.js",ignore:!0}),a.startFile&&b.push(a.startFile));b.length&&d.apply(g,b)});g.steal=d;m();g.resources=A;g.Resource=k})(this);