yui-pathogen-encoder
Version:
Enables pathogen encoding in YUI Loader
2 lines (1 loc) • 2.75 kB
JavaScript
YUI.add("gallery-pathogen-encoder",function(e,t){var n=e.Loader.prototype.resolve,r="p/",s=";",o="+",u=",",a=/-(min|debug).js/,f=/\.(?:js|css)$/,l=/^(?:yui:)?gallery-([^\/]+)/,c={js:!0,css:!0},h,p,d;e.Loader.prototype.buildCombo=function(e,t,n){var r=t,i=t.length+n.length,a,f,l,c,h,d,v,m;for(m=0,v=e.length;m<v;m+=1){d=e[m],a=r===t?"":s,f=d.key,c=d.modules;while(c.length){l=a+f,l=l?l+o:u,d.key.indexOf("path")===0&&(l=a),h=l+c[0];if(!(i+h.length<p))return r+n;r+=h,i+=h.length,c.shift(),a=f=""}}return r+=n,r.length===t.length+n.length&&(r=null),r},e.Loader.prototype.aggregateGroups=function(t){var n={},r,i,s,u,a,c,h;for(h=0,c=t.length;h<c;h+=1){u=t[h],s=u.name,i=this.groups&&this.groups[u.group];if(i){if(!i.combine||u.fullpath)continue}else if(!this.combine)continue;if(!u.combine&&u.ext)continue;u.group?u.group==="gallery"?(d||(r=l.exec(this.groups.gallery.root),d=r&&r[1]),s=s.split("gallery-").pop(),a="gallery"+o+d):u.path.indexOf(s+"/"+s)!==0?(a="path"+o+s,s=u.path.split(f).shift()):(a=i.root,a[0]==="/"&&(a=a.slice(1)),a[a.length-1]==="/"&&(a=a.slice(0,-1))):a="core"+o+YUI.version,n[a]=n[a]||[],n[a].push(s),e.config.customComboFallback&&(u.group==="gallery"&&(s="gallery-"+s),this.pathogenSeen[s]=!0)}return n},e.Loader.prototype.sortAggregatedGroups=function(e){var t=[],n,r,i;for(n in e)e.hasOwnProperty(n)&&t.push({key:n,modules:e[n]});t.sort(function(e,t){return e.key>t.key});for(i=0,r=t.length;i<r;i+=1)t[i].modules.sort();return t},e.Loader.prototype.customResolve=function(t,n){var r=this.aggregateGroups(t),i=this.sortAggregatedGroups(r),s=[],o,u,f,l;u||(f=a.exec(e.config.loaderPath),u=f&&f[1]||"raw",u=n==="css"&&u==="debug"?"raw":"min",o=u==="min"?"":"."+u,o=o+"."+n),l=this.buildCombo(i,h,o);while(l)s.push(l),l=this.buildCombo(i,h,o);return s},e.Loader.prototype.shouldFallback=function(e){var t,n,r;if(this.fallbackMode)return this.fallbackMode;for(r in c)if(c.hasOwnProperty(r)){t=e[r+"Mods"];for(i=0,len=t.length;i<len;i+=1){n=t[i].name;if(this.pathogenSeen[n])return this.fallbackMode=!0,this.fallbackMode}}},e.Loader.prototype.resolve=function(){var t=n.apply(this,arguments),i=this.combine,s,o,u,a,f,l,d,v,m,g,y;if(!i)for(d in this.groups)if(this.groups.hasOwnProperty(d)&&!i&&d.combine){i=d.combine;break}e.config.customComboBase&&(h=e.config.customComboBase+r);if(e.config.customComboFallback){this.pathogenSeen=this.pathogenSeen||{};if(this.shouldFallback(t))return t}if(h&&i){p=this.maxURLLength;for(v in c){if(!c.hasOwnProperty(v))continue;a=[],f=v,l=v+"Mods",t[f]=s=t[f]||[],t[l]=o=t[l]||[];for(y=0,g=s.length;y<g;y+=1)m=s[y],(typeof m=="object"||typeof m=="string"&&m.indexOf("/combo?")===-1)&&a.push(m);u=this.customResolve(o,v),JSON,t[v]=[].concat(u,a)}}return t}},"@VERSION@",{requires:["loader-base"]});