Permalink
Browse files

reverted to original 0.99 files

  • Loading branch information...
1 parent 9c5b9c4 commit 03f5d55d4c9f8a12b7177538c18563fdab5ac4a3 @robert-hoffmann robert-hoffmann committed Nov 23, 2013
View
@@ -1,14 +1,15 @@
///#source 1 1 /src/0.99/core.js
-/*!
- * HeadJS The only script in your <HEAD>
+/*! head.core v0.99 */
+/*
+ * HeadJS The only script in your <HEAD>
* Author Tero Piirainen (tipiirai)
* Maintainer Robert Hoffmann (itechnology)
* License MIT / http://bit.ly/mit-license
*
* Version 0.99
* http://headjs.com
*/
-(function(win, undefined) {
+; (function (win, undefined) {
"use strict";
// gt, gte, lt, lte, eq breakpoints would have been more simple to write as ['gt','gte','lt','lte','eq']
@@ -20,21 +21,20 @@
html = doc.documentElement,
klass = [],
conf = {
- screens : [240, 320, 480, 640, 768, 800, 1024, 1280, 1440, 1680, 1920],
+ screens : [240, 320, 480, 640, 768, 800, 1024, 1280, 1440, 1680, 1920],
screensCss: { "gt": true, "gte": false, "lt": true, "lte": false, "eq": false },
browsers : [
- { ie: { min: 6, max: 11 } }
- //,{ chrome : { min: 8, max: 31 } }
- //,{ ff : { min: 3, max: 26 } }
- //,{ ios : { min: 3, max: 7 } }
- //,{ android: { min: 2, max: 4 } }
- //,{ webkit : { min: 9, max: 12 } }
- //,{ opera : { min: 9, max: 12 } }
- ],
+ { ie : { min: 6, max: 11 } }
+ //,{ chrome : { min: 8, max: 29 } }
+ //,{ ff : { min: 3, max: 24 } }
+ //,{ ios : { min: 3, max: 6 } }
+ //,{ android: { min: 2, max: 4 } }
+ //,{ webkit : { min: 9, max: 12 } }
+ //,{ opera : { min: 9, max: 12 } }
+ ],
browserCss: { "gt": true, "gte": false, "lt": true, "lte": false, "eq": true },
- html5 : true,
- page : "-page",
section : "-section",
+ page : "-page",
head : "head"
};
@@ -51,11 +51,8 @@
}
function removeClass(name) {
- // need to test for both space and no space
- // https://github.com/headjs/headjs/issues/270
- // https://github.com/headjs/headjs/issues/226
- var re = new RegExp(" ?\\b" + name + "\\b");
- html.className = html.className.replace(re, "");
+ var re = new RegExp(" \\b" + name + "\\b");
+ html.className = html.className.replace(re, '');
}
function each(arr, fn) {
@@ -65,30 +62,29 @@
}
// API
- var api = win[conf.head] = function() {
+ var api = win[conf.head] = function () {
api.ready.apply(null, arguments);
};
- api.feature = function(key, enabled, queue) {
+ api.feature = function (key, enabled, queue) {
// internal: apply all classes
if (!key) {
- html.className += " " + klass.join(" ");
+ html.className += ' ' + klass.join(' ');
klass = [];
-
return api;
}
- if (Object.prototype.toString.call(enabled) === "[object Function]") {
+ if (Object.prototype.toString.call(enabled) === '[object Function]') {
enabled = enabled.call();
}
- pushClass((enabled ? "" : "no-") + key);
+ pushClass((enabled ? '' : 'no-') + key);
api[key] = !!enabled;
// apply class to HTML element
if (!queue) {
- removeClass("no-" + key);
+ removeClass('no-' + key);
removeClass(key);
api.feature();
}
@@ -101,55 +97,54 @@
// browser type & version
var ua = nav.userAgent.toLowerCase(),
- mobile = /mobile|android|kindle|silk|midp|phone|(windows .+arm|touch)/.test(ua);
+ mobile = /mobile|android|kindle|silk|midp|(windows nt 6\.2.+arm|touch)/.test(ua);
- // useful for enabling/disabling feature (we can consider a desktop navigator to have more cpu/gpu power)
+ // useful for enabling/disabling feature (we can consider a desktop navigator to have more cpu/gpu power)
api.feature("mobile" , mobile , true);
api.feature("desktop", !mobile, true);
// http://www.zytrax.com/tech/web/browser_ids.htm
// http://www.zytrax.com/tech/web/mobile_ids.html
ua = /(chrome|firefox)[ \/]([\w.]+)/.exec(ua) || // Chrome & Firefox
- /(iphone|ipad|ipod)(?:.*version)?[ \/]([\w.]+)/.exec(ua) || // Mobile IOS
- /(android)(?:.*version)?[ \/]([\w.]+)/.exec(ua) || // Mobile Webkit
- /(webkit|opera)(?:.*version)?[ \/]([\w.]+)/.exec(ua) || // Safari & Opera
- /(msie) ([\w.]+)/.exec(ua) ||
- /(trident).+rv:(\w.)+/.exec(ua) || [];
+ /(iphone|ipad|ipod)(?:.*version)?[ \/]([\w.]+)/.exec(ua) || // Mobile IOS
+ /(android)(?:.*version)?[ \/]([\w.]+)/.exec(ua) || // Mobile Webkit
+ /(webkit|opera)(?:.*version)?[ \/]([\w.]+)/.exec(ua) || // Safari & Opera
+ /(msie) ([\w.]+)/.exec(ua) || [];
- var browser = ua[1],
- version = parseFloat(ua[2]);
+ var browser = ua[1],
+ version = parseFloat(ua[2]);
+
switch (browser) {
- case "msie":
- case "trident":
- browser = "ie";
- version = doc.documentMode || version;
- break;
-
- case "firefox":
- browser = "ff";
- break;
-
- case "ipod":
- case "ipad":
- case "iphone":
- browser = "ios";
- break;
-
- case "webkit":
- browser = "safari";
- break;
+ case 'msie':
+ browser = 'ie';
+ version = doc.documentMode || version;
+ break;
+
+ case 'firefox':
+ browser = 'ff';
+ break;
+
+ case 'ipod':
+ case 'ipad':
+ case 'iphone':
+ browser = 'ios';
+ break;
+
+ case 'webkit':
+ browser = 'safari';
+ break;
}
// Browser vendor and version
api.browser = {
- name: browser,
+ name : browser,
version: version
};
api.browser[browser] = true;
for (var i = 0, l = conf.browsers.length; i < l; i++) {
- for (var key in conf.browsers[i]) {
+ for (var key in conf.browsers[i]) {
if (browser === key) {
pushClass(key);
@@ -158,55 +153,53 @@
for (var v = min; v <= max; v++) {
if (version > v) {
- if (conf.browserCss.gt) {
+ if (conf.browserCss.gt)
pushClass("gt-" + key + v);
- }
- if (conf.browserCss.gte) {
+ if (conf.browserCss.gte)
pushClass("gte-" + key + v);
- }
- } else if (version < v) {
- if (conf.browserCss.lt) {
+ }
+
+ else if (version < v) {
+ if (conf.browserCss.lt)
pushClass("lt-" + key + v);
- }
-
- if (conf.browserCss.lte) {
- pushClass("lte-" + key + v);
- }
- } else if (version === v) {
- if (conf.browserCss.lte) {
+
+ if (conf.browserCss.lte)
pushClass("lte-" + key + v);
- }
+ }
- if (conf.browserCss.eq) {
+ else if (version === v) {
+ if (conf.browserCss.lte)
+ pushClass("lte-" + key + v);
+
+ if (conf.browserCss.eq)
pushClass("eq-" + key + v);
- }
- if (conf.browserCss.gte) {
+ if (conf.browserCss.gte)
pushClass("gte-" + key + v);
- }
}
}
- } else {
- pushClass("no-" + key);
+ }
+ else {
+ pushClass('no-' + key);
}
}
}
-
+
pushClass(browser);
pushClass(browser + parseInt(version, 10));
// IE lt9 specific
- if (conf.html5 && browser === "ie" && version < 9) {
+ if (browser === "ie" && version < 9) {
// HTML5 support : you still need to add html5 css initialization styles to your site
// See: assets/html5.css
- each("abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|main|mark|meter|nav|output|progress|section|summary|time|video".split("|"), function(el) {
+ each("abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|main|mark|meter|nav|output|progress|section|summary|time|video".split("|"), function (el) {
doc.createElement(el);
});
}
// CSS "router"
- each(loc.pathname.split("/"), function(el, i) {
+ each(loc.pathname.split("/"), function (el, i) {
if (this.length > 2 && this[i + 1] !== undefined) {
if (i) {
pushClass(this.slice(i, i + 1).join("-").toLowerCase() + conf.section);
@@ -241,52 +234,49 @@
// Viewport width
var iw = win.innerWidth || html.clientWidth,
ow = win.outerWidth || win.screen.width;
-
+
api.screen.innerWidth = iw;
api.screen.outerWidth = ow;
-
+
// for debugging purposes, not really useful for anything else
pushClass("w-" + iw);
- each(conf.screens, function(width) {
+ each(conf.screens, function (width) {
if (iw > width) {
- if (conf.screensCss.gt) {
+ if (conf.screensCss.gt)
pushClass("gt-" + width);
- }
-
- if (conf.screensCss.gte) {
+
+ if (conf.screensCss.gte)
pushClass("gte-" + width);
- }
- } else if (iw < width) {
- if (conf.screensCss.lt) {
- pushClass("lt-" + width);
- }
+ }
- if (conf.screensCss.lte) {
+ else if (iw < width) {
+ if (conf.screensCss.lt)
+ pushClass("lt-" + width);
+
+ if (conf.screensCss.lte)
pushClass("lte-" + width);
- }
- } else if (iw === width) {
- if (conf.screensCss.lte) {
+ }
+
+ else if (iw === width) {
+ if (conf.screensCss.lte)
pushClass("lte-" + width);
- }
- if (conf.screensCss.eq) {
+ if (conf.screensCss.eq)
pushClass("e-q" + width);
- }
- if (conf.screensCss.gte) {
+ if (conf.screensCss.gte)
pushClass("gte-" + width);
- }
}
});
-
+
// Viewport height
var ih = win.innerHeight || html.clientHeight,
oh = win.outerHeight || win.screen.height;
api.screen.innerHeight = ih;
api.screen.outerHeight = oh;
-
+
// no need for onChange event to detect this
api.feature("portrait" , (ih > iw));
api.feature("landscape", (ih < iw));
@@ -296,7 +286,6 @@
// Throttle navigators from triggering too many resize events
var resizeId = 0;
-
function onResize() {
win.clearTimeout(resizeId);
resizeId = win.setTimeout(screenSize, 50);
@@ -307,7 +296,6 @@
win.addEventListener("resize", onResize, false);
} else {
- // IE8 and less
win.attachEvent("onresize", onResize);
}
-}(window));
+})(window);
@@ -1,11 +1,5 @@
-/*!
- * HeadJS The only script in your <HEAD>
- * Author Tero Piirainen (tipiirai)
- * Maintainer Robert Hoffmann (itechnology)
- * License MIT / http://bit.ly/mit-license
- *
- * Version 0.99
- * http://headjs.com
- */
-(function(n,t){"use strict";function r(n){a[a.length]=n}function k(n){var t=new RegExp(" ?\\b"+n+"\\b");c.className=c.className.replace(t,"")}function p(n,t){for(var i=0,r=n.length;i<r;i++)t.call(n,n[i],i)}function tt(){var t,e,f,o;c.className=c.className.replace(/ (w-|eq-|gt-|gte-|lt-|lte-|portrait|no-portrait|landscape|no-landscape)\d+/g,""),t=n.innerWidth||c.clientWidth,e=n.outerWidth||n.screen.width,u.screen.innerWidth=t,u.screen.outerWidth=e,r("w-"+t),p(i.screens,function(n){t>n?(i.screensCss.gt&&r("gt-"+n),i.screensCss.gte&&r("gte-"+n)):t<n?(i.screensCss.lt&&r("lt-"+n),i.screensCss.lte&&r("lte-"+n)):t===n&&(i.screensCss.lte&&r("lte-"+n),i.screensCss.eq&&r("e-q"+n),i.screensCss.gte&&r("gte-"+n))}),f=n.innerHeight||c.clientHeight,o=n.outerHeight||n.screen.height,u.screen.innerHeight=f,u.screen.outerHeight=o,u.feature("portrait",f>t),u.feature("landscape",f<t)}function it(){n.clearTimeout(b),b=n.setTimeout(tt,50)}var y=n.document,rt=n.navigator,ut=n.location,c=y.documentElement,a=[],i={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:11}}],browserCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!0},html5:!0,page:"-page",section:"-section",head:"head"},v,u,s,w,o,h,l,d,f,g,nt,e,b;if(n.head_conf)for(v in n.head_conf)n.head_conf[v]!==t&&(i[v]=n.head_conf[v]);u=n[i.head]=function(){u.ready.apply(null,arguments)},u.feature=function(n,t,i){return n?(Object.prototype.toString.call(t)==="[object Function]"&&(t=t.call()),r((t?"":"no-")+n),u[n]=!!t,i||(k("no-"+n),k(n),u.feature()),u):(c.className+=" "+a.join(" "),a=[],u)},u.feature("js",!0),s=rt.userAgent.toLowerCase(),w=/mobile|android|kindle|silk|midp|phone|(windows .+arm|touch)/.test(s),u.feature("mobile",w,!0),u.feature("desktop",!w,!0),s=/(chrome|firefox)[ \/]([\w.]+)/.exec(s)||/(iphone|ipad|ipod)(?:.*version)?[ \/]([\w.]+)/.exec(s)||/(android)(?:.*version)?[ \/]([\w.]+)/.exec(s)||/(webkit|opera)(?:.*version)?[ \/]([\w.]+)/.exec(s)||/(msie) ([\w.]+)/.exec(s)||/(trident).+rv:(\w.)+/.exec(s)||[],o=s[1],h=parseFloat(s[2]);switch(o){case"msie":case"trident":o="ie",h=y.documentMode||h;break;case"firefox":o="ff";break;case"ipod":case"ipad":case"iphone":o="ios";break;case"webkit":o="safari"}for(u.browser={name:o,version:h},u.browser[o]=!0,l=0,d=i.browsers.length;l<d;l++)for(f in i.browsers[l])if(o===f)for(r(f),g=i.browsers[l][f].min,nt=i.browsers[l][f].max,e=g;e<=nt;e++)h>e?(i.browserCss.gt&&r("gt-"+f+e),i.browserCss.gte&&r("gte-"+f+e)):h<e?(i.browserCss.lt&&r("lt-"+f+e),i.browserCss.lte&&r("lte-"+f+e)):h===e&&(i.browserCss.lte&&r("lte-"+f+e),i.browserCss.eq&&r("eq-"+f+e),i.browserCss.gte&&r("gte-"+f+e));else r("no-"+f);r(o),r(o+parseInt(h,10)),i.html5&&o==="ie"&&h<9&&p("abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|main|mark|meter|nav|output|progress|section|summary|time|video".split("|"),function(n){y.createElement(n)}),p(ut.pathname.split("/"),function(n,u){if(this.length>2&&this[u+1]!==t)u&&r(this.slice(u,u+1).join("-").toLowerCase()+i.section);else{var f=n||"index",e=f.indexOf(".");e>0&&(f=f.substring(0,e)),c.id=f.toLowerCase()+i.page,u||r("root"+i.section)}}),u.screen={height:n.screen.height,width:n.screen.width},tt(),b=0,n.addEventListener?n.addEventListener("resize",it,!1):n.attachEvent("onresize",it)})(window);
-//# sourceMappingURL=head.core.min.js.map
+/*! head.core v0.99 */
+(function(n,t){"use strict";function r(n){a[a.length]=n}function k(n){var t=new RegExp(" \\b"+n+"\\b");c.className=c.className.replace(t,"")}function p(n,t){for(var i=0,r=n.length;i<r;i++)t.call(n,n[i],i)}function tt(){var t,e,f,o;c.className=c.className.replace(/ (w-|eq-|gt-|gte-|lt-|lte-|portrait|no-portrait|landscape|no-landscape)\d+/g,"");t=n.innerWidth||c.clientWidth;e=n.outerWidth||n.screen.width;u.screen.innerWidth=t;u.screen.outerWidth=e;r("w-"+t);p(i.screens,function(n){t>n?(i.screensCss.gt&&r("gt-"+n),i.screensCss.gte&&r("gte-"+n)):t<n?(i.screensCss.lt&&r("lt-"+n),i.screensCss.lte&&r("lte-"+n)):t===n&&(i.screensCss.lte&&r("lte-"+n),i.screensCss.eq&&r("e-q"+n),i.screensCss.gte&&r("gte-"+n))});f=n.innerHeight||c.clientHeight;o=n.outerHeight||n.screen.height;u.screen.innerHeight=f;u.screen.outerHeight=o;u.feature("portrait",f>t);u.feature("landscape",f<t)}function it(){n.clearTimeout(b);b=n.setTimeout(tt,50)}var y=n.document,rt=n.navigator,ut=n.location,c=y.documentElement,a=[],i={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:11}}],browserCss:{gt:!0,gte:!1,lt:!0,lte:!1,eq:!0},section:"-section",page:"-page",head:"head"},v,u,s,w,o,h,l,d,f,g,nt,e,b;if(n.head_conf)for(v in n.head_conf)n.head_conf[v]!==t&&(i[v]=n.head_conf[v]);u=n[i.head]=function(){u.ready.apply(null,arguments)};u.feature=function(n,t,i){return n?(Object.prototype.toString.call(t)==="[object Function]"&&(t=t.call()),r((t?"":"no-")+n),u[n]=!!t,i||(k("no-"+n),k(n),u.feature()),u):(c.className+=" "+a.join(" "),a=[],u)};u.feature("js",!0);s=rt.userAgent.toLowerCase();w=/mobile|android|kindle|silk|midp|(windows nt 6\.2.+arm|touch)/.test(s);u.feature("mobile",w,!0);u.feature("desktop",!w,!0);s=/(chrome|firefox)[ \/]([\w.]+)/.exec(s)||/(iphone|ipad|ipod)(?:.*version)?[ \/]([\w.]+)/.exec(s)||/(android)(?:.*version)?[ \/]([\w.]+)/.exec(s)||/(webkit|opera)(?:.*version)?[ \/]([\w.]+)/.exec(s)||/(msie) ([\w.]+)/.exec(s)||[];o=s[1];h=parseFloat(s[2]);switch(o){case"msie":o="ie";h=y.documentMode||h;break;case"firefox":o="ff";break;case"ipod":case"ipad":case"iphone":o="ios";break;case"webkit":o="safari"}for(u.browser={name:o,version:h},u.browser[o]=!0,l=0,d=i.browsers.length;l<d;l++)for(f in i.browsers[l])if(o===f)for(r(f),g=i.browsers[l][f].min,nt=i.browsers[l][f].max,e=g;e<=nt;e++)h>e?(i.browserCss.gt&&r("gt-"+f+e),i.browserCss.gte&&r("gte-"+f+e)):h<e?(i.browserCss.lt&&r("lt-"+f+e),i.browserCss.lte&&r("lte-"+f+e)):h===e&&(i.browserCss.lte&&r("lte-"+f+e),i.browserCss.eq&&r("eq-"+f+e),i.browserCss.gte&&r("gte-"+f+e));else r("no-"+f);r(o);r(o+parseInt(h,10));o==="ie"&&h<9&&p("abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|main|mark|meter|nav|output|progress|section|summary|time|video".split("|"),function(n){y.createElement(n)});p(ut.pathname.split("/"),function(n,u){if(this.length>2&&this[u+1]!==t)u&&r(this.slice(u,u+1).join("-").toLowerCase()+i.section);else{var f=n||"index",e=f.indexOf(".");e>0&&(f=f.substring(0,e));c.id=f.toLowerCase()+i.page;u||r("root"+i.section)}});u.screen={height:n.screen.height,width:n.screen.width};tt();b=0;n.addEventListener?n.addEventListener("resize",it,!1):n.attachEvent("onresize",it)})(window);
+/*
+//# sourceMappingURL=head.core.min.js.map
+*/
Oops, something went wrong.

0 comments on commit 03f5d55

Please sign in to comment.