/*! * modernizr v2.8.3 * www.modernizr.com * * copyright (c) faruk ates, paul irish, alex sexton * available under the bsd and mit licenses: www.modernizr.com/license/ */ /* * modernizr tests which native css3 and html5 features are available in * the current ua and makes the results available to you in two ways: * as properties on a global modernizr object, and as classes on the * element. this information allows you to progressively enhance * your pages with a granular level of control over the experience. * * modernizr has an optional (not included) conditional resource loader * called modernizr.load(), based on yepnope.js (yepnopejs.com). * to get a build that includes modernizr.load(), as well as choosing * which tests to include, go to www.modernizr.com/download/ * * authors faruk ates, paul irish, alex sexton * contributors ryan seddon, ben alman */ window.modernizr = (function( window, document, undefined ) { var version = '2.8.3', modernizr = {}, /*>>cssclasses*/ // option for enabling the html classes to be added enableclasses = true, /*>>cssclasses*/ docelement = document.documentelement, /** * create our "modernizr" element that we do most feature tests on. */ mod = 'modernizr', modelem = document.createelement(mod), mstyle = modelem.style, /** * create the input element for various web forms feature tests. */ inputelem /*>>inputelem*/ = document.createelement('input') /*>>inputelem*/ , /*>>smile*/ smile = ':)', /*>>smile*/ tostring = {}.tostring, // todo :: make the prefixes more granular /*>>prefixes*/ // list of property values to set for css tests. see ticket #21 prefixes = ' -webkit- -moz- -o- -ms- '.split(' '), /*>>prefixes*/ /*>>domprefixes*/ // following spec is to expose vendor-specific style properties as: // elem.style.webkitborderradius // and the following would be incorrect: // elem.style.webkitborderradius // webkit ghosts their properties in lowercase but opera & moz do not. // microsoft uses a lowercase `ms` instead of the correct `ms` in ie8+ // erik.eae.net/archives/2008/03/10/21.48.10/ // more here: github.com/modernizr/modernizr/issues/issue/21 omprefixes = 'webkit moz o ms', cssomprefixes = omprefixes.split(' '), domprefixes = omprefixes.tolowercase().split(' '), /*>>domprefixes*/ /*>>ns*/ ns = {'svg': 'http://www.w3.org/2000/svg'}, /*>>ns*/ tests = {}, inputs = {}, attrs = {}, classes = [], slice = classes.slice, featurename, // used in testing loop /*>>teststyles*/ // inject element with style element and some css rules injectelementwithstyles = function( rule, callback, nodes, testnames ) { var style, ret, node, docoverflow, div = document.createelement('div'), // after page load injecting a fake body doesn't work so check if body exists body = document.body, // ie6 and 7 won't return offsetwidth or offsetheight unless it's in the body element, so we fake it. fakebody = body || document.createelement('body'); if ( parseint(nodes, 10) ) { // in order not to give false positives we create a node for each test // this also allows the method to scale for unspecified uses while ( nodes-- ) { node = document.createelement('div'); node.id = testnames ? testnames[nodes] : mod + (nodes + 1); div.appendchild(node); } } // '].join(''); div.id = mod; // ie6 will false positive on some tests due to the style element inside the test div somehow interfering offsetheight, so insert it into body or fakebody. // opera will act all quirky when injecting elements in documentelement when page is served as xml, needs fakebody too. #270 (body ? div : fakebody).innerhtml += style; fakebody.appendchild(div); if ( !body ) { //avoid crashing ie8, if background image is used fakebody.style.background = ''; //safari 5.13/5.1.4 osx stops loading if ::-webkit-scrollbar is used and scrollbars are visible fakebody.style.overflow = 'hidden'; docoverflow = docelement.style.overflow; docelement.style.overflow = 'hidden'; docelement.appendchild(fakebody); } ret = callback(div, rule); // if this is done after page load we don't want to remove the body so check if body exists if ( !body ) { fakebody.parentnode.removechild(fakebody); docelement.style.overflow = docoverflow; } else { div.parentnode.removechild(div); } return !!ret; }, /*>>teststyles*/ /*>>mq*/ // adapted from matchmedia polyfill // by scott jehl and paul irish // gist.github.com/786768 testmediaquery = function( mq ) { var matchmedia = window.matchmedia || window.msmatchmedia; if ( matchmedia ) { return matchmedia(mq) && matchmedia(mq).matches || false; } var bool; injectelementwithstyles('@media ' + mq + ' { #' + mod + ' { position: absolute; } }', function( node ) { bool = (window.getcomputedstyle ? getcomputedstyle(node, null) : node.currentstyle)['position'] == 'absolute'; }); return bool; }, /*>>mq*/ /*>>hasevent*/ // // iseventsupported determines if a given element supports the given event // kangax.github.com/iseventsupported/ // // the following results are known incorrects: // modernizr.hasevent("webkittransitionend", elem) // false negative // modernizr.hasevent("textinput") // in webkit. github.com/modernizr/modernizr/issues/333 // ... iseventsupported = (function() { var tagnames = { 'select': 'input', 'change': 'input', 'submit': 'form', 'reset': 'form', 'error': 'img', 'load': 'img', 'abort': 'img' }; function iseventsupported( eventname, element ) { element = element || document.createelement(tagnames[eventname] || 'div'); eventname = 'on' + eventname; // when using `setattribute`, ie skips "unload", webkit skips "unload" and "resize", whereas `in` "catches" those var issupported = eventname in element; if ( !issupported ) { // if it has no `setattribute` (i.e. doesn't implement node interface), try generic element if ( !element.setattribute ) { element = document.createelement('div'); } if ( element.setattribute && element.removeattribute ) { element.setattribute(eventname, ''); issupported = is(element[eventname], 'function'); // if property was created, "remove it" (by setting value to `undefined`) if ( !is(element[eventname], 'undefined') ) { element[eventname] = undefined; } element.removeattribute(eventname); } } element = null; return issupported; } return iseventsupported; })(), /*>>hasevent*/ // todo :: add flag for hasownprop ? didn't last time // hasownproperty shim by kangax needed for safari 2.0 support _hasownproperty = ({}).hasownproperty, hasownprop; if ( !is(_hasownproperty, 'undefined') && !is(_hasownproperty.call, 'undefined') ) { hasownprop = function (object, property) { return _hasownproperty.call(object, property); }; } else { hasownprop = function (object, property) { /* yes, this can give false positives/negatives, but most of the time we don't care about those */ return ((property in object) && is(object.constructor.prototype[property], 'undefined')); }; } // adapted from es5-shim https://github.com/kriskowal/es5-shim/blob/master/es5-shim.js // es5.github.com/#x15.3.4.5 if (!function.prototype.bind) { function.prototype.bind = function bind(that) { var target = this; if (typeof target != "function") { throw new typeerror(); } var args = slice.call(arguments, 1), bound = function () { if (this instanceof bound) { var f = function(){}; f.prototype = target.prototype; var self = new f(); var result = target.apply( self, args.concat(slice.call(arguments)) ); if (object(result) === result) { return result; } return self; } else { return target.apply( that, args.concat(slice.call(arguments)) ); } }; return bound; }; } /** * setcss applies given styles to the modernizr dom node. */ function setcss( str ) { mstyle.csstext = str; } /** * setcssall extrapolates all vendor-specific css strings. */ function setcssall( str1, str2 ) { return setcss(prefixes.join(str1 + ';') + ( str2 || '' )); } /** * is returns a boolean for if typeof obj is exactly type. */ function is( obj, type ) { return typeof obj === type; } /** * contains returns a boolean for if substr is found within str. */ function contains( str, substr ) { return !!~('' + str).indexof(substr); } /*>>testprop*/ // testprops is a generic css / dom property test. // in testing support for a given css property, it's legit to test: // `elem.style[stylename] !== undefined` // if the property is supported it will return an empty string, // if unsupported it will return undefined. // we'll take advantage of this quick test and skip setting a style // on our modernizr element, but instead just testing undefined vs // empty string. // because the testing of the css property names (with "-", as // opposed to the camelcase dom properties) is non-portable and // non-standard but works in webkit and ie (but not gecko or opera), // we explicitly reject properties with dashes so that authors // developing in webkit or ie first don't end up with // browser-specific content by accident. function testprops( props, prefixed ) { for ( var i in props ) { var prop = props[i]; if ( !contains(prop, "-") && mstyle[prop] !== undefined ) { return prefixed == 'pfx' ? prop : true; } } return false; } /*>>testprop*/ // todo :: add testdomprops /** * testdomprops is a generic dom property test; if a browser supports * a certain property, it won't return undefined for it. */ function testdomprops( props, obj, elem ) { for ( var i in props ) { var item = obj[props[i]]; if ( item !== undefined) { // return the property name as a string if (elem === false) return props[i]; // let's bind a function if (is(item, 'function')){ // default to autobind unless override return item.bind(elem || obj); } // return the unbound function or obj or value return item; } } return false; } /*>>testallprops*/ /** * testpropsall tests a list of dom properties we want to check against. * we specify literally all possible (known and/or likely) properties on * the element including the non-vendor prefixed one, for forward- * compatibility. */ function testpropsall( prop, prefixed, elem ) { var ucprop = prop.charat(0).touppercase() + prop.slice(1), props = (prop + ' ' + cssomprefixes.join(ucprop + ' ') + ucprop).split(' '); // did they call .prefixed('boxsizing') or are we just testing a prop? if(is(prefixed, "string") || is(prefixed, "undefined")) { return testprops(props, prefixed); // otherwise, they called .prefixed('requestanimationframe', window[, elem]) } else { props = (prop + ' ' + (domprefixes).join(ucprop + ' ') + ucprop).split(' '); return testdomprops(props, prefixed, elem); } } /*>>testallprops*/ /** * tests * ----- */ // the *new* flexbox // dev.w3.org/csswg/css3-flexbox tests['flexbox'] = function() { return testpropsall('flexwrap'); }; // the *old* flexbox // www.w3.org/tr/2009/wd-css3-flexbox-20090723/ tests['flexboxlegacy'] = function() { return testpropsall('boxdirection'); }; // on the s60 and bb storm, getcontext exists, but always returns undefined // so we actually have to call getcontext() to verify // github.com/modernizr/modernizr/issues/issue/97/ tests['canvas'] = function() { var elem = document.createelement('canvas'); return !!(elem.getcontext && elem.getcontext('2d')); }; tests['canvastext'] = function() { return !!(modernizr['canvas'] && is(document.createelement('canvas').getcontext('2d').filltext, 'function')); }; // webk.it/70117 is tracking a legit webgl feature detect proposal // we do a soft detect which may false positive in order to avoid // an expensive context creation: bugzil.la/732441 tests['webgl'] = function() { return !!window.webglrenderingcontext; }; /* * the modernizr.touch test only indicates if the browser supports * touch events, which does not necessarily reflect a touchscreen * device, as evidenced by tablets running windows 7 or, alas, * the palm pre / webos (touch) phones. * * additionally, chrome (desktop) used to lie about its support on this, * but that has since been rectified: crbug.com/36415 * * we also test for firefox 4 multitouch support. * * for more info, see: modernizr.github.com/modernizr/touch.html */ tests['touch'] = function() { var bool; if(('ontouchstart' in window) || window.documenttouch && document instanceof documenttouch) { bool = true; } else { injectelementwithstyles(['@media (',prefixes.join('touch-enabled),('),mod,')','{#modernizr{top:9px;position:absolute}}'].join(''), function( node ) { bool = node.offsettop === 9; }); } return bool; }; // geolocation is often considered a trivial feature detect... // turns out, it's quite tricky to get right: // // using !!navigator.geolocation does two things we don't want. it: // 1. leaks memory in ie9: github.com/modernizr/modernizr/issues/513 // 2. disables page caching in webkit: webk.it/43956 // // meanwhile, in firefox < 8, an about:config setting could expose // a false positive that would throw an exception: bugzil.la/688158 tests['geolocation'] = function() { return 'geolocation' in navigator; }; tests['postmessage'] = function() { return !!window.postmessage; }; // chrome incognito mode used to throw an exception when using opendatabase // it doesn't anymore. tests['websqldatabase'] = function() { return !!window.opendatabase; }; // vendors had inconsistent prefixing with the experimental indexed db: // - webkit's implementation is accessible through webkitindexeddb // - firefox shipped moz_indexeddb before ff4b9, but since then has been mozindexeddb // for speed, we don't test the legacy (and beta-only) indexeddb tests['indexeddb'] = function() { return !!testpropsall("indexeddb", window); }; // documentmode logic from yui to filter out ie8 compat mode // which false positives. tests['hashchange'] = function() { return iseventsupported('hashchange', window) && (document.documentmode === undefined || document.documentmode > 7); }; // per 1.6: // this used to be modernizr.historymanagement but the longer // name has been deprecated in favor of a shorter and property-matching one. // the old api is still available in 1.6, but as of 2.0 will throw a warning, // and in the first release thereafter disappear entirely. tests['history'] = function() { return !!(window.history && history.pushstate); }; tests['draganddrop'] = function() { var div = document.createelement('div'); return ('draggable' in div) || ('ondragstart' in div && 'ondrop' in div); }; // ff3.6 was eol'ed on 4/24/12, but the esr version of ff10 // will be supported until ff19 (2/12/13), at which time, esr becomes ff17. // ff10 still uses prefixes, so check for it until then. // for more esr info, see: mozilla.org/en-us/firefox/organizations/faq/ tests['websockets'] = function() { return 'websocket' in window || 'mozwebsocket' in window; }; // css-tricks.com/rgba-browser-support/ tests['rgba'] = function() { // set an rgba() color and check the returned value setcss('background-color:rgba(150,255,150,.5)'); return contains(mstyle.backgroundcolor, 'rgba'); }; tests['hsla'] = function() { // same as rgba(), in fact, browsers re-map hsla() to rgba() internally, // except ie9 who retains it as hsla setcss('background-color:hsla(120,40%,100%,.5)'); return contains(mstyle.backgroundcolor, 'rgba') || contains(mstyle.backgroundcolor, 'hsla'); }; tests['multiplebgs'] = function() { // setting multiple images and a color on the background shorthand property // and then querying the style.background property value for the number of // occurrences of "url(" is a reliable method for detecting actual support for this! setcss('background:url(https://),url(https://),red url(https://)'); // if the ua supports multiple backgrounds, there should be three occurrences // of the string "url(" in the return value for elemstyle.background return (/(url\s*\(.*?){3}/).test(mstyle.background); }; // this will false positive in opera mini // github.com/modernizr/modernizr/issues/396 tests['backgroundsize'] = function() { return testpropsall('backgroundsize'); }; tests['borderimage'] = function() { return testpropsall('borderimage'); }; // super comprehensive table about all the unique implementations of // border-radius: muddledramblings.com/table-of-css3-border-radius-compliance tests['borderradius'] = function() { return testpropsall('borderradius'); }; // webos unfortunately false positives on this test. tests['boxshadow'] = function() { return testpropsall('boxshadow'); }; // ff3.0 will false positive on this test tests['textshadow'] = function() { return document.createelement('div').style.textshadow === ''; }; tests['opacity'] = function() { // browsers that actually have css opacity implemented have done so // according to spec, which means their return values are within the // range of [0.0,1.0] - including the leading zero. setcssall('opacity:.55'); // the non-literal . in this regex is intentional: // german chrome returns this value as 0,55 // github.com/modernizr/modernizr/issues/#issue/59/comment/516632 return (/^0.55$/).test(mstyle.opacity); }; // note, android < 4 will pass this test, but can only animate // a single property at a time // goo.gl/v3v4gp tests['cssanimations'] = function() { return testpropsall('animationname'); }; tests['csscolumns'] = function() { return testpropsall('columncount'); }; tests['cssgradients'] = function() { /** * for css gradients syntax, please see: * webkit.org/blog/175/introducing-css-gradients/ * developer.mozilla.org/en/css/-moz-linear-gradient * developer.mozilla.org/en/css/-moz-radial-gradient * dev.w3.org/csswg/css3-images/#gradients- */ var str1 = 'background-image:', str2 = 'gradient(linear,left top,right bottom,from(#9f9),to(white));', str3 = 'linear-gradient(left top,#9f9, white);'; setcss( // legacy webkit syntax (fixme: remove when syntax not in use anymore) (str1 + '-webkit- '.split(' ').join(str2 + str1) + // standard syntax // trailing 'background-image:' prefixes.join(str3 + str1)).slice(0, -str1.length) ); return contains(mstyle.backgroundimage, 'gradient'); }; tests['cssreflections'] = function() { return testpropsall('boxreflect'); }; tests['csstransforms'] = function() { return !!testpropsall('transform'); }; tests['csstransforms3d'] = function() { var ret = !!testpropsall('perspective'); // webkit's 3d transforms are passed off to the browser's own graphics renderer. // it works fine in safari on leopard and snow leopard, but not in chrome in // some conditions. as a result, webkit typically recognizes the syntax but // will sometimes throw a false positive, thus we must do a more thorough check: if ( ret && 'webkitperspective' in docelement.style ) { // webkit allows this media query to succeed only if the feature is enabled. // `@media (transform-3d),(-webkit-transform-3d){ ... }` injectelementwithstyles('@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}', function( node, rule ) { ret = node.offsetleft === 9 && node.offsetheight === 3; }); } return ret; }; tests['csstransitions'] = function() { return testpropsall('transition'); }; /*>>fontface*/ // @font-face detection routine by diego perini // javascript.nwbox.com/csssupport/ // false positives: // webos github.com/modernizr/modernizr/issues/342 // wp7 github.com/modernizr/modernizr/issues/538 tests['fontface'] = function() { var bool; injectelementwithstyles('@font-face {font-family:"font";src:url("https://")}', function( node, rule ) { var style = document.getelementbyid('smodernizr'), sheet = style.sheet || style.stylesheet, csstext = sheet ? (sheet.cssrules && sheet.cssrules[0] ? sheet.cssrules[0].csstext : sheet.csstext || '') : ''; bool = /src/i.test(csstext) && csstext.indexof(rule.split(' ')[0]) === 0; }); return bool; }; /*>>fontface*/ // css generated content detection tests['generatedcontent'] = function() { var bool; injectelementwithstyles(['#',mod,'{font:0/0 a}#',mod,':after{content:"',smile,'";visibility:hidden;font:3px/1 a}'].join(''), function( node ) { bool = node.offsetheight >= 3; }); return bool; }; // these tests evaluate support of the video/audio elements, as well as // testing what types of content they support. // // we're using the boolean constructor here, so that we can extend the value // e.g. modernizr.video // true // modernizr.video.ogg // 'probably' // // codec values from : github.com/nielsleenheer/html5test/blob/9106a8/index.html#l845 // thx to nielsleenheer and zcorpan // note: in some older browsers, "no" was a return value instead of empty string. // it was live in ff3.5.0 and 3.5.1, but fixed in 3.5.2 // it was also live in safari 4.0.0 - 4.0.4, but fixed in 4.0.5 tests['video'] = function() { var elem = document.createelement('video'), bool = false; // ie9 running on windows server sku can cause an exception to be thrown, bug #224 try { if ( bool = !!elem.canplaytype ) { bool = new boolean(bool); bool.ogg = elem.canplaytype('video/ogg; codecs="theora"') .replace(/^no$/,''); // without quicktime, this value will be `undefined`. github.com/modernizr/modernizr/issues/546 bool.h264 = elem.canplaytype('video/mp4; codecs="avc1.42e01e"') .replace(/^no$/,''); bool.webm = elem.canplaytype('video/webm; codecs="vp8, vorbis"').replace(/^no$/,''); } } catch(e) { } return bool; }; tests['audio'] = function() { var elem = document.createelement('audio'), bool = false; try { if ( bool = !!elem.canplaytype ) { bool = new boolean(bool); bool.ogg = elem.canplaytype('audio/ogg; codecs="vorbis"').replace(/^no$/,''); bool.mp3 = elem.canplaytype('audio/mpeg;') .replace(/^no$/,''); // mimetypes accepted: // developer.mozilla.org/en/media_formats_supported_by_the_audio_and_video_elements // bit.ly/iphoneoscodecs bool.wav = elem.canplaytype('audio/wav; codecs="1"') .replace(/^no$/,''); bool.m4a = ( elem.canplaytype('audio/x-m4a;') || elem.canplaytype('audio/aac;')) .replace(/^no$/,''); } } catch(e) { } return bool; }; // in ff4, if disabled, window.localstorage should === null. // normally, we could not test that directly and need to do a // `('localstorage' in window) && ` test first because otherwise firefox will // throw bugzil.la/365772 if cookies are disabled // also in ios5 private browsing mode, attempting to use localstorage.setitem // will throw the exception: // quota_exceeded_errror dom exception 22. // peculiarly, getitem and removeitem calls do not throw. // because we are forced to try/catch this, we'll go aggressive. // just fwiw: ie8 compat mode supports these features completely: // www.quirksmode.org/dom/html5.html // but ie8 doesn't support either with local files tests['localstorage'] = function() { try { localstorage.setitem(mod, mod); localstorage.removeitem(mod); return true; } catch(e) { return false; } }; tests['sessionstorage'] = function() { try { sessionstorage.setitem(mod, mod); sessionstorage.removeitem(mod); return true; } catch(e) { return false; } }; tests['webworkers'] = function() { return !!window.worker; }; tests['applicationcache'] = function() { return !!window.applicationcache; }; // thanks to erik dahlstrom tests['svg'] = function() { return !!document.createelementns && !!document.createelementns(ns.svg, 'svg').createsvgrect; }; // specifically for svg inline in html, not within xhtml // test page: paulirish.com/demo/inline-svg tests['inlinesvg'] = function() { var div = document.createelement('div'); div.innerhtml = ''; return (div.firstchild && div.firstchild.namespaceuri) == ns.svg; }; // svg smil animation tests['smil'] = function() { return !!document.createelementns && /svganimate/.test(tostring.call(document.createelementns(ns.svg, 'animate'))); }; // this test is only for clip paths in svg proper, not clip paths on html content // demo: srufaculty.sru.edu/david.dailey/svg/newstuff/clippath4.svg // however read the comments to dig into applying svg clippaths to html content here: // github.com/modernizr/modernizr/issues/213#issuecomment-1149491 tests['svgclippaths'] = function() { return !!document.createelementns && /svgclippath/.test(tostring.call(document.createelementns(ns.svg, 'clippath'))); }; /*>>webforms*/ // input features and input types go directly onto the ret object, bypassing the tests loop. // hold this guy to execute in a moment. function webforms() { /*>>input*/ // run through html5's new input attributes to see if the ua understands any. // we're using f which is the element created early on // mike taylr has created a comprehensive resource for testing these attributes // when applied to all input types: // miketaylr.com/code/input-type-attr.html // spec: www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary // only input placeholder is tested while textarea's placeholder is not. // currently safari 4 and opera 11 have support only for the input placeholder // both tests are available in feature-detects/forms-placeholder.js modernizr['input'] = (function( props ) { for ( var i = 0, len = props.length; i < len; i++ ) { attrs[ props[i] ] = !!(props[i] in inputelem); } if (attrs.list){ // safari false positive's on datalist: webk.it/74252 // see also github.com/modernizr/modernizr/issues/146 attrs.list = !!(document.createelement('datalist') && window.htmldatalistelement); } return attrs; })('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' ')); /*>>input*/ /*>>inputtypes*/ // run through html5's new input types to see if the ua understands any. // this is put behind the tests runloop because it doesn't return a // true/false like all the other tests; instead, it returns an object // containing each input type with its corresponding true/false value // big thanks to @miketaylr for the html5 forms expertise. miketaylr.com/ modernizr['inputtypes'] = (function(props) { for ( var i = 0, bool, inputelemtype, defaultview, len = props.length; i < len; i++ ) { inputelem.setattribute('type', inputelemtype = props[i]); bool = inputelem.type !== 'text'; // we first check to see if the type we give it sticks.. // if the type does, we feed it a textual value, which shouldn't be valid. // if the value doesn't stick, we know there's input sanitization which infers a custom ui if ( bool ) { inputelem.value = smile; inputelem.style.csstext = 'position:absolute;visibility:hidden;'; if ( /^range$/.test(inputelemtype) && inputelem.style.webkitappearance !== undefined ) { docelement.appendchild(inputelem); defaultview = document.defaultview; // safari 2-4 allows the smiley as a value, despite making a slider bool = defaultview.getcomputedstyle && defaultview.getcomputedstyle(inputelem, null).webkitappearance !== 'textfield' && // mobile android web browser has false positive, so must // check the height to see if the widget is actually there. (inputelem.offsetheight !== 0); docelement.removechild(inputelem); } else if ( /^(search|tel)$/.test(inputelemtype) ){ // spec doesn't define any special parsing or detectable ui // behaviors so we pass these through as true // interestingly, opera fails the earlier test, so it doesn't // even make it here. } else if ( /^(url|email)$/.test(inputelemtype) ) { // real url and email support comes with prebaked validation. bool = inputelem.checkvalidity && inputelem.checkvalidity() === false; } else { // if the upgraded input compontent rejects the :) text, we got a winner bool = inputelem.value != smile; } } inputs[ props[i] ] = !!bool; } return inputs; })('search tel url email datetime date month week time datetime-local number range color'.split(' ')); /*>>inputtypes*/ } /*>>webforms*/ // end of test definitions // ----------------------- // run through all tests and detect their support in the current ua. // todo: hypothetically we could be doing an array of tests and use a basic loop here. for ( var feature in tests ) { if ( hasownprop(tests, feature) ) { // run the test, throw the return value into the modernizr, // then based on that boolean, define an appropriate classname // and push it into an array of classes we'll join later. featurename = feature.tolowercase(); modernizr[featurename] = tests[feature](); classes.push((modernizr[featurename] ? '' : 'no-') + featurename); } } /*>>webforms*/ // input tests need to run. modernizr.input || webforms(); /*>>webforms*/ /** * addtest allows the user to define their own feature tests * the result will be added onto the modernizr object, * as well as an appropriate classname set on the html element * * @param feature - string naming the feature * @param test - function returning true if feature is supported, false if not */ modernizr.addtest = function ( feature, test ) { if ( typeof feature == 'object' ) { for ( var key in feature ) { if ( hasownprop( feature, key ) ) { modernizr.addtest( key, feature[ key ] ); } } } else { feature = feature.tolowercase(); if ( modernizr[feature] !== undefined ) { // we're going to quit if you're trying to overwrite an existing test // if we were to allow it, we'd do this: // var re = new regexp("\\b(no-)?" + feature + "\\b"); // docelement.classname = docelement.classname.replace( re, '' ); // but, no rly, stuff 'em. return modernizr; } test = typeof test == 'function' ? test() : test; if (typeof enableclasses !== "undefined" && enableclasses) { docelement.classname += ' ' + (test ? '' : 'no-') + feature; } modernizr[feature] = test; } return modernizr; // allow chaining. }; // reset modelem.csstext to nothing to reduce memory footprint. setcss(''); modelem = inputelem = null; /*>>shiv*/ /** * @preserve html5 shiv prev3.7.1 | @afarkas @jdalton @jon_neal @rem | mit/gpl2 licensed */ ;(function(window, document) { /*jshint evil:true */ /** version */ var version = '3.7.0'; /** preset options */ var options = window.html5 || {}; /** used to skip problem elements */ var reskip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i; /** not all elements can be cloned in ie **/ var saveclones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i; /** detect whether the browser supports default html5 styles */ var supportshtml5styles; /** name of the expando, to work with multiple documents or to re-shiv one document */ var expando = '_html5shiv'; /** the id for the the documents expando */ var expanid = 0; /** cached data for each document */ var expandodata = {}; /** detect whether the browser supports unknown elements */ var supportsunknownelements; (function() { try { var a = document.createelement('a'); a.innerhtml = ''; //if the hidden property is implemented we can assume, that the browser supports basic html5 styles supportshtml5styles = ('hidden' in a); supportsunknownelements = a.childnodes.length == 1 || (function() { // assign a false positive if unable to shiv (document.createelement)('a'); var frag = document.createdocumentfragment(); return ( typeof frag.clonenode == 'undefined' || typeof frag.createdocumentfragment == 'undefined' || typeof frag.createelement == 'undefined' ); }()); } catch(e) { // assign a false positive if detection fails => unable to shiv supportshtml5styles = true; supportsunknownelements = true; } }()); /*--------------------------------------------------------------------------*/ /** * creates a style sheet with the given css text and adds it to the document. * @private * @param {document} ownerdocument the document. * @param {string} csstext the css text. * @returns {stylesheet} the style element. */ function addstylesheet(ownerdocument, csstext) { var p = ownerdocument.createelement('p'), parent = ownerdocument.getelementsbytagname('head')[0] || ownerdocument.documentelement; p.innerhtml = 'x'; return parent.insertbefore(p.lastchild, parent.firstchild); } /** * returns the value of `html5.elements` as an array. * @private * @returns {array} an array of shived element node names. */ function getelements() { var elements = html5.elements; return typeof elements == 'string' ? elements.split(' ') : elements; } /** * returns the data associated to the given document * @private * @param {document} ownerdocument the document. * @returns {object} an object of data. */ function getexpandodata(ownerdocument) { var data = expandodata[ownerdocument[expando]]; if (!data) { data = {}; expanid++; ownerdocument[expando] = expanid; expandodata[expanid] = data; } return data; } /** * returns a shived element for the given nodename and document * @memberof html5 * @param {string} nodename name of the element * @param {document} ownerdocument the context document. * @returns {object} the shived element. */ function createelement(nodename, ownerdocument, data){ if (!ownerdocument) { ownerdocument = document; } if(supportsunknownelements){ return ownerdocument.createelement(nodename); } if (!data) { data = getexpandodata(ownerdocument); } var node; if (data.cache[nodename]) { node = data.cache[nodename].clonenode(); } else if (saveclones.test(nodename)) { node = (data.cache[nodename] = data.createelem(nodename)).clonenode(); } else { node = data.createelem(nodename); } // avoid adding some elements to fragments in ie < 9 because // * attributes like `name` or `type` cannot be set/changed once an element // is inserted into a document/fragment // * link elements with `src` attributes that are inaccessible, as with // a 403 response, will cause the tab/window to crash // * script elements appended to fragments will execute when their `src` // or `text` property is set return node.canhavechildren && !reskip.test(nodename) && !node.tagurn ? data.frag.appendchild(node) : node; } /** * returns a shived documentfragment for the given document * @memberof html5 * @param {document} ownerdocument the context document. * @returns {object} the shived documentfragment. */ function createdocumentfragment(ownerdocument, data){ if (!ownerdocument) { ownerdocument = document; } if(supportsunknownelements){ return ownerdocument.createdocumentfragment(); } data = data || getexpandodata(ownerdocument); var clone = data.frag.clonenode(), i = 0, elems = getelements(), l = elems.length; for(;i>shiv*/ // assign private properties to the return object with prefix modernizr._version = version; // expose these for the plugin api. look in the source for how to join() them against your input /*>>prefixes*/ modernizr._prefixes = prefixes; /*>>prefixes*/ /*>>domprefixes*/ modernizr._domprefixes = domprefixes; modernizr._cssomprefixes = cssomprefixes; /*>>domprefixes*/ /*>>mq*/ // modernizr.mq tests a given media query, live against the current state of the window // a few important notes: // * if a browser does not support media queries at all (eg. oldie) the mq() will always return false // * a max-width or orientation query will be evaluated against the current state, which may change later. // * you must specify values. eg. if you are testing support for the min-width media query use: // modernizr.mq('(min-width:0)') // usage: // modernizr.mq('only screen and (max-width:768)') modernizr.mq = testmediaquery; /*>>mq*/ /*>>hasevent*/ // modernizr.hasevent() detects support for a given event, with an optional element to test on // modernizr.hasevent('gesturestart', elem) modernizr.hasevent = iseventsupported; /*>>hasevent*/ /*>>testprop*/ // modernizr.testprop() investigates whether a given style property is recognized // note that the property names must be provided in the camelcase variant. // modernizr.testprop('pointerevents') modernizr.testprop = function(prop){ return testprops([prop]); }; /*>>testprop*/ /*>>testallprops*/ // modernizr.testallprops() investigates whether a given style property, // or any of its vendor-prefixed variants, is recognized // note that the property names must be provided in the camelcase variant. // modernizr.testallprops('boxsizing') modernizr.testallprops = testpropsall; /*>>testallprops*/ /*>>teststyles*/ // modernizr.teststyles() allows you to add custom styles to the document and test an element afterwards // modernizr.teststyles('#modernizr { position:absolute }', function(elem, rule){ ... }) modernizr.teststyles = injectelementwithstyles; /*>>teststyles*/ /*>>prefixed*/ // modernizr.prefixed() returns the prefixed or nonprefixed property name variant of your input // modernizr.prefixed('boxsizing') // 'mozboxsizing' // properties must be passed as dom-style camelcase, rather than `box-sizing` hypentated style. // return values will also be the camelcase variant, if you need to translate that to hypenated style use: // // str.replace(/([a-z])/g, function(str,m1){ return '-' + m1.tolowercase(); }).replace(/^ms-/,'-ms-'); // if you're trying to ascertain which transition end event to bind to, you might do something like... // // var transendeventnames = { // 'webkittransition' : 'webkittransitionend', // 'moztransition' : 'transitionend', // 'otransition' : 'otransitionend', // 'mstransition' : 'mstransitionend', // 'transition' : 'transitionend' // }, // transendeventname = transendeventnames[ modernizr.prefixed('transition') ]; modernizr.prefixed = function(prop, obj, elem){ if(!obj) { return testpropsall(prop, 'pfx'); } else { // testing dom property e.g. modernizr.prefixed('requestanimationframe', window) // 'mozrequestanimationframe' return testpropsall(prop, obj, elem); } }; /*>>prefixed*/ /*>>cssclasses*/ // remove "no-js" class from element, if it exists: docelement.classname = docelement.classname.replace(/(^|\s)no-js(\s|$)/, '$1$2') + // add the new classes to the element. (enableclasses ? ' js ' + classes.join(' ') : ''); /*>>cssclasses*/ return modernizr; })(this, this.document);