Browse Source

src : Don't overwrite previous Modernizr. use Modernizr.addTest if available

pull/14/head
David DeSandro 14 years ago
parent
commit
052c2c8c08
  1. 151
      jquery.isotope.js

151
jquery.isotope.js

@ -70,72 +70,97 @@
/* /*
* This version whittles down the script just to check support for * This version whittles down the script just to check support for
* CSS transitions, transforms, and 3D transforms. * CSS transitions, transforms, and 3D transforms.
*/ */
window.Modernizr = window.Modernizr || (function(window,doc,undefined){
var version = '1.6ish: miniModernizr for Isotope', var tests = [
miniModernizr = {}, {
vendorCSSPrefixes = ' -o- -moz- -ms- -webkit- -khtml- '.split(' '), name : 'csstransforms',
classes = [], getResult : function() {
docElement = document.documentElement, return !!getStyleProperty('transform');
i, len, }
},
tests = [ {
{ name : 'csstransforms3d',
name : 'csstransforms', getResult : function() {
result : function() { var test = !!getStyleProperty('perspective');
return !!getStyleProperty('transform'); // double check for Chrome's false positive
} if ( test ){
}, var st = document.createElement('style'),
{ div = document.createElement('div'),
name : 'csstransforms3d', mq = '@media (' + vendorCSSPrefixes.join('transform-3d),(') + 'modernizr)';
result : function() {
var test = !!getStyleProperty('perspective'); st.textContent = mq + '{#modernizr{height:3px}}';
// double check for Chrome's false positive (doc.head || doc.getElementsByTagName('head')[0]).appendChild(st);
if ( test ){ div.id = 'modernizr';
var st = document.createElement('style'), docElement.appendChild(div);
div = document.createElement('div'),
mq = '@media (' + vendorCSSPrefixes.join('transform-3d),(') + 'modernizr)'; test = div.offsetHeight === 3;
st.textContent = mq + '{#modernizr{height:3px}}'; st.parentNode.removeChild(st);
(doc.head || doc.getElementsByTagName('head')[0]).appendChild(st); div.parentNode.removeChild(div);
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');
} }
return !!test;
} }
] },
; {
name : 'csstransitions',
getResult : function() {
// Run through all tests and detect their support in the current UA. return !!getStyleProperty('transitionProperty');
for ( 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; i, len = tests.length
classes.push( className );
} ;
// Add the new classes to the <html> element. if ( window.Modernizr ) {
docElement.className += ' ' + classes.join( ' ' ); // hasOwnProperty shim by kangax needed for Safari 2.0 support
// var _hasOwnProperty = ({}).hasOwnProperty, hasOwnProperty;
return miniModernizr; // if (!is(_hasOwnProperty, undefined) && !is(_hasOwnProperty.call, undefined)) {
// hasOwnProperty = function (object, property) {
})(this,this.document); // return _hasOwnProperty.call(object, property);
// };
// }
// else {
// hasOwnProperty = function (object, property) {
// return ((property in object) && is(object.constructor.prototype[property], undefined));
// };
// }
for ( i=0; i < len; i++ ) {
var test = test[i];
if ( !Modernizr.hasOwnProperty( test.name ) ) {
Modernizr.addTest( test.name, test.getResult );
}
}
} else {
window.Modernizr = (function(){
var version = '1.6ish: miniModernizr for Isotope',
miniModernizr = {},
vendorCSSPrefixes = ' -o- -moz- -ms- -webkit- -khtml- '.split(' '),
classes = [],
test, result, className;
// Run through all tests and detect their support in the current UA.
for ( i=0; i < len; i++ ) {
test = tests[i];
result = test.getResult();
miniModernizr[ test.name ] = result;
className = ( result ? '' : 'no-' ) + test.name;
classes.push( className );
}
// Add the new classes to the <html> element.
document.documentElement.className += ' ' + classes.join( ' ' );
return miniModernizr;
})();
}

Loading…
Cancel
Save