diff --git a/src/mini-modernizr.js b/src/mini-modernizr.js index 326f4ea..4bfa2d8 100644 --- a/src/mini-modernizr.js +++ b/src/mini-modernizr.js @@ -39,13 +39,50 @@ var getStyleProperty = (function(){ // ========================= miniModernizr =============================== // <3<3<3 and thanks to Faruk and Paul for doing the heavy lifting -if ( !window.Modernizr ) { - var miniModernizr = {}, +/*! + * Modernizr v1.6ish: miniModernizr for Molequul + * http://www.modernizr.com + * + * Developed by: + * - Faruk Ates http://farukat.es/ + * - Paul Irish http://paulirish.com/ + * + * Copyright (c) 2009-2010 + * Dual-licensed under the BSD or MIT licenses. + * http://www.modernizr.com/license/ + */ + + +/* + * Modernizr is a script that detects native CSS3 and HTML5 features + * available in the current UA and provides an object containing all + * features with a true/false value, depending on whether the UA has + * native support for it or not. + * + * Modernizr will also add classes to the element of the page, + * one for each feature it detects. If the UA supports it, a class + * like "cssgradients" will be added. If not, the class name will be + * "no-cssgradients". This allows for simple if-conditionals in your + * CSS, giving you fine control over the look & feel of your website. + * + * This version whittles down the script just to check support for + * CSS transitions, transforms, and 3D transforms. + * + * @author Faruk Ates + * @author Paul Irish + * @copyright (c) 2009-2010 Faruk Ates. + * @contributor Ben Alman + */ + +window.Modernizr = window.Modernizr || (function(window,doc,undefined){ + + var version = '1.6ish: miniModernizr for Molequul', + miniModernizr = {}, vendorCSSPrefixes = ' -o- -moz- -ms- -webkit- -khtml- '.split(' '), classes = [], docElement = document.documentElement, - + tests = [ { name : 'csstransforms', @@ -56,24 +93,24 @@ if ( !window.Modernizr ) { { name : 'csstransforms3d', result : function() { - var ret = !!getStyleProperty('perspective'); - console.log( ret ) - if (ret){ + var test = !!getStyleProperty('perspective'); + // double check for Chrome's false positive + if ( test ){ var st = document.createElement('style'), - div = document.createElement('div'); + div = document.createElement('div'), + mq = '@media (' + vendorCSSPrefixes.join('transform-3d),(') + 'modernizr)'; - st.textContent = '@media ('+vendorCSSPrefixes.join('transform-3d),(') + - 'modernizr){#modernizr{height:3px}}'; - document.getElementsByTagName('head')[0].appendChild(st); + st.textContent = mq + '{#modernizr{height:3px}}'; + (doc.head || doc.getElementsByTagName('head')[0]).appendChild(st); div.id = 'modernizr'; docElement.appendChild(div); - ret = div.offsetHeight === 3; + test = div.offsetHeight === 3; st.parentNode.removeChild(st); div.parentNode.removeChild(div); } - return ret; + return !!test; } }, { @@ -88,16 +125,16 @@ if ( !window.Modernizr ) { // Run through all tests and detect their support in the current UA. for ( var i = 0, len = tests.length; i < len; i++ ) { - var test = tests[i]; - miniModernizr[ test.name ] = test.result(); - var className = ( test.result() ? '' : 'no-' ) + test.name; + var test = tests[i], + result = test.result(); + miniModernizr[ test.name ] = result; + var className = ( result ? '' : 'no-' ) + test.name; classes.push( className ); } // Add the new classes to the element. docElement.className += ' ' + classes.join( ' ' ); - window.Modernizr = miniModernizr; - + return miniModernizr; -} \ No newline at end of file +})(this,this.document); \ No newline at end of file