Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Initial Commit

  • Loading branch information...
commit 1ab9cbb67b432761bd636283fe5beae43cdb6520 0 parents
Dav Glass authored
30 LICENSE
... ... @@ -0,0 +1,30 @@
  1 +Software License Agreement (BSD License)
  2 +
  3 +Copyright (c) 2012, Dav Glass <davglass@gmail.com>.
  4 +All rights reserved.
  5 +
  6 +Redistribution and use of this software in source and binary forms, with or without modification, are
  7 +permitted provided that the following conditions are met:
  8 +
  9 +* Redistributions of source code must retain the above
  10 + copyright notice, this list of conditions and the
  11 + following disclaimer.
  12 +
  13 +* Redistributions in binary form must reproduce the above
  14 + copyright notice, this list of conditions and the
  15 + following disclaimer in the documentation and/or other
  16 + materials provided with the distribution.
  17 +
  18 +* The name of Dav Glass may not be used to endorse or promote products
  19 + derived from this software without specific prior
  20 + written permission of Dav Glass.
  21 +
  22 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
  23 +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  24 +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  25 +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27 +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  28 +TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  29 +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30 +
2  Makefile
... ... @@ -0,0 +1,2 @@
  1 +all:
  2 + ./scripts/concat.sh
93 README.md
Source Rendered
... ... @@ -0,0 +1,93 @@
  1 +Prototype YUI Loader Stand Alone
  2 +================================
  3 +
  4 +This repo contains a little build script to create a stand alone version
  5 +of the latest YUI 3.5.0pr2 Loader.
  6 +
  7 +It includes:
  8 +
  9 + yui-core
  10 + get
  11 + loader-base
  12 +
  13 +Currently it's 225k raw, 43k minimized and 16K minned and gzipped.
  14 +
  15 +This can easily be worked on once I modularize the YUI core more so it doesn't
  16 +contain things that are not needed all the time.
  17 +
  18 +Example here:
  19 +http://dl.dropbox.com/u/5669457/loader-alone/test/index.html
  20 +
  21 +**Notice that YUI is not loaded on the page, it's there but wrapped up in an anonymous function.**
  22 +
  23 +Usage
  24 +-----
  25 +
  26 +Everything you need to use Loader is already on this repo, the `build` directory contains
  27 +a loader.js and loader-min.js
  28 +
  29 +```javascript
  30 +var loader = new YUILoader({
  31 + root: '',
  32 + base: '',
  33 + groups: {
  34 + local: {
  35 + modules: {
  36 + foo: {
  37 + type: 'js',
  38 + path: 'foo/foo.js',
  39 + requires: [ 'bar', 'baz' ]
  40 + },
  41 + baz: 'path/to/baz.js',
  42 + bar: 'bar.js',
  43 + somecss: 'my/css/files.css'
  44 + }
  45 + }
  46 + },
  47 + require: [ 'foo', 'somecss' ]
  48 +});
  49 +
  50 +loader.load(function(e) {
  51 + log('All items have been loaded..', e);
  52 +});
  53 +```
  54 +
  55 +
  56 +Concept
  57 +-------
  58 +
  59 +The concept here is pretty simple, it concats `yui-core`, `get` &amp; `loader-base` into a single file.
  60 +Then it wraps that code with something like this:
  61 +
  62 +```javascript
  63 +(function() {
  64 + var YUI;
  65 + var exports = {};
  66 +
  67 + //Concatted Source here
  68 +
  69 + YUI.Env.core.push('loader-base');
  70 +
  71 + var Y = YUI();
  72 +
  73 + window.YUILoader = Y.Loader;
  74 +
  75 + Y.Loader.prototype.load = function(cb) {
  76 + var self = this,
  77 + out = self.resolve(true);
  78 +
  79 + self.data = out;
  80 +
  81 + self.onEnd = function() {
  82 + cb.apply(self.context || window, arguments);
  83 + }
  84 +
  85 + self.insert();
  86 + }
  87 +
  88 +}());
  89 +```
  90 +
  91 +This wrapping code is boilerplate for forcing YUI to attach itself to the `exports` object.
  92 +Then augment the core to autoload the `loader-base` module, then expose a global `YUILoader` var.
  93 +Then it adds a `load` method into Loader's prototype and does all the `Loader` magic.
1  build/loader-min.js
... ... @@ -0,0 +1 @@
  1 +(function(){var b;var a={};if(typeof b!="undefined"){b._YUI=b}var b=function(){var f=0,j=this,e=arguments,d=e.length,h=function(k,i){return(k&&k.hasOwnProperty&&(k instanceof i))},g=(typeof YUI_config!=="undefined")&&YUI_config;if(!(h(j,b))){j=new b()}else{j._init();if(b.GlobalConfig){j.applyConfig(b.GlobalConfig)}if(g){j.applyConfig(g)}if(!d){j._setup()}}if(d){for(;f<d;f++){j.applyConfig(e[f])}j._setup()}j.instanceOf=h;return j};(function(){var t,e,u="@VERSION@",l=".",r="http://yui.yahooapis.com/",x="yui3-js-enabled",g="yui3-css-stamp",p=function(){},k=Array.prototype.slice,v={"io.xdrReady":1,"io.xdrResponse":1,"SWF.eventHandler":1},j=(typeof window!="undefined"),i=(j)?window:null,z=(j)?i.document:null,h=z&&z.documentElement,d=h&&h.className,f={},m=new Date().getTime(),q=function(D,C,B,A){if(D&&D.addEventListener){D.addEventListener(C,B,A)}else{if(D&&D.attachEvent){D.attachEvent("on"+C,B)}}},y=function(E,D,C,A){if(E&&E.removeEventListener){try{E.removeEventListener(D,C,A)}catch(B){}}else{if(E&&E.detachEvent){E.detachEvent("on"+D,C)}}},w=function(){b.Env.windowLoaded=true;b.Env.DOMReady=true;if(j){y(window,"load",w)}},n=function(C,B){var A=C.Env._loader;if(A){A.ignoreRegistered=false;A.onEnd=null;A.data=null;A.required=[];A.loadType=null}else{A=new C.Loader(C.config);C.Env._loader=A}b.Env.core=C.Array.dedupe([].concat(b.Env.core,["loader-base","loader-rollup","loader-yui3"]));return A},s=function(C,B){for(var A in B){if(B.hasOwnProperty(A)){C[A]=B[A]}}},o={success:true};if(h&&d.indexOf(x)==-1){if(d){d+=" "}d+=x;h.className=d}if(u.indexOf("@")>-1){u="3.3.0"}t={applyConfig:function(G){G=G||p;var C,E,D=this.config,F=D.modules,B=D.groups,A=this.Env._loader;for(E in G){if(G.hasOwnProperty(E)){C=G[E];if(F&&E=="modules"){s(F,C)}else{if(B&&E=="groups"){s(B,C)}else{if(E=="win"){D[E]=(C&&C.contentWindow)||C;D.doc=D[E]?D[E].document:null}else{if(E=="_yuid"){}else{D[E]=C}}}}}}if(A){A._config(G)}},_config:function(A){this.applyConfig(A)},_init:function(){var D,C,E=this,A=b.Env,B=E.Env,F;E.version=u;if(!B){E.Env={core:["get","intl-base"],mods:{},versions:{},base:r,cdn:r+u+"/build/",_idx:0,_used:{},_attached:{},_missed:[],_yidx:0,_uidx:0,_guidp:"y",_loaded:{},_BASE_RE:/(?:\?(?:[^&]*&)*([^&]*))?\b(simpleyui|yui(?:-\w+)?)\/\2(?:-(min|debug))?\.js/,parseBasePath:function(K,I){var G=K.match(I),J,H;if(G){J=RegExp.leftContext||K.slice(0,K.indexOf(G[0]));H=G[3];if(G[1]){J+="?"+G[1]}J={filter:H,path:J}}return J},getBase:A&&A.getBase||function(K){var I=(z&&z.getElementsByTagName("script"))||[],L=B.cdn,H,J,G,M;for(J=0,G=I.length;J<G;++J){M=I[J].src;if(M){H=E.Env.parseBasePath(M,K);if(H){D=H.filter;L=H.path;break}}}return L}};B=E.Env;B._loaded[u]={};if(A&&E!==b){B._yidx=++A._yidx;B._guidp=("yui_"+u+"_"+B._yidx+"_"+m).replace(/\./g,"_")}else{if(b._YUI){A=b._YUI.Env;B._yidx+=A._yidx;B._uidx+=A._uidx;for(F in A){if(!(F in B)){B[F]=A[F]}}delete b._YUI}}E.id=E.stamp(E);f[E.id]=E}E.constructor=b;E.config=E.config||{win:i,doc:z,debug:true,useBrowserConsole:true,throwFail:true,bootstrap:true,cacheUse:true,fetchCSS:true};if(z&&!z.getElementById(g)){C=z.createElement("div");C.innerHTML='<div id="'+g+'" style="position: absolute !important; visibility: hidden !important"></div>';b.Env.cssStampEl=C.firstChild;h.insertBefore(b.Env.cssStampEl,h.firstChild)}E.config.lang=E.config.lang||"en-US";E.config.base=b.config.base||E.Env.getBase(E.Env._BASE_RE);if(!D||(!("mindebug").indexOf(D))){D="min"}D=(D)?"-"+D:D;E.config.loaderPath=b.config.loaderPath||"loader/loader"+D+".js"},_setup:function(F){var B,E=this,A=[],D=b.Env.mods,C=E.config.core||[].concat(b.Env.core);for(B=0;B<C.length;B++){if(D[C[B]]){A.push(C[B])}}E._attach(["yui-base"]);E._attach(A);if(E.Loader){n(E)}},applyTo:function(G,F,C){if(!(F in v)){this.log(F+": applyTo not allowed","warn","yui");return null}var B=f[G],E,A,D;if(B){E=F.split(".");A=B;for(D=0;D<E.length;D=D+1){A=A[E[D]];if(!A){this.log("applyTo not found: "+F,"warn","yui")}}return A&&A.apply(B,C)}return null},add:function(B,G,F,A){A=A||{};var E=b.Env,H={name:B,fn:G,version:F,details:A},I,D,C=E.versions;E.mods[B]=H;C[F]=C[F]||{};C[F][B]=H;for(D in f){if(f.hasOwnProperty(D)){I=f[D].Env._loader;if(I){if(!I.moduleInfo[B]){I.addModule(A,B)}}}}return this},_attach:function(F,Q){var J,R,P,M,A,H,C,D=b.Env.mods,K=b.Env.aliases,B=this,I,E=B.Env._loader,G=B.Env._attached,L=F.length,E,O=[];for(J=0;J<L;J++){R=F[J];P=D[R];O.push(R);if(E&&E.conditions[R]){B.Object.each(E.conditions[R],function(T){var S=T&&((T.ua&&B.UA[T.ua])||(T.test&&T.test(B)));if(S){O.push(T.name)}})}}F=O;L=F.length;for(J=0;J<L;J++){if(!G[F[J]]){R=F[J];P=D[R];if(K&&K[R]){B._attach(K[R]);continue}if(!P){if(E&&E.moduleInfo[R]){P=E.moduleInfo[R];Q=true}if(!Q&&R){if((R.indexOf("skin-")===-1)&&(R.indexOf("css")===-1)){B.Env._missed.push(R);B.Env._missed=B.Array.dedupe(B.Env._missed);B.message("NOT loaded: "+R,"warn","yui")}}}else{G[R]=true;for(I=0;I<B.Env._missed.length;I++){if(B.Env._missed[I]===R){B.message("Found: "+R+" (was reported as missing earlier)","warn","yui");B.Env._missed.splice(I,1)}}M=P.details;A=M.requires;H=M.use;C=M.after;if(A){for(I=0;I<A.length;I++){if(!G[A[I]]){if(!B._attach(A)){return false}break}}}if(C){for(I=0;I<C.length;I++){if(!G[C[I]]){if(!B._attach(C,true)){return false}break}}}if(P.fn){try{P.fn(B,R)}catch(N){B.error("Attach error: "+R,N,R);return false}}if(H){for(I=0;I<H.length;I++){if(!G[H[I]]){if(!B._attach(H)){return false}break}}}}}}return true},use:function(){var D=k.call(arguments,0),H=D[D.length-1],G=this,F=0,B=[],C,A=G.Env,E=true;if(G.Lang.isFunction(H)){D.pop()}else{H=null}if(G.Lang.isArray(D[0])){D=D[0]}if(G.config.cacheUse){while((C=D[F++])){if(!A._attached[C]){E=false;break}}if(E){if(D.length){}G._notify(H,o,D);return G}}if(G._loading){G._useQueue=G._useQueue||new G.Queue();G._useQueue.add([D,H])}else{G._use(D,function(J,I){J._notify(H,I,D)})}return G},_notify:function(D,A,B){if(!A.success&&this.config.loadErrorFn){this.config.loadErrorFn.call(this,this,D,A,B)}else{if(D){try{D(this,A)}catch(C){this.error("use callback error",C,B)}}}},_use:function(C,E){if(!this.Array){this._attach(["yui-base"])}var R,J,S,O,B=this,T=b.Env,D=T.mods,A=B.Env,G=A._used,Q=T.aliases,N=T._loaderQueue,W=C[0],I=B.Array,U=B.config,H=U.bootstrap,P=[],L=[],V=true,F=U.fetchCSS,M=function(aa,Z){var Y=0,X=[];if(!aa.length){return}if(Q){for(Y=0;Y<aa.length;Y++){if(Q[aa[Y]]){X=[].concat(X,Q[aa[Y]])}else{X.push(aa[Y])}}aa=X}I.each(aa,function(ad){if(!Z){L.push(ad)}if(G[ad]){return}var ab=D[ad],ae,ac;if(ab){G[ad]=true;ae=ab.details.requires;ac=ab.details.use}else{if(!T._loaded[u][ad]){P.push(ad)}else{G[ad]=true}}if(ae&&ae.length){M(ae)}if(ac&&ac.length){M(ac,1)}})},K=function(ab){var Z=ab||{success:true,msg:"not dynamic"},Y,X,aa=true,ac=Z.data;B._loading=false;if(ac){X=P;P=[];L=[];M(ac);Y=P.length;if(Y){if(P.sort().join()==X.sort().join()){Y=false}}}if(Y&&ac){B._loading=false;B._use(C,function(){if(B._attach(ac)){B._notify(E,Z,ac)}})}else{if(ac){aa=B._attach(ac)}if(aa){B._notify(E,Z,C)}}if(B._useQueue&&B._useQueue.size()&&!B._loading){B._use.apply(B,B._useQueue.next())}};if(W==="*"){V=B._attach(B.Object.keys(D));if(V){K()}return B}if(D.loader&&!B.Loader){B._attach(["loader"])}if(H&&B.Loader&&C.length){J=n(B);J.require(C);J.ignoreRegistered=true;J._boot=true;J.calculate(null,(F)?null:"js");C=J.sorted;J._boot=false}M(C);R=P.length;if(R){P=B.Object.keys(I.hash(P));R=P.length}if(H&&R&&B.Loader){B._loading=true;J=n(B);J.onEnd=K;J.context=B;J.data=C;J.ignoreRegistered=false;J.require(C);J.insert(null,(F)?null:"js")}else{if(H&&R&&B.Get&&!A.bootstrapped){B._loading=true;S=function(){B._loading=false;N.running=false;A.bootstrapped=true;T._bootstrapping=false;if(B._attach(["loader"])){B._use(C,E)}};if(T._bootstrapping){N.add(S)}else{T._bootstrapping=true;B.Get.script(U.base+U.loaderPath,{onEnd:S})}}else{V=B._attach(C);if(V){K()}}}return B},namespace:function(){var B=arguments,F,D=0,C,E,A;for(;D<B.length;D++){F=this;A=B[D];if(A.indexOf(l)>-1){E=A.split(l);for(C=(E[0]=="YAHOO")?1:0;C<E.length;C++){F[E[C]]=F[E[C]]||{};F=F[E[C]]}}else{F[A]=F[A]||{};F=F[A]}}return F},log:p,message:p,dump:function(A){return""+A},error:function(E,B,D){var C=this,A;if(C.config.errorFn){A=C.config.errorFn.apply(C,arguments)}if(C.config.throwFail&&!A){throw (B||new Error(E))}else{C.message(E,"error",""+D)}return C},guid:function(A){var B=this.Env._guidp+"_"+(++this.Env._uidx);return(A)?(A+B):B},stamp:function(C,D){var A;if(!C){return C}if(C.uniqueID&&C.nodeType&&C.nodeType!==9){A=C.uniqueID}else{A=(typeof C==="string")?C:C._yuid}if(!A){A=this.guid();if(!D){try{C._yuid=A}catch(B){A=null}}}return A},destroy:function(){var A=this;if(A.Event){A.Event._unload()}delete f[A.id];delete A.Env;delete A.config}};b.prototype=t;for(e in t){if(t.hasOwnProperty(e)){b[e]=t[e]}}b.applyConfig=function(A){if(!A){return}if(b.GlobalConfig){this.prototype.applyConfig.call(this,b.GlobalConfig)}this.prototype.applyConfig.call(this,A);b.GlobalConfig=this.config};b._init();if(j){q(window,"load",w)}else{w()}b.Env.add=q;b.Env.remove=y;if(typeof a=="object"){a.YUI=b}}());b.add("yui-base",function(e){var m=e.Lang||(e.Lang={}),r=String.prototype,o=Object.prototype.toString,d={"undefined":"undefined",number:"number","boolean":"boolean",string:"string","[object Function]":"function","[object RegExp]":"regexp","[object Array]":"array","[object Date]":"date","[object Error]":"error"},f=/\{\s*([^|}]+?)\s*(?:\|([^}]*))?\s*\}/g,v=/^\s+|\s+$/g,h=/\{\s*\[(?:native code|function)\]\s*\}/i;m._isNative=function(z){return !!(z&&h.test(z))};m.isArray=m._isNative(Array.isArray)?Array.isArray:function(z){return m.type(z)==="array"};m.isBoolean=function(z){return typeof z==="boolean"};m.isDate=function(z){return m.type(z)==="date"&&z.toString()!=="Invalid Date"&&!isNaN(z)};m.isFunction=function(z){return m.type(z)==="function"};m.isNull=function(z){return z===null};m.isNumber=function(z){return typeof z==="number"&&isFinite(z)};m.isObject=function(B,A){var z=typeof B;return(B&&(z==="object"||(!A&&(z==="function"||m.isFunction(B)))))||false};m.isString=function(z){return typeof z==="string"};m.isUndefined=function(z){return typeof z==="undefined"};m.isValue=function(A){var z=m.type(A);switch(z){case"number":return isFinite(A);case"null":case"undefined":return false;default:return !!z}};m.now=Date.now||function(){return new Date().getTime()};m.sub=function(z,A){return z.replace?z.replace(f,function(B,C){return m.isUndefined(A[C])?B:A[C]}):z};m.trim=r.trim?function(z){return z&&z.trim?z.trim():z}:function(z){try{return z.replace(v,"")}catch(A){return z}};m.trimLeft=r.trimLeft?function(z){return z.trimLeft()}:function(z){return z.replace(/^\s+/,"")};m.trimRight=r.trimRight?function(z){return z.trimRight()}:function(z){return z.replace(/\s+$/,"")};m.type=function(z){return d[typeof z]||d[o.call(z)]||(z?"object":"null")};var j=e.Lang,u=Array.prototype,s=Object.prototype.hasOwnProperty;function n(B,E,D){var A,z;E||(E=0);if(D||n.test(B)){try{return u.slice.call(B,E)}catch(C){z=[];for(A=B.length;E<A;++E){z.push(B[E])}return z}}return[B]}e.Array=n;n.dedupe=function(E){var D={},B=[],A,C,z;for(A=0,z=E.length;A<z;++A){C=E[A];if(!s.call(D,C)){D[C]=1;B.push(C)}}return B};n.each=n.forEach=j._isNative(u.forEach)?function(B,z,A){u.forEach.call(B||[],z,A||e);return e}:function(D,B,C){for(var A=0,z=(D&&D.length)||0;A<z;++A){if(A in D){B.call(C||e,D[A],A,D)}}return e};n.hash=function(C,A){var D={},E=(A&&A.length)||0,B,z;for(B=0,z=C.length;B<z;++B){if(B in C){D[C[B]]=E>B&&B in A?A[B]:true}}return D};n.indexOf=j._isNative(u.indexOf)?function(A,z){return u.indexOf.call(A,z)}:function(C,B){for(var A=0,z=C.length;A<z;++A){if(A in C&&C[A]===B){return A}}return -1};n.numericSort=function(A,z){return A-z};n.some=j._isNative(u.some)?function(B,z,A){return u.some.call(B,z,A)}:function(D,B,C){for(var A=0,z=D.length;A<z;++A){if(A in D&&B.call(C,D[A],A,D)){return true}}return false};n.test=function(B){var z=0;if(j.isArray(B)){z=1}else{if(j.isObject(B)){try{if("length" in B&&!B.tagName&&!B.alert&&!B.apply){z=2}}catch(A){}}}return z};function x(){this._init();this.add.apply(this,arguments)}x.prototype={_init:function(){this._q=[]},next:function(){return this._q.shift()},last:function(){return this._q.pop()},add:function(){this._q.push.apply(this._q,arguments);return this},size:function(){return this._q.length}};e.Queue=x;b.Env._loaderQueue=b.Env._loaderQueue||new x();var q="__",s=Object.prototype.hasOwnProperty,p=e.Lang.isObject,i=e.config.win;e.cached=function(B,z,A){z||(z={});return function(C){var D=arguments.length>1?Array.prototype.join.call(arguments,q):String(C);if(!(D in z)||(A&&z[D]==A)){z[D]=B.apply(B,arguments)}return z[D]}};e.getLocation=function(){return i&&i.location};e.merge=function(){var B=arguments,C=0,A=B.length,z={};for(;C<A;++C){e.mix(z,B[C],true)}return z};e.mix=function(z,A,G,B,D,H){var E,K,J,C,L,F,I;if(!z||!A){return z||e}if(D){if(D===2){e.mix(z.prototype,A.prototype,G,B,0,H)}J=D===1||D===3?A.prototype:A;I=D===1||D===4?z.prototype:z;if(!J||!I){return z}}else{J=A;I=z}E=G&&!H;if(B){for(C=0,F=B.length;C<F;++C){L=B[C];if(!s.call(J,L)){continue}K=E?false:L in I;if(H&&K&&p(I[L],true)&&p(J[L],true)){e.mix(I[L],J[L],G,null,0,H)}else{if(G||!K){I[L]=J[L]}}}}else{for(L in J){if(!s.call(J,L)){continue}K=E?false:L in I;if(H&&K&&p(I[L],true)&&p(J[L],true)){e.mix(I[L],J[L],G,null,0,H)}else{if(G||!K){I[L]=J[L]}}}if(e.Object._hasEnumBug){e.mix(I,J,G,e.Object._forceEnum,D,H)}}return z};var j=e.Lang,s=Object.prototype.hasOwnProperty,y,k=e.Object=j._isNative(Object.create)?function(z){return Object.create(z)}:(function(){function z(){}return function(A){z.prototype=A;return new z()}}()),g=k._forceEnum=["hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toString","toLocaleString","valueOf"],w=k._hasEnumBug=!{valueOf:0}.propertyIsEnumerable("valueOf"),t=k._hasProtoEnumBug=(function(){}).propertyIsEnumerable("prototype"),l=k.owns=function(A,z){return !!A&&s.call(A,z)};k.hasKey=l;k.keys=j._isNative(Object.keys)?Object.keys:function(D){if(!j.isObject(D)){throw new TypeError("Object.keys called on a non-object")}var C=[],B,A,z;if(t&&typeof D==="function"){for(A in D){if(l(D,A)&&A!=="prototype"){C.push(A)}}}else{for(A in D){if(l(D,A)){C.push(A)}}}if(w){for(B=0,z=g.length;B<z;++B){A=g[B];if(l(D,A)){C.push(A)}}}return C};k.values=function(D){var C=k.keys(D),B=0,z=C.length,A=[];for(;B<z;++B){A.push(D[C[B]])}return A};k.size=function(A){try{return k.keys(A).length}catch(z){return 0}};k.hasValue=function(A,z){return e.Array.indexOf(k.values(A),z)>-1};k.each=function(C,A,D,B){var z;for(z in C){if(B||l(C,z)){A.call(D||e,C[z],z,C)}}return e};k.some=function(C,A,D,B){var z;for(z in C){if(B||l(C,z)){if(A.call(D||e,C[z],z,C)){return true}}}return false};k.getValue=function(D,C){if(!j.isObject(D)){return y}var A,B=e.Array(C),z=B.length;for(A=0;D!==y&&A<z;A++){D=D[B[A]]}return D};k.setValue=function(F,D,E){var z,C=e.Array(D),B=C.length-1,A=F;if(B>=0){for(z=0;A!==y&&z<B;z++){A=A[C[z]]}if(A!==y){A[C[z]]=E}else{return y}}return F};k.isEmpty=function(z){return !k.keys(Object(z)).length};b.Env.parseUA=function(F){var E=function(I){var J=0;return parseFloat(I.replace(/\./g,function(){return(J++==1)?"":"."}))},H=e.config.win,z=H&&H.navigator,C={ie:0,opera:0,gecko:0,webkit:0,safari:0,chrome:0,mobile:null,air:0,ipad:0,iphone:0,ipod:0,ios:null,android:0,silk:0,accel:false,webos:0,caja:z&&z.cajaVersion,secure:false,os:null,nodejs:0},A=F||z&&z.userAgent,G=H&&H.location,B=G&&G.href,D;C.userAgent=A;C.secure=B&&(B.toLowerCase().indexOf("https")===0);if(A){if((/windows|win32/i).test(A)){C.os="windows"}else{if((/macintosh/i).test(A)){C.os="macintosh"}else{if((/rhino/i).test(A)){C.os="rhino"}}}if((/KHTML/).test(A)){C.webkit=1}D=A.match(/AppleWebKit\/([^\s]*)/);if(D&&D[1]){C.webkit=E(D[1]);C.safari=C.webkit;if(/ Mobile\//.test(A)){C.mobile="Apple";D=A.match(/OS ([^\s]*)/);if(D&&D[1]){D=E(D[1].replace("_","."))}C.ios=D;C.ipad=C.ipod=C.iphone=0;D=A.match(/iPad|iPod|iPhone/);if(D&&D[0]){C[D[0].toLowerCase()]=C.ios}}else{D=A.match(/NokiaN[^\/]*|webOS\/\d\.\d/);if(D){C.mobile=D[0]}if(/webOS/.test(A)){C.mobile="WebOS";D=A.match(/webOS\/([^\s]*);/);if(D&&D[1]){C.webos=E(D[1])}}if(/ Android/.test(A)){if(/Mobile/.test(A)){C.mobile="Android"}D=A.match(/Android ([^\s]*);/);if(D&&D[1]){C.android=E(D[1])}}if(/Silk/.test(A)){D=A.match(/Silk\/([^\s]*)\)/);if(D&&D[1]){C.silk=E(D[1])}if(!C.android){C.android=2.34;C.os="Android"}if(/Accelerated=true/.test(A)){C.accel=true}}}D=A.match(/Chrome\/([^\s]*)/);if(D&&D[1]){C.chrome=E(D[1]);C.safari=0}else{D=A.match(/AdobeAIR\/([^\s]*)/);if(D){C.air=D[0]}}}if(!C.webkit){D=A.match(/Opera[\s\/]([^\s]*)/);if(D&&D[1]){C.opera=E(D[1]);D=A.match(/Version\/([^\s]*)/);if(D&&D[1]){C.opera=E(D[1])}D=A.match(/Opera Mini[^;]*/);if(D){C.mobile=D[0]}}else{D=A.match(/MSIE\s([^;]*)/);if(D&&D[1]){C.ie=E(D[1])}else{D=A.match(/Gecko\/([^\s]*)/);if(D){C.gecko=1;D=A.match(/rv:([^\s\)]*)/);if(D&&D[1]){C.gecko=E(D[1])}}}}}}if(!F){if(typeof process=="object"){if(process.versions&&process.versions.node){C.os=process.platform;C.nodejs=process.versions.node}}b.Env.UA=C}return C};e.UA=b.Env.UA||b.Env.parseUA();b.Env.aliases={anim:["anim-base","anim-color","anim-curve","anim-easing","anim-node-plugin","anim-scroll","anim-xy"],app:["app-base","model","model-list","router","view"],attribute:["attribute-base","attribute-complex"],autocomplete:["autocomplete-base","autocomplete-sources","autocomplete-list","autocomplete-plugin"],base:["base-base","base-pluginhost","base-build"],button:["button-base","button-group","cssbutton"],cache:["cache-base","cache-offline","cache-plugin"],collection:["array-extras","arraylist","arraylist-add","arraylist-filter","array-invoke"],controller:["router"],dataschema:["dataschema-base","dataschema-json","dataschema-xml","dataschema-array","dataschema-text"],datasource:["datasource-local","datasource-io","datasource-get","datasource-function","datasource-cache","datasource-jsonschema","datasource-xmlschema","datasource-arrayschema","datasource-textschema","datasource-polling"],datatable:["datatable-core","datatable-head","datatable-body","datatable-base","datatable-column-widths","datatable-mutable","datatable-scroll","datatable-datasource","datatable-sort"],datatype:["datatype-number","datatype-date","datatype-xml"],"datatype-date":["datatype-date-parse","datatype-date-format"],"datatype-number":["datatype-number-parse","datatype-number-format"],"datatype-xml":["datatype-xml-parse","datatype-xml-format"],dd:["dd-ddm-base","dd-ddm","dd-ddm-drop","dd-drag","dd-proxy","dd-constrain","dd-drop","dd-scroll","dd-delegate"],dom:["dom-base","dom-screen","dom-style","selector-native","selector"],editor:["frame","editor-selection","exec-command","editor-base","editor-para","editor-br","editor-bidi","editor-tab","createlink-base"],event:["event-base","event-delegate","event-synthetic","event-mousewheel","event-mouseenter","event-key","event-focus","event-resize","event-hover","event-outside","event-touch","event-move","event-flick","event-valuechange"],"event-custom":["event-custom-base","event-custom-complex"],"event-gestures":["event-flick","event-move"],handlebars:["handlebars-compiler"],highlight:["highlight-base","highlight-accentfold"],history:["history-base","history-hash","history-hash-ie","history-html5"],io:["io-base","io-xdr","io-form","io-upload-iframe","io-queue"],json:["json-parse","json-stringify"],loader:["loader-base","loader-rollup","loader-yui3"],node:["node-base","node-event-delegate","node-pluginhost","node-screen","node-style"],pluginhost:["pluginhost-base","pluginhost-config"],querystring:["querystring-parse","querystring-stringify"],recordset:["recordset-base","recordset-sort","recordset-filter","recordset-indexer"],resize:["resize-base","resize-proxy","resize-constrain"],slider:["slider-base","slider-value-range","clickable-rail","range-slider"],text:["text-accentfold","text-wordbreak"],widget:["widget-base","widget-htmlparser","widget-uievents","widget-skin"]}},"@VERSION@");b.add("get",function(f){var e=f.Lang,g,d;f.Get=g={cssOptions:{attributes:{rel:"stylesheet"},doc:f.config.linkDoc||f.config.doc,pollInterval:50},jsOptions:{autopurge:true,doc:f.config.scriptDoc||f.config.doc},options:{attributes:{charset:"utf-8"},purgethreshold:20},REGEX_CSS:/\.css(?:[?;].*)?$/i,REGEX_JS:/\.js(?:[?;].*)?$/i,_insertCache:{},_pending:null,_purgeNodes:[],_queue:[],abort:function(m){var j,n,k,h,l;if(!m.abort){n=m;l=this._pending;m=null;if(l&&l.transaction.id===n){m=l.transaction;this._pending=null}else{for(j=0,h=this._queue.length;j<h;++j){k=this._queue[j].transaction;if(k.id===n){m=k;this._queue.splice(j,1);break}}}}m&&m.abort()},css:function(i,h,j){return this._load("css",i,h,j)},js:function(i,h,j){return this._load("js",i,h,j)},load:function(i,h,j){return this._load(null,i,h,j)},_autoPurge:function(h){if(h&&this._purgeNodes.length>=h){this._purge(this._purgeNodes)}},_getEnv:function(){var i=f.config.doc,h=f.UA;return(this._env={async:i&&i.createElement("script").async===true,cssLoad:!!(h.gecko?h.gecko>=9:!h.webkit),preservesScriptOrder:!!(h.gecko||h.opera)})},_getTransaction:function(n,k){var o=[],l,h,m,j;if(!e.isArray(n)){n=[n]}for(l=0,h=n.length;l<h;++l){j=n[l];m={attributes:{}};if(typeof j==="string"){m.url=j}else{if(j.url){f.mix(m,j,false,null,0,true);j=j.url}else{continue}}f.mix(m,k,false,null,0,true);f.mix(m,this.options,false,null,0,true);if(!m.type){if(this.REGEX_CSS.test(j)){m.type="css"}else{if(!this.REGEX_JS.test(j)){}m.type="js"}}f.mix(m,m.type==="js"?this.jsOptions:this.cssOptions,false,null,0,true);m.attributes.id||(m.attributes.id=f.guid());if(m.win){m.doc=m.win.document}else{m.win=m.doc.defaultView||m.doc.parentWindow}if(m.charset){m.attributes.charset=m.charset}o.push(m)}return new d(o,k)},_load:function(i,j,h,l){var k;if(typeof h==="function"){l=h;h={}}h||(h={});h.type=i;if(!this._env){this._getEnv()}k=this._getTransaction(j,h);this._queue.push({callback:l,transaction:k});this._next();return k},_next:function(){var h;if(this._pending){return}h=this._queue.shift();if(h){this._pending=h;h.transaction.execute(function(){h.callback&&h.callback.apply(this,arguments);g._pending=null;g._next()})}},_purge:function(h){var j=this._purgeNodes,l=h!==j,i,k;while(k=h.pop()){if(!k._yuiget_finished){continue}k.parentNode&&k.parentNode.removeChild(k);if(l){i=f.Array.indexOf(j,k);if(i>-1){j.splice(i,1)}}}}};g.script=g.js;g.Transaction=d=function(j,i){var h=this;h.id=d._lastId+=1;h.data=i.data;h.errors=[];h.nodes=[];h.options=i;h.requests=j;h._callbacks=[];h._queue=[];h._waiting=0;h.tId=h.id;h.win=i.win||f.config.win};d._lastId=0;d.prototype={_state:"new",abort:function(h){this._pending=null;this._pendingCSS=null;this._pollTimer=clearTimeout(this._pollTimer);this._queue=[];this._waiting=0;this.errors.push({error:h||"Aborted"});this._finish()},execute:function(p){var k=this,o=k.requests,n=k._state,l,j,h,m;if(n==="done"){p&&p(k.errors.length?k.errors:null,k);return}else{p&&k._callbacks.push(p);if(n==="executing"){return}}k._state="executing";k._queue=h=[];if(k.options.timeout){k._timeout=setTimeout(function(){k.abort("Timeout")},k.options.timeout)}for(l=0,j=o.length;l<j;++l){m=k.requests[l];if(m.async||m.type==="css"){k._insert(m)}else{h.push(m)}}k._next()},purge:function(){g._purge(this.nodes)},_createNode:function(j,i,l){var k=l.createElement(j),h;for(h in i){if(i.hasOwnProperty(h)){k.setAttribute(h,i[h])}}return k},_finish:function(){var n=this.errors.length?this.errors:null,j=this.options,m=j.context||this,l,k,h;if(this._state==="done"){return}this._state="done";for(k=0,h=this._callbacks.length;k<h;++k){this._callbacks[k].call(m,n,this)}l=this._getEventData();if(n){if(j.onTimeout&&n[n.length-1].error==="Timeout"){j.onTimeout.call(m,l)}if(j.onFailure){j.onFailure.call(m,l)}}else{if(j.onSuccess){j.onSuccess.call(m,l)}}if(j.onEnd){j.onEnd.call(m,l)}},_getEventData:function(h){if(h){return f.merge(this,{abort:this.abort,purge:this.purge,request:h,url:h.url,win:h.win})}else{return this}},_getInsertBefore:function(l){var m=l.doc,j=l.insertBefore,i,k,h;if(j){return typeof j==="string"?m.getElementById(j):j}i=g._insertCache;h=f.stamp(m);if((j=i[h])){return j}if((j=m.getElementsByTagName("base")[0])){return(i[h]=j)}j=m.head||m.getElementsByTagName("head")[0];if(j){j.appendChild(m.createTextNode(""));return(i[h]=j.lastChild)}return(i[h]=m.getElementsByTagName("script")[0])},_insert:function(p){var m=g._env,n=this._getInsertBefore(p),j=p.type==="js",i=p.node,q=this,h=f.UA,k;if(!i){if(j){k="script"}else{if(!m.cssLoad&&h.gecko){k="style"}else{k="link"}}i=p.node=this._createNode(k,p.attributes,p.doc)}function l(){q._progress("Failed to load "+p.url,p)}function o(){q._progress(null,p)}if(j){i.setAttribute("src",p.url);if(p.async){i.async=true}else{if(m.async){i.async=false}if(!m.preservesScriptOrder){this._pending=p}}}else{if(!m.cssLoad&&h.gecko){i.innerHTML=(p.attributes.charset?'@charset "'+p.attributes.charset+'";':"")+'@import "'+p.url+'";'}else{i.setAttribute("href",p.url)}}if(j&&h.ie&&h.ie<9){i.onreadystatechange=function(){if(/loaded|complete/.test(i.readyState)){i.onreadystatechange=null;o()}}}else{if(!j&&!m.cssLoad){this._poll(p)}else{i.onerror=l;i.onload=o}}this._waiting+=1;this.nodes.push(i);n.parentNode.insertBefore(i,n)},_next:function(){if(this._pending){return}if(this._queue.length){this._insert(this._queue.shift())}else{if(!this._waiting){this._finish()}}},_poll:function(p){var s=this,t=s._pendingCSS,n=f.UA.webkit,l,h,k,r,q,m;if(p){t||(t=s._pendingCSS=[]);t.push(p);if(s._pollTimer){return}}s._pollTimer=null;for(l=0;l<t.length;++l){q=t[l];if(n){m=q.doc.styleSheets;k=m.length;r=q.node.href;while(--k>=0){if(m[k].href===r){t.splice(l,1);l-=1;s._progress(null,q);break}}}else{try{h=!!q.node.sheet.cssRules;t.splice(l,1);l-=1;s._progress(null,q)}catch(o){}}}if(t.length){s._pollTimer=setTimeout(function(){s._poll.call(s)},s.options.pollInterval)}},_progress:function(j,i){var h=this.options;if(j){i.error=j;this.errors.push({error:j,request:i})}i.node._yuiget_finished=i.finished=true;if(h.onProgress){h.onProgress.call(h.context||this,this._getEventData(i))}if(i.autopurge){g._autoPurge(this.options.purgethreshold);g._purgeNodes.push(i.node)}if(this._pending===i){this._pending=null}this._waiting-=1;this._next()}}},"@VERSION@",{requires:["yui-base"]});b.add("loader-base",function(g){if(!b.Env[g.version]){(function(){var L=g.version,H="/build/",I=L+H,G=g.Env.base,D="gallery-2012.01.25-21-14",F="2in3",E="4",C="2.9.0",J=G+"combo?",K={version:L,root:I,base:g.Env.base,comboBase:J,skin:{defaultSkin:"sam",base:"assets/skins/",path:"skin.css",after:["cssreset","cssfonts","cssgrids","cssbase","cssreset-context","cssfonts-context"]},groups:{},patterns:{}},B=K.groups,A=function(N,O){var M=F+"."+(N||E)+"/"+(O||C)+H;B.yui2.base=G+M;B.yui2.root=M},z=function(M){var N=(M||D)+H;B.gallery.base=G+N;B.gallery.root=N};B[L]={};B.gallery={ext:false,combine:true,comboBase:J,update:z,patterns:{"gallery-":{},"lang/gallery-":{},"gallerycss-":{type:"css"}}};B.yui2={combine:true,ext:false,comboBase:J,update:A,patterns:{"yui2-":{configFn:function(M){if(/-skin|reset|fonts|grids|base/.test(M.name)){M.type="css";M.path=M.path.replace(/\.js/,".css");M.path=M.path.replace(/\/yui2-skin/,"/assets/skins/sam/yui2-skin")}}}}};z();A();b.Env[L]=K}())}var i={},f=[],p=1024,d=b.Env,s=d._loaded,t="css",n="js",y="intl",v=g.version,x="",h=g.Object,u=h.each,m=g.Array,k=d._loaderQueue,w=d[v],e="skin-",l=g.Lang,q=d.mods,o,r,j=function(A,B,C,z){var D=A+"/"+B;if(!z){D+="-min"}D+="."+(C||t);return D};g.Env.meta=w;g.Loader=function(D){var C=w.modules,A=this;D=D||{};o=w.md5;A.context=g;A.base=g.Env.meta.base+g.Env.meta.root;A.comboBase=g.Env.meta.comboBase;A.combine=D.base&&(D.base.indexOf(A.comboBase.substr(0,20))>-1);A.comboSep="&";A.maxURLLength=p;A.root=g.Env.meta.root;A.timeout=0;A.forceMap={};A.allowRollup=false;A.filters={};A.required={};A.patterns={};A.moduleInfo={};A.groups=g.merge(g.Env.meta.groups);A.skin=g.merge(g.Env.meta.skin);A.conditions={};A.config=D;A._internal=true;r=d._renderedMods;if(r){u(r,function B(F,E){A.moduleInfo[E]=g.merge(F)});r=d._conditions;u(r,function z(F,E){A.conditions[E]=g.merge(F)})}else{u(C,A.addModule,A)}A.loaded=s[v];A._inspectPage();A._internal=false;A._config(D);A.forceMap=(A.force)?g.Array.hash(A.force):{};A.testresults=null;if(g.config.tests){A.testresults=g.config.tests}A.sorted=[];A.dirty=true;A.inserted={};A.skipped={};A.tested={}};g.Loader.prototype={REGEX_CSS:/\.css(?:[?;].*)?$/i,FILTER_DEFS:{RAW:{searchExp:"-min\\.js",replaceStr:".js"},DEBUG:{searchExp:"-min\\.js",replaceStr:"-debug.js"}},_inspectPage:function(){u(this.moduleInfo,function(A,z){if(A.type&&A.type===t){if(this.isCSSLoaded(A.name)){this.loaded[z]=true}}},this);u(q,function(B,A){if(B.details){var z=this.moduleInfo[A],D=B.details.requires,C=z&&z.requires;if(z){if(!z._inspected&&D&&C.length!=D.length){delete z.expanded}}else{z=this.addModule(B.details,A)}z._inspected=true}},this)},_requires:function(F,E){var B,D,G,H,z=this.moduleInfo,A=z[F],C=z[E];if(!A||!C){return false}D=A.expanded_map;G=A.after_map;if(G&&(E in G)){return true}G=C.after_map;if(G&&(F in G)){return false}H=z[E]&&z[E].supersedes;if(H){for(B=0;B<H.length;B++){if(this._requires(F,H[B])){return true}}}H=z[F]&&z[F].supersedes;if(H){for(B=0;B<H.length;B++){if(this._requires(E,H[B])){return false}}}if(D&&(E in D)){return true}if(A.ext&&A.type==t&&!C.ext&&C.type==t){return true}return false},_config:function(F){var B,A,E,C,D,G,z=this;if(F){for(B in F){if(F.hasOwnProperty(B)){E=F[B];if(B=="require"){z.require(E)}else{if(B=="skin"){if(typeof E==="string"){z.skin.defaultSkin=F.skin;E={defaultSkin:E}}g.mix(z.skin,E,true)}else{if(B=="groups"){for(A in E){if(E.hasOwnProperty(A)){G=A;D=E[A];z.addGroup(D,G)}}}else{if(B=="modules"){u(E,z.addModule,z)}else{if(B=="gallery"){this.groups.gallery.update(E)}else{if(B=="yui2"||B=="2in3"){this.groups.yui2.update(F["2in3"],F.yui2)}else{z[B]=E}}}}}}}}}C=z.filter;if(l.isString(C)){C=C.toUpperCase();z.filterName=C;z.filter=z.FILTER_DEFS[C];if(C=="DEBUG"){z.require("yui-log","dump")}}if(z.lang){z.require("intl-base","intl")}},formatSkin:function(B,z){var A=e+B;if(z){A=A+"-"+z}return A},_addSkin:function(I,G,H){var F,E,A,z,D=this.moduleInfo,B=this.skin,C=D[G]&&D[G].ext;if(G){A=this.formatSkin(I,G);if(!D[A]){F=D[G];E=F.pkg||G;z={name:A,group:F.group,type:"css",after:B.after,path:(H||E)+"/"+B.base+I+"/"+G+".css",ext:C};if(F.base){z.base=F.base}if(F.configFn){z.configFn=F.configFn}this.addModule(z,A)}}return A},addGroup:function(C,A){var B=C.modules,z=this;A=A||C.name;C.name=A;z.groups[A]=C;if(C.patterns){u(C.patterns,function(E,D){E.group=A;z.patterns[D]=E})}if(B){u(B,function(E,D){if(typeof E==="string"){E={name:D,fullpath:E}}E.group=A;z.addModule(E,D)},z)}},addModule:function(Q,X){X=X||Q.name;if(typeof Q==="string"){Q={name:X,fullpath:Q}}if(this.moduleInfo[X]&&this.moduleInfo[X].temp){Q=g.merge(this.moduleInfo[X],Q)}Q.name=X;if(!Q||!Q.name){return null}if(!Q.type){Q.type=n;var O=Q.path||Q.fullpath;if(O&&this.REGEX_CSS.test(O)){Q.type=t}}if(!Q.path&&!Q.fullpath){Q.path=j(X,X,Q.type)}Q.supersedes=Q.supersedes||Q.use;Q.ext=("ext" in Q)?Q.ext:(this._internal)?false:true;Q.requires=this.filterRequires(Q.requires)||[];var U=Q.submodules,T,R,K,z,L,B,P,A,S,M,I,F,D,C,W,V,J,E,G,H=this.conditions,N;this.moduleInfo[X]=Q;if(!Q.langPack&&Q.lang){M=m(Q.lang);for(S=0;S<M.length;S++){W=M[S];I=this.getLangPackName(W,X);B=this.moduleInfo[I];if(!B){B=this._addLangPack(W,Q,I)}}}if(U){z=Q.supersedes||[];R=0;for(T in U){if(U.hasOwnProperty(T)){L=U[T];L.path=L.path||j(X,T,Q.type);L.pkg=X;L.group=Q.group;if(L.supersedes){z=z.concat(L.supersedes)}B=this.addModule(L,T);z.push(T);if(B.skinnable){Q.skinnable=true;J=this.skin.overrides;if(J&&J[T]){for(S=0;S<J[T].length;S++){E=this._addSkin(J[T][S],T,X);z.push(E)}}E=this._addSkin(this.skin.defaultSkin,T,X);z.push(E)}if(L.lang&&L.lang.length){M=m(L.lang);for(S=0;S<M.length;S++){W=M[S];I=this.getLangPackName(W,X);F=this.getLangPackName(W,T);B=this.moduleInfo[I];if(!B){B=this._addLangPack(W,Q,I)}D=D||m.hash(B.supersedes);if(!(F in D)){B.supersedes.push(F)}Q.lang=Q.lang||[];C=C||m.hash(Q.lang);if(!(W in C)){Q.lang.push(W)}I=this.getLangPackName(x,X);F=this.getLangPackName(x,T);B=this.moduleInfo[I];if(!B){B=this._addLangPack(W,Q,I)}if(!(F in D)){B.supersedes.push(F)}}}R++}}Q.supersedes=m.dedupe(z);if(this.allowRollup){Q.rollup=(R<4)?R:Math.min(R-1,4)}}P=Q.plugins;if(P){for(T in P){if(P.hasOwnProperty(T)){A=P[T];A.pkg=X;A.path=A.path||j(X,T,Q.type);A.requires=A.requires||[];A.group=Q.group;this.addModule(A,T);if(Q.skinnable){this._addSkin(this.skin.defaultSkin,T,X)}}}}if(Q.condition){K=Q.condition.trigger;if(b.Env.aliases[K]){K=b.Env.aliases[K]}if(!g.Lang.isArray(K)){K=[K]}for(T=0;T<K.length;T++){N=K[T];G=Q.condition.when;H[N]=H[N]||{};H[N][X]=Q.condition;if(G&&G!="after"){if(G=="instead"){Q.supersedes=Q.supersedes||[];Q.supersedes.push(N)}else{}}else{Q.after=Q.after||[];Q.after.push(N)}}}if(Q.supersedes){Q.supersedes=this.filterRequires(Q.supersedes)}if(Q.after){Q.after=this.filterRequires(Q.after);Q.after_map=m.hash(Q.after)}if(Q.configFn){V=Q.configFn(Q);if(V===false){delete this.moduleInfo[X];delete d._renderedMods[X];Q=null}}if(Q){if(!d._renderedMods){d._renderedMods={}}d._renderedMods[X]=g.merge(Q);d._conditions=H}return Q},require:function(A){var z=(typeof A==="string")?m(arguments):A;this.dirty=true;this.required=g.merge(this.required,m.hash(this.filterRequires(z)));this._explodeRollups()},_explodeRollups:function(){var A=this,z,B=A.required;if(!A.allowRollup){u(B,function(C,D){z=A.getModule(D);if(z&&z.use){m.each(z.use,function(E){z=A.getModule(E);if(z&&z.use){m.each(z.use,function(F){B[F]=true})}else{B[E]=true}})}});A.required=B}},filterRequires:function(C){if(C){if(!g.Lang.isArray(C)){C=[C]}C=g.Array(C);var E=[],B,A,D,z;for(B=0;B<C.length;B++){A=this.getModule(C[B]);if(A&&A.use){for(D=0;D<A.use.length;D++){z=this.getModule(A.use[D]);if(z&&z.use){E=g.Array.dedupe([].concat(E,this.filterRequires(z.use)))}else{E.push(A.use[D])}}}else{E.push(C[B])}}C=E}return C},getRequires:function(U){if(!U){return f}if(U._parsed){return U.expanded||f}var O,K,N,G,F,W,D=this.testresults,X=U.name,E,V=q[X]&&q[X].details,Q,L,z,H,R,I,C,S,T,B,J=U.lang||U.intl,P=this.moduleInfo,M=g.Features&&g.Features.tests.load,A;if(U.temp&&V){R=U;U=this.addModule(V,X);U.group=R.group;U.pkg=R.pkg;delete U.expanded}if(U.expanded&&(!this.lang||U.langCache===this.lang)){return U.expanded}Q=[];A={};H=this.filterRequires(U.requires);if(U.lang){Q.unshift("intl");H.unshift("intl");J=true}I=this.filterRequires(U.optional);U._parsed=true;U.langCache=this.lang;for(O=0;O<H.length;O++){if(!A[H[O]]){Q.push(H[O]);A[H[O]]=true;K=this.getModule(H[O]);if(K){G=this.getRequires(K);J=J||(K.expanded_map&&(y in K.expanded_map));for(N=0;N<G.length;N++){Q.push(G[N])}}}}H=this.filterRequires(U.supersedes);if(H){for(O=0;O<H.length;O++){if(!A[H[O]]){if(U.submodules){Q.push(H[O])}A[H[O]]=true;K=this.getModule(H[O]);if(K){G=this.getRequires(K);J=J||(K.expanded_map&&(y in K.expanded_map));for(N=0;N<G.length;N++){Q.push(G[N])}}}}}if(I&&this.loadOptional){for(O=0;O<I.length;O++){if(!A[I[O]]){Q.push(I[O]);A[I[O]]=true;K=P[I[O]];if(K){G=this.getRequires(K);J=J||(K.expanded_map&&(y in K.expanded_map));for(N=0;N<G.length;N++){Q.push(G[N])}}}}}E=this.conditions[X];if(E){U._parsed=false;if(D&&M){u(D,function(Y,aa){var Z=M[aa].name;if(!A[Z]&&M[aa].trigger==X){if(Y&&M[aa]){A[Z]=true;Q.push(Z)}}})}else{u(E,function(aa,Z){if(!A[Z]){var Y=aa&&((!aa.ua&&!aa.test)||(aa.ua&&g.UA[aa.ua])||(aa.test&&aa.test(g,H)));if(Y){A[Z]=true;Q.push(Z);K=this.getModule(Z);if(K){G=this.getRequires(K);for(N=0;N<G.length;N++){Q.push(G[N])}}}}},this)}}if(U.skinnable){S=this.skin.overrides;u(b.Env.aliases,function(Y,Z){if(g.Array.indexOf(Y,X)>-1){T=Z}});if(S&&(S[X]||(T&&S[T]))){B=X;if(S[T]){B=T}for(O=0;O<S[B].length;O++){C=this._addSkin(S[B][O],X);if(!this.isCSSLoaded(C,this._boot)){Q.push(C)}}}else{C=this._addSkin(this.skin.defaultSkin,X);if(!this.isCSSLoaded(C,this._boot)){Q.push(C)}}}U._parsed=false;if(J){if(U.lang&&!U.langPack&&g.Intl){W=g.Intl.lookupBestLang(this.lang||x,U.lang);F=this.getLangPackName(W,X);if(F){Q.unshift(F)}}Q.unshift(y)}U.expanded_map=m.hash(Q);U.expanded=h.keys(U.expanded_map);return U.expanded},isCSSLoaded:function(A,D){if(!A||!b.Env.cssStampEl||(!D&&this.ignoreRegistered)){return false}var C=b.Env.cssStampEl,z=false,B=C.currentStyle;C.className=A;if(!B){B=g.config.doc.defaultView.getComputedStyle(C,null)}if(B.display==="none"){z=true}C.className="";return z},getProvides:function(A){var z=this.getModule(A),C,B;if(!z){return i}if(z&&!z.provides){C={};B=z.supersedes;if(B){m.each(B,function(D){g.mix(C,this.getProvides(D))},this)}C[A]=true;z.provides=C}return z.provides},calculate:function(A,z){if(A||z||this.dirty){if(A){this._config(A)}if(!this._init){this._setup()}this._explode();if(this.allowRollup){this._rollup()}else{this._explodeRollups()}this._reduce();this._sort()}},_addLangPack:function(F,z,E){var C=z.name,A,B,D=this.moduleInfo[E];if(!D){A=j((z.pkg||C),E,n,true);B={path:A,intl:true,langPack:true,ext:z.ext,group:z.group,supersedes:[]};if(z.configFn){B.configFn=z.configFn}this.addModule(B,E);if(F){g.Env.lang=g.Env.lang||{};g.Env.lang[F]=g.Env.lang[F]||{};g.Env.lang[F][C]=true}}return this.moduleInfo[E]},_setup:function(){var F=this.moduleInfo,C,D,B,z,A,E;for(C in F){if(F.hasOwnProperty(C)){z=F[C];if(z){z.requires=m.dedupe(z.requires);if(z.lang&&z.lang.length){E=this.getLangPackName(x,C);this._addLangPack(null,z,E)}}}}A={};if(!this.ignoreRegistered){g.mix(A,d.mods)}if(this.ignore){g.mix(A,m.hash(this.ignore))}for(B in A){if(A.hasOwnProperty(B)){g.mix(A,this.getProvides(B))}}if(this.force){for(D=0;D<this.force.length;D++){if(this.force[D] in A){delete A[this.force[D]]}}}g.mix(this.loaded,A);this._init=true},getLangPackName:function(A,z){return("lang/"+z+((A)?"_"+A:""))},_explode:function(){var D=this.required,z,C,A={},B=this;B.dirty=false;B._explodeRollups();D=B.required;u(D,function(E,F){if(!A[F]){A[F]=true;z=B.getModule(F);if(z){var G=z.expound;if(G){D[G]=B.getModule(G);C=B.getRequires(D[G]);g.mix(D,m.hash(C))}C=B.getRequires(z);g.mix(D,m.hash(C))}}})},getModule:function(E){if(!E){return null}var D,C,A,z=this.moduleInfo[E],B=this.patterns;if(!z){for(A in B){if(B.hasOwnProperty(A)){D=B[A];if(!D.test){D.test=function(G,F){return(G.indexOf(F)>-1)}}if(D.test(E,A)){C=D;break}}}if(C){if(D.action){D.action.call(this,E,A)}else{z=this.addModule(g.merge(C),E);z.temp=true}}}return z},_rollup:function(){},_reduce:function(E){E=E||this.required;var B,A,D,z,C=this.loadType,F=this.ignore?m.hash(this.ignore):false;for(B in E){if(E.hasOwnProperty(B)){z=this.getModule(B);if(((this.loaded[B]||q[B])&&!this.forceMap[B]&&!this.ignoreRegistered)||(C&&z&&z.type!=C)){delete E[B]}if(F&&F[B]){delete E[B]}D=z&&z.supersedes;if(D){for(A=0;A<D.length;A++){if(D[A] in E){delete E[D[A]]}}}}}return E},_finish:function(B,A){k.running=false;var z=this.onEnd;if(z){z.call(this.context,{msg:B,data:this.data,success:A})}this._continue()},_onSuccess:function(){var B=this,A=g.merge(B.skipped),D,z=[],C=B.requireRegistration,F,E;u(A,function(G){delete B.inserted[G]});B.skipped={};u(B.inserted,function(H,G){var I=B.getModule(G);if(I&&C&&I.type==n&&!(G in b.Env.mods)){z.push(G)}else{g.mix(B.loaded,B.getProvides(G))}});D=B.onSuccess;E=(z.length)?"notregistered":"success";F=!(z.length);if(D){D.call(B.context,{msg:E,data:B.data,success:F,failed:z,skipped:A})}B._finish(E,F)},_onProgress:function(A){var z=this;if(z.onProgress){z.onProgress.call(z.context,{name:A.url,data:A.data})}},_onFailure:function(D){var B=this.onFailure,C=[],A=0,z=D.errors.length;for(A;A<z;A++){C.push(D.errors[A].error)}C=C.join(",");if(B){B.call(this.context,{msg:C,data:this.data,success:false})}this._finish(C,false)},_onTimeout:function(){var z=this.onTimeout;if(z){z.call(this.context,{msg:"timeout",data:this.data,success:false})}this._finish("timeout",false)},_sort:function(){var I=h.keys(this.required),E={},z=0,B,H,G,D,C,F,A;for(;;){B=I.length;F=false;for(D=z;D<B;D++){H=I[D];for(C=D+1;C<B;C++){A=H+I[C];if(!E[A]&&this._requires(H,I[C])){G=I.splice(C,1);I.splice(D,0,G[0]);E[A]=true;F=true;break}}if(F){break}else{z++}}if(!F){break}}this.sorted=I},_insert:function(z,C,G,B){if(z){this._config(z)}if(!B){this.calculate(C)}var D=this.resolve(),H=this,F=0,E=0;if(G){D[((G===n)?t:n)]=[]}if(D.js.length){F++}if(D.css.length){F++}var A=function(M){E++;var I={},K=0,J="",L;if(M&&M.errors){for(K=0;K<M.errors.length;K++){if(M.errors[K].request){J=M.errors[K].request.url}else{J=M.errors[K]}I[J]=J}}if(M&&M.data&&M.data.length){for(K=0;K<M.data.length;K++){H.inserted[M.data[K].name]=true}}if(E===F){H._loading=null;if(M&&M.fn){L=M.fn;delete M.fn;L.call(H,M)}}};this._loading=true;if(!D.js.length&&!D.css.length){E=-1;A({fn:H._onSuccess});return}if(D.css.length){g.Get.css(D.css,{data:D.cssMods,insertBefore:H.insertBefore,charset:H.charset,timeout:H.timeout,context:H,onProgress:function(I){H._onProgress.call(H,I)},onTimeout:function(I){I.fn=H._onTimeout;A.call(H,I)},onSuccess:function(I){I.fn=H._onSuccess;A.call(H,I)},onFailure:function(I){I.fn=H._onFailure;A.call(H,I)}})}if(D.js.length){g.Get.script(D.js,{data:D.jsMods,insertBefore:H.insertBefore,charset:H.charset,timeout:H.timeout,autopurge:false,context:H,async:true,onProgress:function(I){H._onProgress.call(H,I)},onTimeout:function(I){I.fn=H._onTimeout;A.call(H,I)},onSuccess:function(I){I.fn=H._onSuccess;A.call(H,I)},onFailure:function(I){I.fn=H._onFailure;A.call(H,I)}})}},_continue:function(){if(!(k.running)&&k.size()>0){k.running=true;k.next()()}},insert:function(C,A,B){var z=this,D=g.merge(this);delete D.require;delete D.dirty;k.add(function(){z._insert(D,C,A,B)});this._continue()},loadNext:function(z){return},_filter:function(B,A){var D=this.filter,z=A&&(A in this.filters),C=z&&this.filters[A],E=this.moduleInfo[A]?this.moduleInfo[A].group:null;if(E&&this.groups[E]&&this.groups[E].filter){C=this.groups[E].filter;z=true}if(B){if(z){D=(l.isString(C))?this.FILTER_DEFS[C.toUpperCase()]||null:C}if(D){B=B.replace(new RegExp(D.searchExp,"g"),D.replaceStr)}}return B},_url:function(B,z,A){return this._filter((A||this.base||"")+B,z)},resolve:function(A,R){var aa,Z,X,H,M,J,W,L,Q,Y,B,K,U,G,ad,I,ab,P=[],N,T,D={},S=this,z,C,ac=[],E=(S.ignoreRegistered)?{}:S.inserted,V={js:[],jsMods:[],css:[],cssMods:[]},F=S.loadType||"js";if(A){S.calculate()}R=R||S.sorted;var O=function(ae){if(ae){L=(ae.group&&S.groups[ae.group])||i;H=(ae.fullpath)?S._filter(ae.fullpath,R[Z]):S._url(ae.path,R[Z],L.base||ae.base);V[ae.type].push(H);V[ae.type+"Mods"].push(ae)}else{}};aa=R.length;ad=S.comboBase;H=ad;U={};for(Z=0;Z<aa;Z++){K=ad;X=S.getModule(R[Z]);Q=X&&X.group;L=S.groups[Q];if(Q&&L){if(!L.combine){O(X);continue}X.combine=true;if(L.comboBase){K=L.comboBase}if("root" in L&&l.isValue(L.root)){X.root=L.root}X.comboSep=L.comboSep||S.comboSep;X.maxURLLength=L.maxURLLength||S.maxURLLength}else{if(!S.combine){O(X);continue}}U[K]=U[K]||[];U[K].push(X)}for(Y in U){if(U.hasOwnProperty(Y)){D[Y]=D[Y]||{js:[],jsMods:[],css:[],cssMods:[]};H=Y;G=U[Y];aa=G.length;if(aa){for(Z=0;Z<aa;Z++){if(E[G[Z]]){continue}X=G[Z];if(X&&(X.combine||!X.ext)){D[Y].comboSep=X.comboSep;D[Y].maxURLLength=X.maxURLLength;B=((l.isValue(X.root))?X.root:S.root)+(X.path||X.fullpath);B=S._filter(B,X.name);D[Y][X.type].push(B);D[Y][X.type+"Mods"].push(X)}else{if(G[Z]){O(G[Z])}}}}}}for(Y in D){I=Y;z=D[I].comboSep||S.comboSep;C=D[I].maxURLLength||S.maxURLLength;for(F in D[I]){if(F===n||F===t){ab=D[I][F];G=D[I][F+"Mods"];aa=ab.length;N=I+ab.join(z);T=N.length;if(C<=I.length){C=p}if(aa){if(T>C){P=[];for(R=0;R<aa;R++){P.push(ab[R]);N=I+P.join(z);if(N.length>C){X=P.pop();N=I+P.join(z);V[F].push(N);P=[];if(X){P.push(X)}}}if(P.length){N=I+P.join(z);V[F].push(N)}}else{V[F].push(N)}}V[F+"Mods"]=V[F+"Mods"].concat(G)}}}D=null;return V}}},"@VERSION@",{requires:["get","features"]});b.Env.core.push("loader-base");var c=b();window.YUILoader=c.Loader;c.Loader.prototype.load=function(d){var e=this,f=e.resolve(true);e.data=f;e.onEnd=function(){d.apply(e.context||window,arguments)};e.insert()}}());
BIN  build/loader-zip.js.gz
Binary file not shown
7,307 build/loader.js
7,307 additions, 0 deletions not shown
1,208 js/get.js
... ... @@ -0,0 +1,1208 @@
  1 +YUI.add('get', function(Y) {
  2 +
  3 +/*jslint boss:true, expr:true, laxbreak: true */
  4 +
  5 +/**
  6 +Provides dynamic loading of remote JavaScript and CSS resources.
  7 +
  8 +@module get
  9 +@class Get
  10 +@static
  11 +**/
  12 +
  13 +var Lang = Y.Lang,
  14 + Get, Transaction;
  15 +
  16 +Y.Get = Get = {
  17 + // -- Public Properties ----------------------------------------------------
  18 +
  19 + /**
  20 + Default options for CSS requests. Options specified here will override
  21 + global defaults for CSS requests.
  22 +
  23 + See the `options` property for all available options.
  24 +
  25 + @property cssOptions
  26 + @type Object
  27 + @static
  28 + @since 3.5.0
  29 + **/
  30 + cssOptions: {
  31 + attributes: {
  32 + rel: 'stylesheet'
  33 + },
  34 +
  35 + doc : Y.config.linkDoc || Y.config.doc,
  36 + pollInterval: 50
  37 + },
  38 +
  39 + /**
  40 + Default options for JS requests. Options specified here will override global
  41 + defaults for JS requests.
  42 +
  43 + See the `options` property for all available options.
  44 +
  45 + @property jsOptions
  46 + @type Object
  47 + @static
  48 + @since 3.5.0
  49 + **/
  50 + jsOptions: {
  51 + autopurge: true,
  52 + doc : Y.config.scriptDoc || Y.config.doc
  53 + },
  54 +
  55 + /**
  56 + Default options to use for all requests.
  57 +
  58 + Note that while all available options are documented here for ease of
  59 + discovery, some options (like callback functions) only make sense at the
  60 + transaction level.
  61 +
  62 + Callback functions specified via the options object or the `options`
  63 + parameter of the `css()`, `js()`, or `load()` methods will receive the
  64 + transaction object as a parameter. See `Y.Get.Transaction` for details on
  65 + the properties and methods available on transactions.
  66 +
  67 + @static
  68 + @since 3.5.0
  69 + @property {Object} options
  70 +
  71 + @property {Boolean} [options.async=false] Whether or not to load scripts
  72 + asynchronously, meaning they're requested in parallel and execution
  73 + order is not guaranteed. Has no effect on CSS, since CSS is always
  74 + loaded asynchronously.
  75 +
  76 + @property {Object} [options.attributes] HTML attribute name/value pairs that
  77 + should be added to inserted nodes. By default, the `charset` attribute
  78 + will be set to "utf-8" and nodes will be given an auto-generated `id`
  79 + attribute, but you can override these with your own values if desired.
  80 +
  81 + @property {Boolean} [options.autopurge] Whether or not to automatically
  82 + purge inserted nodes after the purge threshold is reached. This is
  83 + `true` by default for JavaScript, but `false` for CSS since purging a
  84 + CSS node will also remove any styling applied by the referenced file.
  85 +
  86 + @property {Object} [options.context] `this` object to use when calling
  87 + callback functions. Defaults to the transaction object.
  88 +
  89 + @property {Mixed} [options.data] Arbitrary data object to pass to "on*"
  90 + callbacks.
  91 +
  92 + @property {Document} [options.doc] Document into which nodes should be
  93 + inserted. By default, the current document is used.
  94 +
  95 + @property {HTMLElement|String} [options.insertBefore] HTML element or id
  96 + string of an element before which all generated nodes should be
  97 + inserted. If not specified, Get will automatically determine the best
  98 + place to insert nodes for maximum compatibility.
  99 +
  100 + @property {Function} [options.onEnd] Callback to execute after a transaction
  101 + is complete, regardless of whether it succeeded or failed.
  102 +
  103 + @property {Function} [options.onFailure] Callback to execute after a
  104 + transaction fails, times out, or is aborted.
  105 +
  106 + @property {Function} [options.onProgress] Callback to execute after each
  107 + individual request in a transaction either succeeds or fails.
  108 +
  109 + @property {Function} [options.onSuccess] Callback to execute after a
  110 + transaction completes successfully with no errors. Note that in browsers
  111 + that don't support the `error` event on CSS `<link>` nodes, a failed CSS
  112 + request may still be reported as a success because in these browsers
  113 + it can be difficult or impossible to distinguish between success and
  114 + failure for CSS resources.
  115 +
  116 + @property {Function} [options.onTimeout] Callback to execute after a
  117 + transaction times out.
  118 +
  119 + @property {Number} [options.pollInterval=50] Polling interval (in
  120 + milliseconds) for detecting CSS load completion in browsers that don't
  121 + support the `load` event on `<link>` nodes. This isn't used for
  122 + JavaScript.
  123 +
  124 + @property {Number} [options.purgethreshold=20] Number of nodes to insert
  125 + before triggering an automatic purge when `autopurge` is `true`.
  126 +
  127 + @property {Number} [options.timeout] Number of milliseconds to wait before
  128 + aborting a transaction. When a timeout occurs, the `onTimeout` callback
  129 + is called, followed by `onFailure` and finally `onEnd`. By default,
  130 + there is no timeout.
  131 +
  132 + @property {String} [options.type] Resource type ("css" or "js"). This option
  133 + is set automatically by the `css()` and `js()` functions and will be
  134 + ignored there, but may be useful when using the `load()` function. If
  135 + not specified, the type will be inferred from the URL, defaulting to
  136 + "js" if the URL doesn't contain a recognizable file extension.
  137 + **/
  138 + options: {
  139 + attributes: {
  140 + charset: 'utf-8'
  141 + },
  142 +
  143 + purgethreshold: 20
  144 + },
  145 +
  146 + // -- Protected Properties -------------------------------------------------
  147 +
  148 + /**
  149 + Regex that matches a CSS URL. Used to guess the file type when it's not
  150 + specified.
  151 +
  152 + @property REGEX_CSS
  153 + @type RegExp
  154 + @final
  155 + @protected
  156 + @static
  157 + @since 3.5.0
  158 + **/
  159 + REGEX_CSS: /\.css(?:[?;].*)?$/i,
  160 +
  161 + /**
  162 + Regex that matches a JS URL. Used to guess the file type when it's not
  163 + specified.
  164 +
  165 + @property REGEX_JS
  166 + @type RegExp
  167 + @final
  168 + @protected
  169 + @static
  170 + @since 3.5.0
  171 + **/
  172 + REGEX_JS : /\.js(?:[?;].*)?$/i,
  173 +
  174 + /**
  175 + Contains information about the current environment, such as what script and
  176 + link injection features it supports.
  177 +
  178 + This object is created and populated the first time the `_getEnv()` method
  179 + is called.
  180 +
  181 + @property _env
  182 + @type Object
  183 + @protected
  184 + @static
  185 + @since 3.5.0
  186 + **/
  187 +
  188 + /**
  189 + Mapping of document _yuid strings to <head> or <base> node references so we
  190 + don't have to look the node up each time we want to insert a request node.
  191 +
  192 + @property _insertCache
  193 + @type Object
  194 + @protected
  195 + @static
  196 + @since 3.5.0
  197 + **/
  198 + _insertCache: {},
  199 +
  200 + /**
  201 + Information about the currently pending transaction, if any.
  202 +
  203 + This is actually an object with two properties: `callback`, containing the
  204 + optional callback passed to `css()`, `load()`, or `js()`; and `transaction`,
  205 + containing the actual transaction instance.
  206 +
  207 + @property _pending
  208 + @type Object
  209 + @protected
  210 + @static
  211 + @since 3.5.0
  212 + **/
  213 + _pending: null,
  214 +
  215 + /**
  216 + HTML nodes eligible to be purged next time autopurge is triggered.
  217 +
  218 + @property _purgeNodes
  219 + @type HTMLElement[]
  220 + @protected
  221 + @static
  222 + @since 3.5.0
  223 + **/
  224 + _purgeNodes: [],
  225 +
  226 + /**
  227 + Queued transactions and associated callbacks.
  228 +
  229 + @property _queue
  230 + @type Object[]
  231 + @protected
  232 + @static
  233 + @since 3.5.0
  234 + **/
  235 + _queue: [],
  236 +
  237 + // -- Public Methods -------------------------------------------------------
  238 +
  239 + /**
  240 + Aborts the specified transaction.
  241 +
  242 + This will cause the transaction's `onFailure` callback to be called and
  243 + will prevent any new script and link nodes from being added to the document,
  244 + but any resources that have already been requested will continue loading
  245 + (there's no safe way to prevent this, unfortunately).
  246 +
  247 + *Note:* This method is deprecated as of 3.5.0, and will be removed in a
  248 + future version of YUI. Use the transaction-level `abort()` method instead.
  249 +
  250 + @method abort
  251 + @param {Get.Transaction} transaction Transaction to abort.
  252 + @deprecated Use the `abort()` method on the transaction instead.
  253 + @static
  254 + **/
  255 + abort: function (transaction) {
  256 + var i, id, item, len, pending;
  257 +
  258 +
  259 + if (!transaction.abort) {
  260 + id = transaction;
  261 + pending = this._pending;
  262 + transaction = null;
  263 +
  264 + if (pending && pending.transaction.id === id) {
  265 + transaction = pending.transaction;
  266 + this._pending = null;
  267 + } else {
  268 + for (i = 0, len = this._queue.length; i < len; ++i) {
  269 + item = this._queue[i].transaction;
  270 +
  271 + if (item.id === id) {
  272 + transaction = item;
  273 + this._queue.splice(i, 1);
  274 + break;
  275 + }
  276 + }
  277 + }
  278 + }
  279 +
  280 + transaction && transaction.abort();
  281 + },
  282 +
  283 + /**
  284 + Loads one or more CSS files.
  285 +
  286 + The _urls_ parameter may be provided as a URL string, a request object,
  287 + or an array of URL strings and/or request objects.
  288 +
  289 + A request object is just an object that contains a `url` property and zero
  290 + or more options that should apply specifically to that request.
  291 + Request-specific options take priority over transaction-level options and
  292 + default options.
  293 +
  294 + URLs may be relative or absolute, and do not have to have the same origin
  295 + as the current page.
  296 +
  297 + The `options` parameter may be omitted completely and a callback passed in
  298 + its place, if desired.
  299 +
  300 + @example
  301 +
  302 + // Load a single CSS file and log a message on completion.
  303 + Y.Get.css('foo.css', function (err) {
  304 + if (err) {
  305 + } else {
  306 + }
  307 + });
  308 +
  309 + // Load multiple CSS files and log a message when all have finished
  310 + // loading.
  311 + var urls = ['foo.css', 'http://example.com/bar.css', 'baz/quux.css'];
  312 +
  313 + Y.Get.css(urls, function (err) {
  314 + if (err) {
  315 + } else {
  316 + }
  317 + });
  318 +
  319 + // Specify transaction-level options, which will apply to all requests
  320 + // within the transaction.
  321 + Y.Get.css(urls, {
  322 + attributes: {'class': 'my-css'},
  323 + timeout : 5000
  324 + });
  325 +
  326 + // Specify per-request options, which override transaction-level and
  327 + // default options.
  328 + Y.Get.css([
  329 + {url: 'foo.css', attributes: {id: 'foo'}},
  330 + {url: 'bar.css', attributes: {id: 'bar', charset: 'iso-8859-1'}}
  331 + ]);
  332 +
  333 + @method css
  334 + @param {String|Object|Array} urls URL string, request object, or array
  335 + of URLs and/or request objects to load.
  336 + @param {Object} [options] Options for this transaction. See the
  337 + `Y.Get.options` property for a complete list of available options.
  338 + @param {Function} [callback] Callback function to be called on completion.
  339 + This is a general callback and will be called before any more granular
  340 + callbacks (`onSuccess`, `onFailure`, etc.) specified in the `options`
  341 + object.
  342 +
  343 + @param {Array|null} callback.err Array of errors that occurred during
  344 + the transaction, or `null` on success.
  345 + @param {Get.Transaction} callback.transaction Transaction object.
  346 +
  347 + @return {Get.Transaction} Transaction object.
  348 + @static
  349 + **/
  350 + css: function (urls, options, callback) {
  351 + return this._load('css', urls, options, callback);
  352 + },
  353 +
  354 + /**
  355 + Loads one or more JavaScript resources.
  356 +
  357 + The _urls_ parameter may be provided as a URL string, a request object,
  358 + or an array of URL strings and/or request objects.
  359 +
  360 + A request object is just an object that contains a `url` property and zero
  361 + or more options that should apply specifically to that request.
  362 + Request-specific options take priority over transaction-level options and
  363 + default options.
  364 +
  365 + URLs may be relative or absolute, and do not have to have the same origin
  366 + as the current page.
  367 +
  368 + The `options` parameter may be omitted completely and a callback passed in
  369 + its place, if desired.
  370 +
  371 + Scripts will be executed in the order they're specified unless the `async`
  372 + option is `true`, in which case they'll be loaded in parallel and executed
  373 + in whatever order they finish loading.
  374 +
  375 + @example
  376 +
  377 + // Load a single JS file and log a message on completion.
  378 + Y.Get.js('foo.js', function (err) {
  379 + if (err) {
  380 + } else {
  381 + }
  382 + });
  383 +
  384 + // Load multiple JS files, execute them in order, and log a message when
  385 + // all have finished loading.
  386 + var urls = ['foo.js', 'http://example.com/bar.js', 'baz/quux.js'];
  387 +
  388 + Y.Get.js(urls, function (err) {
  389 + if (err) {
  390 + } else {
  391 + }
  392 + });
  393 +
  394 + // Specify transaction-level options, which will apply to all requests
  395 + // within the transaction.
  396 + Y.Get.js(urls, {
  397 + attributes: {'class': 'my-js'},
  398 + timeout : 5000
  399 + });
  400 +
  401 + // Specify per-request options, which override transaction-level and
  402 + // default options.
  403 + Y.Get.js([
  404 + {url: 'foo.js', attributes: {id: 'foo'}},
  405 + {url: 'bar.js', attributes: {id: 'bar', charset: 'iso-8859-1'}}
  406 + ]);
  407 +
  408 + @method js
  409 + @param {String|Object|Array} urls URL string, request object, or array
  410 + of URLs and/or request objects to load.
  411 + @param {Object} [options] Options for this transaction. See the
  412 + `Y.Get.options` property for a complete list of available options.
  413 + @param {Function} [callback] Callback function to be called on completion.
  414 + This is a general callback and will be called before any more granular
  415 + callbacks (`onSuccess`, `onFailure`, etc.) specified in the `options`
  416 + object.
  417 +
  418 + @param {Array|null} callback.err Array of errors that occurred during
  419 + the transaction, or `null` on success.
  420 + @param {Get.Transaction} callback.transaction Transaction object.
  421 +
  422 + @return {Get.Transaction} Transaction object.
  423 + @since 3.5.0
  424 + @static
  425 + **/
  426 + js: function (urls, options, callback) {
  427 + return this._load('js', urls, options, callback);
  428 + },
  429 +
  430 + /**
  431 + Loads one or more CSS and/or JavaScript resources in the same transaction.
  432 +
  433 + Use this method when you want to load both CSS and JavaScript in a single
  434 + transaction and be notified when all requested URLs have finished loading,
  435 + regardless of type.
  436 +
  437 + Behavior and options are the same as for the `css()` and `js()` methods. If
  438 + a resource type isn't specified in per-request options or transaction-level
  439 + options, Get will guess the file type based on the URL's extension (`.css`
  440 + or `.js`, with or without a following query string). If the file type can't
  441 + be guessed from the URL, a warning will be logged and Get will assume the
  442 + URL is a JavaScript resource.
  443 +
  444 + @example
  445 +
  446 + // Load both CSS and JS files in a single transaction, and log a message
  447 + // when all files have finished loading.
  448 + Y.Get.load(['foo.css', 'bar.js', 'baz.css'], function (err) {
  449 + if (err) {
  450 + } else {
  451 + }
  452 + });
  453 +
  454 + @method load
  455 + @param {String|Object|Array} urls URL string, request object, or array
  456 + of URLs and/or request objects to load.
  457 + @param {Object} [options] Options for this transaction. See the
  458 + `Y.Get.options` property for a complete list of available options.
  459 + @param {Function} [callback] Callback function to be called on completion.
  460 + This is a general callback and will be called before any more granular
  461 + callbacks (`onSuccess`, `onFailure`, etc.) specified in the `options`
  462 + object.
  463 +
  464 + @param {Array|null} err Array of errors that occurred during the
  465 + transaction, or `null` on success.
  466 + @param {Get.Transaction} Transaction object.
  467 +
  468 + @return {Get.Transaction} Transaction object.
  469 + @since 3.5.0
  470 + @static
  471 + **/
  472 + load: function (urls, options, callback) {
  473 + return this._load(null, urls, options, callback);
  474 + },
  475 +
  476 + // -- Protected Methods ----------------------------------------------------
  477 +
  478 + /**
  479 + Triggers an automatic purge if the purge threshold has been reached.
  480 +
  481 + @method _autoPurge
  482 + @param {Number} threshold Purge threshold to use, in milliseconds.
  483 + @protected
  484 + @since 3.5.0
  485 + @static
  486 + **/
  487 + _autoPurge: function (threshold) {
  488 + if (threshold && this._purgeNodes.length >= threshold) {
  489 + this._purge(this._purgeNodes);
  490 + }
  491 + },
  492 +
  493 + /**
  494 + Populates the `_env` property with information about the current
  495 + environment.
  496 +
  497 + @method _getEnv
  498 + @return {Object} Environment information.
  499 + @protected
  500 + @since 3.5.0
  501 + @static
  502 + **/
  503 + _getEnv: function () {
  504 + var doc = Y.config.doc,
  505 + ua = Y.UA;
  506 +
  507 + // Note: some of these checks require browser sniffs since it's not
  508 + // feasible to load test files on every pageview just to perform a
  509 + // feature test. I'm sorry if this makes you sad.
  510 + return (this._env = {
  511 + // True if this is a browser that supports disabling async mode on
  512 + // dynamically created script nodes. See
  513 + // https://developer.mozilla.org/En/HTML/Element/Script#Attributes
  514 + async: doc && doc.createElement('script').async === true,
  515 +
  516 + // True if this browser fires an event when a dynamically injected
  517 + // link node finishes loading. This is currently true for IE, Opera,
  518 + // and Firefox 9+. Note that IE versions <9 fire the DOM 0 "onload"
  519 + // event, but not "load". All versions of IE fire "onload".
  520 + cssLoad: !!(ua.gecko ? ua.gecko >= 9 : !ua.webkit),
  521 +
  522 + // True if this browser preserves script execution order while
  523 + // loading scripts in parallel as long as the script node's `async`
  524 + // attribute is set to false to explicitly disable async execution.
  525 + preservesScriptOrder: !!(ua.gecko || ua.opera)
  526 + });
  527 + },
  528 +
  529 + _getTransaction: function (urls, options) {
  530 + var requests = [],
  531 + i, len, req, url;
  532 +
  533 + if (!Lang.isArray(urls)) {
  534 + urls = [urls];
  535 + }
  536 +
  537 + for (i = 0, len = urls.length; i < len; ++i) {
  538 + url = urls[i];
  539 + req = {attributes: {}};
  540 +
  541 + // If `url` is a string, we create a URL object for it, then mix in
  542 + // global options and request-specific options. If it's an object
  543 + // with a "url" property, we assume it's a request object containing
  544 + // URL-specific options.
  545 + if (typeof url === 'string') {
  546 + req.url = url;
  547 + } else if (url.url) {
  548 + // URL-specific options override both global defaults and
  549 + // request-specific options.
  550 + Y.mix(req, url, false, null, 0, true);
  551 + url = url.url; // Make url a string so we can use it later.
  552 + } else {
  553 + continue;
  554 + }
  555 +
  556 + Y.mix(req, options, false, null, 0, true);
  557 + Y.mix(req, this.options, false, null, 0, true);
  558 +
  559 + // If we didn't get an explicit type for this URL either in the
  560 + // request options or the URL-specific options, try to determine
  561 + // one from the file extension.
  562 + if (!req.type) {
  563 + if (this.REGEX_CSS.test(url)) {
  564 + req.type = 'css';
  565 + } else {
  566 + if (!this.REGEX_JS.test(url)) {
  567 + }
  568 +
  569 + req.type = 'js';
  570 + }
  571 + }
  572 +
  573 + // Mix in type-specific default options, but don't overwrite any
  574 + // options that have already been set.
  575 + Y.mix(req, req.type === 'js' ? this.jsOptions : this.cssOptions,
  576 + false, null, 0, true);
  577 +
  578 + // Give the node an id attribute if it doesn't already have one.
  579 + req.attributes.id || (req.attributes.id = Y.guid());
  580 +
  581 + // Backcompat for <3.5.0 behavior.
  582 + if (req.win) {
  583 + req.doc = req.win.document;
  584 + } else {
  585 + req.win = req.doc.defaultView || req.doc.parentWindow;
  586 + }
  587 +
  588 + if (req.charset) {
  589 + req.attributes.charset = req.charset;
  590 + }
  591 +
  592 + requests.push(req);
  593 + }
  594 +
  595 + return new Transaction(requests, options);
  596 + },
  597 +
  598 + _load: function (type, urls, options, callback) {
  599 + var transaction;
  600 +
  601 + // Allow callback as third param.
  602 + if (typeof options === 'function') {
  603 + callback = options;
  604 + options = {};
  605 + }
  606 +
  607 + options || (options = {});
  608 + options.type = type;
  609 +
  610 + if (!this._env) {
  611 + this._getEnv();
  612 + }
  613 +
  614 + transaction = this._getTransaction(urls, options);
  615 +
  616 + this._queue.push({
  617 + callback : callback,
  618 + transaction: transaction
  619 + });
  620 +
  621 + this._next();
  622 +
  623 + return transaction;
  624 + },
  625 +
  626 + _next: function () {
  627 + var item;
  628 +
  629 + if (this._pending) {
  630 + return;
  631 + }
  632 +
  633 + item = this._queue.shift();
  634 +
  635 + if (item) {
  636 + this._pending = item;
  637 +
  638 + item.transaction.execute(function () {
  639 + item.callback && item.callback.apply(this, arguments);
  640 +
  641 + Get._pending = null;
  642 + Get._next();
  643 + });
  644 + }
  645 + },
  646 +
  647 + _purge: function (nodes) {
  648 + var purgeNodes = this._purgeNodes,
  649 + isTransaction = nodes !== purgeNodes,
  650 + index, node;
  651 +
  652 + while (node = nodes.pop()) { // assignment
  653 + // Don't purge nodes that haven't finished loading (or errored out),
  654 + // since this can hang the transaction.
  655 + if (!node._yuiget_finished) {
  656 + continue;
  657 + }
  658 +
  659 + node.parentNode && node.parentNode.removeChild(node);
  660 +
  661 + // If this is a transaction-level purge and this node also exists in
  662 + // the Get-level _purgeNodes array, we need to remove it from
  663 + // _purgeNodes to avoid creating a memory leak. The indexOf lookup
  664 + // sucks, but until we get WeakMaps, this is the least troublesome
  665 + // way to do this (we can't just hold onto node ids because they may
  666 + // not be in the same document).
  667 + if (isTransaction) {
  668 + index = Y.Array.indexOf(purgeNodes, node);
  669 +
  670 + if (index > -1) {
  671 + purgeNodes.splice(index, 1);
  672 + }
  673 + }
  674 + }
  675 + }
  676 +};
  677 +
  678 +/**
  679 +Alias for `js()`.
  680 +
  681 +@method script
  682 +@static
  683 +**/
  684 +Get.script = Get.js;
  685 +
  686 +/**
  687 +Represents a Get transaction, which may contain requests for one or more JS or
  688 +CSS files.
  689 +
  690 +This class should not be instantiated manually. Instances will be created and
  691 +returned as needed by Y.Get's `css()`, `js()`, and `load()` methods.
  692 +
  693 +@class Get.Transaction
  694 +@constructor
  695 +@since 3.5.0
  696 +**/
  697 +Get.Transaction = Transaction = function (requests, options) {
  698 + var self = this;
  699 +
  700 + self.id = Transaction._lastId += 1;
  701 + self.data = options.data;
  702 + self.errors = [];
  703 + self.nodes = [];
  704 + self.options = options;
  705 + self.requests = requests;
  706 +
  707 + self._callbacks = []; // callbacks to call after execution finishes
  708 + self._queue = [];
  709 + self._waiting = 0;
  710 +
  711 + // Deprecated pre-3.5.0 properties.
  712 + self.tId = self.id; // Use `id` instead.
  713 + self.win = options.win || Y.config.win;
  714 +};
  715 +
  716 +/**
  717 +Arbitrary data object associated with this transaction.
  718 +
  719 +This object comes from the options passed to `Get.css()`, `Get.js()`, or
  720 +`Get.load()`, and will be `undefined` if no data object was specified.
  721 +
  722 +@property {Object} data
  723 +**/
  724 +
  725 +/**
  726 +Array of errors that have occurred during this transaction, if any.
  727 +
  728 +@since 3.5.0
  729 +@property {Object[]} errors
  730 +@property {String} errors.error Error message.
  731 +@property {Object} errors.request Request object related to the error.
  732 +**/
  733 +
  734 +/**
  735 +Numeric id for this transaction, unique among all transactions within the same
  736 +YUI sandbox in the current pageview.
  737 +
  738 +@property {Number} id
  739 +@since 3.5.0
  740 +**/
  741 +
  742 +/**
  743 +HTMLElement nodes (native ones, not YUI Node instances) that have been inserted
  744 +during the current transaction.
  745 +
  746 +@property {HTMLElement[]} nodes
  747 +**/
  748 +
  749 +/**
  750 +Options associated with this transaction.
  751 +
  752 +See `Get.options` for the full list of available options.
  753 +
  754 +@property {Object} options
  755 +@since 3.5.0
  756 +**/
  757 +
  758 +/**
  759 +Request objects contained in this transaction. Each request object represents
  760 +one CSS or JS URL that will be (or has been) requested and loaded into the page.
  761 +
  762 +@property {Object} requests
  763 +@since 3.5.0
  764 +**/
  765 +
  766 +/**
  767 +Id of the most recent transaction.
  768 +
  769 +@property _lastId
  770 +@type Number
  771 +@protected
  772 +@static
  773 +**/
  774 +Transaction._lastId = 0;
  775 +
  776 +Transaction.prototype = {
  777 + // -- Public Properties ----------------------------------------------------
  778 +
  779 + /**
  780 + Current state of this transaction. One of "new", "executing", or "done".
  781 +
  782 + @property _state
  783 + @type String
  784 + @protected
  785 + **/
  786 + _state: 'new', // "new", "executing", or "done"
  787 +
  788 + // -- Public Methods -------------------------------------------------------
  789 +
  790 + /**
  791 + Aborts this transaction.
  792 +
  793 + This will cause the transaction's `onFailure` callback to be called and
  794 + will prevent any new script and link nodes from being added to the document,
  795 + but any resources that have already been requested will continue loading
  796 + (there's no safe way to prevent this, unfortunately).
  797 +
  798 + @method abort
  799 + @param {String} [msg="Aborted."] Optional message to use in the `errors`
  800 + array describing why the transaction was aborted.
  801 + **/
  802 + abort: function (msg) {
  803 + this._pending = null;
  804 + this._pendingCSS = null;
  805 + this._pollTimer = clearTimeout(this._pollTimer);
  806 + this._queue = [];
  807 + this._waiting = 0;
  808 +
  809 + this.errors.push({error: msg || 'Aborted'});
  810 + this._finish();
  811 + },
  812 +
  813 + /**
  814 + Begins execting the transaction.
  815 +
  816 + There's usually no reason to call this manually, since Get will call it
  817 + automatically when other pending transactions have finished. If you really
  818 + want to execute your transaction before Get does, you can, but be aware that
  819 + this transaction's scripts may end up executing before the scripts in other
  820 + pending transactions.
  821 +
  822 + If the transaction is already executing, the specified callback (if any)
  823 + will be queued and called after execution finishes. If the transaction has
  824 + already finished, the callback will be called immediately (the transaction
  825 + will not be executed again).
  826 +
  827 + @method execute
  828 + @param {Function} callback Callback function to execute after all requests
  829 + in the transaction are complete, or after the transaction is aborted.
  830 + **/
  831 + execute: function (callback) {
  832 + var self = this,
  833 + requests = self.requests,
  834 + state = self._state,
  835 + i, len, queue, req;
  836 +
  837 + if (state === 'done') {
  838 + callback && callback(self.errors.length ? self.errors : null, self);
  839 + return;
  840 + } else {
  841 + callback && self._callbacks.push(callback);
  842 +
  843 + if (state === 'executing') {
  844 + return;
  845 + }
  846 + }
  847 +
  848 + self._state = 'executing';
  849 + self._queue = queue = [];
  850 +
  851 + if (self.options.timeout) {
  852 + self._timeout = setTimeout(function () {
  853 + self.abort('Timeout');
  854 + }, self.options.timeout);
  855 + }
  856 +
  857 + for (i = 0, len = requests.length; i < len; ++i) {
  858 + req = self.requests[i];
  859 +
  860 + if (req.async || req.type === 'css') {
  861 + // No need to queue CSS or fully async JS.
  862 + self._insert(req);
  863 + } else {
  864 + queue.push(req);
  865 + }
  866 + }
  867 +
  868 + self._next();
  869 + },
  870 +
  871 + /**
  872 + Manually purges any `<script>` or `<link>` nodes this transaction has
  873 + created.
  874 +
  875 + Be careful when purging a transaction that contains CSS requests, since
  876 + removing `<link>` nodes will also remove any styles they applied.
  877 +
  878 + @method purge
  879 + **/
  880 + purge: function () {
  881 + Get._purge(this.nodes);
  882 + },
  883 +
  884 + // -- Protected Methods ----------------------------------------------------
  885 + _createNode: function (name, attrs, doc) {
  886 + var node = doc.createElement(name),
  887 + attr;
  888 +
  889 + for (attr in attrs) {
  890 + if (attrs.hasOwnProperty(attr)) {
  891 + node.setAttribute(attr, attrs[attr]);
  892 + }
  893 + }
  894 +
  895 + return node;
  896 + },
  897 +
  898 + _finish: function () {
  899 + var errors = this.errors.length ? this.errors : null,
  900 + options = this.options,
  901 + thisObj = options.context || this,
  902 + data, i, len;
  903 +
  904 + if (this._state === 'done') {
  905 + return;
  906 + }
  907 +
  908 + this._state = 'done';
  909 +
  910 + for (i = 0, len = this._callbacks.length; i < len; ++i) {
  911 + this._callbacks[i].call(thisObj, errors, this);
  912 + }
  913 +
  914 + data = this._getEventData();
  915 +
  916 + if (errors) {
  917 + if (options.onTimeout && errors[errors.length - 1].error === 'Timeout') {
  918 + options.onTimeout.call(thisObj, data);
  919 + }
  920 +
  921 + if (options.onFailure) {
  922 + options.onFailure.call(thisObj, data);
  923 + }
  924 + } else if (options.onSuccess) {
  925 + options.onSuccess.call(thisObj, data);
  926 + }
  927 +
  928 + if (options.onEnd) {
  929 + options.onEnd.call(thisObj, data);
  930 + }
  931 + },
  932 +
  933 + _getEventData: function (req) {
  934 + if (req) {
  935 + // This merge is necessary for backcompat. I hate it.
  936 + return Y.merge(this, {
  937 + abort : this.abort, // have to copy these because the prototype isn't preserved
  938 + purge : this.purge,
  939 + request: req,
  940 + url : req.url,
  941 + win : req.win
  942 + });
  943 + } else {
  944 + return this;
  945 + }
  946 + },
  947 +
  948 + _getInsertBefore: function (req) {
  949 + var doc = req.doc,
  950 + el = req.insertBefore,
  951 + cache, cachedNode, docStamp;
  952 +
  953 + if (el) {
  954 + return typeof el === 'string' ? doc.getElementById(el) : el;
  955 + }
  956 +
  957 + cache = Get._insertCache;
  958 + docStamp = Y.stamp(doc);
  959 +
  960 + if ((el = cache[docStamp])) { // assignment
  961 + return el;
  962 + }
  963 +
  964 + // Inserting before a <base> tag apparently works around an IE bug
  965 + // (according to a comment from pre-3.5.0 Y.Get), but I'm not sure what
  966 + // bug that is, exactly. Better safe than sorry?
  967 + if ((el = doc.getElementsByTagName('base')[0])) { // assignment
  968 + return (cache[docStamp] = el);
  969 + }
  970 +
  971 + // Look for a <head> element.
  972 + el = doc.head || doc.getElementsByTagName('head')[0];
  973 +
  974 + if (el) {
  975 + // Create a marker node at the end of <head> to use as an insertion
  976 + // point. Inserting before this node will ensure that all our CSS
  977 + // gets inserted in the correct order, to maintain style precedence.
  978 + el.appendChild(doc.createTextNode(''));
  979 + return (cache[docStamp] = el.lastChild);
  980 + }
  981 +
  982 + // If all else fails, just insert before the first script node on the
  983 + // page, which is virtually guaranteed to exist.
  984 + return (cache[docStamp] = doc.getElementsByTagName('script')[0]);
  985 + },
  986 +
  987 + _insert: function (req) {
  988 + var env = Get._env,
  989 + insertBefore = this._getInsertBefore(req),
  990 + isScript = req.type === 'js',
  991 + node = req.node,
  992 + self = this,
  993 + ua = Y.UA,
  994 + nodeType;
  995 +
  996 + if (!node) {
  997 + if (isScript) {
  998 + nodeType = 'script';
  999 + } else if (!env.cssLoad && ua.gecko) {
  1000 + nodeType = 'style';
  1001 + } else {
  1002 + nodeType = 'link';
  1003 + }
  1004 +
  1005 + node = req.node = this._createNode(nodeType, req.attributes,
  1006 + req.doc);
  1007 + }
  1008 +
  1009 + function onError() {
  1010 + self._progress('Failed to load ' + req.url, req);
  1011 + }
  1012 +
  1013 + function onLoad() {
  1014 + self._progress(null, req);
  1015 + }
  1016 +
  1017 + // Deal with script asynchronicity.
  1018 + if (isScript) {
  1019 + node.setAttribute('src', req.url);
  1020 +
  1021 + if (req.async) {
  1022 + // Explicitly indicate that we want the browser to execute this
  1023 + // script asynchronously. This is necessary for older browsers
  1024 + // like Firefox <4.
  1025 + node.async = true;
  1026 + } else {
  1027 + if (env.async) {
  1028 + // This browser treats injected scripts as async by default
  1029 + // (standard HTML5 behavior) but asynchronous loading isn't
  1030 + // desired, so tell the browser not to mark this script as
  1031 + // async.
  1032 + node.async = false;
  1033 + }
  1034 +
  1035 + // If this browser doesn't preserve script execution order based
  1036 + // on insertion order, we'll need to avoid inserting other
  1037 + // scripts until this one finishes loading.
  1038 + if (!env.preservesScriptOrder) {
  1039 + this._pending = req;
  1040 + }
  1041 + }
  1042 + } else {
  1043 + if (!env.cssLoad && ua.gecko) {
  1044 + // In Firefox <9, we can import the requested URL into a <style>
  1045 + // node and poll for the existence of node.sheet.cssRules. This
  1046 + // gives us a reliable way to determine CSS load completion that
  1047 + // also works for cross-domain stylesheets.
  1048 + //
  1049 + // Props to Zach Leatherman for calling my attention to this
  1050 + // technique.
  1051 + node.innerHTML = (req.attributes.charset ?
  1052 + '@charset "' + req.attributes.charset + '";' : '') +
  1053 + '@import "' + req.url + '";';
  1054 + } else {
  1055 + node.setAttribute('href', req.url);
  1056 + }
  1057 + }
  1058 +
  1059 + // Inject the node.
  1060 + if (isScript && ua.ie && ua.