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