Browse Source

Revert "miniModernizr : encapsulate in self-executing function; add some 1.6 touches"

This reverts commit 6afbf058b4.
pull/14/head
David DeSandro 14 years ago
parent
commit
0592b84b55
  1. 111
      src/mini-modernizr.js

111
src/mini-modernizr.js

@ -41,68 +41,63 @@ var getStyleProperty = (function(){
// <3<3<3 and thanks to Faruk and Paul for doing the heavy lifting
if ( !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',
result : function() {
return !!getStyleProperty('transform');
}
},
{
name : 'csstransforms3d',
result : function() {
var test = !!getStyleProperty('perspective');
// double check for Chrome's false positive
if ( test ){
var st = document.createElement('style'),
div = document.createElement('div'),
mq = '@media (' + vendorCSSPrefixes.join('transform-3d),(') + 'modernizr)';
st.textContent = mq + '{#modernizr{height:3px}}';
(doc.head || doc.getElementsByTagName('head')[0]).appendChild(st);
div.id = 'modernizr';
docElement.appendChild(div);
test = div.offsetHeight === 3;
st.parentNode.removeChild(st);
div.parentNode.removeChild(div);
}
return !!test;
}
},
{
name : 'csstransitions',
result : function() {
return !!getStyleProperty('transitionProperty');
var miniModernizr = {},
vendorCSSPrefixes = ' -o- -moz- -ms- -webkit- -khtml- '.split(' '),
classes = [],
docElement = document.documentElement,
tests = [
{
name : 'csstransforms',
result : function() {
return !!getStyleProperty('transform');
}
},
{
name : 'csstransforms3d',
result : function() {
var ret = !!getStyleProperty('perspective');
console.log( ret )
if (ret){
var st = document.createElement('style'),
div = document.createElement('div');
st.textContent = '@media ('+vendorCSSPrefixes.join('transform-3d),(') +
'modernizr){#modernizr{height:3px}}';
document.getElementsByTagName('head')[0].appendChild(st);
div.id = 'modernizr';
docElement.appendChild(div);
ret = div.offsetHeight === 3;
st.parentNode.removeChild(st);
div.parentNode.removeChild(div);
}
return ret;
}
]
;
},
{
name : 'csstransitions',
result : function() {
return !!getStyleProperty('transitionProperty');
}
}
]
;
// 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],
result = test.result();
miniModernizr[ test.name ] = result;
var className = ( result ? '' : 'no-' ) + test.name;
classes.push( className );
}
// Add the new classes to the <html> element.
docElement.className += ' ' + classes.join( ' ' );
// 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;
classes.push( className );
}
return miniModernizr;
})(this,this.document);
// Add the new classes to the <html> element.
docElement.className += ' ' + classes.join( ' ' );
window.Modernizr = miniModernizr;
}
Loading…
Cancel
Save