diff --git a/CHANGELOG b/CHANGELOG index e8a5184..680c245 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,12 @@ THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT. SUPER MINOR REVISION NUMBERS WON'T SHOW UP IN GITHUB BUT IT'LL HELP ME ORGANIZE WHEN I MADE A SET OF FIXES +DET-v0.9.0 (Aug. 24, 2012) + - FIX: updated Modernizr to 2.6.1 + - FIX: trimmed down the config + - FIX: the test build page now waits for the onload event before building the cookie & redirecting. should address race conditions with a few tests. + - ADD: added per-session tests that existed in Modernizr feature-detects that I wanted for v1.0 of Detector (see http://bit.ly/O14wcZ for full list) + DET-v0.8.5 (Aug. 14, 2012) - FIX: commmented out call to addToUAList() to increase performance - ADD: now throwing profiles into directories based on the first two characters of the hash. performance tweak because IE 7+8 create profiles an amazing number of profiles diff --git a/lib/Detector/Detector.php b/lib/Detector/Detector.php index b310115..31f2b64 100644 --- a/lib/Detector/Detector.php +++ b/lib/Detector/Detector.php @@ -15,28 +15,33 @@ class Detector { - private static $debug = false; // gets overwritten by the config so changing this won't do anything for you... + private static $debug = false; // gets overwritten by the config so changing this won't do anything for you... public static $ua; public static $accept; - - private static $coreVersion; - private static $extendedVersion; - - public static $foundIn; // this is just for the demo. won't ever really be needed i don't think - + private static $uaHash; private static $sessionID; private static $cookieID; - private static $uaFeaturesMaxJS; // all the default Modernizr Tests - private static $uaFeaturesMinJS; // NO default tests except media queries, meant to run those in the perrequest folder - private static $uaFeaturesCore; - private static $uaFeaturesExtended; - private static $uaFeaturesPerSession; - private static $uaFeaturesPerRequest; + + // version number so that profiles can be rebuilt if necessary + private static $coreVersion = "0.95"; + private static $extendedVersion; + + // where to find the modernizr scripts + private static $uaFeaturesMaxJS = "lib/modernizr/modernizr.full.js"; // all the default Modernizr Tests + private static $uaFeaturesMinJS = "lib/modernizr/modernizr.slim.js"; // NO default tests except media queries, meant to run those in the perrequest folder + + // where to find the tests that should be run against browsers + private static $uaFeaturesCore = "tests/core/"; + private static $uaFeaturesExtended = "tests/extended/"; + private static $uaFeaturesPerSession = "tests/persession/"; + private static $uaFeaturesPerRequest = "tests/perrequest/"; + + // where to find the user agent profiles + private static $uaDirCore = "user-agents/core/"; + private static $uaDirExtended = "user-agents/extended/"; - private static $uaDirCore; - private static $uaDirExtended; private static $featuresScriptWebPath; @@ -48,6 +53,8 @@ class Detector { public static $noJSDefaultFamily; public static $noCookieFamily; + public static $foundIn; // this is just for the demo. won't ever really be needed i don't think + /** * Configures the shared variables in Detector so that they can be used in functions that might not need to run Detector::build(); * @@ -312,6 +319,12 @@ public static function build() { // unset the cookie that held the vast amount of test data setcookie(self::$cookieID,""); + setcookie(self::$cookieID,"",time()-3600); + + unset($jsonTemplateCore); + unset($jsonTemplateExtended); + unset($cookiePerSession); + unset($cookiePerRequest); // add our collected data to the session for use in future requests, also add the per request data if (isset($_SESSION)) { @@ -361,6 +374,7 @@ public static function persession() { readfile(__DIR__ . '/' . self::$uaFeaturesMinJS); self::readDirFiles(self::$uaFeaturesPerSession); self::readDirFiles(self::$uaFeaturesPerRequest); + readfile(__DIR__. '/lib/modernizr/onload.js'); print self::_mer() . ""; exit; } @@ -377,9 +391,9 @@ public static function buildTestPage() { self::readDirFiles(self::$uaFeaturesExtended); self::readDirFiles(self::$uaFeaturesPerSession); self::readDirFiles(self::$uaFeaturesPerRequest); + readfile(__DIR__. '/lib/modernizr/onload.js'); print self::_mer() . ""; - exit; - + exit; } /** @@ -392,7 +406,7 @@ public static function buildTestPage() { * @return {String} the HTML & JavaScript that tracks the per request test */ private static function _mer($reload = true, $cookieExtra = '') { - $output = "". + $output = "function cm() {". "var m=Modernizr;var c='';var k=''; var f;". "for(f in m){". "var j='';". @@ -428,7 +442,7 @@ private static function _mer($reload = true, $cookieExtra = '') { $output .= "document.location.reload();"; } $output .= "}"; - $output .= "}catch(e){}".""; + $output .= "}catch(e){}"."}"; return $output; } @@ -532,9 +546,7 @@ private static function writeUAFile($jsonEncoded,$uaFilePath) { mkdir(__DIR__."/".self::$uaDirExtended.$dir); chmod(__DIR__."/".self::$uaDirCore.$dir,0775); } - $fp = fopen($uaFilePath, "w"); - fwrite($fp, $jsonEncoded); - fclose($fp); + file_put_contents($uaFilePath,$jsonEncoded); chmod($uaFilePath,0664); } @@ -593,7 +605,7 @@ private static function parseCookie($cookieExtension,$obj,$default = false) { foreach($uaFeatures as $key => $value) { if ((strpos($key,$cookieExtension."-") !== false) || (($cookieExtension == 'core') && (strpos($key,"extended-") === false) && (strpos($key,"pr-") === false) && (strpos($key,"ps-") === false))) { $key = str_replace($cookieExtension."-", "", $key); - if (is_object($value)) { + if (is_object($value) && (strpos($key,"_") !== 0)) { foreach ($value as $vkey => $vvalue) { if ($vvalue == "probably") { // hack for modernizr $value->$vkey = true; diff --git a/lib/Detector/config/config.ini.default b/lib/Detector/config/config.ini.default index be7fa27..4031362 100644 --- a/lib/Detector/config/config.ini.default +++ b/lib/Detector/config/config.ini.default @@ -1,31 +1,16 @@ /* - * Configuration options for Detector - * If config.ini doesn't exist Detector will attempt to read in config.ini.copy - * and write out config.ini. + * Configuration Options for Detector + * If config.ini doesn't exist Detector will attempt to read in config.ini.default + * and write out the config.ini file. */ // if we should run in debug mode. only useful if we want to view the site populated // w/ other Detector profiles debug = false -// version number so that core and extended profiles can be rebuilt if necessary -coreVersion = "0.9" +// version number so that extended profiles can be rebuilt if necessary extendedVersion = "1.0" -// where to find the modernizr scripts -uaFeaturesMaxJS = "lib/modernizr/modernizr.2.5.2.min.custom.js" -uaFeaturesMinJS = "lib/modernizr/modernizr.2.5.2.min.no-tests.js" - -// where to find the tests that should be run against browsers -uaFeaturesCore = "tests/core/" -uaFeaturesExtended = "tests/extended/" -uaFeaturesPerSession = "tests/persession/" -uaFeaturesPerRequest = "tests/perrequest/" - -// where to find the user agent profiles -uaDirCore = "user-agents/core/" -uaDirExtended = "user-agents/extended/" - // where to find the features.js.php file from the web featuresScriptWebPath = "/js/"; diff --git a/lib/Detector/lib/modernizr/modernizr.2.5.2.min.custom.js b/lib/Detector/lib/modernizr/modernizr.2.5.2.min.custom.js deleted file mode 100644 index a2fda57..0000000 --- a/lib/Detector/lib/modernizr/modernizr.2.5.2.min.custom.js +++ /dev/null @@ -1,4 +0,0 @@ -/* Modernizr 2.5.2 (Custom Build) | MIT & BSD - * Build: http://www.modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-touch-webgl-mq-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-a_download-audio_audiodata_api-audio_webaudio_api-battery_api-battery_level-contenteditable-cookies-css_backgroundrepeat-css_backgroundsizecover-css_boxsizing-css_cubicbezierrange-css_mediaqueries-css_overflow_scrolling-css_pointerevents-css_remunit-css_resize-css_scrollbars-css_userselect-dataview_api-dom_createElement_attrs-dom_microdata-elem_progress_meter-elem_time-event_deviceorientation_motion-file_api-file_filesystem-forms_speechinput-forms_validation-fullscreen_api-gamepad-ie8compat-img_webp-json-network_connection-network_eventsource-notification-performance-quota_management_api-script_async-script_defer-unicode-url_data_uri-web_intents-websockets_binary-workers_blobworkers-workers_dataworkers-workers_sharedworkers - */ -;window.Modernizr=function(a,b,c){function B(a){i.cssText=a}function C(a,b){return B(m.join(a+";")+(b||""))}function D(a,b){return typeof a===b}function E(a,b){return!!~(""+a).indexOf(b)}function F(a,b){for(var d in a)if(i[a[d]]!==c)return b=="pfx"?a[d]:!0;return!1}function G(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:D(f,"function")?f.bind(d||b):f}return!1}function H(a,b,c){var d=a.charAt(0).toUpperCase()+a.substr(1),e=(a+" "+o.join(d+" ")+d).split(" ");return D(b,"string")||D(b,"undefined")?F(e,b):(e=(a+" "+p.join(d+" ")+d).split(" "),G(e,b,c))}function J(){e.input=function(c){for(var d=0,e=c.length;d",a,""].join(""),k.id=g,m.innerHTML+=h,m.appendChild(k),l||f.appendChild(m),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!i},x=function(b){var c=a.matchMedia||a.msMatchMedia;if(c)return c(b).matches;var d;return w("@media "+b+" { #"+g+" { position: absolute; } }",function(b){d=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle)["position"]=="absolute"}),d},y=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=D(e[d],"function"),D(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),z={}.hasOwnProperty,A;!D(z,"undefined")&&!D(z.call,"undefined")?A=function(a,b){return z.call(a,b)}:A=function(a,b){return b in a&&D(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=u.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(u.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(u.call(arguments)))};return e});var I=function(c,d){var f=c.join(""),g=d.length;w(f,function(c,d){var f=b.styleSheets[b.styleSheets.length-1],h=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"",i=c.childNodes,j={};while(g--)j[i[g].id]=i[g];e.touch="ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch||(j.touch&&j.touch.offsetTop)===9,e.csstransforms3d=(j.csstransforms3d&&j.csstransforms3d.offsetLeft)===9&&j.csstransforms3d.offsetHeight===3,e.generatedcontent=(j.generatedcontent&&j.generatedcontent.offsetHeight)>=1,e.fontface=/src/i.test(h)&&h.indexOf(d.split(" ")[0])===0},g,d)}(['@font-face {font-family:"font";src:url("https://")}',["@media (",m.join("touch-enabled),("),g,")","{#touch{top:9px;position:absolute}}"].join(""),["@media (",m.join("transform-3d),("),g,")","{#csstransforms3d{left:9px;position:absolute;height:3px;}}"].join(""),['#generatedcontent:after{content:"',k,'";visibility:hidden}'].join("")],["fontface","touch","csstransforms3d","generatedcontent"]);q.flexbox=function(){return H("flexOrder")},q.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},q.canvastext=function(){return!!e.canvas&&!!D(b.createElement("canvas").getContext("2d").fillText,"function")},q.webgl=function(){try{var d=b.createElement("canvas"),e;e=!(!a.WebGLRenderingContext||!d.getContext("experimental-webgl")&&!d.getContext("webgl")),d=c}catch(f){e=!1}return e},q.touch=function(){return e.touch},q.geolocation=function(){return!!navigator.geolocation},q.postmessage=function(){return!!a.postMessage},q.websqldatabase=function(){return!!a.openDatabase},q.indexedDB=function(){return!!H("indexedDB",a)},q.hashchange=function(){return y("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},q.history=function(){return!!a.history&&!!history.pushState},q.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},q.websockets=function(){for(var b=-1,c=o.length;++b7)}),Modernizr.addTest("cubicbezierrange",function(){return el=document.createElement("div"),el.style.cssText=Modernizr._prefixes.join("transition-timing-function:cubic-bezier(1,0,0,1.1); "),!!el.style.length}),Modernizr.addTest("overflowscrolling",function(){return Modernizr.testAllProps("overflowScrolling")}),Modernizr.addTest("mediaqueries",Modernizr.mq("only all")),Modernizr.addTest("cssremunit",function(){var a=document.createElement("div");try{a.style.fontSize="3rem"}catch(b){}return/rem/.test(a.style.fontSize)}),Modernizr.addTest("cssresize",Modernizr.testAllProps("resize")),Modernizr.addTest("cssscrollbar",function(){var a,b="#modernizr{overflow: scroll; width: 40px }#"+Modernizr._prefixes.join("scrollbar{width:0px} #modernizr::").split("#").slice(1).join("#")+"scrollbar{width:0px}";return Modernizr.testStyles(b,function(b){a="scrollWidth"in b&&b.scrollWidth==40}),a}),Modernizr.addTest("userselect",function(){return Modernizr.testAllProps("user-select")}),Modernizr.addTest("dataview",typeof DataView!="undefined"&&"getFloat64"in DataView.prototype),Modernizr.addTest("microdata",!!document.getItems),Modernizr.addTest("progressbar",function(){return document.createElement("progress").max!=undefined}),Modernizr.addTest("meter",function(){return document.createElement("meter").max!=undefined}),Modernizr.addTest("createelement-attrs",function(){try{return document.createElement("").getAttribute("name")=="test"}catch(a){return!1}}),Modernizr.addTest("time","valueAsDate"in document.createElement("time")),Modernizr.addTest("pointerevents",function(){var a=document.createElement("x"),b=document.documentElement,c=window.getComputedStyle,d;return"pointerEvents"in a.style?(a.style.pointerEvents="auto",a.style.pointerEvents="x",b.appendChild(a),d=c&&c(a,"").pointerEvents==="auto",b.removeChild(a),!!d):!1}),Modernizr.addTest("devicemotion","DeviceMotionEvent"in window),Modernizr.addTest("deviceorientation","DeviceOrientationEvent"in window),Modernizr.addTest("speechinput",function(){var a=document.createElement("input");return"speech"in a||"onwebkitspeechchange"in a}),Modernizr.addTest("filereader",function(){return!!(window.File&&window.FileList&&window.FileReader)}),Modernizr.addTest("filesystem",function(){var a=Modernizr._domPrefixes;for(var b=-1,c=a.length;++b",a,""].join(""),k.id=g,m.innerHTML+=h,m.appendChild(k),l||f.appendChild(m),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!i},w=function(b){var c=a.matchMedia||a.msMatchMedia;if(c)return c(b).matches;var d;return v("@media "+b+" { #"+g+" { position: absolute; } }",function(b){d=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle)["position"]=="absolute"}),d},x=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=C(e[d],"function"),C(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),y={}.hasOwnProperty,z;!C(y,"undefined")&&!C(y.call,"undefined")?z=function(a,b){return y.call(a,b)}:z=function(a,b){return b in a&&C(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=t.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(t.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(t.call(arguments)))};return e});for(var H in p)z(p,H)&&(u=H.toLowerCase(),e[u]=p[H](),s.push((e[u]?"":"no-")+u));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)z(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,f.className+=" "+(b?"":"no-")+a,e[a]=b}return e},A(""),h=j=null,e._version=d,e._prefixes=l,e._domPrefixes=o,e._cssomPrefixes=n,e.mq=w,e.hasEvent=x,e.testProp=function(a){return E([a])},e.testAllProps=G,e.testStyles=v,e.prefixed=function(a,b,c){return b?G(a,b,c):G(a,"pfx")},e}(this,this.document); \ No newline at end of file diff --git a/lib/Detector/lib/modernizr/modernizr.full.js b/lib/Detector/lib/modernizr/modernizr.full.js new file mode 100644 index 0000000..3a57a65 --- /dev/null +++ b/lib/Detector/lib/modernizr/modernizr.full.js @@ -0,0 +1,4 @@ +/* Modernizr 2.6.1 (Custom Build) | MIT & BSD + * Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-touch-mq-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-a_download-audio_audiodata_api-audio_webaudio_api-battery_api-contenteditable-contextmenu-css_backgroundrepeat-css_backgroundsizecover-css_boxsizing-css_cubicbezierrange-css_mask-css_mediaqueries-css_overflow_scrolling-css_pointerevents-css_remunit-css_resize-css_scrollbars-css_subpixelfont-css_userselect-dom_dataset-dom_microdata-elem_progress_meter-elem_time-event_deviceorientation_motion-exif_orientation-file_api-forms_fileinput-file_filesystem-forms_placeholder-forms_speechinput-forms_validation-fullscreen_api-getusermedia-json-network_eventsource-network_xhr2-notification-performance-quota_management_api-script_async-script_defer-url_data_uri-vibration-web_intents + */ +;window.Modernizr=function(a,b,c){function C(a){j.cssText=a}function D(a,b){return C(n.join(a+";")+(b||""))}function E(a,b){return typeof a===b}function F(a,b){return!!~(""+a).indexOf(b)}function G(a,b){for(var d in a){var e=a[d];if(!F(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function H(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:E(f,"function")?f.bind(d||b):f}return!1}function I(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+p.join(d+" ")+d).split(" ");return E(b,"string")||E(b,"undefined")?G(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),H(e,b,c))}function J(){e.input=function(c){for(var d=0,e=c.length;d',a,""].join(""),k.id=h,(l?k:m).innerHTML+=f,m.appendChild(k),l||(m.style.background="",g.appendChild(m)),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!i},y=function(b){var c=a.matchMedia||a.msMatchMedia;if(c)return c(b).matches;var d;return x("@media "+b+" { #"+h+" { position: absolute; } }",function(b){d=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle)["position"]=="absolute"}),d},z=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=E(e[d],"function"),E(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),A={}.hasOwnProperty,B;!E(A,"undefined")&&!E(A.call,"undefined")?B=function(a,b){return A.call(a,b)}:B=function(a,b){return b in a&&E(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=v.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(v.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(v.call(arguments)))};return e}),r.flexbox=function(){return I("flexWrap")},r.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},r.canvastext=function(){return!!e.canvas&&!!E(b.createElement("canvas").getContext("2d").fillText,"function")},r.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:x(["@media (",n.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},r.geolocation=function(){return"geolocation"in navigator},r.postmessage=function(){return!!a.postMessage},r.websqldatabase=function(){return!!a.openDatabase},r.indexedDB=function(){return!!I("indexedDB",a)},r.hashchange=function(){return z("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},r.history=function(){return!!a.history&&!!history.pushState},r.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},r.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},r.rgba=function(){return C("background-color:rgba(150,255,150,.5)"),F(j.backgroundColor,"rgba")},r.hsla=function(){return C("background-color:hsla(120,40%,100%,.5)"),F(j.backgroundColor,"rgba")||F(j.backgroundColor,"hsla")},r.multiplebgs=function(){return C("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(j.background)},r.backgroundsize=function(){return I("backgroundSize")},r.borderimage=function(){return I("borderImage")},r.borderradius=function(){return I("borderRadius")},r.boxshadow=function(){return I("boxShadow")},r.textshadow=function(){return b.createElement("div").style.textShadow===""},r.opacity=function(){return D("opacity:.55"),/^0.55$/.test(j.opacity)},r.cssanimations=function(){return I("animationName")},r.csscolumns=function(){return I("columnCount")},r.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return C((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),F(j.backgroundImage,"gradient")},r.cssreflections=function(){return I("boxReflect")},r.csstransforms=function(){return!!I("transform")},r.csstransforms3d=function(){var a=!!I("perspective");return a&&"webkitPerspective"in g.style&&x("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},r.csstransitions=function(){return I("transition")},r.fontface=function(){var a;return x('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},r.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},r.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},r.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},r.sessionstorage=function(){try{return sessionStorage.setItem(h,h),sessionStorage.removeItem(h),!0}catch(a){return!1}},r.webworkers=function(){return!!a.Worker},r.applicationcache=function(){return!!a.applicationCache};for(var K in r)B(r,K)&&(w=K.toLowerCase(),e[w]=r[K](),u.push((e[w]?"":"no-")+w));return e.input||J(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)B(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},C(""),i=k=null,e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.mq=y,e.hasEvent=z,e.testProp=function(a){return G([a])},e.testAllProps=I,e.testStyles=x,e.prefixed=function(a,b,c){return b?I(a,b,c):I(a,"pfx")},g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+u.join(" "):""),e}(this,this.document),Modernizr.addTest("adownload","download"in document.createElement("a")),Modernizr.addTest("audiodata",!!window.Audio),Modernizr.addTest("webaudio",!!window.webkitAudioContext||!!window.AudioContext),Modernizr.addTest("battery",!!Modernizr.prefixed("battery",navigator)),Modernizr.addTest("contenteditable","contentEditable"in document.documentElement),Modernizr.addTest("contextmenu","contextMenu"in document.documentElement&&"HTMLMenuItemElement"in window),function(){function a(a){return window.getComputedStyle?getComputedStyle(a,null).getPropertyValue("background"):a.currentStyle.background}Modernizr.testStyles(" #modernizr { background-repeat: round; } ",function(b,c){Modernizr.addTest("bgrepeatround",a(b)=="round")}),Modernizr.testStyles(" #modernizr { background-repeat: space; } ",function(b,c){Modernizr.addTest("bgrepeatspace",a(b)=="space")})}(),Modernizr.testStyles("#modernizr{background-size:cover}",function(a){var b=window.getComputedStyle?window.getComputedStyle(a,null):a.currentStyle;Modernizr.addTest("bgsizecover",b.backgroundSize=="cover")}),Modernizr.addTest("boxsizing",function(){return Modernizr.testAllProps("boxSizing")&&(document.documentMode===undefined||document.documentMode>7)}),Modernizr.addTest("cubicbezierrange",function(){var a=document.createElement("div");return a.style.cssText=Modernizr._prefixes.join("transition-timing-function:cubic-bezier(1,0,0,1.1); "),!!a.style.length}),Modernizr.addTest("mediaqueries",Modernizr.mq("only all")),Modernizr.addTest("cssmask",Modernizr.testAllProps("mask-repeat")),Modernizr.addTest("overflowscrolling",function(){return Modernizr.testAllProps("overflowScrolling")}),Modernizr.addTest("pointerevents",function(){var a=document.createElement("x"),b=document.documentElement,c=window.getComputedStyle,d;return"pointerEvents"in a.style?(a.style.pointerEvents="auto",a.style.pointerEvents="x",b.appendChild(a),d=c&&c(a,"").pointerEvents==="auto",b.removeChild(a),!!d):!1}),Modernizr.addTest("cssremunit",function(){var a=document.createElement("div");try{a.style.fontSize="3rem"}catch(b){}return/rem/.test(a.style.fontSize)}),Modernizr.addTest("cssresize",Modernizr.testAllProps("resize")),Modernizr.addTest("cssscrollbar",function(){var a,b="#modernizr{overflow: scroll; width: 40px }#"+Modernizr._prefixes.join("scrollbar{width:0px} #modernizr::").split("#").slice(1).join("#")+"scrollbar{width:0px}";return Modernizr.testStyles(b,function(b){a="scrollWidth"in b&&b.scrollWidth==40}),a}),Modernizr.addTest("subpixelfont",function(){var a,b="#modernizr{position: absolute; top: -10em; visibility:hidden; font: normal 10px arial;}#subpixel{float: left; font-size: 33.3333%;}";return Modernizr.testStyles(b,function(b){var c=b.firstChild;c.innerHTML="This is a text written in Arial",a=window.getComputedStyle?window.getComputedStyle(c,null).getPropertyValue("width")!=="44px":!1},1,["subpixel"]),a}),Modernizr.addTest("userselect",function(){return Modernizr.testAllProps("user-select")}),Modernizr.addTest("dataset",function(){var a=document.createElement("div");return a.setAttribute("data-a-b","c"),!!a.dataset&&a.dataset.aB==="c"}),Modernizr.addTest("progressbar",function(){return document.createElement("progress").max!==undefined}),Modernizr.addTest("meter",function(){return document.createElement("meter").max!==undefined}),Modernizr.addTest("microdata",!!document.getItems),Modernizr.addTest("time","valueAsDate"in document.createElement("time")),function(){var a=new Image;a.onerror=function(){Modernizr.addTest("exif-orientation",function(){return!1})},a.onload=function(){Modernizr.addTest("exif-orientation",function(){return a.width!==2})},a.src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QAiRXhpZgAASUkqAAgAAAABABIBAwABAAAABgASAAAAAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAABAAIDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD+/iiiigD/2Q=="}(),Modernizr.addTest("filereader",function(){return!!(window.File&&window.FileList&&window.FileReader)}),Modernizr.addTest("placeholder",function(){return"placeholder"in(Modernizr.input||document.createElement("input"))&&"placeholder"in(Modernizr.textarea||document.createElement("textarea"))}),Modernizr.addTest("fileinput",function(){var a=document.createElement("input");return a.type="file",!a.disabled}),Modernizr.addTest("filesystem",!!Modernizr.prefixed("requestFileSystem",window)),Modernizr.addTest("speechinput",function(){var a=document.createElement("input");return"speech"in a||"onwebkitspeechchange"in a}),Modernizr.addTest("fullscreen",function(){for(var a=0;a',c.style.position="absolute",c.style.top="-99999em",d||(f=!0,d=a.createElement("body"),d.style.background="",e.appendChild(d)),d.appendChild(c),h=c.getElementsByTagName("input")[0],h.oninvalid=function(a){g=!0,a.preventDefault(),a.stopPropagation()},b.formvalidationmessage=!!h.validationMessage,c.getElementsByTagName("button")[0].click(),d.removeChild(c),f&&e.removeChild(d),g}return!1})}(document,window.Modernizr),Modernizr.addTest("getusermedia",!!Modernizr.prefixed("getUserMedia",navigator)),Modernizr.addTest("json",!!window.JSON&&!!JSON.parse),Modernizr.addTest("quotamanagement",function(){var a=Modernizr.prefixed("StorageInfo",window);return!!(a&&"TEMPORARY"in a&&"PERSISTENT"in a)}),Modernizr.addTest("performance",!!Modernizr.prefixed("performance",window)),Modernizr.addTest("eventsource",!!window.EventSource),Modernizr.addTest("scriptasync","async"in document.createElement("script")),Modernizr.addTest("scriptdefer","defer"in document.createElement("script")),function(){var a=new Image;a.onerror=function(){Modernizr.addTest("datauri",function(){return!1})},a.onload=function(){Modernizr.addTest("datauri",function(){return a.width==1&&a.height==1})},a.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="}(),Modernizr.addTest("vibrate",!!Modernizr.prefixed("vibrate",navigator)),Modernizr.addTest("webintents",function(){return!!Modernizr.prefixed("startActivity",navigator)}),Modernizr.addTest("notification",!!Modernizr.prefixed("Notifications",window)),Modernizr.addTest("xhr2","FormData"in window),Modernizr.addTest("devicemotion","DeviceMotionEvent"in window),Modernizr.addTest("deviceorientation","DeviceOrientationEvent"in window); \ No newline at end of file diff --git a/lib/Detector/lib/modernizr/modernizr.slim.js b/lib/Detector/lib/modernizr/modernizr.slim.js new file mode 100644 index 0000000..5ef37dd --- /dev/null +++ b/lib/Detector/lib/modernizr/modernizr.slim.js @@ -0,0 +1,4 @@ +/* Modernizr 2.6.1 (Custom Build) | MIT & BSD + * Build: http://modernizr.com/download/#-mq-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes + */ +;window.Modernizr=function(a,b,c){function B(a){j.cssText=a}function C(a,b){return B(m.join(a+";")+(b||""))}function D(a,b){return typeof a===b}function E(a,b){return!!~(""+a).indexOf(b)}function F(a,b){for(var d in a){var e=a[d];if(!E(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function G(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:D(f,"function")?f.bind(d||b):f}return!1}function H(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+o.join(d+" ")+d).split(" ");return D(b,"string")||D(b,"undefined")?F(e,b):(e=(a+" "+p.join(d+" ")+d).split(" "),G(e,b,c))}var d="2.6.1",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={}.toString,m=" -webkit- -moz- -o- -ms- ".split(" "),n="Webkit Moz O ms",o=n.split(" "),p=n.toLowerCase().split(" "),q={},r={},s={},t=[],u=t.slice,v,w=function(a,c,d,e){var f,i,j,k=b.createElement("div"),l=b.body,m=l?l:b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),k.appendChild(j);return f=["­",'"].join(""),k.id=h,(l?k:m).innerHTML+=f,m.appendChild(k),l||(m.style.background="",g.appendChild(m)),i=c(k,a),l?k.parentNode.removeChild(k):m.parentNode.removeChild(m),!!i},x=function(b){var c=a.matchMedia||a.msMatchMedia;if(c)return c(b).matches;var d;return w("@media "+b+" { #"+h+" { position: absolute; } }",function(b){d=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle)["position"]=="absolute"}),d},y=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=D(e[d],"function"),D(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),z={}.hasOwnProperty,A;!D(z,"undefined")&&!D(z.call,"undefined")?A=function(a,b){return z.call(a,b)}:A=function(a,b){return b in a&&D(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=u.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(u.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(u.call(arguments)))};return e});for(var I in q)A(q,I)&&(v=I.toLowerCase(),e[v]=q[I](),t.push((e[v]?"":"no-")+v));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)A(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},B(""),i=k=null,e._version=d,e._prefixes=m,e._domPrefixes=p,e._cssomPrefixes=o,e.mq=x,e.hasEvent=y,e.testProp=function(a){return F([a])},e.testAllProps=H,e.testStyles=w,e.prefixed=function(a,b,c){return b?H(a,b,c):H(a,"pfx")},g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+t.join(" "):""),e}(this,this.document); \ No newline at end of file diff --git a/lib/Detector/lib/modernizr/onload.js b/lib/Detector/lib/modernizr/onload.js new file mode 100644 index 0000000..3a92092 --- /dev/null +++ b/lib/Detector/lib/modernizr/onload.js @@ -0,0 +1,8 @@ +// handle older versions of IE with onload +if (window.addEventListener) { + window.addEventListener("load",cm,false); +} else if (window.attachEvent ) { + window.attachEvent("onload",cm); +} else if (window.onLoad) { + window.onload = cm; +} \ No newline at end of file diff --git a/lib/Detector/tests/persession/_webgl.js b/lib/Detector/tests/persession/_webgl.js new file mode 100644 index 0000000..7763e8c --- /dev/null +++ b/lib/Detector/tests/persession/_webgl.js @@ -0,0 +1,3 @@ +Modernizr.addTest('ps-webgl', function() { + return !!window.WebGLRenderingContext; +}); \ No newline at end of file diff --git a/lib/Detector/tests/persession/battery-level.js b/lib/Detector/tests/persession/battery-level.js new file mode 100644 index 0000000..bb0548c --- /dev/null +++ b/lib/Detector/tests/persession/battery-level.js @@ -0,0 +1,10 @@ +// Low Battery Level +// Enable a developer to remove CPU intensive CSS/JS when battery is low +// developer.mozilla.org/en/DOM/window.navigator.mozBattery +// By: Paul Sayre + +Modernizr.addTest('ps-lowbattery', function () { + var minLevel = 0.20, + battery = Modernizr.prefixed('battery', navigator); + return !!(battery && !battery.charging && battery.level <= minLevel); +}); \ No newline at end of file diff --git a/lib/Detector/tests/persession/cookies.js b/lib/Detector/tests/persession/cookies.js new file mode 100644 index 0000000..563a973 --- /dev/null +++ b/lib/Detector/tests/persession/cookies.js @@ -0,0 +1,13 @@ +// by tauren +// https://github.com/Modernizr/Modernizr/issues/191 + +Modernizr.addTest('ps-cookies', function () { + // Quick test if browser has cookieEnabled host property + if (navigator.cookieEnabled) return true; + // Create cookie + document.cookie = "cookietest=1"; + var ret = document.cookie.indexOf("cookietest=") != -1; + // Delete cookie + document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT"; + return ret; +}); diff --git a/lib/Detector/tests/persession/ie8compat.js b/lib/Detector/tests/persession/ie8compat.js new file mode 100644 index 0000000..567e691 --- /dev/null +++ b/lib/Detector/tests/persession/ie8compat.js @@ -0,0 +1,11 @@ +// IE8 compat mode aka Fake IE7 +// by Erich Ocean + +// In this case, IE8 will be acting as IE7. You may choose to remove features in this case. + +// related: +// james.padolsey.com/javascript/detect-ie-in-js-using-conditional-comments/ + +Modernizr.addTest('ps-ie8compat',function(){ + return (!window.addEventListener && document.documentMode && document.documentMode === 7); +}); \ No newline at end of file diff --git a/lib/Detector/tests/persession/network-connection.js b/lib/Detector/tests/persession/network-connection.js new file mode 100644 index 0000000..4c2a920 --- /dev/null +++ b/lib/Detector/tests/persession/network-connection.js @@ -0,0 +1,22 @@ +// determining low-bandwidth via navigator.connection + +// There are two iterations of the navigator.connection interface: + +// The first is present in Android 2.2+ and only in the Browser (not WebView) +// : docs.phonegap.com/en/1.2.0/phonegap_connection_connection.md.html#connection.type +// : davidbcalhoun.com/2010/using-navigator-connection-android + +// The second is specced at dev.w3.org/2009/dap/netinfo/ and perhaps landing in WebKit +// : bugs.webkit.org/show_bug.cgi?id=73528 + +// unknown devices are assumed as fast +// for more rigorous network testing, consider boomerang.js: github.com/bluesmoon/boomerang/ + +Modernizr.addTest('ps-lowbandwidth', function() { + + var connection = navigator.connection || { type: 0 }; // polyfill + + return connection.type == 3 || // connection.CELL_2G + connection.type == 4 || // connection.CELL_3G + /^[23]g$/.test(connection.type); // string value in new spec +}); \ No newline at end of file diff --git a/lib/Detector/tests/persession/unicode.js b/lib/Detector/tests/persession/unicode.js new file mode 100644 index 0000000..81568df --- /dev/null +++ b/lib/Detector/tests/persession/unicode.js @@ -0,0 +1,26 @@ +/** + * Unicode special character support + * + * Detection is made by testing missing glyph box rendering against star character + * If widths are the same, this "probably" means the browser didn't support the star character and rendered a glyph box instead + * Just need to ensure the font characters have different widths + * + * Warning : positive Unicode support doesn't mean you can use it inside , this seams more related to OS & Language packs + */ +Modernizr.addTest('ps-unicode', function() { + + var bool, + missingGlyph = document.createElement('span'), + star = document.createElement('span'); + + Modernizr.testStyles('#modernizr{font-family:Arial,sans;font-size:300em;}', function(node) { + missingGlyph.innerHTML = 'ᝣ'; + star.innerHTML = '☆'; + node.appendChild(missingGlyph); + node.appendChild(star); + bool = 'offsetWidth' in missingGlyph && missingGlyph.offsetWidth !== star.offsetWidth; + }); + + return bool; + +}); \ No newline at end of file