Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updating to 0.99

  • Loading branch information...
commit 8d8d7408a578bafc51b09006e26cac535bba127e 1 parent 70f17ad
@robert-hoffmann robert-hoffmann authored
View
2  README.md
@@ -13,7 +13,7 @@ This project was never announced. `git push` and it was all viral.
* [http://headjs.uservoice.com](http://headjs.uservoice.com/forums/182905-headjs-feature-suggestions)
-###0.99 / soon
+###0.99 / 2012-11-15
- Load: Fixed regression in IE6, caused by IE10 fix
- Load: CSS loading seems to work in all browsers.
View
8 dist/head.core.js
@@ -195,15 +195,12 @@
});
}
- api.router = {};
-
+
// CSS "router"
each(loc.pathname.split("/"), function (el, i) {
if (this.length > 2 && this[i + 1] !== undefined) {
if (i) {
- var test = this.slice(1, i + 1).join("-").toLowerCase() + conf.section;
- console.log(test);
- pushClass(test);
+ pushClass(this.slice(1, i + 1).join("-").toLowerCase() + conf.section);
}
} else {
// pageId
@@ -212,7 +209,6 @@
id = id.substring(0, index);
}
- api.router[conf.page.replace(/[^A-Z]/i, "")] = id.toLowerCase();
html.id = id.toLowerCase() + conf.page;
// on root?
View
13 dist/head.core.min.js
@@ -1,7 +1,6 @@
-(function(b,p){function e(c){l[l.length]=c}function q(c){i.className=i.className.replace(RegExp("\\b"+c+"\\b"),"")}function m(c,b){for(var a=0,e=c.length;a<e;a++)b.call(c,c[a],a)}function r(){i.className=i.className.replace(/ (w-|eq-|gt-|gte-|lt-|lte-|portrait|no-portrait|landscape|no-landscape)\d+/g,"");var a=b.innerWidth||i.clientWidth,j=b.outerWidth||b.screen.width;f.screen.innerWidth=a;f.screen.outerWidth=j;e("w-"+a);m(c.screens,function(b){a>b?(c.screensCss.gt&&e("gt-"+b),c.screensCss.gte&&e("gte-"+
-b)):a<b?(c.screensCss.lt&&e("lt-"+b),c.screensCss.lte&&e("lte-"+b)):a===b&&(c.screensCss.lte&&e("lte-"+b),c.screensCss.eq&&e("e-q"+b),c.screensCss.gte&&e("gte-"+b))});var j=b.innerHeight||i.clientHeight,d=b.outerHeight||b.screen.height;f.screen.innerHeight=j;f.screen.outerHeight=d;f.feature("portrait",j>a);f.feature("landscape",j<a)}function s(){b.clearTimeout(t);t=b.setTimeout(r,100)}var n=b.document,d=b.navigator,u=b.location,i=n.documentElement,l=[],c={screens:[240,320,480,640,768,800,1024,1280,
-1440,1680,1920],screensCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!1},browsers:[{ie:{min:6,max:10}}],browserCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!0},section:"-section",page:"-page",head:"head"};if(b.head_conf)for(var a in b.head_conf)b.head_conf[a]!==p&&(c[a]=b.head_conf[a]);var f=b[c.head]=function(){f.ready.apply(null,arguments)};f.feature=function(b,a,c){if(!b)return i.className+=" "+l.join(" "),l=[],f;"[object Function]"===Object.prototype.toString.call(a)&&(a=a.call());e((a?"":"no-")+b);f[b]=!!a;c||(q("no-"+
-b),q(b),f.feature());return f};f.feature("js",!0);a=d.userAgent.toLowerCase();d=/mobile|midp/.test(a);f.feature("mobile",d,!0);f.feature("desktop",!d,!0);a=/(chrome|firefox)[ \/]([\w.]+)/.exec(a)||/(iphone|ipad|ipod)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(android)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(webkit|opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||[];d=a[1];a=parseFloat(a[2]);switch(d){case "msie":d="ie";a=n.documentMode||a;break;case "firefox":d="ff";break;case "ipod":case "ipad":case "iphone":d=
-"ios";break;case "webkit":d="safari"}f.browser={name:d,version:a};f.browser[d]=!0;for(var k=0,v=c.browsers.length;k<v;k++)for(var g in c.browsers[k])if(d===g){e(g);for(var w=c.browsers[k][g].max,h=c.browsers[k][g].min;h<=w;h++)a>h?(c.browserCss.gt&&e("gt-"+g+h),c.browserCss.gte&&e("gte-"+g+h)):a<h?(c.browserCss.lt&&e("lt-"+g+h),c.browserCss.lte&&e("lte-"+g+h)):a===h&&(c.browserCss.lte&&e("lte-"+g+h),c.browserCss.eq&&e("eq-"+g+h),c.browserCss.gte&&e("gte-"+g+h))}else e("no-"+g);"ie"===d&&9>a&&m("abbr article aside audio canvas details figcaption figure footer header hgroup mark meter nav output progress section summary time video".split(" "),
-function(b){n.createElement(b)});f.router={};m(u.pathname.split("/"),function(b,a){if(2<this.length&&this[a+1]!==p){if(a){var d=this.slice(1,a+1).join("-").toLowerCase()+c.section;console.log(d);e(d)}}else{var d=b||"index",g=d.indexOf(".");0<g&&(d=d.substring(0,g));f.router[c.page.replace(/^[A-Z]/i)]=d.toLowerCase();i.id=d.toLowerCase()+c.page;a||e("root"+c.section)}});f.screen={height:b.screen.height,width:b.screen.width};r();var t=0;b.addEventListener?b.addEventListener("resize",s,!1):b.attachEvent("onresize",
-s)})(window);
+(function(b,p){function e(g){l[l.length]=g}function q(g){j.className=j.className.replace(RegExp("\\b"+g+"\\b"),"")}function m(g,c){for(var b=0,a=g.length;b<a;b++)c.call(g,g[b],b)}function r(){j.className=j.className.replace(/ (w-|eq-|gt-|gte-|lt-|lte-|portrait|no-portrait|landscape|no-landscape)\d+/g,"");var g=b.innerWidth||j.clientWidth,a=b.outerWidth||b.screen.width;d.screen.innerWidth=g;d.screen.outerWidth=a;e("w-"+g);m(c.screens,function(a){g>a?(c.screensCss.gt&&e("gt-"+a),c.screensCss.gte&&e("gte-"+
+a)):g<a?(c.screensCss.lt&&e("lt-"+a),c.screensCss.lte&&e("lte-"+a)):g===a&&(c.screensCss.lte&&e("lte-"+a),c.screensCss.eq&&e("e-q"+a),c.screensCss.gte&&e("gte-"+a))});var a=b.innerHeight||j.clientHeight,f=b.outerHeight||b.screen.height;d.screen.innerHeight=a;d.screen.outerHeight=f;d.feature("portrait",a>g);d.feature("landscape",a<g)}function s(){b.clearTimeout(t);t=b.setTimeout(r,100)}var n=b.document,f=b.navigator,u=b.location,j=n.documentElement,l=[],c={screens:[240,320,480,640,768,800,1024,1280,
+1440,1680,1920],screensCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!1},browsers:[{ie:{min:6,max:10}}],browserCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!0},section:"-section",page:"-page",head:"head"};if(b.head_conf)for(var a in b.head_conf)b.head_conf[a]!==p&&(c[a]=b.head_conf[a]);var d=b[c.head]=function(){d.ready.apply(null,arguments)};d.feature=function(a,b,c){if(!a)return j.className+=" "+l.join(" "),l=[],d;"[object Function]"===Object.prototype.toString.call(b)&&(b=b.call());e((b?"":"no-")+a);d[a]=!!b;c||(q("no-"+
+a),q(a),d.feature());return d};d.feature("js",!0);a=f.userAgent.toLowerCase();f=/mobile|midp/.test(a);d.feature("mobile",f,!0);d.feature("desktop",!f,!0);a=/(chrome|firefox)[ \/]([\w.]+)/.exec(a)||/(iphone|ipad|ipod)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(android)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(webkit|opera)(?:.*version)?[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||[];f=a[1];a=parseFloat(a[2]);switch(f){case "msie":f="ie";a=n.documentMode||a;break;case "firefox":f="ff";break;case "ipod":case "ipad":case "iphone":f=
+"ios";break;case "webkit":f="safari"}d.browser={name:f,version:a};d.browser[f]=!0;for(var k=0,v=c.browsers.length;k<v;k++)for(var h in c.browsers[k])if(f===h){e(h);for(var w=c.browsers[k][h].max,i=c.browsers[k][h].min;i<=w;i++)a>i?(c.browserCss.gt&&e("gt-"+h+i),c.browserCss.gte&&e("gte-"+h+i)):a<i?(c.browserCss.lt&&e("lt-"+h+i),c.browserCss.lte&&e("lte-"+h+i)):a===i&&(c.browserCss.lte&&e("lte-"+h+i),c.browserCss.eq&&e("eq-"+h+i),c.browserCss.gte&&e("gte-"+h+i))}else e("no-"+h);"ie"===f&&9>a&&m("abbr article aside audio canvas details figcaption figure footer header hgroup mark meter nav output progress section summary time video".split(" "),
+function(a){n.createElement(a)});m(u.pathname.split("/"),function(a,b){if(2<this.length&&this[b+1]!==p)b&&e(this.slice(1,b+1).join("-").toLowerCase()+c.section);else{var d=a||"index",f=d.indexOf(".");0<f&&(d=d.substring(0,f));j.id=d.toLowerCase()+c.page;b||e("root"+c.section)}});d.screen={height:b.screen.height,width:b.screen.width};r();var t=0;b.addEventListener?b.addEventListener("resize",s,!1):b.attachEvent("onresize",s)})(window);
View
8 dist/head.css3.js
@@ -195,15 +195,12 @@
});
}
- api.router = {};
-
+
// CSS "router"
each(loc.pathname.split("/"), function (el, i) {
if (this.length > 2 && this[i + 1] !== undefined) {
if (i) {
- var test = this.slice(1, i + 1).join("-").toLowerCase() + conf.section;
- console.log(test);
- pushClass(test);
+ pushClass(this.slice(1, i + 1).join("-").toLowerCase() + conf.section);
}
} else {
// pageId
@@ -212,7 +209,6 @@
id = id.substring(0, index);
}
- api.router[conf.page.replace(/[^A-Z]/i, "")] = id.toLowerCase();
html.id = id.toLowerCase() + conf.page;
// on root?
View
19 dist/head.css3.min.js
@@ -1,10 +1,9 @@
-(function(a,q){function e(b){r[r.length]=b}function m(b){j.className=j.className.replace(RegExp("\\b"+b+"\\b"),"")}function h(b,a){for(var e=0,j=b.length;e<j;e++)a.call(b,b[e],e)}function n(){j.className=j.className.replace(/ (w-|eq-|gt-|gte-|lt-|lte-|portrait|no-portrait|landscape|no-landscape)\d+/g,"");var d=a.innerWidth||j.clientWidth,c=a.outerWidth||a.screen.width;f.screen.innerWidth=d;f.screen.outerWidth=c;e("w-"+d);h(b.screens,function(a){d>a?(b.screensCss.gt&&e("gt-"+a),b.screensCss.gte&&e("gte-"+
-a)):d<a?(b.screensCss.lt&&e("lt-"+a),b.screensCss.lte&&e("lte-"+a)):d===a&&(b.screensCss.lte&&e("lte-"+a),b.screensCss.eq&&e("e-q"+a),b.screensCss.gte&&e("gte-"+a))});var c=a.innerHeight||j.clientHeight,g=a.outerHeight||a.screen.height;f.screen.innerHeight=c;f.screen.outerHeight=g;f.feature("portrait",c>d);f.feature("landscape",c<d)}function s(){a.clearTimeout(t);t=a.setTimeout(n,100)}var k=a.document,c=a.navigator,l=a.location,j=k.documentElement,r=[],b={screens:[240,320,480,640,768,800,1024,1280,
-1440,1680,1920],screensCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!1},browsers:[{ie:{min:6,max:10}}],browserCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!0},section:"-section",page:"-page",head:"head"};if(a.head_conf)for(var d in a.head_conf)a.head_conf[d]!==q&&(b[d]=a.head_conf[d]);var f=a[b.head]=function(){f.ready.apply(null,arguments)};f.feature=function(a,b,d){if(!a)return j.className+=" "+r.join(" "),r=[],f;"[object Function]"===Object.prototype.toString.call(b)&&(b=b.call());e((b?"":"no-")+a);f[a]=!!b;d||(m("no-"+
-a),m(a),f.feature());return f};f.feature("js",!0);d=c.userAgent.toLowerCase();c=/mobile|midp/.test(d);f.feature("mobile",c,!0);f.feature("desktop",!c,!0);d=/(chrome|firefox)[ \/]([\w.]+)/.exec(d)||/(iphone|ipad|ipod)(?:.*version)?[ \/]([\w.]+)/.exec(d)||/(android)(?:.*version)?[ \/]([\w.]+)/.exec(d)||/(webkit|opera)(?:.*version)?[ \/]([\w.]+)/.exec(d)||/(msie) ([\w.]+)/.exec(d)||[];c=d[1];d=parseFloat(d[2]);switch(c){case "msie":c="ie";d=k.documentMode||d;break;case "firefox":c="ff";break;case "ipod":case "ipad":case "iphone":c=
-"ios";break;case "webkit":c="safari"}f.browser={name:c,version:d};f.browser[c]=!0;for(var p=0,u=b.browsers.length;p<u;p++)for(var g in b.browsers[p])if(c===g){e(g);for(var v=b.browsers[p][g].max,i=b.browsers[p][g].min;i<=v;i++)d>i?(b.browserCss.gt&&e("gt-"+g+i),b.browserCss.gte&&e("gte-"+g+i)):d<i?(b.browserCss.lt&&e("lt-"+g+i),b.browserCss.lte&&e("lte-"+g+i)):d===i&&(b.browserCss.lte&&e("lte-"+g+i),b.browserCss.eq&&e("eq-"+g+i),b.browserCss.gte&&e("gte-"+g+i))}else e("no-"+g);"ie"===c&&9>d&&h("abbr article aside audio canvas details figcaption figure footer header hgroup mark meter nav output progress section summary time video".split(" "),
-function(a){k.createElement(a)});f.router={};h(l.pathname.split("/"),function(a,d){if(2<this.length&&this[d+1]!==q){if(d){var c=this.slice(1,d+1).join("-").toLowerCase()+b.section;console.log(c);e(c)}}else{var c=a||"index",g=c.indexOf(".");0<g&&(c=c.substring(0,g));f.router[b.page.replace(/^[A-Z]/i)]=c.toLowerCase();j.id=c.toLowerCase()+b.page;d||e("root"+b.section)}});f.screen={height:a.screen.height,width:a.screen.width};n();var t=0;a.addEventListener?a.addEventListener("resize",s,!1):a.attachEvent("onresize",
-s)})(window);
-(function(a,q){function e(a){var c=a.charAt(0).toUpperCase()+a.substr(1),a=(a+" "+s.join(c+" ")+c).split(" "),b;a:{for(b in a)if(h[a[b]]!==q){b=!0;break a}b=!1}return!!b}var m=a.document.createElement("i"),h=m.style,n=" -o- -moz- -ms- -webkit- -khtml- ".split(" "),s=["Webkit","Moz","O","ms","Khtml"],k=a[a.head_conf&&a.head_conf.head||"head"],c={gradient:function(){h.cssText=("background-image:"+n.join("gradient(linear,left top,right bottom,from(#9f9),to(#fff));background-image:")+n.join("linear-gradient(left top,#eee,#fff);background-image:")).slice(0,-17);
-return!!h.backgroundImage},rgba:function(){h.cssText="background-color:rgba(0,0,0,0.5)";return!!h.backgroundColor},opacity:function(){return""===m.style.opacity},textshadow:function(){return""===h.textShadow},multiplebgs:function(){h.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(h.background)},boxshadow:function(){return e("boxShadow")},borderimage:function(){return e("borderImage")},borderradius:function(){return e("borderRadius")},cssreflections:function(){return e("boxReflect")},
-csstransforms:function(){return e("transform")},csstransitions:function(){return e("transition")},touch:function(){return"ontouchstart"in a},retina:function(){return 1<a.devicePixelRatio},fontface:function(){var a=k.browser.version;switch(k.browser.name){case "ie":return 9<=a;case "chrome":return 13<=a;case "ff":return 6<=a;case "ios":return 5<=a;case "android":return!1;case "webkit":return 5.1<=a;case "opera":return 10<=a;default:return!1}}},l;for(l in c)c[l]&&k.feature(l,c[l].call(),!0);k.feature()})(window);
+(function(a,q){function d(b){r[r.length]=b}function m(b){j.className=j.className.replace(RegExp("\\b"+b+"\\b"),"")}function h(b,a){for(var d=0,j=b.length;d<j;d++)a.call(b,b[d],d)}function n(){j.className=j.className.replace(/ (w-|eq-|gt-|gte-|lt-|lte-|portrait|no-portrait|landscape|no-landscape)\d+/g,"");var c=a.innerWidth||j.clientWidth,e=a.outerWidth||a.screen.width;f.screen.innerWidth=c;f.screen.outerWidth=e;d("w-"+c);h(b.screens,function(a){c>a?(b.screensCss.gt&&d("gt-"+a),b.screensCss.gte&&d("gte-"+
+a)):c<a?(b.screensCss.lt&&d("lt-"+a),b.screensCss.lte&&d("lte-"+a)):c===a&&(b.screensCss.lte&&d("lte-"+a),b.screensCss.eq&&d("e-q"+a),b.screensCss.gte&&d("gte-"+a))});var e=a.innerHeight||j.clientHeight,g=a.outerHeight||a.screen.height;f.screen.innerHeight=e;f.screen.outerHeight=g;f.feature("portrait",e>c);f.feature("landscape",e<c)}function s(){a.clearTimeout(t);t=a.setTimeout(n,100)}var k=a.document,e=a.navigator,l=a.location,j=k.documentElement,r=[],b={screens:[240,320,480,640,768,800,1024,1280,
+1440,1680,1920],screensCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!1},browsers:[{ie:{min:6,max:10}}],browserCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!0},section:"-section",page:"-page",head:"head"};if(a.head_conf)for(var c in a.head_conf)a.head_conf[c]!==q&&(b[c]=a.head_conf[c]);var f=a[b.head]=function(){f.ready.apply(null,arguments)};f.feature=function(a,b,c){if(!a)return j.className+=" "+r.join(" "),r=[],f;"[object Function]"===Object.prototype.toString.call(b)&&(b=b.call());d((b?"":"no-")+a);f[a]=!!b;c||(m("no-"+
+a),m(a),f.feature());return f};f.feature("js",!0);c=e.userAgent.toLowerCase();e=/mobile|midp/.test(c);f.feature("mobile",e,!0);f.feature("desktop",!e,!0);c=/(chrome|firefox)[ \/]([\w.]+)/.exec(c)||/(iphone|ipad|ipod)(?:.*version)?[ \/]([\w.]+)/.exec(c)||/(android)(?:.*version)?[ \/]([\w.]+)/.exec(c)||/(webkit|opera)(?:.*version)?[ \/]([\w.]+)/.exec(c)||/(msie) ([\w.]+)/.exec(c)||[];e=c[1];c=parseFloat(c[2]);switch(e){case "msie":e="ie";c=k.documentMode||c;break;case "firefox":e="ff";break;case "ipod":case "ipad":case "iphone":e=
+"ios";break;case "webkit":e="safari"}f.browser={name:e,version:c};f.browser[e]=!0;for(var p=0,u=b.browsers.length;p<u;p++)for(var g in b.browsers[p])if(e===g){d(g);for(var v=b.browsers[p][g].max,i=b.browsers[p][g].min;i<=v;i++)c>i?(b.browserCss.gt&&d("gt-"+g+i),b.browserCss.gte&&d("gte-"+g+i)):c<i?(b.browserCss.lt&&d("lt-"+g+i),b.browserCss.lte&&d("lte-"+g+i)):c===i&&(b.browserCss.lte&&d("lte-"+g+i),b.browserCss.eq&&d("eq-"+g+i),b.browserCss.gte&&d("gte-"+g+i))}else d("no-"+g);"ie"===e&&9>c&&h("abbr article aside audio canvas details figcaption figure footer header hgroup mark meter nav output progress section summary time video".split(" "),
+function(a){k.createElement(a)});h(l.pathname.split("/"),function(a,c){if(2<this.length&&this[c+1]!==q)c&&d(this.slice(1,c+1).join("-").toLowerCase()+b.section);else{var e=a||"index",f=e.indexOf(".");0<f&&(e=e.substring(0,f));j.id=e.toLowerCase()+b.page;c||d("root"+b.section)}});f.screen={height:a.screen.height,width:a.screen.width};n();var t=0;a.addEventListener?a.addEventListener("resize",s,!1):a.attachEvent("onresize",s)})(window);
+(function(a,q){function d(a){var d=a.charAt(0).toUpperCase()+a.substr(1),a=(a+" "+s.join(d+" ")+d).split(" "),b;a:{for(b in a)if(h[a[b]]!==q){b=!0;break a}b=!1}return!!b}var m=a.document.createElement("i"),h=m.style,n=" -o- -moz- -ms- -webkit- -khtml- ".split(" "),s=["Webkit","Moz","O","ms","Khtml"],k=a[a.head_conf&&a.head_conf.head||"head"],e={gradient:function(){h.cssText=("background-image:"+n.join("gradient(linear,left top,right bottom,from(#9f9),to(#fff));background-image:")+n.join("linear-gradient(left top,#eee,#fff);background-image:")).slice(0,
+-17);return!!h.backgroundImage},rgba:function(){h.cssText="background-color:rgba(0,0,0,0.5)";return!!h.backgroundColor},opacity:function(){return""===m.style.opacity},textshadow:function(){return""===h.textShadow},multiplebgs:function(){h.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(h.background)},boxshadow:function(){return d("boxShadow")},borderimage:function(){return d("borderImage")},borderradius:function(){return d("borderRadius")},cssreflections:function(){return d("boxReflect")},
+csstransforms:function(){return d("transform")},csstransitions:function(){return d("transition")},touch:function(){return"ontouchstart"in a},retina:function(){return 1<a.devicePixelRatio},fontface:function(){var a=k.browser.version;switch(k.browser.name){case "ie":return 9<=a;case "chrome":return 13<=a;case "ff":return 6<=a;case "ios":return 5<=a;case "android":return!1;case "webkit":return 5.1<=a;case "opera":return 10<=a;default:return!1}}},l;for(l in e)e[l]&&k.feature(l,e[l].call(),!0);k.feature()})(window);
View
172 dist/head.js
@@ -195,15 +195,12 @@
});
}
- api.router = {};
-
+
// CSS "router"
each(loc.pathname.split("/"), function (el, i) {
if (this.length > 2 && this[i + 1] !== undefined) {
if (i) {
- var test = this.slice(1, i + 1).join("-").toLowerCase() + conf.section;
- console.log(test);
- pushClass(test);
+ pushClass(this.slice(1, i + 1).join("-").toLowerCase() + conf.section);
}
} else {
// pageId
@@ -212,7 +209,6 @@
id = id.substring(0, index);
}
- api.router[conf.page.replace(/[^A-Z]/i, "")] = id.toLowerCase();
html.id = id.toLowerCase() + conf.page;
// on root?
@@ -478,7 +474,7 @@
domWaiters = [],
queue = [], // waiters for the "head ready" event
handlers = {}, // user functions waiting for events
- scripts = {}, // loadable scripts in different states
+ assets = {}, // loadable items in various states
isAsync = "async" in doc.createElement("script") || "MozAppearance" in doc.documentElement.style || win.opera,
isHeadReady,
isDomReady,
@@ -511,7 +507,7 @@
each(args, function (item, i) {
if (item !== callback) {
- item = getScript(item);
+ item = getAsset(item);
items[item.name] = item;
load(item, callback && i === args.length - 2 ? function () {
@@ -548,24 +544,22 @@
/* Preload with text/cache hack (not good!)
* http://blog.getify.com/on-script-loaders/
* http://www.nczonline.net/blog/2010/12/21/thoughts-on-script-loaders/
- * If caching is not configured correctly on the server, then scripts will load twice !
- **************************************************************************************/
+ * If caching is not configured correctly on the server, then items could load twice !
+ *************************************************************************************/
each(rest, function (item) {
if (!isFunction(item)) {
- preLoad(getScript(item));
+ preLoad(getAsset(item));
}
});
// execute
- load(getScript(args[0]), isFunction(next) ? next : function () {
+ load(getAsset(args[0]), isFunction(next) ? next : function () {
api.load.apply(null, rest);
- });
-
-
- // single script
+ });
}
else {
- load(getScript(args[0]));
+ // single item
+ load(getAsset(args[0]));
}
return api;
@@ -655,10 +649,10 @@
}
// This can also be called when we trigger events based on filenames & labels
- var script = scripts[key];
+ var asset = assets[key];
- // script already loaded --> execute and return
- if (script && script.state === LOADED || key === 'ALL' && allLoaded() && isDomReady) {
+ // item already loaded --> execute and return
+ if (asset && asset.state === LOADED || key === 'ALL' && allLoaded() && isDomReady) {
one(callback);
return api;
}
@@ -750,20 +744,21 @@
callback._done = 1;
}
- function getScript(item) {
+ function getAsset(item) {
///<summary>
- /// Gets a script in the form of
+ /// Assets are in the form of
/// {
- /// name: label,
- /// url : url
+ /// name : label,
+ /// url : url,
+ /// state: state
/// }
///</summary>
- var script = {};
+ var asset = {};
if (typeof item === 'object') {
for (var label in item) {
if (!!item[label]) {
- script = {
+ asset = {
name: label,
url : item[label]
};
@@ -771,24 +766,24 @@
}
}
else {
- script = {
+ asset = {
name: toLabel(item),
url : item
};
}
// is the item already existant
- var existing = scripts[script.name];
- if (existing && existing.url === script.url) {
+ var existing = assets[asset.name];
+ if (existing && existing.url === asset.url) {
return existing;
}
- scripts[script.name] = script;
- return script;
+ assets[asset.name] = asset;
+ return asset;
}
function allLoaded(items) {
- items = items || scripts;
+ items = items || assets;
for (var name in items) {
if (items.hasOwnProperty(name) && items[name].state !== LOADED) {
@@ -800,60 +795,60 @@
}
- function onPreload(script) {
- script.state = PRELOADED;
+ function onPreload(asset) {
+ asset.state = PRELOADED;
- each(script.onpreload, function (afterPreload) {
+ each(asset.onpreload, function (afterPreload) {
afterPreload.call();
});
}
- function preLoad(script, callback) {
- if (script.state === undefined) {
+ function preLoad(asset, callback) {
+ if (asset.state === undefined) {
- script.state = PRELOADING;
- script.onpreload = [];
+ asset.state = PRELOADING;
+ asset.onpreload = [];
- scriptTag({ src: script.url, type: 'cache' }, function () {
- onPreload(script);
+ loadAsset({ url: asset.url, type: 'cache' }, function () {
+ onPreload(asset);
});
}
}
- function load(script, callback) {
+ function load(asset, callback) {
///<summary>Used with normal loading logic</summary>
callback = callback || noop;
- if (script.state === LOADED) {
+ if (asset.state === LOADED) {
callback();
return;
}
// INFO: why would we trigger a ready event when its not really loaded yet ?
- if (script.state === LOADING) {
- api.ready(script.name, callback);
+ if (asset.state === LOADING) {
+ api.ready(asset.name, callback);
return;
}
- if (script.state === PRELOADING) {
- script.onpreload.push(function () {
- load(script, callback);
+ if (asset.state === PRELOADING) {
+ asset.onpreload.push(function () {
+ load(asset, callback);
});
return;
}
- script.state = LOADING;
-
- scriptTag(script.url, function () {
- script.state = LOADED;
+ asset.state = LOADING;
+
+ loadAsset(asset, function () {
+ asset.state = LOADED;
callback();
- // handlers for this script
- each(handlers[script.name], function (fn) {
+ // handlers for this asset
+ each(handlers[asset.name], function (fn) {
one(fn);
});
- // dom is ready & no scripts are queued for loading
+ // dom is ready & no assets are queued for loading
// INFO: shouldn't we be doing the same test above ?
if (isDomReady && allLoaded()) {
each(handlers.ALL, function (fn) {
@@ -862,32 +857,27 @@
}
});
}
-
- function scriptTag(src, callback) {
- var s;
-
- if (/\.css[^\.]*$/.test(src)) {
- s = doc.createElement('link');
- s.type = 'text/' + (src.type || 'css');
- s.rel = 'stylesheet';
- s.href = src.src || src;
- }
- else {
- s = doc.createElement('script');
- s.type = 'text/' + (src.type || 'javascript');
- s.src = src.src || src;
- }
-
- loadAsset(s, callback);
- }
/* Parts inspired from: https://github.com/cujojs/curl
******************************************************/
- function loadAsset(s, callback) {
+ function loadAsset(asset, callback) {
callback = callback || noop;
- s.onload = s.onreadystatechange = process;
- s.onerror = error;
+ var ele;
+ if (/\.css[^\.]*$/.test(asset.url)) {
+ ele = doc.createElement('link');
+ ele.type = 'text/' + (asset.type || 'css');
+ ele.rel = 'stylesheet';
+ ele.href = asset.url;
+ }
+ else {
+ ele = doc.createElement('script');
+ ele.type = 'text/' + (asset.type || 'javascript');
+ ele.src = asset.url;
+ }
+
+ ele.onload = ele.onreadystatechange = process;
+ ele.onerror = error;
/* Good read, but doesn't give much hope !
* http://blog.getify.com/on-script-loaders/
@@ -896,16 +886,18 @@
*/
// ASYNC: load in parellel and execute as soon as possible
- s.async = false;
+ ele.async = false;
// DEFER: load in parallel but maintain execution order
- s.defer = false;
+ ele.defer = false;
function error(event) {
+ event = event || win.event;
+
// need some more detailed error handling here
// release event listeners
- s.onload = s.onreadystatechange = s.onerror = null;
-
+ ele.onload = ele.onreadystatechange = ele.onerror = null;
+
// do callback
callback();
}
@@ -955,26 +947,26 @@
// event.type == 'load' && s.readyState = undefined
-
// !doc.documentMode is for IE6/7, IE8+ have documentMode
- if (event.type === 'load' || (/loaded|complete/.test(s.readyState) && (!doc.documentMode || doc.documentMode < 9))) {
+ if (event.type === 'load' || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) {
// release event listeners
- s.onload = s.onreadystatechange = s.onerror = null;
+ ele.onload = ele.onreadystatechange = ele.onerror = null;
+
// do callback
callback();
}
// emulates error on browsers that don't create an exception
// INFO: timeout not clearing ..why ?
- //s.timeout = win.setTimeout(function () {
+ //asset.timeout = win.setTimeout(function () {
// error({ type: "timeout" });
- //}, 7000);
+ //}, 3000);
}
// use insertBefore to keep IE from throwing Operation Aborted (thx Bryan Forbes!)
var head = doc['head'] || doc.getElementsByTagName('head')[0];
// but insert at end of head, because otherwise if it is a stylesheet, it will not ovverride values
- head.insertBefore(s, head.lastChild);
+ head.insertBefore(ele, head.lastChild);
}
/* Mix of stuff from jQuery & IEContentLoaded
@@ -983,7 +975,7 @@
function domReady() {
// Make sure body exists, at least, in case IE gets a little overzealous (jQuery ticket #5443).
if (!doc.body) {
- // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if scripts are queued)
+ // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if assets are queued)
win.clearTimeout(api.readyTimeout);
api.readyTimeout = win.setTimeout(domReady, 50);
return;
@@ -1052,7 +1044,7 @@
// http://javascript.nwbox.com/IEContentLoaded/
top.doScroll("left");
} catch (error) {
- // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if scripts are queued)
+ // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if assets are queued)
win.clearTimeout(api.readyTimeout);
api.readyTimeout = win.setTimeout(doScrollCheck, 50);
return;
@@ -1066,8 +1058,8 @@
}
/*
- We wait for 300 ms before script loading starts. for some reason this is needed
- to make sure scripts are cached. Not sure why this happens yet. A case study:
+ We wait for 300 ms before asset loading starts. for some reason this is needed
+ to make sure assets are cached. Not sure why this happens yet. A case study:
https://github.com/headjs/headjs/issues/closed#issue/83
*/
View
164 dist/head.load.js
@@ -14,7 +14,7 @@
domWaiters = [],
queue = [], // waiters for the "head ready" event
handlers = {}, // user functions waiting for events
- scripts = {}, // loadable scripts in different states
+ assets = {}, // loadable items in various states
isAsync = "async" in doc.createElement("script") || "MozAppearance" in doc.documentElement.style || win.opera,
isHeadReady,
isDomReady,
@@ -47,7 +47,7 @@
each(args, function (item, i) {
if (item !== callback) {
- item = getScript(item);
+ item = getAsset(item);
items[item.name] = item;
load(item, callback && i === args.length - 2 ? function () {
@@ -84,24 +84,22 @@
/* Preload with text/cache hack (not good!)
* http://blog.getify.com/on-script-loaders/
* http://www.nczonline.net/blog/2010/12/21/thoughts-on-script-loaders/
- * If caching is not configured correctly on the server, then scripts will load twice !
- **************************************************************************************/
+ * If caching is not configured correctly on the server, then items could load twice !
+ *************************************************************************************/
each(rest, function (item) {
if (!isFunction(item)) {
- preLoad(getScript(item));
+ preLoad(getAsset(item));
}
});
// execute
- load(getScript(args[0]), isFunction(next) ? next : function () {
+ load(getAsset(args[0]), isFunction(next) ? next : function () {
api.load.apply(null, rest);
- });
-
-
- // single script
+ });
}
else {
- load(getScript(args[0]));
+ // single item
+ load(getAsset(args[0]));
}
return api;
@@ -191,10 +189,10 @@
}
// This can also be called when we trigger events based on filenames & labels
- var script = scripts[key];
+ var asset = assets[key];
- // script already loaded --> execute and return
- if (script && script.state === LOADED || key === 'ALL' && allLoaded() && isDomReady) {
+ // item already loaded --> execute and return
+ if (asset && asset.state === LOADED || key === 'ALL' && allLoaded() && isDomReady) {
one(callback);
return api;
}
@@ -286,20 +284,21 @@
callback._done = 1;
}
- function getScript(item) {
+ function getAsset(item) {
///<summary>
- /// Gets a script in the form of
+ /// Assets are in the form of
/// {
- /// name: label,
- /// url : url
+ /// name : label,
+ /// url : url,
+ /// state: state
/// }
///</summary>
- var script = {};
+ var asset = {};
if (typeof item === 'object') {
for (var label in item) {
if (!!item[label]) {
- script = {
+ asset = {
name: label,
url : item[label]
};
@@ -307,24 +306,24 @@
}
}
else {
- script = {
+ asset = {
name: toLabel(item),
url : item
};
}
// is the item already existant
- var existing = scripts[script.name];
- if (existing && existing.url === script.url) {
+ var existing = assets[asset.name];
+ if (existing && existing.url === asset.url) {
return existing;
}
- scripts[script.name] = script;
- return script;
+ assets[asset.name] = asset;
+ return asset;
}
function allLoaded(items) {
- items = items || scripts;
+ items = items || assets;
for (var name in items) {
if (items.hasOwnProperty(name) && items[name].state !== LOADED) {
@@ -336,60 +335,60 @@
}
- function onPreload(script) {
- script.state = PRELOADED;
+ function onPreload(asset) {
+ asset.state = PRELOADED;
- each(script.onpreload, function (afterPreload) {
+ each(asset.onpreload, function (afterPreload) {
afterPreload.call();
});
}
- function preLoad(script, callback) {
- if (script.state === undefined) {
+ function preLoad(asset, callback) {
+ if (asset.state === undefined) {
- script.state = PRELOADING;
- script.onpreload = [];
+ asset.state = PRELOADING;
+ asset.onpreload = [];
- scriptTag({ src: script.url, type: 'cache' }, function () {
- onPreload(script);
+ loadAsset({ url: asset.url, type: 'cache' }, function () {
+ onPreload(asset);
});
}
}
- function load(script, callback) {
+ function load(asset, callback) {
///<summary>Used with normal loading logic</summary>
callback = callback || noop;
- if (script.state === LOADED) {
+ if (asset.state === LOADED) {
callback();
return;
}
// INFO: why would we trigger a ready event when its not really loaded yet ?
- if (script.state === LOADING) {
- api.ready(script.name, callback);
+ if (asset.state === LOADING) {
+ api.ready(asset.name, callback);
return;
}
- if (script.state === PRELOADING) {
- script.onpreload.push(function () {
- load(script, callback);
+ if (asset.state === PRELOADING) {
+ asset.onpreload.push(function () {
+ load(asset, callback);
});
return;
}
- script.state = LOADING;
-
- scriptTag(script.url, function () {
- script.state = LOADED;
+ asset.state = LOADING;
+
+ loadAsset(asset, function () {
+ asset.state = LOADED;
callback();
- // handlers for this script
- each(handlers[script.name], function (fn) {
+ // handlers for this asset
+ each(handlers[asset.name], function (fn) {
one(fn);
});
- // dom is ready & no scripts are queued for loading
+ // dom is ready & no assets are queued for loading
// INFO: shouldn't we be doing the same test above ?
if (isDomReady && allLoaded()) {
each(handlers.ALL, function (fn) {
@@ -398,32 +397,27 @@
}
});
}
-
- function scriptTag(src, callback) {
- var s;
-
- if (/\.css[^\.]*$/.test(src)) {
- s = doc.createElement('link');
- s.type = 'text/' + (src.type || 'css');
- s.rel = 'stylesheet';
- s.href = src.src || src;
- }
- else {
- s = doc.createElement('script');
- s.type = 'text/' + (src.type || 'javascript');
- s.src = src.src || src;
- }
-
- loadAsset(s, callback);
- }
/* Parts inspired from: https://github.com/cujojs/curl
******************************************************/
- function loadAsset(s, callback) {
+ function loadAsset(asset, callback) {
callback = callback || noop;
- s.onload = s.onreadystatechange = process;
- s.onerror = error;
+ var ele;
+ if (/\.css[^\.]*$/.test(asset.url)) {
+ ele = doc.createElement('link');
+ ele.type = 'text/' + (asset.type || 'css');
+ ele.rel = 'stylesheet';
+ ele.href = asset.url;
+ }
+ else {
+ ele = doc.createElement('script');
+ ele.type = 'text/' + (asset.type || 'javascript');
+ ele.src = asset.url;
+ }
+
+ ele.onload = ele.onreadystatechange = process;
+ ele.onerror = error;
/* Good read, but doesn't give much hope !
* http://blog.getify.com/on-script-loaders/
@@ -432,16 +426,18 @@
*/
// ASYNC: load in parellel and execute as soon as possible
- s.async = false;
+ ele.async = false;
// DEFER: load in parallel but maintain execution order
- s.defer = false;
+ ele.defer = false;
function error(event) {
+ event = event || win.event;
+
// need some more detailed error handling here
// release event listeners
- s.onload = s.onreadystatechange = s.onerror = null;
-
+ ele.onload = ele.onreadystatechange = ele.onerror = null;
+
// do callback
callback();
}
@@ -491,26 +487,26 @@
// event.type == 'load' && s.readyState = undefined
-
// !doc.documentMode is for IE6/7, IE8+ have documentMode
- if (event.type === 'load' || (/loaded|complete/.test(s.readyState) && (!doc.documentMode || doc.documentMode < 9))) {
+ if (event.type === 'load' || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) {
// release event listeners
- s.onload = s.onreadystatechange = s.onerror = null;
+ ele.onload = ele.onreadystatechange = ele.onerror = null;
+
// do callback
callback();
}
// emulates error on browsers that don't create an exception
// INFO: timeout not clearing ..why ?
- //s.timeout = win.setTimeout(function () {
+ //asset.timeout = win.setTimeout(function () {
// error({ type: "timeout" });
- //}, 7000);
+ //}, 3000);
}
// use insertBefore to keep IE from throwing Operation Aborted (thx Bryan Forbes!)
var head = doc['head'] || doc.getElementsByTagName('head')[0];
// but insert at end of head, because otherwise if it is a stylesheet, it will not ovverride values
- head.insertBefore(s, head.lastChild);
+ head.insertBefore(ele, head.lastChild);
}
/* Mix of stuff from jQuery & IEContentLoaded
@@ -519,7 +515,7 @@
function domReady() {
// Make sure body exists, at least, in case IE gets a little overzealous (jQuery ticket #5443).
if (!doc.body) {
- // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if scripts are queued)
+ // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if assets are queued)
win.clearTimeout(api.readyTimeout);
api.readyTimeout = win.setTimeout(domReady, 50);
return;
@@ -588,7 +584,7 @@
// http://javascript.nwbox.com/IEContentLoaded/
top.doScroll("left");
} catch (error) {
- // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if scripts are queued)
+ // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if assets are queued)
win.clearTimeout(api.readyTimeout);
api.readyTimeout = win.setTimeout(doScrollCheck, 50);
return;
@@ -602,8 +598,8 @@
}
/*
- We wait for 300 ms before script loading starts. for some reason this is needed
- to make sure scripts are cached. Not sure why this happens yet. A case study:
+ We wait for 300 ms before asset loading starts. for some reason this is needed
+ to make sure assets are cached. Not sure why this happens yet. A case study:
https://github.com/headjs/headjs/issues/closed#issue/83
*/
View
16 dist/head.load.min.js
@@ -1,8 +1,8 @@
-(function(g,x){function n(){}function h(a,b){if(a){"object"===typeof a&&(a=[].slice.call(a));for(var c=0,f=a.length;c<f;c++)b.call(a,a[c],c)}}function w(a,b){var c=Object.prototype.toString.call(b).slice(8,-1);return b!==x&&null!==b&&c===a}function l(a){return w("Function",a)}function i(a){a=a||n;a._done||(a(),a._done=1)}function p(a){var b={};if("object"===typeof a)for(var c in a)a[c]&&(b={name:c,url:a[c]});else b=a.split("/"),b=b[b.length-1],c=b.indexOf("?"),b={name:-1!==c?b.substring(0,c):b,url:a};
-return(a=q[b.name])&&a.url===b.url?a:q[b.name]=b}function r(a){var a=a||q,b;for(b in a)if(a.hasOwnProperty(b)&&a[b].state!==s)return!1;return!0}function t(a,b){b=b||n;a.state===s?b():a.state===y?d.ready(a.name,b):a.state===z?a.onpreload.push(function(){t(a,b)}):(a.state=y,A(a.url,function(){a.state=s;b();h(m[a.name],function(a){i(a)});k&&r()&&h(m.ALL,function(a){i(a)})}))}function A(a,b){var c;/\.css[^\.]*$/.test(a)?(c=e.createElement("link"),c.type="text/"+(a.type||"css"),c.rel="stylesheet",c.href=
-a.src||a):(c=e.createElement("script"),c.type="text/"+(a.type||"javascript"),c.src=a.src||a);var f=c,d=b,d=d||n;f.onload=f.onreadystatechange=function(a){a=a||g.event;if("load"===a.type||/loaded|complete/.test(f.readyState)&&(!e.documentMode||9>e.documentMode))f.onload=f.onreadystatechange=f.onerror=null,d()};f.onerror=function(){f.onload=f.onreadystatechange=f.onerror=null;d()};f.async=!1;f.defer=!1;c=e.head||e.getElementsByTagName("head")[0];c.insertBefore(f,c.lastChild)}function j(){e.body?k||
-(k=!0,h(B,function(a){i(a)})):(g.clearTimeout(d.readyTimeout),d.readyTimeout=g.setTimeout(j,50))}function u(){e.addEventListener?(e.removeEventListener("DOMContentLoaded",u,!1),j()):"complete"===e.readyState&&(e.detachEvent("onreadystatechange",u),j())}var e=g.document,B=[],C=[],m={},q={},F="async"in e.createElement("script")||"MozAppearance"in e.documentElement.style||g.opera,D,k,E=g.head_conf&&g.head_conf.head||"head",d=g[E]=g[E]||function(){d.ready.apply(null,arguments)},z=1,y=3,s=4;d.load=F?function(){var a=
-arguments,b=a[a.length-1],c={};l(b)||(b=null);h(a,function(d,e){d!==b&&(d=p(d),c[d.name]=d,t(d,b&&e===a.length-2?function(){r(c)&&i(b)}:null))});return d}:function(){var a=arguments,b=[].slice.call(a,1),c=b[0];if(!D)return C.push(function(){d.load.apply(null,a)}),d;c?(h(b,function(a){if(!l(a)){var b=p(a);b.state===x&&(b.state=z,b.onpreload=[],A({src:b.url,type:"cache"},function(){b.state=2;h(b.onpreload,function(a){a.call()})}))}}),t(p(a[0]),l(c)?c:function(){d.load.apply(null,b)})):t(p(a[0]));return d};
-d.js=d.load;d.test=function(a,b,c,e){a="object"===typeof a?a:{test:a,success:b?w("Array",b)?b:[b]:!1,failure:c?w("Array",c)?c:[c]:!1,callback:e||n};(b=!!a.test)&&a.success?(a.success.push(a.callback),d.load.apply(null,a.success)):!b&&a.failure?(a.failure.push(a.callback),d.load.apply(null,a.failure)):e();return d};d.ready=function(a,b){if(a===e)return k?i(b):B.push(b),d;l(a)&&(b=a,a="ALL");if("string"!==typeof a||!l(b))return d;var c=q[a];if(c&&c.state===s||"ALL"===a&&r()&&k)return i(b),d;(c=m[a])?
-c.push(b):m[a]=[b];return d};d.ready(e,function(){r()&&h(m.ALL,function(a){i(a)});d.feature&&d.feature("domloaded",!0)});if("complete"===e.readyState)j();else if(e.addEventListener)e.addEventListener("DOMContentLoaded",u,!1),g.addEventListener("load",j,!1);else{e.attachEvent("onreadystatechange",u);g.attachEvent("onload",j);var v=!1;try{v=null==g.frameElement&&e.documentElement}catch(G){}v&&v.doScroll&&function b(){if(!k){try{v.doScroll("left")}catch(c){g.clearTimeout(d.readyTimeout);d.readyTimeout=
-g.setTimeout(b,50);return}j()}}()}setTimeout(function(){D=!0;h(C,function(b){b()})},300)})(window);
+(function(f,w){function m(){}function g(a,b){if(a){"object"===typeof a&&(a=[].slice.call(a));for(var c=0,d=a.length;c<d;c++)b.call(a,a[c],c)}}function v(a,b){var c=Object.prototype.toString.call(b).slice(8,-1);return b!==w&&null!==b&&c===a}function k(a){return v("Function",a)}function h(a){a=a||m;a._done||(a(),a._done=1)}function n(a){var b={};if("object"===typeof a)for(var c in a)a[c]&&(b={name:c,url:a[c]});else b=a.split("/"),b=b[b.length-1],c=b.indexOf("?"),b={name:-1!==c?b.substring(0,c):b,url:a};
+return(a=p[b.name])&&a.url===b.url?a:p[b.name]=b}function q(a){var a=a||p,b;for(b in a)if(a.hasOwnProperty(b)&&a[b].state!==r)return!1;return!0}function s(a,b){b=b||m;a.state===r?b():a.state===x?d.ready(a.name,b):a.state===y?a.onpreload.push(function(){s(a,b)}):(a.state=x,z(a,function(){a.state=r;b();g(l[a.name],function(a){h(a)});j&&q()&&g(l.ALL,function(a){h(a)})}))}function z(a,b){var b=b||m,c;/\.css[^\.]*$/.test(a.url)?(c=e.createElement("link"),c.type="text/"+(a.type||"css"),c.rel="stylesheet",
+c.href=a.url):(c=e.createElement("script"),c.type="text/"+(a.type||"javascript"),c.src=a.url);c.onload=c.onreadystatechange=function(a){a=a||f.event;if("load"===a.type||/loaded|complete/.test(c.readyState)&&(!e.documentMode||9>e.documentMode))c.onload=c.onreadystatechange=c.onerror=null,b()};c.onerror=function(){c.onload=c.onreadystatechange=c.onerror=null;b()};c.async=!1;c.defer=!1;var d=e.head||e.getElementsByTagName("head")[0];d.insertBefore(c,d.lastChild)}function i(){e.body?j||(j=!0,g(A,function(a){h(a)})):
+(f.clearTimeout(d.readyTimeout),d.readyTimeout=f.setTimeout(i,50))}function t(){e.addEventListener?(e.removeEventListener("DOMContentLoaded",t,!1),i()):"complete"===e.readyState&&(e.detachEvent("onreadystatechange",t),i())}var e=f.document,A=[],B=[],l={},p={},E="async"in e.createElement("script")||"MozAppearance"in e.documentElement.style||f.opera,C,j,D=f.head_conf&&f.head_conf.head||"head",d=f[D]=f[D]||function(){d.ready.apply(null,arguments)},y=1,x=3,r=4;d.load=E?function(){var a=arguments,b=a[a.length-
+1],c={};k(b)||(b=null);g(a,function(d,e){d!==b&&(d=n(d),c[d.name]=d,s(d,b&&e===a.length-2?function(){q(c)&&h(b)}:null))});return d}:function(){var a=arguments,b=[].slice.call(a,1),c=b[0];if(!C)return B.push(function(){d.load.apply(null,a)}),d;c?(g(b,function(a){if(!k(a)){var b=n(a);b.state===w&&(b.state=y,b.onpreload=[],z({url:b.url,type:"cache"},function(){b.state=2;g(b.onpreload,function(a){a.call()})}))}}),s(n(a[0]),k(c)?c:function(){d.load.apply(null,b)})):s(n(a[0]));return d};d.js=d.load;d.test=
+function(a,b,c,e){a="object"===typeof a?a:{test:a,success:b?v("Array",b)?b:[b]:!1,failure:c?v("Array",c)?c:[c]:!1,callback:e||m};(b=!!a.test)&&a.success?(a.success.push(a.callback),d.load.apply(null,a.success)):!b&&a.failure?(a.failure.push(a.callback),d.load.apply(null,a.failure)):e();return d};d.ready=function(a,b){if(a===e)return j?h(b):A.push(b),d;k(a)&&(b=a,a="ALL");if("string"!==typeof a||!k(b))return d;var c=p[a];if(c&&c.state===r||"ALL"===a&&q()&&j)return h(b),d;(c=l[a])?c.push(b):l[a]=[b];
+return d};d.ready(e,function(){q()&&g(l.ALL,function(a){h(a)});d.feature&&d.feature("domloaded",!0)});if("complete"===e.readyState)i();else if(e.addEventListener)e.addEventListener("DOMContentLoaded",t,!1),f.addEventListener("load",i,!1);else{e.attachEvent("onreadystatechange",t);f.attachEvent("onload",i);var u=!1;try{u=null==f.frameElement&&e.documentElement}catch(F){}u&&u.doScroll&&function b(){if(!j){try{u.doScroll("left")}catch(c){f.clearTimeout(d.readyTimeout);d.readyTimeout=f.setTimeout(b,50);
+return}i()}}()}setTimeout(function(){C=!0;g(B,function(b){b()})},300)})(window);
View
35 dist/head.min.js
@@ -1,18 +1,17 @@
-(function(a,v){function f(a){n[n.length]=a}function l(a){p.className=p.className.replace(RegExp("\\b"+a+"\\b"),"")}function j(a,d){for(var b=0,c=a.length;b<c;b++)d.call(a,a[b],b)}function r(){p.className=p.className.replace(/ (w-|eq-|gt-|gte-|lt-|lte-|portrait|no-portrait|landscape|no-landscape)\d+/g,"");var b=a.innerWidth||p.clientWidth,d=a.outerWidth||a.screen.width;g.screen.innerWidth=b;g.screen.outerWidth=d;f("w-"+b);j(c.screens,function(a){b>a?(c.screensCss.gt&&f("gt-"+a),c.screensCss.gte&&f("gte-"+
-a)):b<a?(c.screensCss.lt&&f("lt-"+a),c.screensCss.lte&&f("lte-"+a)):b===a&&(c.screensCss.lte&&f("lte-"+a),c.screensCss.eq&&f("e-q"+a),c.screensCss.gte&&f("gte-"+a))});var d=a.innerHeight||p.clientHeight,e=a.outerHeight||a.screen.height;g.screen.innerHeight=d;g.screen.outerHeight=e;g.feature("portrait",d>b);g.feature("landscape",d<b)}function q(){a.clearTimeout(t);t=a.setTimeout(r,100)}var m=a.document,e=a.navigator,s=a.location,p=m.documentElement,n=[],c={screens:[240,320,480,640,768,800,1024,1280,
-1440,1680,1920],screensCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!1},browsers:[{ie:{min:6,max:10}}],browserCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!0},section:"-section",page:"-page",head:"head"};if(a.head_conf)for(var b in a.head_conf)a.head_conf[b]!==v&&(c[b]=a.head_conf[b]);var g=a[c.head]=function(){g.ready.apply(null,arguments)};g.feature=function(a,b,c){if(!a)return p.className+=" "+n.join(" "),n=[],g;"[object Function]"===Object.prototype.toString.call(b)&&(b=b.call());f((b?"":"no-")+a);g[a]=!!b;c||(l("no-"+
-a),l(a),g.feature());return g};g.feature("js",!0);b=e.userAgent.toLowerCase();e=/mobile|midp/.test(b);g.feature("mobile",e,!0);g.feature("desktop",!e,!0);b=/(chrome|firefox)[ \/]([\w.]+)/.exec(b)||/(iphone|ipad|ipod)(?:.*version)?[ \/]([\w.]+)/.exec(b)||/(android)(?:.*version)?[ \/]([\w.]+)/.exec(b)||/(webkit|opera)(?:.*version)?[ \/]([\w.]+)/.exec(b)||/(msie) ([\w.]+)/.exec(b)||[];e=b[1];b=parseFloat(b[2]);switch(e){case "msie":e="ie";b=m.documentMode||b;break;case "firefox":e="ff";break;case "ipod":case "ipad":case "iphone":e=
-"ios";break;case "webkit":e="safari"}g.browser={name:e,version:b};g.browser[e]=!0;for(var u=0,w=c.browsers.length;u<w;u++)for(var i in c.browsers[u])if(e===i){f(i);for(var z=c.browsers[u][i].max,k=c.browsers[u][i].min;k<=z;k++)b>k?(c.browserCss.gt&&f("gt-"+i+k),c.browserCss.gte&&f("gte-"+i+k)):b<k?(c.browserCss.lt&&f("lt-"+i+k),c.browserCss.lte&&f("lte-"+i+k)):b===k&&(c.browserCss.lte&&f("lte-"+i+k),c.browserCss.eq&&f("eq-"+i+k),c.browserCss.gte&&f("gte-"+i+k))}else f("no-"+i);"ie"===e&&9>b&&j("abbr article aside audio canvas details figcaption figure footer header hgroup mark meter nav output progress section summary time video".split(" "),
-function(a){m.createElement(a)});g.router={};j(s.pathname.split("/"),function(a,b){if(2<this.length&&this[b+1]!==v){if(b){var e=this.slice(1,b+1).join("-").toLowerCase()+c.section;console.log(e);f(e)}}else{var e=a||"index",i=e.indexOf(".");0<i&&(e=e.substring(0,i));g.router[c.page.replace(/^[A-Z]/i)]=e.toLowerCase();p.id=e.toLowerCase()+c.page;b||f("root"+c.section)}});g.screen={height:a.screen.height,width:a.screen.width};r();var t=0;a.addEventListener?a.addEventListener("resize",q,!1):a.attachEvent("onresize",
-q)})(window);
-(function(a,v){function f(a){var e=a.charAt(0).toUpperCase()+a.substr(1),a=(a+" "+q.join(e+" ")+e).split(" "),c;a:{for(c in a)if(j[a[c]]!==v){c=!0;break a}c=!1}return!!c}var l=a.document.createElement("i"),j=l.style,r=" -o- -moz- -ms- -webkit- -khtml- ".split(" "),q=["Webkit","Moz","O","ms","Khtml"],m=a[a.head_conf&&a.head_conf.head||"head"],e={gradient:function(){j.cssText=("background-image:"+r.join("gradient(linear,left top,right bottom,from(#9f9),to(#fff));background-image:")+r.join("linear-gradient(left top,#eee,#fff);background-image:")).slice(0,-17);
-return!!j.backgroundImage},rgba:function(){j.cssText="background-color:rgba(0,0,0,0.5)";return!!j.backgroundColor},opacity:function(){return""===l.style.opacity},textshadow:function(){return""===j.textShadow},multiplebgs:function(){j.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(j.background)},boxshadow:function(){return f("boxShadow")},borderimage:function(){return f("borderImage")},borderradius:function(){return f("borderRadius")},cssreflections:function(){return f("boxReflect")},
-csstransforms:function(){return f("transform")},csstransitions:function(){return f("transition")},touch:function(){return"ontouchstart"in a},retina:function(){return 1<a.devicePixelRatio},fontface:function(){var a=m.browser.version;switch(m.browser.name){case "ie":return 9<=a;case "chrome":return 13<=a;case "ff":return 6<=a;case "ios":return 5<=a;case "android":return!1;case "webkit":return 5.1<=a;case "opera":return 10<=a;default:return!1}}},s;for(s in e)e[s]&&m.feature(s,e[s].call(),!0);m.feature()})(window);
-(function(a,v){function f(){}function l(h,a){if(h){"object"===typeof h&&(h=[].slice.call(h));for(var b=0,c=h.length;b<c;b++)a.call(h,h[b],b)}}function j(h,a){var b=Object.prototype.toString.call(a).slice(8,-1);return a!==v&&null!==a&&b===h}function r(a){return j("Function",a)}function q(a){a=a||f;a._done||(a(),a._done=1)}function m(a){var b={};if("object"===typeof a)for(var c in a)a[c]&&(b={name:c,url:a[c]});else b=a.split("/"),b=b[b.length-1],c=b.indexOf("?"),b={name:-1!==c?b.substring(0,c):b,url:a};
-return(a=i[b.name])&&a.url===b.url?a:i[b.name]=b}function e(a){var a=a||i,b;for(b in a)if(a.hasOwnProperty(b)&&a[b].state!==x)return!1;return!0}function s(a,b){b=b||f;a.state===x?b():a.state===C?d.ready(a.name,b):a.state===B?a.onpreload.push(function(){s(a,b)}):(a.state=C,p(a.url,function(){a.state=x;b();l(w[a.name],function(a){q(a)});t&&e()&&l(w.ALL,function(a){q(a)})}))}function p(h,c){var e;/\.css[^\.]*$/.test(h)?(e=b.createElement("link"),e.type="text/"+(h.type||"css"),e.rel="stylesheet",e.href=
-h.src||h):(e=b.createElement("script"),e.type="text/"+(h.type||"javascript"),e.src=h.src||h);var d=e,g=c,g=g||f;d.onload=d.onreadystatechange=function(h){h=h||a.event;if("load"===h.type||/loaded|complete/.test(d.readyState)&&(!b.documentMode||9>b.documentMode))d.onload=d.onreadystatechange=d.onerror=null,g()};d.onerror=function(){d.onload=d.onreadystatechange=d.onerror=null;g()};d.async=!1;d.defer=!1;e=b.head||b.getElementsByTagName("head")[0];e.insertBefore(d,e.lastChild)}function n(){b.body?t||
-(t=!0,l(g,function(a){q(a)})):(a.clearTimeout(d.readyTimeout),d.readyTimeout=a.setTimeout(n,50))}function c(){b.addEventListener?(b.removeEventListener("DOMContentLoaded",c,!1),n()):"complete"===b.readyState&&(b.detachEvent("onreadystatechange",c),n())}var b=a.document,g=[],u=[],w={},i={},z="async"in b.createElement("script")||"MozAppearance"in b.documentElement.style||a.opera,k,t,A=a.head_conf&&a.head_conf.head||"head",d=a[A]=a[A]||function(){d.ready.apply(null,arguments)},B=1,C=3,x=4;d.load=z?function(){var a=
-arguments,b=a[a.length-1],c={};r(b)||(b=null);l(a,function(d,f){d!==b&&(d=m(d),c[d.name]=d,s(d,b&&f===a.length-2?function(){e(c)&&q(b)}:null))});return d}:function(){var a=arguments,b=[].slice.call(a,1),c=b[0];if(!k)return u.push(function(){d.load.apply(null,a)}),d;c?(l(b,function(a){if(!r(a)){var b=m(a);b.state===v&&(b.state=B,b.onpreload=[],p({src:b.url,type:"cache"},function(){b.state=2;l(b.onpreload,function(a){a.call()})}))}}),s(m(a[0]),r(c)?c:function(){d.load.apply(null,b)})):s(m(a[0]));return d};
-d.js=d.load;d.test=function(a,b,c,e){a="object"===typeof a?a:{test:a,success:b?j("Array",b)?b:[b]:!1,failure:c?j("Array",c)?c:[c]:!1,callback:e||f};(b=!!a.test)&&a.success?(a.success.push(a.callback),d.load.apply(null,a.success)):!b&&a.failure?(a.failure.push(a.callback),d.load.apply(null,a.failure)):e();return d};d.ready=function(a,c){if(a===b)return t?q(c):g.push(c),d;r(a)&&(c=a,a="ALL");if("string"!==typeof a||!r(c))return d;var f=i[a];if(f&&f.state===x||"ALL"===a&&e()&&t)return q(c),d;(f=w[a])?
-f.push(c):w[a]=[c];return d};d.ready(b,function(){e()&&l(w.ALL,function(a){q(a)});d.feature&&d.feature("domloaded",!0)});if("complete"===b.readyState)n();else if(b.addEventListener)b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",n,!1);else{b.attachEvent("onreadystatechange",c);a.attachEvent("onload",n);var y=!1;try{y=null==a.frameElement&&b.documentElement}catch(E){}y&&y.doScroll&&function D(){if(!t){try{y.doScroll("left")}catch(b){a.clearTimeout(d.readyTimeout);d.readyTimeout=
-a.setTimeout(D,50);return}n()}}()}setTimeout(function(){k=!0;l(u,function(a){a()})},300)})(window);
+(function(a,w){function f(a){p[p.length]=a}function m(a){q.className=q.className.replace(RegExp("\\b"+a+"\\b"),"")}function k(a,d){for(var b=0,c=a.length;b<c;b++)d.call(a,a[b],b)}function s(){q.className=q.className.replace(/ (w-|eq-|gt-|gte-|lt-|lte-|portrait|no-portrait|landscape|no-landscape)\d+/g,"");var b=a.innerWidth||q.clientWidth,d=a.outerWidth||a.screen.width;h.screen.innerWidth=b;h.screen.outerWidth=d;f("w-"+b);k(c.screens,function(a){b>a?(c.screensCss.gt&&f("gt-"+a),c.screensCss.gte&&f("gte-"+
+a)):b<a?(c.screensCss.lt&&f("lt-"+a),c.screensCss.lte&&f("lte-"+a)):b===a&&(c.screensCss.lte&&f("lte-"+a),c.screensCss.eq&&f("e-q"+a),c.screensCss.gte&&f("gte-"+a))});var d=a.innerHeight||q.clientHeight,g=a.outerHeight||a.screen.height;h.screen.innerHeight=d;h.screen.outerHeight=g;h.feature("portrait",d>b);h.feature("landscape",d<b)}function r(){a.clearTimeout(u);u=a.setTimeout(s,100)}var n=a.document,g=a.navigator,t=a.location,q=n.documentElement,p=[],c={screens:[240,320,480,640,768,800,1024,1280,
+1440,1680,1920],screensCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!1},browsers:[{ie:{min:6,max:10}}],browserCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!0},section:"-section",page:"-page",head:"head"};if(a.head_conf)for(var b in a.head_conf)a.head_conf[b]!==w&&(c[b]=a.head_conf[b]);var h=a[c.head]=function(){h.ready.apply(null,arguments)};h.feature=function(a,b,c){if(!a)return q.className+=" "+p.join(" "),p=[],h;"[object Function]"===Object.prototype.toString.call(b)&&(b=b.call());f((b?"":"no-")+a);h[a]=!!b;c||(m("no-"+
+a),m(a),h.feature());return h};h.feature("js",!0);b=g.userAgent.toLowerCase();g=/mobile|midp/.test(b);h.feature("mobile",g,!0);h.feature("desktop",!g,!0);b=/(chrome|firefox)[ \/]([\w.]+)/.exec(b)||/(iphone|ipad|ipod)(?:.*version)?[ \/]([\w.]+)/.exec(b)||/(android)(?:.*version)?[ \/]([\w.]+)/.exec(b)||/(webkit|opera)(?:.*version)?[ \/]([\w.]+)/.exec(b)||/(msie) ([\w.]+)/.exec(b)||[];g=b[1];b=parseFloat(b[2]);switch(g){case "msie":g="ie";b=n.documentMode||b;break;case "firefox":g="ff";break;case "ipod":case "ipad":case "iphone":g=
+"ios";break;case "webkit":g="safari"}h.browser={name:g,version:b};h.browser[g]=!0;for(var v=0,x=c.browsers.length;v<x;v++)for(var i in c.browsers[v])if(g===i){f(i);for(var A=c.browsers[v][i].max,l=c.browsers[v][i].min;l<=A;l++)b>l?(c.browserCss.gt&&f("gt-"+i+l),c.browserCss.gte&&f("gte-"+i+l)):b<l?(c.browserCss.lt&&f("lt-"+i+l),c.browserCss.lte&&f("lte-"+i+l)):b===l&&(c.browserCss.lte&&f("lte-"+i+l),c.browserCss.eq&&f("eq-"+i+l),c.browserCss.gte&&f("gte-"+i+l))}else f("no-"+i);"ie"===g&&9>b&&k("abbr article aside audio canvas details figcaption figure footer header hgroup mark meter nav output progress section summary time video".split(" "),
+function(a){n.createElement(a)});k(t.pathname.split("/"),function(a,b){if(2<this.length&&this[b+1]!==w)b&&f(this.slice(1,b+1).join("-").toLowerCase()+c.section);else{var g=a||"index",h=g.indexOf(".");0<h&&(g=g.substring(0,h));q.id=g.toLowerCase()+c.page;b||f("root"+c.section)}});h.screen={height:a.screen.height,width:a.screen.width};s();var u=0;a.addEventListener?a.addEventListener("resize",r,!1):a.attachEvent("onresize",r)})(window);
+(function(a,w){function f(a){var f=a.charAt(0).toUpperCase()+a.substr(1),a=(a+" "+r.join(f+" ")+f).split(" "),c;a:{for(c in a)if(k[a[c]]!==w){c=!0;break a}c=!1}return!!c}var m=a.document.createElement("i"),k=m.style,s=" -o- -moz- -ms- -webkit- -khtml- ".split(" "),r=["Webkit","Moz","O","ms","Khtml"],n=a[a.head_conf&&a.head_conf.head||"head"],g={gradient:function(){k.cssText=("background-image:"+s.join("gradient(linear,left top,right bottom,from(#9f9),to(#fff));background-image:")+s.join("linear-gradient(left top,#eee,#fff);background-image:")).slice(0,
+-17);return!!k.backgroundImage},rgba:function(){k.cssText="background-color:rgba(0,0,0,0.5)";return!!k.backgroundColor},opacity:function(){return""===m.style.opacity},textshadow:function(){return""===k.textShadow},multiplebgs:function(){k.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(k.background)},boxshadow:function(){return f("boxShadow")},borderimage:function(){return f("borderImage")},borderradius:function(){return f("borderRadius")},cssreflections:function(){return f("boxReflect")},
+csstransforms:function(){return f("transform")},csstransitions:function(){return f("transition")},touch:function(){return"ontouchstart"in a},retina:function(){return 1<a.devicePixelRatio},fontface:function(){var a=n.browser.version;switch(n.browser.name){case "ie":return 9<=a;case "chrome":return 13<=a;case "ff":return 6<=a;case "ios":return 5<=a;case "android":return!1;case "webkit":return 5.1<=a;case "opera":return 10<=a;default:return!1}}},t;for(t in g)g[t]&&n.feature(t,g[t].call(),!0);n.feature()})(window);
+(function(a,w){function f(){}function m(j,a){if(j){"object"===typeof j&&(j=[].slice.call(j));for(var b=0,c=j.length;b<c;b++)a.call(j,j[b],b)}}function k(a,b){var e=Object.prototype.toString.call(b).slice(8,-1);return b!==w&&null!==b&&e===a}function s(a){return k("Function",a)}function r(a){a=a||f;a._done||(a(),a._done=1)}function n(a){var b={};if("object"===typeof a)for(var e in a)a[e]&&(b={name:e,url:a[e]});else b=a.split("/"),b=b[b.length-1],e=b.indexOf("?"),b={name:-1!==e?b.substring(0,e):b,url:a};
+return(a=i[b.name])&&a.url===b.url?a:i[b.name]=b}function g(a){var a=a||i,b;for(b in a)if(a.hasOwnProperty(b)&&a[b].state!==y)return!1;return!0}function t(a,b){b=b||f;a.state===y?b():a.state===D?d.ready(a.name,b):a.state===C?a.onpreload.push(function(){t(a,b)}):(a.state=D,q(a,function(){a.state=y;b();m(x[a.name],function(a){r(a)});u&&g()&&m(x.ALL,function(a){r(a)})}))}function q(j,c){var c=c||f,e;/\.css[^\.]*$/.test(j.url)?(e=b.createElement("link"),e.type="text/"+(j.type||"css"),e.rel="stylesheet",
+e.href=j.url):(e=b.createElement("script"),e.type="text/"+(j.type||"javascript"),e.src=j.url);e.onload=e.onreadystatechange=function(j){j=j||a.event;if("load"===j.type||/loaded|complete/.test(e.readyState)&&(!b.documentMode||9>b.documentMode))e.onload=e.onreadystatechange=e.onerror=null,c()};e.onerror=function(){e.onload=e.onreadystatechange=e.onerror=null;c()};e.async=!1;e.defer=!1;var d=b.head||b.getElementsByTagName("head")[0];d.insertBefore(e,d.lastChild)}function p(){b.body?u||(u=!0,m(h,function(a){r(a)})):
+(a.clearTimeout(d.readyTimeout),d.readyTimeout=a.setTimeout(p,50))}function c(){b.addEventListener?(b.removeEventListener("DOMContentLoaded",c,!1),p()):"complete"===b.readyState&&(b.detachEvent("onreadystatechange",c),p())}var b=a.document,h=[],v=[],x={},i={},A="async"in b.createElement("script")||"MozAppearance"in b.documentElement.style||a.opera,l,u,B=a.head_conf&&a.head_conf.head||"head",d=a[B]=a[B]||function(){d.ready.apply(null,arguments)},C=1,D=3,y=4;d.load=A?function(){var a=arguments,b=a[a.length-
+1],e={};s(b)||(b=null);m(a,function(c,d){c!==b&&(c=n(c),e[c.name]=c,t(c,b&&d===a.length-2?function(){g(e)&&r(b)}:null))});return d}:function(){var a=arguments,b=[].slice.call(a,1),c=b[0];if(!l)return v.push(function(){d.load.apply(null,a)}),d;c?(m(b,function(a){if(!s(a)){var b=n(a);b.state===w&&(b.state=C,b.onpreload=[],q({url:b.url,type:"cache"},function(){b.state=2;m(b.onpreload,function(a){a.call()})}))}}),t(n(a[0]),s(c)?c:function(){d.load.apply(null,b)})):t(n(a[0]));return d};d.js=d.load;d.test=
+function(a,b,c,g){a="object"===typeof a?a:{test:a,success:b?k("Array",b)?b:[b]:!1,failure:c?k("Array",c)?c:[c]:!1,callback:g||f};(b=!!a.test)&&a.success?(a.success.push(a.callback),d.load.apply(null,a.success)):!b&&a.failure?(a.failure.push(a.callback),d.load.apply(null,a.failure)):g();return d};d.ready=function(a,c){if(a===b)return u?r(c):h.push(c),d;s(a)&&(c=a,a="ALL");if("string"!==typeof a||!s(c))return d;var e=i[a];if(e&&e.state===y||"ALL"===a&&g()&&u)return r(c),d;(e=x[a])?e.push(c):x[a]=[c];
+return d};d.ready(b,function(){g()&&m(x.ALL,function(a){r(a)});d.feature&&d.feature("domloaded",!0)});if("complete"===b.readyState)p();else if(b.addEventListener)b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",p,!1);else{b.attachEvent("onreadystatechange",c);a.attachEvent("onload",p);var z=!1;try{z=null==a.frameElement&&b.documentElement}catch(F){}z&&z.doScroll&&function E(){if(!u){try{z.doScroll("left")}catch(b){a.clearTimeout(d.readyTimeout);d.readyTimeout=a.setTimeout(E,50);
+return}p()}}()}setTimeout(function(){l=!0;m(v,function(a){a()})},300)})(window);
View
14 dist/nuget/HeadJS.0.99.nuspec
@@ -3,7 +3,7 @@
<metadata>
<id>HeadJS</id>
<version>0.99</version>
- <title>HeadJS, the only script in your &lt;head&gt;</title>
+ <title>HeadJS</title>
<authors>Tero Piirainen,Robert Hoffmann</authors>
<owners>itechnology</owners>
<licenseUrl>http://bit.ly/mit-license</licenseUrl>
@@ -16,7 +16,7 @@ HeadJS provides you with:
* Asset Loader
Load assets when you need them.
-head.load("file1.js" , "file2.js", function() { done(); })
+head.load("file1.js" , "file2.js" , function() { done(); })
head.load("file1.css", "file2.css", function() { done(); })
* JavaScript Organizer
@@ -28,27 +28,27 @@ Detect and react to resolutions with simple css classes or js tests that work wi
.landscape, .lt-800, .gt-1680, if (head.mobile) { }
* Browser Detection
-Detect browsers &amp; versions, and apply css or js logic to them.
+Detect browsers &amp; their version, and apply css or js logic to them.
.gt-ie6, .lt-ie10, if (head.browser.ios) { }
* Feature Detection
Detect browser features like cssreflections, touch-enabled
-.no-cssreflections, .no-touch if (!head.touch) { }
+.no-touch if (!head.touch) { }
* CSS Moderniser
Detect css support like box-shadow, border-radius
.no-borderradius, if (!head.borderradius) { }
* CSS Router
-Detect page and section someone is on and target it with specific css.
+Detect which page and section someone is on and target it with specific css.
.index-page, .register-page, .root-section, .user-section,
-* HTML5 Enabler
+* HTML5 Shim
Need to support the new HTML5 tags in older browsers ? No problem !
* And more
..well, a little bit :-)</description>
- <summary>Load scripts on demand. Achieve responsive design with CSS that targets different screen reolutions, paths, states and browsers. Make it the only script in your HEAD. A concise solution to universal issues.</summary>
+ <summary>Load scripts and css on demand. Achieve responsive design with CSS that targets different screen resolutions, paths, states and browsers. Detect various browsers and their features. Target HTML5 and CSS3 safely.</summary>
<releaseNotes />
<copyright>Tero Piirainen</copyright>
<language>en-US</language>
View
19 index.html
@@ -6,8 +6,7 @@
<meta name="google-site-verification" content="pqzn85yrum0AY6ugIrX0zoIEazSHL9p09us5yvHwZqw" />
<title>HeadJS, the only script in your &lt;head&gt;</title>
- <meta name="description" content="Load scripts on demand. Use HTML5 and CSS3 safely. Target CSS for different screens, paths, states and browsers. Make it the only script in your HEAD. A concise solution to universal issues." />
- <meta name="keywords" content="labjs, modernizr, parallel script loading, javascript loader, non-blocking javascript, javascript modernizer" />
+ <meta name="description" content="Load scripts and css on demand. Achieve responsive design with CSS that targets different screen resolutions, paths, states and browsers. Detect various browsers and their features. Target HTML5 and CSS3 safely." />
<meta name="author" content="Tero Piirainen">
<!-- include the stylesheet after headjs -->
@@ -36,16 +35,16 @@
</a>
<div id="wrap">
<nav>
- <a href="#highlights">highlights</a> &bull;<a href="#theory">theory</a> &bull;<a href="#usage">usage</a> &bull;<a href="#api">api</a> &bull;<a href="#download">download <strong>(v 0.98)</strong></a>
+ <a href="#highlights">highlights</a> &bull;<a href="#theory">theory</a> &bull;<a href="#usage">usage</a> &bull;<a href="#api">api</a> &bull;<a href="#download">download <strong>(v 0.99)</strong></a>
</nav>
<div id="hero">
<h1>HEAD<em>JS</em></h1>
<h2>The only script in your &lt;HEAD&gt;</h2>
<h3>A tiny script that simplifies, speeds up, and modernizes your site</h3>
<p>
- Load scripts on demand.
- Achieve responsive design with CSS targeting different screen reolutions, paths, states and browsers.
- Detect browsers & browser features.
+ Load scripts and css on demand.
+ Achieve responsive design with CSS that targets different screen reolutions, paths, states and browsers.
+ Detect various browsers and their features.
Target HTML5 and CSS3 safely.
<br />
Make it the only script in your HEAD.
@@ -797,20 +796,20 @@
<h1>Download</h1>
<section id="download">
- <h2>Version 0.98</h2>
+ <h2>Version 0.99</h2>
<table>
<tr>
- <td><a href="https://github.com/headjs/headjs/raw/v0.98/dist/head.min.js" target="_blank" onclick="trackPageView('download/head.min.js')">head.min.js</a></td>
+ <td><a href="https://github.com/headjs/headjs/raw/v0.99/dist/head.min.js" target="_blank" onclick="trackPageView('download/head.min.js')">head.min.js</a></td>
<td>Full Bundle</td>
<td><small><em><strong>4.1K</strong> (minified &amp; gzipped)</em></small></td>
</tr>
<tr>
- <td><a href="https://github.com/headjs/headjs/raw/v0.98/dist/head.core.min.js" target="_blank" onclick="trackPageView('download/head.core.min.js')">head.core.min.js</a></td>
+ <td><a href="https://github.com/headjs/headjs/raw/v0.99/dist/head.core.min.js" target="_blank" onclick="trackPageView('download/head.core.min.js')">head.core.min.js</a></td>
<td>Responsive Design & Feature Detection Only</td>
<td><small><em><strong>1.8K</strong> (minified &amp; gzipped)</em></small></td>
</tr>
<tr>
- <td><a href="https://github.com/headjs/headjs/raw/v0.98/dist/head.load.min.js" target="_blank" onclick="trackPageView('download/head.load.min.js')">head.load.min.js</a></td>
+ <td><a href="https://github.com/headjs/headjs/raw/v0.99/dist/head.load.min.js" target="_blank" onclick="trackPageView('download/head.load.min.js')">head.load.min.js</a></td>
<td>JavaScript Loader Only</td>
<td><small><em><strong>1.9K</strong> (minified &amp; gzipped)</em></small></td>
</tr>
View
34 media/libs/headjs/0.99/head.min.js
@@ -1,17 +1,17 @@
-(function(a,v){function f(a){n[n.length]=a}function l(a){p.className=p.className.replace(RegExp("\\b"+a+"\\b"),"")}function j(a,d){for(var b=0,c=a.length;b<c;b++)d.call(a,a[b],b)}function r(){p.className=p.className.replace(/ (w-|eq-|gt-|gte-|lt-|lte-|portrait|no-portrait|landscape|no-landscape)\d+/g,"");var b=a.innerWidth||p.clientWidth,d=a.outerWidth||a.screen.width;g.screen.innerWidth=b;g.screen.outerWidth=d;f("w-"+b);j(c.screens,function(a){b>a?(c.screensCss.gt&&f("gt-"+a),c.screensCss.gte&&f("gte-"+
-a)):b<a?(c.screensCss.lt&&f("lt-"+a),c.screensCss.lte&&f("lte-"+a)):b===a&&(c.screensCss.lte&&f("lte-"+a),c.screensCss.eq&&f("e-q"+a),c.screensCss.gte&&f("gte-"+a))});var d=a.innerHeight||p.clientHeight,e=a.outerHeight||a.screen.height;g.screen.innerHeight=d;g.screen.outerHeight=e;g.feature("portrait",d>b);g.feature("landscape",d<b)}function q(){a.clearTimeout(t);t=a.setTimeout(r,100)}var m=a.document,e=a.navigator,s=a.location,p=m.documentElement,n=[],c={screens:[240,320,480,640,768,800,1024,1280,
-1440,1680,1920],screensCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!1},browsers:[{ie:{min:6,max:10}}],browserCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!0},section:"-section",page:"-page",head:"head"};if(a.head_conf)for(var b in a.head_conf)a.head_conf[b]!==v&&(c[b]=a.head_conf[b]);var g=a[c.head]=function(){g.ready.apply(null,arguments)};g.feature=function(a,b,c){if(!a)return p.className+=" "+n.join(" "),n=[],g;"[object Function]"===Object.prototype.toString.call(b)&&(b=b.call());f((b?"":"no-")+a);g[a]=!!b;c||(l("no-"+
-a),l(a),g.feature());return g};g.feature("js",!0);b=e.userAgent.toLowerCase();e=/mobile|midp/.test(b);g.feature("mobile",e,!0);g.feature("desktop",!e,!0);b=/(chrome|firefox)[ \/]([\w.]+)/.exec(b)||/(iphone|ipad|ipod)(?:.*version)?[ \/]([\w.]+)/.exec(b)||/(android)(?:.*version)?[ \/]([\w.]+)/.exec(b)||/(webkit|opera)(?:.*version)?[ \/]([\w.]+)/.exec(b)||/(msie) ([\w.]+)/.exec(b)||[];e=b[1];b=parseFloat(b[2]);switch(e){case "msie":e="ie";b=m.documentMode||b;break;case "firefox":e="ff";break;case "ipod":case "ipad":case "iphone":e=
-"ios";break;case "webkit":e="safari"}g.browser={name:e,version:b};g.browser[e]=!0;for(var u=0,w=c.browsers.length;u<w;u++)for(var i in c.browsers[u])if(e===i){f(i);for(var z=c.browsers[u][i].max,k=c.browsers[u][i].min;k<=z;k++)b>k?(c.browserCss.gt&&f("gt-"+i+k),c.browserCss.gte&&f("gte-"+i+k)):b<k?(c.browserCss.lt&&f("lt-"+i+k),c.browserCss.lte&&f("lte-"+i+k)):b===k&&(c.browserCss.lte&&f("lte-"+i+k),c.browserCss.eq&&f("eq-"+i+k),c.browserCss.gte&&f("gte-"+i+k))}else f("no-"+i);"ie"===e&&9>b&&j("abbr article aside audio canvas details figcaption figure footer header hgroup mark meter nav output progress section summary time video".split(" "),
-function(a){m.createElement(a)});j(s.pathname.split("/"),function(a,b){if(2<this.length&&this[b+1]!==v)b&&f(this.slice(1,b+1).join("-").toLowerCase()+c.section);else{var e=a||"index",g=e.indexOf(".");0<g&&(e=e.substring(0,g));p.id=e.toLowerCase()+c.page;b||f("root"+c.section)}});g.screen={height:a.screen.height,width:a.screen.width};r();var t=0;a.addEventListener?a.addEventListener("resize",q,!1):a.attachEvent("onresize",q)})(window);
-(function(a,v){function f(a){var f=a.charAt(0).toUpperCase()+a.substr(1),a=(a+" "+q.join(f+" ")+f).split(" "),c;a:{for(c in a)if(j[a[c]]!==v){c=!0;break a}c=void 0}return!!c}var l=a.document.createElement("i"),j=l.style,r=" -o- -moz- -ms- -webkit- -khtml- ".split(" "),q=["Webkit","Moz","O","ms","Khtml"],m=a[a.head_conf&&a.head_conf.head||"head"],e={gradient:function(){j.cssText=("background-image:"+r.join("gradient(linear,left top,right bottom,from(#9f9),to(#fff));background-image:")+r.join("linear-gradient(left top,#eee,#fff);background-image:")).slice(0,
--17);return!!j.backgroundImage},rgba:function(){j.cssText="background-color:rgba(0,0,0,0.5)";return!!j.backgroundColor},opacity:function(){return""===l.style.opacity},textshadow:function(){return""===j.textShadow},multiplebgs:function(){j.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(j.background)},boxshadow:function(){return f("boxShadow")},borderimage:function(){return f("borderImage")},borderradius:function(){return f("borderRadius")},cssreflections:function(){return f("boxReflect")},
-csstransforms:function(){return f("transform")},csstransitions:function(){return f("transition")},touch:function(){return"ontouchstart"in a},retina:function(){return 1<a.devicePixelRatio},fontface:function(){var a=m.browser.version;switch(m.browser.name){case "ie":return 9<=a;case "chrome":return 13<=a;case "ff":return 6<=a;case "ios":return 5<=a;case "android":return!1;case "webkit":return 5.1<=a;case "opera":return 10<=a;default:return!1}}},s;for(s in e)e[s]&&m.feature(s,e[s].call(),!0);m.feature()})(window);
-(function(a,v){function f(){}function l(h,a){if(h){"object"===typeof h&&(h=[].slice.call(h));for(var b=0,c=h.length;b<c;b++)a.call(h,h[b],b)}}function j(h,a){var b=Object.prototype.toString.call(a).slice(8,-1);return a!==v&&null!==a&&b===h}function r(a){return j("Function",a)}function q(a){a=a||f;a._done||(a(),a._done=1)}function m(a){var b={};if("object"===typeof a)for(var c in a)a[c]&&(b={name:c,url:a[c]});else b=a.split("/"),b=b[b.length-1],c=b.indexOf("?"),b={name:-1!==c?b.substring(0,c):b,url:a};
-return(a=i[b.name])&&a.url===b.url?a:i[b.name]=b}function e(a){var a=a||i,b;for(b in a)if(a.hasOwnProperty(b)&&a[b].state!==x)return!1;return!0}function s(a,b){b=b||f;a.state===x?b():a.state===C?d.ready(a.name,b):a.state===B?a.onpreload.push(function(){s(a,b)}):(a.state=C,p(a.url,function(){a.state=x;b();l(w[a.name],function(a){q(a)});t&&e()&&l(w.ALL,function(a){q(a)})}))}function p(h,c){var d;/\.css[^\.]*$/.test(h)?(d=b.createElement("link"),d.type="text/"+(h.type||"css"),d.rel="stylesheet",d.href=
-h.src||h):(d=b.createElement("script"),d.type="text/"+(h.type||"javascript"),d.src=h.src||h);var e=d,g=c,g=g||f;e.onload=e.onreadystatechange=function(h){h=h||a.event;if("load"===h.type||/loaded|complete/.test(e.readyState)&&(!b.documentMode||9>b.documentMode))e.onload=e.onreadystatechange=e.onerror=null,g()};e.onerror=function(){e.onload=e.onreadystatechange=e.onerror=null;g()};e.async=!1;e.defer=!1;d=b.head||b.getElementsByTagName("head")[0];d.insertBefore(e,d.lastChild)}function n(){b.body?t||
-(t=!0,l(g,function(a){q(a)})):(a.clearTimeout(d.readyTimeout),d.readyTimeout=a.setTimeout(n,50))}function c(){b.addEventListener?(b.removeEventListener("DOMContentLoaded",c,!1),n()):"complete"===b.readyState&&(b.detachEvent("onreadystatechange",c),n())}var b=a.document,g=[],u=[],w={},i={},z="async"in b.createElement("script")||"MozAppearance"in b.documentElement.style||a.opera,k,t,A=a.head_conf&&a.head_conf.head||"head",d=a[A]=a[A]||function(){d.ready.apply(null,arguments)},B=1,C=3,x=4;d.load=z?function(){var a=
-arguments,b=a[a.length-1],c={};r(b)||(b=null);l(a,function(d,f){d!==b&&(d=m(d),c[d.name]=d,s(d,b&&f===a.length-2?function(){e(c)&&q(b)}:null))});return d}:function(){var a=arguments,b=[].slice.call(a,1),c=b[0];if(!k)return u.push(function(){d.load.apply(null,a)}),d;c?(l(b,function(a){if(!r(a)){var b=m(a);b.state===v&&(b.state=B,b.onpreload=[],p({src:b.url,type:"cache"},function(){b.state=2;l(b.onpreload,function(a){a.call()})}))}}),s(m(a[0]),r(c)?c:function(){d.load.apply(null,b)})):s(m(a[0]));return d};
-d.js=d.load;d.test=function(a,b,c,e){a="object"===typeof a?a:{test:a,success:b?j("Array",b)?b:[b]:!1,failure:c?j("Array",c)?c:[c]:!1,callback:e||f};(b=!!a.test)&&a.success?(a.success.push(a.callback),d.load.apply(null,a.success)):!b&&a.failure?(a.failure.push(a.callback),d.load.apply(null,a.failure)):e();return d};d.ready=function(a,c){if(a===b)return t?q(c):g.push(c),d;r(a)&&(c=a,a="ALL");if("string"!==typeof a||!r(c))return d;var f=i[a];if(f&&f.state===x||"ALL"===a&&e()&&t)return q(c),d;(f=w[a])?
-f.push(c):w[a]=[c];return d};d.ready(b,function(){e()&&l(w.ALL,function(a){q(a)});d.feature&&d.feature("domloaded",!0)});if("complete"===b.readyState)n();else if(b.addEventListener)b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",n,!1);else{b.attachEvent("onreadystatechange",c);a.attachEvent("onload",n);var y=!1;try{y=null==a.frameElement&&b.documentElement}catch(E){}y&&y.doScroll&&function D(){if(!t){try{y.doScroll("left")}catch(b){a.clearTimeout(d.readyTimeout);d.readyTimeout=
-a.setTimeout(D,50);return}n()}}()}setTimeout(function(){k=!0;l(u,function(a){a()})},300)})(window);
+(function(a,w){function f(a){p[p.length]=a}function m(a){q.className=q.className.replace(RegExp("\\b"+a+"\\b"),"")}function k(a,d){for(var b=0,c=a.length;b<c;b++)d.call(a,a[b],b)}function s(){q.className=q.className.replace(/ (w-|eq-|gt-|gte-|lt-|lte-|portrait|no-portrait|landscape|no-landscape)\d+/g,"");var b=a.innerWidth||q.clientWidth,d=a.outerWidth||a.screen.width;h.screen.innerWidth=b;h.screen.outerWidth=d;f("w-"+b);k(c.screens,function(a){b>a?(c.screensCss.gt&&f("gt-"+a),c.screensCss.gte&&f("gte-"+
+a)):b<a?(c.screensCss.lt&&f("lt-"+a),c.screensCss.lte&&f("lte-"+a)):b===a&&(c.screensCss.lte&&f("lte-"+a),c.screensCss.eq&&f("e-q"+a),c.screensCss.gte&&f("gte-"+a))});var d=a.innerHeight||q.clientHeight,g=a.outerHeight||a.screen.height;h.screen.innerHeight=d;h.screen.outerHeight=g;h.feature("portrait",d>b);h.feature("landscape",d<b)}function r(){a.clearTimeout(u);u=a.setTimeout(s,100)}var n=a.document,g=a.navigator,t=a.location,q=n.documentElement,p=[],c={screens:[240,320,480,640,768,800,1024,1280,
+1440,1680,1920],screensCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!1},browsers:[{ie:{min:6,max:10}}],browserCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!0},section:"-section",page:"-page",head:"head"};if(a.head_conf)for(var b in a.head_conf)a.head_conf[b]!==w&&(c[b]=a.head_conf[b]);var h=a[c.head]=function(){h.ready.apply(null,arguments)};h.feature=function(a,b,c){if(!a)return q.className+=" "+p.join(" "),p=[],h;"[object Function]"===Object.prototype.toString.call(b)&&(b=b.call());f((b?"":"no-")+a);h[a]=!!b;c||(m("no-"+
+a),m(a),h.feature());return h};h.feature("js",!0);b=g.userAgent.toLowerCase();g=/mobile|midp/.test(b);h.feature("mobile",g,!0);h.feature("desktop",!g,!0);b=/(chrome|firefox)[ \/]([\w.]+)/.exec(b)||/(iphone|ipad|ipod)(?:.*version)?[ \/]([\w.]+)/.exec(b)||/(android)(?:.*version)?[ \/]([\w.]+)/.exec(b)||/(webkit|opera)(?:.*version)?[ \/]([\w.]+)/.exec(b)||/(msie) ([\w.]+)/.exec(b)||[];g=b[1];b=parseFloat(b[2]);switch(g){case "msie":g="ie";b=n.documentMode||b;break;case "firefox":g="ff";break;case "ipod":case "ipad":case "iphone":g=
+"ios";break;case "webkit":g="safari"}h.browser={name:g,version:b};h.browser[g]=!0;for(var v=0,x=c.browsers.length;v<x;v++)for(var i in c.browsers[v])if(g===i){f(i);for(var A=c.browsers[v][i].max,l=c.browsers[v][i].min;l<=A;l++)b>l?(c.browserCss.gt&&f("gt-"+i+l),c.browserCss.gte&&f("gte-"+i+l)):b<l?(c.browserCss.lt&&f("lt-"+i+l),c.browserCss.lte&&f("lte-"+i+l)):b===l&&(c.browserCss.lte&&f("lte-"+i+l),c.browserCss.eq&&f("eq-"+i+l),c.browserCss.gte&&f("gte-"+i+l))}else f("no-"+i);"ie"===g&&9>b&&k("abbr article aside audio canvas details figcaption figure footer header hgroup mark meter nav output progress section summary time video".split(" "),
+function(a){n.createElement(a)});k(t.pathname.split("/"),function(a,b){if(2<this.length&&this[b+1]!==w)b&&f(this.slice(1,b+1).join("-").toLowerCase()+c.section);else{var g=a||"index",h=g.indexOf(".");0<h&&(g=g.substring(0,h));q.id=g.toLowerCase()+c.page;b||f("root"+c.section)}});h.screen={height:a.screen.height,width:a.screen.width};s();var u=0;a.addEventListener?a.addEventListener("resize",r,!1):a.attachEvent("onresize",r)})(window);
+(function(a,w){function f(a){var f=a.charAt(0).toUpperCase()+a.substr(1),a=(a+" "+r.join(f+" ")+f).split(" "),c;a:{for(c in a)if(k[a[c]]!==w){c=!0;break a}c=!1}return!!c}var m=a.document.createElement("i"),k=m.style,s=" -o- -moz- -ms- -webkit- -khtml- ".split(" "),r=["Webkit","Moz","O","ms","Khtml"],n=a[a.head_conf&&a.head_conf.head||"head"],g={gradient:function(){k.cssText=("background-image:"+s.join("gradient(linear,left top,right bottom,from(#9f9),to(#fff));background-image:")+s.join("linear-gradient(left top,#eee,#fff);background-image:")).slice(0,
+-17);return!!k.backgroundImage},rgba:function(){k.cssText="background-color:rgba(0,0,0,0.5)";return!!k.backgroundColor},opacity:function(){return""===m.style.opacity},textshadow:function(){return""===k.textShadow},multiplebgs:function(){k.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(k.background)},boxshadow:function(){return f("boxShadow")},borderimage:function(){return f("borderImage")},borderradius:function(){return f("borderRadius")},cssreflections:function(){return f("boxReflect")},
+csstransforms:function(){return f("transform")},csstransitions:function(){return f("transition")},touch:function(){return"ontouchstart"in a},retina:function(){return 1<a.devicePixelRatio},fontface:function(){var a=n.browser.version;switch(n.browser.name){case "ie":return 9<=a;case "chrome":return 13<=a;case "ff":return 6<=a;case "ios":return 5<=a;case "android":return!1;case "webkit":return 5.1<=a;case "opera":return 10<=a;default:return!1}}},t;for(t in g)g[t]&&n.feature(t,g[t].call(),!0);n.feature()})(window);
+(function(a,w){function f(){}function m(j,a){if(j){"object"===typeof j&&(j=[].slice.call(j));for(var b=0,c=j.length;b<c;b++)a.call(j,j[b],b)}}function k(a,b){var e=Object.prototype.toString.call(b).slice(8,-1);return b!==w&&null!==b&&e===a}function s(a){return k("Function",a)}function r(a){a=a||f;a._done||(a(),a._done=1)}function n(a){var b={};if("object"===typeof a)for(var e in a)a[e]&&(b={name:e,url:a[e]});else b=a.split("/"),b=b[b.length-1],e=b.indexOf("?"),b={name:-1!==e?b.substring(0,e):b,url:a};
+return(a=i[b.name])&&a.url===b.url?a:i[b.name]=b}function g(a){var a=a||i,b;for(b in a)if(a.hasOwnProperty(b)&&a[b].state!==y)return!1;return!0}function t(a,b){b=b||f;a.state===y?b():a.state===D?d.ready(a.name,b):a.state===C?a.onpreload.push(function(){t(a,b)}):(a.state=D,q(a,function(){a.state=y;b();m(x[a.name],function(a){r(a)});u&&g()&&m(x.ALL,function(a){r(a)})}))}function q(j,c){var c=c||f,e;/\.css[^\.]*$/.test(j.url)?(e=b.createElement("link"),e.type="text/"+(j.type||"css"),e.rel="stylesheet",
+e.href=j.url):(e=b.createElement("script"),e.type="text/"+(j.type||"javascript"),e.src=j.url);e.onload=e.onreadystatechange=function(j){j=j||a.event;if("load"===j.type||/loaded|complete/.test(e.readyState)&&(!b.documentMode||9>b.documentMode))e.onload=e.onreadystatechange=e.onerror=null,c()};e.onerror=function(){e.onload=e.onreadystatechange=e.onerror=null;c()};e.async=!1;e.defer=!1;var d=b.head||b.getElementsByTagName("head")[0];d.insertBefore(e,d.lastChild)}function p(){b.body?u||(u=!0,m(h,function(a){r(a)})):
+(a.clearTimeout(d.readyTimeout),d.readyTimeout=a.setTimeout(p,50))}function c(){b.addEventListener?(b.removeEventListener("DOMContentLoaded",c,!1),p()):"complete"===b.readyState&&(b.detachEvent("onreadystatechange",c),p())}var b=a.document,h=[],v=[],x={},i={},A="async"in b.createElement("script")||"MozAppearance"in b.documentElement.style||a.opera,l,u,B=a.head_conf&&a.head_conf.head||"head",d=a[B]=a[B]||function(){d.ready.apply(null,arguments)},C=1,D=3,y=4;d.load=A?function(){var a=arguments,b=a[a.length-
+1],e={};s(b)||(b=null);m(a,function(c,d){c!==b&&(c=n(c),e[c.name]=c,t(c,b&&d===a.length-2?function(){g(e)&&r(b)}:null))});return d}:function(){var a=arguments,b=[].slice.call(a,1),c=b[0];if(!l)return v.push(function(){d.load.apply(null,a)}),d;c?(m(b,function(a){if(!s(a)){var b=n(a);b.state===w&&(b.state=C,b.onpreload=[],q({url:b.url,type:"cache"},function(){b.state=2;m(b.onpreload,function(a){a.call()})}))}}),t(n(a[0]),s(c)?c:function(){d.load.apply(null,b)})):t(n(a[0]));return d};d.js=d.load;d.test=
+function(a,b,c,g){a="object"===typeof a?a:{test:a,success:b?k("Array",b)?b:[b]:!1,failure:c?k("Array",c)?c:[c]:!1,callback:g||f};(b=!!a.test)&&a.success?(a.success.push(a.callback),d.load.apply(null,a.success)):!b&&a.failure?(a.failure.push(a.callback),d.load.apply(null,a.failure)):g();return d};d.ready=function(a,c){if(a===b)return u?r(c):h.push(c),d;s(a)&&(c=a,a="ALL");if("string"!==typeof a||!s(c))return d;var e=i[a];if(e&&e.state===y||"ALL"===a&&g()&&u)return r(c),d;(e=x[a])?e.push(c):x[a]=[c];
+return d};d.ready(b,function(){g()&&m(x.ALL,function(a){r(a)});d.feature&&d.feature("domloaded",!0)});if("complete"===b.readyState)p();else if(b.addEventListener)b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",p,!1);else{b.attachEvent("onreadystatechange",c);a.attachEvent("onload",p);var z=!1;try{z=null==a.frameElement&&b.documentElement}catch(F){}z&&z.doScroll&&function E(){if(!u){try{z.doScroll("left")}catch(b){a.clearTimeout(d.readyTimeout);d.readyTimeout=a.setTimeout(E,50);
+return}p()}}()}setTimeout(function(){l=!0;m(v,function(a){a()})},300)})(window);
View
164 src/load.js
@@ -14,7 +14,7 @@
domWaiters = [],
queue = [], // waiters for the "head ready" event
handlers = {}, // user functions waiting for events
- scripts = {}, // loadable scripts in different states
+ assets = {}, // loadable items in various states
isAsync = "async" in doc.createElement("script") || "MozAppearance" in doc.documentElement.style || win.opera,
isHeadReady,
isDomReady,
@@ -47,7 +47,7 @@
each(args, function (item, i) {
if (item !== callback) {
- item = getScript(item);
+ item = getAsset(item);
items[item.name] = item;
load(item, callback && i === args.length - 2 ? function () {
@@ -84,24 +84,22 @@
/* Preload with text/cache hack (not good!)
* http://blog.getify.com/on-script-loaders/
* http://www.nczonline.net/blog/2010/12/21/thoughts-on-script-loaders/
- * If caching is not configured correctly on the server, then scripts will load twice !
- **************************************************************************************/
+ * If caching is not configured correctly on the server, then items could load twice !
+ *************************************************************************************/
each(rest, function (item) {
if (!isFunction(item)) {
- preLoad(getScript(item));
+ preLoad(getAsset(item));
}
});
// execute
- load(getScript(args[0]), isFunction(next) ? next : function () {
+ load(getAsset(args[0]), isFunction(next) ? next : function () {
api.load.apply(null, rest);
- });
-
-
- // single script
+ });
}
else {
- load(getScript(args[0]));
+ // single item
+ load(getAsset(args[0]));
}
return api;
@@ -191,10 +189,10 @@
}
// This can also be called when we trigger events based on filenames & labels
- var script = scripts[key];
+ var asset = assets[key];
- // script already loaded --> execute and return
- if (script && script.state === LOADED || key === 'ALL' && allLoaded() && isDomReady) {
+ // item already loaded --> execute and return
+ if (asset && asset.state === LOADED || key === 'ALL' && allLoaded() && isDomReady) {
one(callback);
return api;
}
@@ -286,20 +284,21 @@
callback._done = 1;
}
- function getScript(item) {
+ function getAsset(item) {
///<summary>
- /// Gets a script in the form of
+ /// Assets are in the form of
/// {
- /// name: label,
- /// url : url
+ /// name : label,
+ /// url : url,
+ /// state: state
/// }
///</summary>
- var script = {};
+ var asset = {};
if (typeof item === 'object') {
for (var label in item) {
if (!!item[label]) {
- script = {
+ asset = {
name: label,
url : item[label]
};
@@ -307,24 +306,24 @@
}
}
else {
- script = {
+ asset = {
name: toLabel(item),
url : item
};
}
// is the item already existant
- var existing = scripts[script.name];
- if (existing && existing.url === script.url) {
+ var existing = assets[asset.name];
+ if (existing && existing.url === asset.url) {
return existing;
}
- scripts[script.name] = script;
- return script;
+ assets[asset.name] = asset;
+ return asset;
}
function allLoaded(items) {
- items = items || scripts;
+ items = items || assets;
for (var name in items) {
if (items.hasOwnProperty(name) && items[name].state !== LOADED) {
@@ -336,60 +335,60 @@
}
- function onPreload(script) {
- script.state = PRELOADED;
+ function onPreload(asset) {
+ asset.state = PRELOADED;
- each(script.onpreload, function (afterPreload) {
+ each(asset.onpreload, function (afterPreload) {
afterPreload.call();
});
}
- function preLoad(script, callback) {
- if (script.state === undefined) {
+ function preLoad(asset, callback) {
+ if (asset.state === undefined) {
- script.state = PRELOADING;
- script.onpreload = [];
+ asset.state = PRELOADING;
+ asset.onpreload = [];
- scriptTag({ src: script.url, type: 'cache' }, function () {
- onPreload(script);
+ loadAsset({ url: asset.url, type: 'cache' }, function () {
+ onPreload(asset);
});
}
}
- function load(script, callback) {
+ function load(asset, callback) {
///<summary>Used with normal loading logic</summary>
callback = callback || noop;
- if (script.state === LOADED) {
+ if (asset.state === LOADED) {
callback();
return;
}
// INFO: why would we trigger a ready event when its not really loaded yet ?
- if (script.state === LOADING) {
- api.ready(script.name, callback);
+ if (asset.state === LOADING) {
+ api.ready(asset.name, callback);
return;
}
- if (script.state === PRELOADING) {
- script.onpreload.push(function () {
- load(script, callback);
+ if (asset.state === PRELOADING) {
+ asset.onpreload.push(function () {
+ load(asset, callback);
});
return;
}
- script.state = LOADING;
-
- scriptTag(script.url, function () {
- script.state = LOADED;
+ asset.state = LOADING;
+
+ loadAsset(asset, function () {
+ asset.state = LOADED;
callback();
- // handlers for this script
- each(handlers[script.name], function (fn) {
+ // handlers for this asset
+ each(handlers[asset.name], function (fn) {
one(fn);
});
- // dom is ready & no scripts are queued for loading
+ // dom is ready & no assets are queued for loading
// INFO: shouldn't we be doing the same test above ?
if (isDomReady && allLoaded()) {
each(handlers.ALL, function (fn) {
@@ -398,32 +397,27 @@
}
});
}
-
- function scriptTag(src, callback) {
- var s;
-
- if (/\.css[^\.]*$/.test(src)) {
- s = doc.createElement('link');
- s.type = 'text/' + (src.type || 'css');
- s.rel = 'stylesheet';
- s.href = src.src || src;
- }
- else {
- s = doc.createElement('script');
- s.type = 'text/' + (src.type || 'javascript');
- s.src = src.src || src;
- }
-
- loadAsset(s, callback);
- }
/* Parts inspired from: https://github.com/cujojs/curl
******************************************************/
- function loadAsset(s, callback) {
+ function loadAsset(asset, callback) {
callback = callback || noop;
- s.onload = s.onreadystatechange = process;
- s.onerror = error;
+ var ele;
+ if (/\.css[^\.]*$/.test(asset.url)) {
+ ele = doc.createElement('link');
+ ele.type = 'text/' + (asset.type || 'css');
+ ele.rel = 'stylesheet';
+ ele.href = asset.url;
+ }
+ else {
+ ele = doc.createElement('script');
+ ele.type = 'text/' + (asset.type || 'javascript');
+ ele.src = asset.url;
+ }
+
+ ele.onload = ele.onreadystatechange = process;
+ ele.onerror = error;
/* Good read, but doesn't give much hope !
* http://blog.getify.com/on-script-loaders/
@@ -432,16 +426,18 @@
*/
// ASYNC: load in parellel and execute as soon as possible
- s.async = false;
+ ele.async = false;
// DEFER: load in parallel but maintain execution order
- s.defer = false;
+ ele.defer = false;
function error(event) {
+ event = event || win.event;
+
// need some more detailed error handling here
// release event listeners
- s.onload = s.onreadystatechange = s.onerror = null;
-
+ ele.onload = ele.onreadystatechange = ele.onerror = null;
+
// do callback
callback();
}
@@ -491,26 +487,26 @@
// event.type == 'load' && s.readyState = undefined
-
// !doc.documentMode is for IE6/7, IE8+ have documentMode
- if (event.type === 'load' || (/loaded|complete/.test(s.readyState) && (!doc.documentMode || doc.documentMode < 9))) {
+ if (event.type === 'load' || (/loaded|complete/.test(ele.readyState) && (!doc.documentMode || doc.documentMode < 9))) {
// release event listeners
- s.onload = s.onreadystatechange = s.onerror = null;
+ ele.onload = ele.onreadystatechange = ele.onerror = null;
+
// do callback
callback();
}
// emulates error on browsers that don't create an exception
// INFO: timeout not clearing ..why ?
- //s.timeout = win.setTimeout(function () {
+ //asset.timeout = win.setTimeout(function () {
// error({ type: "timeout" });
- //}, 7000);
+ //}, 3000);
}
// use insertBefore to keep IE from throwing Operation Aborted (thx Bryan Forbes!)
var head = doc['head'] || doc.getElementsByTagName('head')[0];
// but insert at end of head, because otherwise if it is a stylesheet, it will not ovverride values
- head.insertBefore(s, head.lastChild);
+ head.insertBefore(ele, head.lastChild);
}
/* Mix of stuff from jQuery & IEContentLoaded
@@ -519,7 +515,7 @@
function domReady() {
// Make sure body exists, at least, in case IE gets a little overzealous (jQuery ticket #5443).
if (!doc.body) {
- // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if scripts are queued)
+ // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if assets are queued)
win.clearTimeout(api.readyTimeout);
api.readyTimeout = win.setTimeout(domReady, 50);
return;
@@ -588,7 +584,7 @@
// http://javascript.nwbox.com/IEContentLoaded/
top.doScroll("left");
} catch (error) {
- // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if scripts are queued)
+ // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if assets are queued)
win.clearTimeout(api.readyTimeout);
api.readyTimeout = win.setTimeout(doScrollCheck, 50);
return;
@@ -602,8 +598,8 @@
}
/*
- We wait for 300 ms before script loading starts. for some reason this is needed
- to make sure scripts are cached. Not sure why this happens yet. A case study:
+ We wait for 300 ms before asset loading starts. for some reason this is needed
+ to make sure assets are cached. Not sure why this happens yet. A case study:
https://github.com/headjs/headjs/issues/closed#issue/83
*/
View
21 test/style.css
@@ -1,10 +1,9 @@
-
html {
background-color: #f9f9f9;
}
body {
color: #333;
- font: 13px sans-serif;