Skip to content

Instantly share code, notes, and snippets.

@b4z81
Created May 7, 2012 16:54
Show Gist options
  • Save b4z81/2628930 to your computer and use it in GitHub Desktop.
Save b4z81/2628930 to your computer and use it in GitHub Desktop.
Detector perrequest
<?php
// to be included in your <head></head> tag to run the per-request tests
require(TEMPLATEPATH."/detector/Detector.php");
header("content-type: application/x-javascript");
$test = Detector::perrequest();
?>
<?php
// Detection
require(TEMPLATEPATH."/detector/util/js-include/features.js.php");
?>
/* Modernizr 2.5.2 (Custom Build) | MIT & BSD
* Build: http://www.modernizr.com/download/#-mq-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes
*/
;window.Modernizr=function(a,b,c){function A(a){i.cssText=a}function B(a,b){return A(l.join(a+";")+(b||""))}function C(a,b){return typeof a===b}function D(a,b){return!!~(""+a).indexOf(b)}function E(a,b){for(var d in a)if(i[a[d]]!==c)return b=="pfx"?a[d]:!0;return!1}function F(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:C(f,"function")?f.bind(d||b):f}return!1}function G(a,b,c){var d=a.charAt(0).toUpperCase()+a.substr(1),e=(a+" "+n.join(d+" ")+d).split(" ");return C(b,"string")||C(b,"undefined")?E(e,b):(e=(a+" "+o.join(d+" ")+d).split(" "),F(e,b,c))}var d="2.5.2",e={},f=b.documentElement,g="modernizr",h=b.createElement(g),i=h.style,j,k={}.toString,l=" -webkit- -moz- -o- -ms- ".split(" "),m="Webkit Moz O ms",n=m.split(" "),o=m.toLowerCase().split(" "),p={},q={},r={},s=[],t=s.slice,u,v=function(a,c,d,e){var h,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]:g+(d+1),k.appendChild(j);return h=["&#173;","<style>",a,"</style>"].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);// Test for DPI
Modernizr.addTest('pr-hiResCapable', Modernizr.mq('only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (min-device-pixel-ratio: 1.5)'));// should be modified to return an object... with different possible color depths set to true/false?
Modernizr.addTest("pr-screenAttributes",function() {
var _windowHeight = (window.innerHeight > 0) ? window.innerHeight : screen.width;
var _windowWidth = (window.innerWidth > 0) ? window.innerWidth : screen.width;
var _colorDepth = screen.colorDepth;
return { windowHeight: _windowHeight, windowWidth: _windowWidth, colorDepth: _colorDepth };
});var m=Modernizr;c='';for(var f in m){if(f[0]=='_'){continue;}var t=typeof m[f];if(t=='function'){continue;}c+=(c?'|':'5bd06b6192c80c77343aa3ae5b928248-pr=')+f+':';if(t=='object'){for(var s in m[f]){if (typeof m[f][s]=='boolean') { c+='/'+s+':'+(m[f][s]?1:0); }else { c+='/'+s+':'+m[f][s]; }}}else{c+=m[f]?'1':'0';}}c+=';path=/';try{document.cookie=c;}catch(e){}<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="ie ie6 no-js" dir="ltr" lang="it-IT"> <![endif]-->
<!--[if IE 7 ]> <html class="ie ie7 no-js" dir="ltr" lang="it-IT"> <![endif]-->
<!--[if IE 8 ]> <html class="ie ie8 no-js" dir="ltr" lang="it-IT"> <![endif]-->
<!--[if IE 9 ]> <html class="ie ie9 no-js" dir="ltr" lang="it-IT"> <![endif]-->
<!--[if gt IE 9]><!--><html class="no-js" dir="ltr" lang="it-IT"><!--<![endif]-->
<head id="www-sitename-com" data-template-set="html5-reset-wordpress-theme" profile="http://gmpg.org/xfn/11">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment