You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1416 lines
50 KiB

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