modernizr.js 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384
  1. /*!
  2. * Modernizr v2.6.1
  3. * www.modernizr.com
  4. *
  5. * Copyright (c) Faruk Ates, Paul Irish, Alex Sexton
  6. * Available under the BSD and MIT licenses: www.modernizr.com/license/
  7. */
  8. /*
  9. * Modernizr tests which native CSS3 and HTML5 features are available in
  10. * the current UA and makes the results available to you in two ways:
  11. * as properties on a global Modernizr object, and as classes on the
  12. * <html> element. This information allows you to progressively enhance
  13. * your pages with a granular level of control over the experience.
  14. *
  15. * Modernizr has an optional (not included) conditional resource loader
  16. * called Modernizr.load(), based on Yepnope.js (yepnopejs.com).
  17. * To get a build that includes Modernizr.load(), as well as choosing
  18. * which tests to include, go to www.modernizr.com/download/
  19. *
  20. * Authors Faruk Ates, Paul Irish, Alex Sexton
  21. * Contributors Ryan Seddon, Ben Alman
  22. */
  23. window.Modernizr = (function( window, document, undefined ) {
  24. var version = '2.6.1',
  25. Modernizr = {},
  26. /*>>cssclasses*/
  27. // option for enabling the HTML classes to be added
  28. enableClasses = true,
  29. /*>>cssclasses*/
  30. docElement = document.documentElement,
  31. /**
  32. * Create our "modernizr" element that we do most feature tests on.
  33. */
  34. mod = 'modernizr',
  35. modElem = document.createElement(mod),
  36. mStyle = modElem.style,
  37. /**
  38. * Create the input element for various Web Forms feature tests.
  39. */
  40. inputElem /*>>inputelem*/ = document.createElement('input') /*>>inputelem*/ ,
  41. /*>>smile*/
  42. smile = ':)',
  43. /*>>smile*/
  44. toString = {}.toString,
  45. // TODO :: make the prefixes more granular
  46. /*>>prefixes*/
  47. // List of property values to set for css tests. See ticket #21
  48. prefixes = ' -webkit- -moz- -o- -ms- '.split(' '),
  49. /*>>prefixes*/
  50. /*>>domprefixes*/
  51. // Following spec is to expose vendor-specific style properties as:
  52. // elem.style.WebkitBorderRadius
  53. // and the following would be incorrect:
  54. // elem.style.webkitBorderRadius
  55. // Webkit ghosts their properties in lowercase but Opera & Moz do not.
  56. // Microsoft uses a lowercase `ms` instead of the correct `Ms` in IE8+
  57. // erik.eae.net/archives/2008/03/10/21.48.10/
  58. // More here: github.com/Modernizr/Modernizr/issues/issue/21
  59. omPrefixes = 'Webkit Moz O ms',
  60. cssomPrefixes = omPrefixes.split(' '),
  61. domPrefixes = omPrefixes.toLowerCase().split(' '),
  62. /*>>domprefixes*/
  63. /*>>ns*/
  64. ns = {'svg': 'http://www.w3.org/2000/svg'},
  65. /*>>ns*/
  66. tests = {},
  67. inputs = {},
  68. attrs = {},
  69. classes = [],
  70. slice = classes.slice,
  71. featureName, // used in testing loop
  72. /*>>teststyles*/
  73. // Inject element with style element and some CSS rules
  74. injectElementWithStyles = function( rule, callback, nodes, testnames ) {
  75. var style, ret, node,
  76. div = document.createElement('div'),
  77. // After page load injecting a fake body doesn't work so check if body exists
  78. body = document.body,
  79. // IE6 and 7 won't return offsetWidth or offsetHeight unless it's in the body element, so we fake it.
  80. fakeBody = body ? body : document.createElement('body');
  81. if ( parseInt(nodes, 10) ) {
  82. // In order not to give false positives we create a node for each test
  83. // This also allows the method to scale for unspecified uses
  84. while ( nodes-- ) {
  85. node = document.createElement('div');
  86. node.id = testnames ? testnames[nodes] : mod + (nodes + 1);
  87. div.appendChild(node);
  88. }
  89. }
  90. // <style> elements in IE6-9 are considered 'NoScope' elements and therefore will be removed
  91. // when injected with innerHTML. To get around this you need to prepend the 'NoScope' element
  92. // with a 'scoped' element, in our case the soft-hyphen entity as it won't mess with our measurements.
  93. // msdn.microsoft.com/en-us/library/ms533897%28VS.85%29.aspx
  94. // Documents served as xml will throw if using &shy; so use xml friendly encoded version. See issue #277
  95. style = ['&#173;','<style id="s', mod, '">', rule, '</style>'].join('');
  96. div.id = mod;
  97. // 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.
  98. // Opera will act all quirky when injecting elements in documentElement when page is served as xml, needs fakebody too. #270
  99. (body ? div : fakeBody).innerHTML += style;
  100. fakeBody.appendChild(div);
  101. if ( !body ) {
  102. //avoid crashing IE8, if background image is used
  103. fakeBody.style.background = "";
  104. docElement.appendChild(fakeBody);
  105. }
  106. ret = callback(div, rule);
  107. // If this is done after page load we don't want to remove the body so check if body exists
  108. !body ? fakeBody.parentNode.removeChild(fakeBody) : div.parentNode.removeChild(div);
  109. return !!ret;
  110. },
  111. /*>>teststyles*/
  112. /*>>mq*/
  113. // adapted from matchMedia polyfill
  114. // by Scott Jehl and Paul Irish
  115. // gist.github.com/786768
  116. testMediaQuery = function( mq ) {
  117. var matchMedia = window.matchMedia || window.msMatchMedia;
  118. if ( matchMedia ) {
  119. return matchMedia(mq).matches;
  120. }
  121. var bool;
  122. injectElementWithStyles('@media ' + mq + ' { #' + mod + ' { position: absolute; } }', function( node ) {
  123. bool = (window.getComputedStyle ?
  124. getComputedStyle(node, null) :
  125. node.currentStyle)['position'] == 'absolute';
  126. });
  127. return bool;
  128. },
  129. /*>>mq*/
  130. /*>>hasevent*/
  131. //
  132. // isEventSupported determines if a given element supports the given event
  133. // kangax.github.com/iseventsupported/
  134. //
  135. // The following results are known incorrect:
  136. // Modernizr.hasEvent("webkitTransitionEnd", elem) // false negative
  137. // Modernizr.hasEvent("textInput") // in Webkit. github.com/Modernizr/Modernizr/issues/333
  138. // ...
  139. isEventSupported = (function() {
  140. var TAGNAMES = {
  141. 'select': 'input', 'change': 'input',
  142. 'submit': 'form', 'reset': 'form',
  143. 'error': 'img', 'load': 'img', 'abort': 'img'
  144. };
  145. function isEventSupported( eventName, element ) {
  146. element = element || document.createElement(TAGNAMES[eventName] || 'div');
  147. eventName = 'on' + eventName;
  148. // When using `setAttribute`, IE skips "unload", WebKit skips "unload" and "resize", whereas `in` "catches" those
  149. var isSupported = eventName in element;
  150. if ( !isSupported ) {
  151. // If it has no `setAttribute` (i.e. doesn't implement Node interface), try generic element
  152. if ( !element.setAttribute ) {
  153. element = document.createElement('div');
  154. }
  155. if ( element.setAttribute && element.removeAttribute ) {
  156. element.setAttribute(eventName, '');
  157. isSupported = is(element[eventName], 'function');
  158. // If property was created, "remove it" (by setting value to `undefined`)
  159. if ( !is(element[eventName], 'undefined') ) {
  160. element[eventName] = undefined;
  161. }
  162. element.removeAttribute(eventName);
  163. }
  164. }
  165. element = null;
  166. return isSupported;
  167. }
  168. return isEventSupported;
  169. })(),
  170. /*>>hasevent*/
  171. // TODO :: Add flag for hasownprop ? didn't last time
  172. // hasOwnProperty shim by kangax needed for Safari 2.0 support
  173. _hasOwnProperty = ({}).hasOwnProperty, hasOwnProp;
  174. if ( !is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined') ) {
  175. hasOwnProp = function (object, property) {
  176. return _hasOwnProperty.call(object, property);
  177. };
  178. }
  179. else {
  180. hasOwnProp = function (object, property) { /* yes, this can give false positives/negatives, but most of the time we don't care about those */
  181. return ((property in object) && is(object.constructor.prototype[property], 'undefined'));
  182. };
  183. }
  184. // Adapted from ES5-shim https://github.com/kriskowal/es5-shim/blob/master/es5-shim.js
  185. // es5.github.com/#x15.3.4.5
  186. if (!Function.prototype.bind) {
  187. Function.prototype.bind = function bind(that) {
  188. var target = this;
  189. if (typeof target != "function") {
  190. throw new TypeError();
  191. }
  192. var args = slice.call(arguments, 1),
  193. bound = function () {
  194. if (this instanceof bound) {
  195. var F = function(){};
  196. F.prototype = target.prototype;
  197. var self = new F();
  198. var result = target.apply(
  199. self,
  200. args.concat(slice.call(arguments))
  201. );
  202. if (Object(result) === result) {
  203. return result;
  204. }
  205. return self;
  206. } else {
  207. return target.apply(
  208. that,
  209. args.concat(slice.call(arguments))
  210. );
  211. }
  212. };
  213. return bound;
  214. };
  215. }
  216. /**
  217. * setCss applies given styles to the Modernizr DOM node.
  218. */
  219. function setCss( str ) {
  220. mStyle.cssText = str;
  221. }
  222. /**
  223. * setCssAll extrapolates all vendor-specific css strings.
  224. */
  225. function setCssAll( str1, str2 ) {
  226. return setCss(prefixes.join(str1 + ';') + ( str2 || '' ));
  227. }
  228. /**
  229. * is returns a boolean for if typeof obj is exactly type.
  230. */
  231. function is( obj, type ) {
  232. return typeof obj === type;
  233. }
  234. /**
  235. * contains returns a boolean for if substr is found within str.
  236. */
  237. function contains( str, substr ) {
  238. return !!~('' + str).indexOf(substr);
  239. }
  240. /*>>testprop*/
  241. // testProps is a generic CSS / DOM property test.
  242. // In testing support for a given CSS property, it's legit to test:
  243. // `elem.style[styleName] !== undefined`
  244. // If the property is supported it will return an empty string,
  245. // if unsupported it will return undefined.
  246. // We'll take advantage of this quick test and skip setting a style
  247. // on our modernizr element, but instead just testing undefined vs
  248. // empty string.
  249. // Because the testing of the CSS property names (with "-", as
  250. // opposed to the camelCase DOM properties) is non-portable and
  251. // non-standard but works in WebKit and IE (but not Gecko or Opera),
  252. // we explicitly reject properties with dashes so that authors
  253. // developing in WebKit or IE first don't end up with
  254. // browser-specific content by accident.
  255. function testProps( props, prefixed ) {
  256. for ( var i in props ) {
  257. var prop = props[i];
  258. if ( !contains(prop, "-") && mStyle[prop] !== undefined ) {
  259. return prefixed == 'pfx' ? prop : true;
  260. }
  261. }
  262. return false;
  263. }
  264. /*>>testprop*/
  265. // TODO :: add testDOMProps
  266. /**
  267. * testDOMProps is a generic DOM property test; if a browser supports
  268. * a certain property, it won't return undefined for it.
  269. */
  270. function testDOMProps( props, obj, elem ) {
  271. for ( var i in props ) {
  272. var item = obj[props[i]];
  273. if ( item !== undefined) {
  274. // return the property name as a string
  275. if (elem === false) return props[i];
  276. // let's bind a function
  277. if (is(item, 'function')){
  278. // default to autobind unless override
  279. return item.bind(elem || obj);
  280. }
  281. // return the unbound function or obj or value
  282. return item;
  283. }
  284. }
  285. return false;
  286. }
  287. /*>>testallprops*/
  288. /**
  289. * testPropsAll tests a list of DOM properties we want to check against.
  290. * We specify literally ALL possible (known and/or likely) properties on
  291. * the element including the non-vendor prefixed one, for forward-
  292. * compatibility.
  293. */
  294. function testPropsAll( prop, prefixed, elem ) {
  295. var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1),
  296. props = (prop + ' ' + cssomPrefixes.join(ucProp + ' ') + ucProp).split(' ');
  297. // did they call .prefixed('boxSizing') or are we just testing a prop?
  298. if(is(prefixed, "string") || is(prefixed, "undefined")) {
  299. return testProps(props, prefixed);
  300. // otherwise, they called .prefixed('requestAnimationFrame', window[, elem])
  301. } else {
  302. props = (prop + ' ' + (domPrefixes).join(ucProp + ' ') + ucProp).split(' ');
  303. return testDOMProps(props, prefixed, elem);
  304. }
  305. }
  306. /*>>testallprops*/
  307. /**
  308. * Tests
  309. * -----
  310. */
  311. // The *new* flexbox
  312. // dev.w3.org/csswg/css3-flexbox
  313. tests['flexbox'] = function() {
  314. return testPropsAll('flexWrap');
  315. };
  316. // The *old* flexbox
  317. // www.w3.org/TR/2009/WD-css3-flexbox-20090723/
  318. tests['flexboxlegacy'] = function() {
  319. return testPropsAll('boxDirection');
  320. };
  321. // On the S60 and BB Storm, getContext exists, but always returns undefined
  322. // so we actually have to call getContext() to verify
  323. // github.com/Modernizr/Modernizr/issues/issue/97/
  324. tests['canvas'] = function() {
  325. var elem = document.createElement('canvas');
  326. return !!(elem.getContext && elem.getContext('2d'));
  327. };
  328. tests['canvastext'] = function() {
  329. return !!(Modernizr['canvas'] && is(document.createElement('canvas').getContext('2d').fillText, 'function'));
  330. };
  331. // webk.it/70117 is tracking a legit WebGL feature detect proposal
  332. // We do a soft detect which may false positive in order to avoid
  333. // an expensive context creation: bugzil.la/732441
  334. tests['webgl'] = function() {
  335. return !!window.WebGLRenderingContext;
  336. };
  337. /*
  338. * The Modernizr.touch test only indicates if the browser supports
  339. * touch events, which does not necessarily reflect a touchscreen
  340. * device, as evidenced by tablets running Windows 7 or, alas,
  341. * the Palm Pre / WebOS (touch) phones.
  342. *
  343. * Additionally, Chrome (desktop) used to lie about its support on this,
  344. * but that has since been rectified: crbug.com/36415
  345. *
  346. * We also test for Firefox 4 Multitouch Support.
  347. *
  348. * For more info, see: modernizr.github.com/Modernizr/touch.html
  349. */
  350. tests['touch'] = function() {
  351. var bool;
  352. if(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch) {
  353. bool = true;
  354. } else {
  355. injectElementWithStyles(['@media (',prefixes.join('touch-enabled),('),mod,')','{#modernizr{top:9px;position:absolute}}'].join(''), function( node ) {
  356. bool = node.offsetTop === 9;
  357. });
  358. }
  359. return bool;
  360. };
  361. // geolocation is often considered a trivial feature detect...
  362. // Turns out, it's quite tricky to get right:
  363. //
  364. // Using !!navigator.geolocation does two things we don't want. It:
  365. // 1. Leaks memory in IE9: github.com/Modernizr/Modernizr/issues/513
  366. // 2. Disables page caching in WebKit: webk.it/43956
  367. //
  368. // Meanwhile, in Firefox < 8, an about:config setting could expose
  369. // a false positive that would throw an exception: bugzil.la/688158
  370. tests['geolocation'] = function() {
  371. return 'geolocation' in navigator;
  372. };
  373. tests['postmessage'] = function() {
  374. return !!window.postMessage;
  375. };
  376. // Chrome incognito mode used to throw an exception when using openDatabase
  377. // It doesn't anymore.
  378. tests['websqldatabase'] = function() {
  379. return !!window.openDatabase;
  380. };
  381. // Vendors had inconsistent prefixing with the experimental Indexed DB:
  382. // - Webkit's implementation is accessible through webkitIndexedDB
  383. // - Firefox shipped moz_indexedDB before FF4b9, but since then has been mozIndexedDB
  384. // For speed, we don't test the legacy (and beta-only) indexedDB
  385. tests['indexedDB'] = function() {
  386. return !!testPropsAll("indexedDB", window);
  387. };
  388. // documentMode logic from YUI to filter out IE8 Compat Mode
  389. // which false positives.
  390. tests['hashchange'] = function() {
  391. return isEventSupported('hashchange', window) && (document.documentMode === undefined || document.documentMode > 7);
  392. };
  393. // Per 1.6:
  394. // This used to be Modernizr.historymanagement but the longer
  395. // name has been deprecated in favor of a shorter and property-matching one.
  396. // The old API is still available in 1.6, but as of 2.0 will throw a warning,
  397. // and in the first release thereafter disappear entirely.
  398. tests['history'] = function() {
  399. return !!(window.history && history.pushState);
  400. };
  401. tests['draganddrop'] = function() {
  402. var div = document.createElement('div');
  403. return ('draggable' in div) || ('ondragstart' in div && 'ondrop' in div);
  404. };
  405. // FF3.6 was EOL'ed on 4/24/12, but the ESR version of FF10
  406. // will be supported until FF19 (2/12/13), at which time, ESR becomes FF17.
  407. // FF10 still uses prefixes, so check for it until then.
  408. // for more ESR info, see: mozilla.org/en-US/firefox/organizations/faq/
  409. tests['websockets'] = function() {
  410. return 'WebSocket' in window || 'MozWebSocket' in window;
  411. };
  412. // css-tricks.com/rgba-browser-support/
  413. tests['rgba'] = function() {
  414. // Set an rgba() color and check the returned value
  415. setCss('background-color:rgba(150,255,150,.5)');
  416. return contains(mStyle.backgroundColor, 'rgba');
  417. };
  418. tests['hsla'] = function() {
  419. // Same as rgba(), in fact, browsers re-map hsla() to rgba() internally,
  420. // except IE9 who retains it as hsla
  421. setCss('background-color:hsla(120,40%,100%,.5)');
  422. return contains(mStyle.backgroundColor, 'rgba') || contains(mStyle.backgroundColor, 'hsla');
  423. };
  424. tests['multiplebgs'] = function() {
  425. // Setting multiple images AND a color on the background shorthand property
  426. // and then querying the style.background property value for the number of
  427. // occurrences of "url(" is a reliable method for detecting ACTUAL support for this!
  428. setCss('background:url(https://),url(https://),red url(https://)');
  429. // If the UA supports multiple backgrounds, there should be three occurrences
  430. // of the string "url(" in the return value for elemStyle.background
  431. return (/(url\s*\(.*?){3}/).test(mStyle.background);
  432. };
  433. // this will false positive in Opera Mini
  434. // github.com/Modernizr/Modernizr/issues/396
  435. tests['backgroundsize'] = function() {
  436. return testPropsAll('backgroundSize');
  437. };
  438. tests['borderimage'] = function() {
  439. return testPropsAll('borderImage');
  440. };
  441. // Super comprehensive table about all the unique implementations of
  442. // border-radius: muddledramblings.com/table-of-css3-border-radius-compliance
  443. tests['borderradius'] = function() {
  444. return testPropsAll('borderRadius');
  445. };
  446. // WebOS unfortunately false positives on this test.
  447. tests['boxshadow'] = function() {
  448. return testPropsAll('boxShadow');
  449. };
  450. // FF3.0 will false positive on this test
  451. tests['textshadow'] = function() {
  452. return document.createElement('div').style.textShadow === '';
  453. };
  454. tests['opacity'] = function() {
  455. // Browsers that actually have CSS Opacity implemented have done so
  456. // according to spec, which means their return values are within the
  457. // range of [0.0,1.0] - including the leading zero.
  458. setCssAll('opacity:.55');
  459. // The non-literal . in this regex is intentional:
  460. // German Chrome returns this value as 0,55
  461. // github.com/Modernizr/Modernizr/issues/#issue/59/comment/516632
  462. return (/^0.55$/).test(mStyle.opacity);
  463. };
  464. // Note, Android < 4 will pass this test, but can only animate
  465. // a single property at a time
  466. // daneden.me/2011/12/putting-up-with-androids-bullshit/
  467. tests['cssanimations'] = function() {
  468. return testPropsAll('animationName');
  469. };
  470. tests['csscolumns'] = function() {
  471. return testPropsAll('columnCount');
  472. };
  473. tests['cssgradients'] = function() {
  474. /**
  475. * For CSS Gradients syntax, please see:
  476. * webkit.org/blog/175/introducing-css-gradients/
  477. * developer.mozilla.org/en/CSS/-moz-linear-gradient
  478. * developer.mozilla.org/en/CSS/-moz-radial-gradient
  479. * dev.w3.org/csswg/css3-images/#gradients-
  480. */
  481. var str1 = 'background-image:',
  482. str2 = 'gradient(linear,left top,right bottom,from(#9f9),to(white));',
  483. str3 = 'linear-gradient(left top,#9f9, white);';
  484. setCss(
  485. // legacy webkit syntax (FIXME: remove when syntax not in use anymore)
  486. (str1 + '-webkit- '.split(' ').join(str2 + str1) +
  487. // standard syntax // trailing 'background-image:'
  488. prefixes.join(str3 + str1)).slice(0, -str1.length)
  489. );
  490. return contains(mStyle.backgroundImage, 'gradient');
  491. };
  492. tests['cssreflections'] = function() {
  493. return testPropsAll('boxReflect');
  494. };
  495. tests['csstransforms'] = function() {
  496. return !!testPropsAll('transform');
  497. };
  498. tests['csstransforms3d'] = function() {
  499. var ret = !!testPropsAll('perspective');
  500. // Webkit's 3D transforms are passed off to the browser's own graphics renderer.
  501. // It works fine in Safari on Leopard and Snow Leopard, but not in Chrome in
  502. // some conditions. As a result, Webkit typically recognizes the syntax but
  503. // will sometimes throw a false positive, thus we must do a more thorough check:
  504. if ( ret && 'webkitPerspective' in docElement.style ) {
  505. // Webkit allows this media query to succeed only if the feature is enabled.
  506. // `@media (transform-3d),(-webkit-transform-3d){ ... }`
  507. injectElementWithStyles('@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}', function( node, rule ) {
  508. ret = node.offsetLeft === 9 && node.offsetHeight === 3;
  509. });
  510. }
  511. return ret;
  512. };
  513. tests['csstransitions'] = function() {
  514. return testPropsAll('transition');
  515. };
  516. /*>>fontface*/
  517. // @font-face detection routine by Diego Perini
  518. // javascript.nwbox.com/CSSSupport/
  519. // false positives:
  520. // WebOS github.com/Modernizr/Modernizr/issues/342
  521. // WP7 github.com/Modernizr/Modernizr/issues/538
  522. tests['fontface'] = function() {
  523. var bool;
  524. injectElementWithStyles('@font-face {font-family:"font";src:url("https://")}', function( node, rule ) {
  525. var style = document.getElementById('smodernizr'),
  526. sheet = style.sheet || style.styleSheet,
  527. cssText = sheet ? (sheet.cssRules && sheet.cssRules[0] ? sheet.cssRules[0].cssText : sheet.cssText || '') : '';
  528. bool = /src/i.test(cssText) && cssText.indexOf(rule.split(' ')[0]) === 0;
  529. });
  530. return bool;
  531. };
  532. /*>>fontface*/
  533. // CSS generated content detection
  534. tests['generatedcontent'] = function() {
  535. var bool;
  536. injectElementWithStyles(['#modernizr:after{content:"',smile,'";visibility:hidden}'].join(''), function( node ) {
  537. bool = node.offsetHeight >= 1;
  538. });
  539. return bool;
  540. };
  541. // These tests evaluate support of the video/audio elements, as well as
  542. // testing what types of content they support.
  543. //
  544. // We're using the Boolean constructor here, so that we can extend the value
  545. // e.g. Modernizr.video // true
  546. // Modernizr.video.ogg // 'probably'
  547. //
  548. // Codec values from : github.com/NielsLeenheer/html5test/blob/9106a8/index.html#L845
  549. // thx to NielsLeenheer and zcorpan
  550. // Note: in some older browsers, "no" was a return value instead of empty string.
  551. // It was live in FF3.5.0 and 3.5.1, but fixed in 3.5.2
  552. // It was also live in Safari 4.0.0 - 4.0.4, but fixed in 4.0.5
  553. tests['video'] = function() {
  554. var elem = document.createElement('video'),
  555. bool = false;
  556. // IE9 Running on Windows Server SKU can cause an exception to be thrown, bug #224
  557. try {
  558. if ( bool = !!elem.canPlayType ) {
  559. bool = new Boolean(bool);
  560. bool.ogg = elem.canPlayType('video/ogg; codecs="theora"') .replace(/^no$/,'');
  561. // Without QuickTime, this value will be `undefined`. github.com/Modernizr/Modernizr/issues/546
  562. bool.h264 = elem.canPlayType('video/mp4; codecs="avc1.42E01E"') .replace(/^no$/,'');
  563. bool.webm = elem.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,'');
  564. }
  565. } catch(e) { }
  566. return bool;
  567. };
  568. tests['audio'] = function() {
  569. var elem = document.createElement('audio'),
  570. bool = false;
  571. try {
  572. if ( bool = !!elem.canPlayType ) {
  573. bool = new Boolean(bool);
  574. bool.ogg = elem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,'');
  575. bool.mp3 = elem.canPlayType('audio/mpeg;') .replace(/^no$/,'');
  576. // Mimetypes accepted:
  577. // developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements
  578. // bit.ly/iphoneoscodecs
  579. bool.wav = elem.canPlayType('audio/wav; codecs="1"') .replace(/^no$/,'');
  580. bool.m4a = ( elem.canPlayType('audio/x-m4a;') ||
  581. elem.canPlayType('audio/aac;')) .replace(/^no$/,'');
  582. }
  583. } catch(e) { }
  584. return bool;
  585. };
  586. // In FF4, if disabled, window.localStorage should === null.
  587. // Normally, we could not test that directly and need to do a
  588. // `('localStorage' in window) && ` test first because otherwise Firefox will
  589. // throw bugzil.la/365772 if cookies are disabled
  590. // Also in iOS5 Private Browsing mode, attempting to use localStorage.setItem
  591. // will throw the exception:
  592. // QUOTA_EXCEEDED_ERRROR DOM Exception 22.
  593. // Peculiarly, getItem and removeItem calls do not throw.
  594. // Because we are forced to try/catch this, we'll go aggressive.
  595. // Just FWIW: IE8 Compat mode supports these features completely:
  596. // www.quirksmode.org/dom/html5.html
  597. // But IE8 doesn't support either with local files
  598. tests['localstorage'] = function() {
  599. try {
  600. localStorage.setItem(mod, mod);
  601. localStorage.removeItem(mod);
  602. return true;
  603. } catch(e) {
  604. return false;
  605. }
  606. };
  607. tests['sessionstorage'] = function() {
  608. try {
  609. sessionStorage.setItem(mod, mod);
  610. sessionStorage.removeItem(mod);
  611. return true;
  612. } catch(e) {
  613. return false;
  614. }
  615. };
  616. tests['webworkers'] = function() {
  617. return !!window.Worker;
  618. };
  619. tests['applicationcache'] = function() {
  620. return !!window.applicationCache;
  621. };
  622. // Thanks to Erik Dahlstrom
  623. tests['svg'] = function() {
  624. return !!document.createElementNS && !!document.createElementNS(ns.svg, 'svg').createSVGRect;
  625. };
  626. // specifically for SVG inline in HTML, not within XHTML
  627. // test page: paulirish.com/demo/inline-svg
  628. tests['inlinesvg'] = function() {
  629. var div = document.createElement('div');
  630. div.innerHTML = '<svg/>';
  631. return (div.firstChild && div.firstChild.namespaceURI) == ns.svg;
  632. };
  633. // SVG SMIL animation
  634. tests['smil'] = function() {
  635. return !!document.createElementNS && /SVGAnimate/.test(toString.call(document.createElementNS(ns.svg, 'animate')));
  636. };
  637. // This test is only for clip paths in SVG proper, not clip paths on HTML content
  638. // demo: srufaculty.sru.edu/david.dailey/svg/newstuff/clipPath4.svg
  639. // However read the comments to dig into applying SVG clippaths to HTML content here:
  640. // github.com/Modernizr/Modernizr/issues/213#issuecomment-1149491
  641. tests['svgclippaths'] = function() {
  642. return !!document.createElementNS && /SVGClipPath/.test(toString.call(document.createElementNS(ns.svg, 'clipPath')));
  643. };
  644. /*>>webforms*/
  645. // input features and input types go directly onto the ret object, bypassing the tests loop.
  646. // Hold this guy to execute in a moment.
  647. function webforms() {
  648. /*>>input*/
  649. // Run through HTML5's new input attributes to see if the UA understands any.
  650. // We're using f which is the <input> element created early on
  651. // Mike Taylr has created a comprehensive resource for testing these attributes
  652. // when applied to all input types:
  653. // miketaylr.com/code/input-type-attr.html
  654. // spec: www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
  655. // Only input placeholder is tested while textarea's placeholder is not.
  656. // Currently Safari 4 and Opera 11 have support only for the input placeholder
  657. // Both tests are available in feature-detects/forms-placeholder.js
  658. Modernizr['input'] = (function( props ) {
  659. for ( var i = 0, len = props.length; i < len; i++ ) {
  660. attrs[ props[i] ] = !!(props[i] in inputElem);
  661. }
  662. if (attrs.list){
  663. // safari false positive's on datalist: webk.it/74252
  664. // see also github.com/Modernizr/Modernizr/issues/146
  665. attrs.list = !!(document.createElement('datalist') && window.HTMLDataListElement);
  666. }
  667. return attrs;
  668. })('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' '));
  669. /*>>input*/
  670. /*>>inputtypes*/
  671. // Run through HTML5's new input types to see if the UA understands any.
  672. // This is put behind the tests runloop because it doesn't return a
  673. // true/false like all the other tests; instead, it returns an object
  674. // containing each input type with its corresponding true/false value
  675. // Big thanks to @miketaylr for the html5 forms expertise. miketaylr.com/
  676. Modernizr['inputtypes'] = (function(props) {
  677. for ( var i = 0, bool, inputElemType, defaultView, len = props.length; i < len; i++ ) {
  678. inputElem.setAttribute('type', inputElemType = props[i]);
  679. bool = inputElem.type !== 'text';
  680. // We first check to see if the type we give it sticks..
  681. // If the type does, we feed it a textual value, which shouldn't be valid.
  682. // If the value doesn't stick, we know there's input sanitization which infers a custom UI
  683. if ( bool ) {
  684. inputElem.value = smile;
  685. inputElem.style.cssText = 'position:absolute;visibility:hidden;';
  686. if ( /^range$/.test(inputElemType) && inputElem.style.WebkitAppearance !== undefined ) {
  687. docElement.appendChild(inputElem);
  688. defaultView = document.defaultView;
  689. // Safari 2-4 allows the smiley as a value, despite making a slider
  690. bool = defaultView.getComputedStyle &&
  691. defaultView.getComputedStyle(inputElem, null).WebkitAppearance !== 'textfield' &&
  692. // Mobile android web browser has false positive, so must
  693. // check the height to see if the widget is actually there.
  694. (inputElem.offsetHeight !== 0);
  695. docElement.removeChild(inputElem);
  696. } else if ( /^(search|tel)$/.test(inputElemType) ){
  697. // Spec doesn't define any special parsing or detectable UI
  698. // behaviors so we pass these through as true
  699. // Interestingly, opera fails the earlier test, so it doesn't
  700. // even make it here.
  701. } else if ( /^(url|email)$/.test(inputElemType) ) {
  702. // Real url and email support comes with prebaked validation.
  703. bool = inputElem.checkValidity && inputElem.checkValidity() === false;
  704. } else {
  705. // If the upgraded input component rejects the :) text, we got a winner
  706. bool = inputElem.value != smile;
  707. }
  708. }
  709. inputs[ props[i] ] = !!bool;
  710. }
  711. return inputs;
  712. })('search tel url email datetime date month week time datetime-local number range color'.split(' '));
  713. /*>>inputtypes*/
  714. }
  715. /*>>webforms*/
  716. // End of test definitions
  717. // -----------------------
  718. // Run through all tests and detect their support in the current UA.
  719. // todo: hypothetically we could be doing an array of tests and use a basic loop here.
  720. for ( var feature in tests ) {
  721. if ( hasOwnProp(tests, feature) ) {
  722. // run the test, throw the return value into the Modernizr,
  723. // then based on that boolean, define an appropriate className
  724. // and push it into an array of classes we'll join later.
  725. featureName = feature.toLowerCase();
  726. Modernizr[featureName] = tests[feature]();
  727. classes.push((Modernizr[featureName] ? '' : 'no-') + featureName);
  728. }
  729. }
  730. /*>>webforms*/
  731. // input tests need to run.
  732. Modernizr.input || webforms();
  733. /*>>webforms*/
  734. /**
  735. * addTest allows the user to define their own feature tests
  736. * the result will be added onto the Modernizr object,
  737. * as well as an appropriate className set on the html element
  738. *
  739. * @param feature - String naming the feature
  740. * @param test - Function returning true if feature is supported, false if not
  741. */
  742. Modernizr.addTest = function ( feature, test ) {
  743. if ( typeof feature == 'object' ) {
  744. for ( var key in feature ) {
  745. if ( hasOwnProp( feature, key ) ) {
  746. Modernizr.addTest( key, feature[ key ] );
  747. }
  748. }
  749. } else {
  750. feature = feature.toLowerCase();
  751. if ( Modernizr[feature] !== undefined ) {
  752. // we're going to quit if you're trying to overwrite an existing test
  753. // if we were to allow it, we'd do this:
  754. // var re = new RegExp("\\b(no-)?" + feature + "\\b");
  755. // docElement.className = docElement.className.replace( re, '' );
  756. // but, no rly, stuff 'em.
  757. return Modernizr;
  758. }
  759. test = typeof test == 'function' ? test() : test;
  760. if (enableClasses) {
  761. docElement.className += ' ' + (test ? '' : 'no-') + feature;
  762. }
  763. Modernizr[feature] = test;
  764. }
  765. return Modernizr; // allow chaining.
  766. };
  767. // Reset modElem.cssText to nothing to reduce memory footprint.
  768. setCss('');
  769. modElem = inputElem = null;
  770. /*>>shiv*/
  771. /*! HTML5 Shiv v3.6 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed */
  772. ;(function(window, document) {
  773. /*jshint evil:true */
  774. /** Preset options */
  775. var options = window.html5 || {};
  776. /** Used to skip problem elements */
  777. var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i;
  778. /** Not all elements can be cloned in IE (this list can be shortend) **/
  779. var saveClones = /^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i;
  780. /** Detect whether the browser supports default html5 styles */
  781. var supportsHtml5Styles;
  782. /** Name of the expando, to work with multiple documents or to re-shiv one document */
  783. var expando = '_html5shiv';
  784. /** The id for the documents expando */
  785. var expanID = 0;
  786. /** Cached data for each document */
  787. var expandoData = {};
  788. /** Detect whether the browser supports unknown elements */
  789. var supportsUnknownElements;
  790. (function() {
  791. try {
  792. var a = document.createElement('a');
  793. a.innerHTML = '<xyz></xyz>';
  794. //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles
  795. supportsHtml5Styles = ('hidden' in a);
  796. supportsUnknownElements = a.childNodes.length == 1 || (function() {
  797. // assign a false positive if unable to shiv
  798. (document.createElement)('a');
  799. var frag = document.createDocumentFragment();
  800. return (
  801. typeof frag.cloneNode == 'undefined' ||
  802. typeof frag.createDocumentFragment == 'undefined' ||
  803. typeof frag.createElement == 'undefined'
  804. );
  805. }());
  806. } catch(e) {
  807. supportsHtml5Styles = true;
  808. supportsUnknownElements = true;
  809. }
  810. }());
  811. /*--------------------------------------------------------------------------*/
  812. /**
  813. * Creates a style sheet with the given CSS text and adds it to the document.
  814. * @private
  815. * @param {Document} ownerDocument The document.
  816. * @param {String} cssText The CSS text.
  817. * @returns {StyleSheet} The style element.
  818. */
  819. function addStyleSheet(ownerDocument, cssText) {
  820. var p = ownerDocument.createElement('p'),
  821. parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement;
  822. p.innerHTML = 'x<style>' + cssText + '</style>';
  823. return parent.insertBefore(p.lastChild, parent.firstChild);
  824. }
  825. /**
  826. * Returns the value of `html5.elements` as an array.
  827. * @private
  828. * @returns {Array} An array of shived element node names.
  829. */
  830. function getElements() {
  831. var elements = html5.elements;
  832. return typeof elements == 'string' ? elements.split(' ') : elements;
  833. }
  834. /**
  835. * Returns the data associated to the given document
  836. * @private
  837. * @param {Document} ownerDocument The document.
  838. * @returns {Object} An object of data.
  839. */
  840. function getExpandoData(ownerDocument) {
  841. var data = expandoData[ownerDocument[expando]];
  842. if (!data) {
  843. data = {};
  844. expanID++;
  845. ownerDocument[expando] = expanID;
  846. expandoData[expanID] = data;
  847. }
  848. return data;
  849. }
  850. /**
  851. * returns a shived element for the given nodeName and document
  852. * @memberOf html5
  853. * @param {String} nodeName name of the element
  854. * @param {Document} ownerDocument The context document.
  855. * @returns {Object} The shived element.
  856. */
  857. function createElement(nodeName, ownerDocument, data){
  858. if (!ownerDocument) {
  859. ownerDocument = document;
  860. }
  861. if(supportsUnknownElements){
  862. return ownerDocument.createElement(nodeName);
  863. }
  864. if (!data) {
  865. data = getExpandoData(ownerDocument);
  866. }
  867. var node;
  868. if (data.cache[nodeName]) {
  869. node = data.cache[nodeName].cloneNode();
  870. } else if (saveClones.test(nodeName)) {
  871. node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
  872. } else {
  873. node = data.createElem(nodeName);
  874. }
  875. // Avoid adding some elements to fragments in IE < 9 because
  876. // * Attributes like `name` or `type` cannot be set/changed once an element
  877. // is inserted into a document/fragment
  878. // * Link elements with `src` attributes that are inaccessible, as with
  879. // a 403 response, will cause the tab/window to crash
  880. // * Script elements appended to fragments will execute when their `src`
  881. // or `text` property is set
  882. return node.canHaveChildren && !reSkip.test(nodeName) ? data.frag.appendChild(node) : node;
  883. }
  884. /**
  885. * returns a shived DocumentFragment for the given document
  886. * @memberOf html5
  887. * @param {Document} ownerDocument The context document.
  888. * @returns {Object} The shived DocumentFragment.
  889. */
  890. function createDocumentFragment(ownerDocument, data){
  891. if (!ownerDocument) {
  892. ownerDocument = document;
  893. }
  894. if(supportsUnknownElements){
  895. return ownerDocument.createDocumentFragment();
  896. }
  897. data = data || getExpandoData(ownerDocument);
  898. var clone = data.frag.cloneNode(),
  899. i = 0,
  900. elems = getElements(),
  901. l = elems.length;
  902. for(;i<l;i++){
  903. clone.createElement(elems[i]);
  904. }
  905. return clone;
  906. }
  907. /**
  908. * Shivs the `createElement` and `createDocumentFragment` methods of the document.
  909. * @private
  910. * @param {Document|DocumentFragment} ownerDocument The document.
  911. * @param {Object} data of the document.
  912. */
  913. function shivMethods(ownerDocument, data) {
  914. if (!data.cache) {
  915. data.cache = {};
  916. data.createElem = ownerDocument.createElement;
  917. data.createFrag = ownerDocument.createDocumentFragment;
  918. data.frag = data.createFrag();
  919. }
  920. ownerDocument.createElement = function(nodeName) {
  921. //abort shiv
  922. if (!html5.shivMethods) {
  923. return data.createElem(nodeName);
  924. }
  925. return createElement(nodeName, ownerDocument, data);
  926. };
  927. ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' +
  928. 'var n=f.cloneNode(),c=n.createElement;' +
  929. 'h.shivMethods&&(' +
  930. // unroll the `createElement` calls
  931. getElements().join().replace(/\w+/g, function(nodeName) {
  932. data.createElem(nodeName);
  933. data.frag.createElement(nodeName);
  934. return 'c("' + nodeName + '")';
  935. }) +
  936. ');return n}'
  937. )(html5, data.frag);
  938. }
  939. /*--------------------------------------------------------------------------*/
  940. /**
  941. * Shivs the given document.
  942. * @memberOf html5
  943. * @param {Document} ownerDocument The document to shiv.
  944. * @returns {Document} The shived document.
  945. */
  946. function shivDocument(ownerDocument) {
  947. if (!ownerDocument) {
  948. ownerDocument = document;
  949. }
  950. var data = getExpandoData(ownerDocument);
  951. if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) {
  952. data.hasCSS = !!addStyleSheet(ownerDocument,
  953. // corrects block display not defined in IE6/7/8/9
  954. 'article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}' +
  955. // adds styling not present in IE6/7/8/9
  956. 'mark{background:#FF0;color:#000}'
  957. );
  958. }
  959. if (!supportsUnknownElements) {
  960. shivMethods(ownerDocument, data);
  961. }
  962. return ownerDocument;
  963. }
  964. /*--------------------------------------------------------------------------*/
  965. /**
  966. * The `html5` object is exposed so that more elements can be shived and
  967. * existing shiving can be detected on iframes.
  968. * @type Object
  969. * @example
  970. *
  971. * // options can be changed before the script is included
  972. * html5 = { 'elements': 'mark section', 'shivCSS': false, 'shivMethods': false };
  973. */
  974. var html5 = {
  975. /**
  976. * An array or space separated string of node names of the elements to shiv.
  977. * @memberOf html5
  978. * @type Array|String
  979. */
  980. 'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video',
  981. /**
  982. * A flag to indicate that the HTML5 style sheet should be inserted.
  983. * @memberOf html5
  984. * @type Boolean
  985. */
  986. 'shivCSS': (options.shivCSS !== false),
  987. /**
  988. * Is equal to true if a browser supports creating unknown/HTML5 elements
  989. * @memberOf html5
  990. * @type boolean
  991. */
  992. 'supportsUnknownElements': supportsUnknownElements,
  993. /**
  994. * A flag to indicate that the document's `createElement` and `createDocumentFragment`
  995. * methods should be overwritten.
  996. * @memberOf html5
  997. * @type Boolean
  998. */
  999. 'shivMethods': (options.shivMethods !== false),
  1000. /**
  1001. * A string to describe the type of `html5` object ("default" or "default print").
  1002. * @memberOf html5
  1003. * @type String
  1004. */
  1005. 'type': 'default',
  1006. // shivs the document according to the specified `html5` object options
  1007. 'shivDocument': shivDocument,
  1008. //creates a shived element
  1009. createElement: createElement,
  1010. //creates a shived documentFragment
  1011. createDocumentFragment: createDocumentFragment
  1012. };
  1013. /*--------------------------------------------------------------------------*/
  1014. // expose html5
  1015. window.html5 = html5;
  1016. // shiv the document
  1017. shivDocument(document);
  1018. }(this, document));
  1019. /*>>shiv*/
  1020. // Assign private properties to the return object with prefix
  1021. Modernizr._version = version;
  1022. // expose these for the plugin API. Look in the source for how to join() them against your input
  1023. /*>>prefixes*/
  1024. Modernizr._prefixes = prefixes;
  1025. /*>>prefixes*/
  1026. /*>>domprefixes*/
  1027. Modernizr._domPrefixes = domPrefixes;
  1028. Modernizr._cssomPrefixes = cssomPrefixes;
  1029. /*>>domprefixes*/
  1030. /*>>mq*/
  1031. // Modernizr.mq tests a given media query, live against the current state of the window
  1032. // A few important notes:
  1033. // * If a browser does not support media queries at all (eg. oldIE) the mq() will always return false
  1034. // * A max-width or orientation query will be evaluated against the current state, which may change later.
  1035. // * You must specify values. Eg. If you are testing support for the min-width media query use:
  1036. // Modernizr.mq('(min-width:0)')
  1037. // usage:
  1038. // Modernizr.mq('only screen and (max-width:768)')
  1039. Modernizr.mq = testMediaQuery;
  1040. /*>>mq*/
  1041. /*>>hasevent*/
  1042. // Modernizr.hasEvent() detects support for a given event, with an optional element to test on
  1043. // Modernizr.hasEvent('gesturestart', elem)
  1044. Modernizr.hasEvent = isEventSupported;
  1045. /*>>hasevent*/
  1046. /*>>testprop*/
  1047. // Modernizr.testProp() investigates whether a given style property is recognized
  1048. // Note that the property names must be provided in the camelCase variant.
  1049. // Modernizr.testProp('pointerEvents')
  1050. Modernizr.testProp = function(prop){
  1051. return testProps([prop]);
  1052. };
  1053. /*>>testprop*/
  1054. /*>>testallprops*/
  1055. // Modernizr.testAllProps() investigates whether a given style property,
  1056. // or any of its vendor-prefixed variants, is recognized
  1057. // Note that the property names must be provided in the camelCase variant.
  1058. // Modernizr.testAllProps('boxSizing')
  1059. Modernizr.testAllProps = testPropsAll;
  1060. /*>>testallprops*/
  1061. /*>>teststyles*/
  1062. // Modernizr.testStyles() allows you to add custom styles to the document and test an element afterwards
  1063. // Modernizr.testStyles('#modernizr { position:absolute }', function(elem, rule){ ... })
  1064. Modernizr.testStyles = injectElementWithStyles;
  1065. /*>>teststyles*/
  1066. /*>>prefixed*/
  1067. // Modernizr.prefixed() returns the prefixed or nonprefixed property name variant of your input
  1068. // Modernizr.prefixed('boxSizing') // 'MozBoxSizing'
  1069. // Properties must be passed as dom-style camelcase, rather than `box-sizing` hypentated style.
  1070. // Return values will also be the camelCase variant, if you need to translate that to hypenated style use:
  1071. //
  1072. // str.replace(/([A-Z])/g, function(str,m1){ return '-' + m1.toLowerCase(); }).replace(/^ms-/,'-ms-');
  1073. // If you're trying to ascertain which transition end event to bind to, you might do something like...
  1074. //
  1075. // var transEndEventNames = {
  1076. // 'WebkitTransition' : 'webkitTransitionEnd',
  1077. // 'MozTransition' : 'transitionend',
  1078. // 'OTransition' : 'oTransitionEnd',
  1079. // 'msTransition' : 'MSTransitionEnd',
  1080. // 'transition' : 'transitionend'
  1081. // },
  1082. // transEndEventName = transEndEventNames[ Modernizr.prefixed('transition') ];
  1083. Modernizr.prefixed = function(prop, obj, elem){
  1084. if(!obj) {
  1085. return testPropsAll(prop, 'pfx');
  1086. } else {
  1087. // Testing DOM property e.g. Modernizr.prefixed('requestAnimationFrame', window) // 'mozRequestAnimationFrame'
  1088. return testPropsAll(prop, obj, elem);
  1089. }
  1090. };
  1091. /*>>prefixed*/
  1092. /*>>cssclasses*/
  1093. // Remove "no-js" class from <html> element, if it exists:
  1094. docElement.className = docElement.className.replace(/(^|\s)no-js(\s|$)/, '$1$2') +
  1095. // Add the new classes to the <html> element.
  1096. (enableClasses ? ' js ' + classes.join(' ') : '');
  1097. /*>>cssclasses*/
  1098. return Modernizr;
  1099. })(this, this.document);