Browse Source

src : Merge src files into one jquery.isotope.js

pull/14/head
David DeSandro 14 years ago
parent
commit
64e4607778
  1. 6
      _layouts/elements.html
  2. 6
      _layouts/inf-scroll-page.html
  3. 6
      _posts/demos/2010-12-12-basic.html
  4. 6
      _posts/demos/2010-12-29-layout-modes.html
  5. 6
      _posts/demos/2010-12-30-filtering.html
  6. 6
      _posts/demos/2010-12-30-sorting.html
  7. 6
      _posts/demos/2010-12-31-relayout.html
  8. 6
      _posts/demos/2011-01-02-adding-items.html
  9. 6
      _posts/demos/2011-01-02-infinite-scroll.html
  10. 7
      _posts/demos/2011-01-11-images.html
  11. 6
      index.html
  12. 384
      jquery.isotope.js
  13. 124
      src/jquery.opto-transform.js
  14. 41
      src/jquery.smartresize.js
  15. 64
      src/jquery.ui.widget.js
  16. 140
      src/mini-modernizr.js

6
_layouts/elements.html

@ -47,11 +47,7 @@
<p id="xray"><a href='#xray'>Toggle X-ray mode</a></p> <p id="xray"><a href='#xray'>Toggle X-ray mode</a></p>
<script src="../js/jquery-1.4.4.min.js"></script> <script src="../js/jquery-1.4.4.min.js"></script>
<script src="../src/mini-modernizr.js"></script> <script src="../jquery.isotope.js"></script>
<script src="../src/jquery.opto-transform.js"></script>
<script src="../src/jquery.smartresize.js"></script>
<script src="../src/jquery.isotope.js"></script>
<script src="../src/jquery.ui.widget.js"></script>
<script src="../js/fake-element.js"></script> <script src="../js/fake-element.js"></script>
<script> <script>

6
_layouts/inf-scroll-page.html

@ -12,11 +12,7 @@
</div> </div>
<script src="../js/jquery-1.4.4.min.js"></script> <script src="../js/jquery-1.4.4.min.js"></script>
<script src="../src/mini-modernizr.js"></script> <script src="../jquery.isotope.js"></script>
<script src="../src/jquery.opto-transform.js"></script>
<script src="../src/jquery.smartresize.js"></script>
<script src="../src/jquery.isotope.js"></script>
<script src="../src/jquery.ui.widget.js"></script>
<script> <script>
$(function(){ $(function(){

6
_posts/demos/2010-12-12-basic.html

@ -16,11 +16,7 @@ related: a-intro
</div> <!-- #container --> </div> <!-- #container -->
<script src="../js/jquery-1.4.4.min.js"></script> <script src="../js/jquery-1.4.4.min.js"></script>
<script src="../src/mini-modernizr.js"></script> <script src="../jquery.isotope.js"></script>
<script src="../src/jquery.opto-transform.js"></script>
<script src="../src/jquery.smartresize.js"></script>
<script src="../src/jquery.isotope.js"></script>
<script src="../src/jquery.ui.widget.js"></script>
<script> <script>
$(function(){ $(function(){

6
_posts/demos/2010-12-29-layout-modes.html

@ -23,11 +23,7 @@ related: layouts
</div> <!-- #container --> </div> <!-- #container -->
<script src="../js/jquery-1.4.4.min.js"></script> <script src="../js/jquery-1.4.4.min.js"></script>
<script src="../src/mini-modernizr.js"></script> <script src="../jquery.isotope.js"></script>
<script src="../src/jquery.opto-transform.js"></script>
<script src="../src/jquery.smartresize.js"></script>
<script src="../src/jquery.isotope.js"></script>
<script src="../src/jquery.ui.widget.js"></script>
<script> <script>
$(function(){ $(function(){

6
_posts/demos/2010-12-30-filtering.html

@ -30,11 +30,7 @@ related: filtering
</div> <!-- #container --> </div> <!-- #container -->
<script src="../js/jquery-1.4.4.min.js"></script> <script src="../js/jquery-1.4.4.min.js"></script>
<script src="../src/mini-modernizr.js"></script> <script src="../jquery.isotope.js"></script>
<script src="../src/jquery.opto-transform.js"></script>
<script src="../src/jquery.smartresize.js"></script>
<script src="../src/jquery.isotope.js"></script>
<script src="../src/jquery.ui.widget.js"></script>
<script> <script>
$(function(){ $(function(){

6
_posts/demos/2010-12-30-sorting.html

@ -23,11 +23,7 @@ related: sorting
</div> <!-- #container --> </div> <!-- #container -->
<script src="../js/jquery-1.4.4.min.js"></script> <script src="../js/jquery-1.4.4.min.js"></script>
<script src="../src/mini-modernizr.js"></script> <script src="../jquery.isotope.js"></script>
<script src="../src/jquery.opto-transform.js"></script>
<script src="../src/jquery.smartresize.js"></script>
<script src="../src/jquery.isotope.js"></script>
<script src="../src/jquery.ui.widget.js"></script>
<script> <script>
$(function(){ $(function(){

6
_posts/demos/2010-12-31-relayout.html

@ -23,11 +23,7 @@ related: methods
</div> <!-- #container --> </div> <!-- #container -->
<script src="../js/jquery-1.4.4.min.js"></script> <script src="../js/jquery-1.4.4.min.js"></script>
<script src="../src/mini-modernizr.js"></script> <script src="../jquery.isotope.js"></script>
<script src="../src/jquery.opto-transform.js"></script>
<script src="../src/jquery.smartresize.js"></script>
<script src="../src/jquery.isotope.js"></script>
<script src="../src/jquery.ui.widget.js"></script>
<script> <script>
$(function(){ $(function(){

6
_posts/demos/2011-01-02-adding-items.html

@ -25,11 +25,7 @@ related: methods
</div> <!-- #container --> </div> <!-- #container -->
<script src="../js/jquery-1.4.4.min.js"></script> <script src="../js/jquery-1.4.4.min.js"></script>
<script src="../src/mini-modernizr.js"></script> <script src="../jquery.isotope.js"></script>
<script src="../src/jquery.opto-transform.js"></script>
<script src="../src/jquery.smartresize.js"></script>
<script src="../src/jquery.isotope.js"></script>
<script src="../src/jquery.ui.widget.js"></script>
<script src="../js/fake-element.js"></script> <script src="../js/fake-element.js"></script>
<script> <script>
$(function(){ $(function(){

6
_posts/demos/2011-01-02-infinite-scroll.html

@ -21,11 +21,7 @@ infinite_scroll: true
</nav> </nav>
<script src="../js/jquery-1.4.4.min.js"></script> <script src="../js/jquery-1.4.4.min.js"></script>
<script src="../src/mini-modernizr.js"></script> <script src="../jquery.isotope.js"></script>
<script src="../src/jquery.opto-transform.js"></script>
<script src="../src/jquery.smartresize.js"></script>
<script src="../src/jquery.isotope.js"></script>
<script src="../src/jquery.ui.widget.js"></script>
<script src="../js/jquery.infinitescroll.min.js"></script> <script src="../js/jquery.infinitescroll.min.js"></script>
<script> <script>
$(function(){ $(function(){

7
_posts/demos/2011-01-11-images.html

@ -32,12 +32,7 @@ photos:
</nav> </nav>
<script src="../js/jquery-1.4.4.min.js"></script> <script src="../js/jquery-1.4.4.min.js"></script>
<script src="../src/mini-modernizr.js"></script> <script src="../jquery.isotope.js"></script>
<script src="../src/jquery.opto-transform.js"></script>
<script src="../src/jquery.smartresize.js"></script>
<script src="../src/jquery.isotope.js"></script>
<script src="../src/jquery.ui.widget.js"></script>
<script src="../js/jquery.infinitescroll.min.js"></script>
<script> <script>
$(function(){ $(function(){

6
index.html

@ -90,11 +90,7 @@ layout: nil
<script src="js/jquery-1.4.4.min.js"></script> <script src="js/jquery-1.4.4.min.js"></script>
<script src="src/mini-modernizr.js"></script> <script src="jquery.isotope.js"></script>
<script src="src/jquery.opto-transform.js"></script>
<script src="src/jquery.smartresize.js"></script>
<script src="src/jquery.isotope.js"></script>
<script src="src/jquery.ui.widget.js"></script>
<script> <script>
$(function(){ $(function(){

384
src/jquery.isotope.js → jquery.isotope.js

@ -1,3 +1,318 @@
// ========================= getStyleProperty by kangax ===============================
var getStyleProperty = (function(){
var prefixes = ['Moz', 'Webkit', 'Khtml', 'O', 'Ms'];
var _cache = { };
function getStyleProperty(propName, element) {
element = element || document.documentElement;
var style = element.style,
prefixed,
uPropName;
// check cache only when no element is given
if (arguments.length == 1 && typeof _cache[propName] == 'string') {
return _cache[propName];
}
// test standard property first
if (typeof style[propName] == 'string') {
return (_cache[propName] = propName);
}
// console.log('getting prop', propName)
// capitalize
uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
// test vendor specific properties
for (var i=0, l=prefixes.length; i<l; i++) {
prefixed = prefixes[i] + uPropName;
if (typeof style[prefixed] == 'string') {
return (_cache[propName] = prefixed);
}
}
}
return getStyleProperty;
})();
// ========================= miniModernizr ===============================
// <3<3<3 and thanks to Faruk and Paul for doing the heavy lifting
/*!
* Modernizr v1.6ish: miniModernizr for Isotope
* 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 <html> 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 Isotope',
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');
}
}
]
;
// 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( ' ' );
return miniModernizr;
})(this,this.document);
// ========================= jQuery transform extensions ===============================
(function($){
$.optoTransform = {
transformProp : getStyleProperty('transform'),
fnUtils : Modernizr.csstransforms3d ?
{ // 2d transform functions
translate : function ( position ) {
return 'translate3d(' + position[0] + 'px, ' + position[1] + 'px, 0) ';
},
scale : function ( scale ) {
return 'scale3d(' + scale + ', ' + scale + ', 1) ';
}
} :
{ // 3d transform functions
translate : function ( position ) {
return 'translate(' + position[0] + 'px, ' + position[1] + 'px) ';
},
scale : function ( scale ) {
return 'scale(' + scale + ') ';
}
}
,
set : function( elem, name, value ) {
// unpack current transform data
var data = $( elem ).data('transform') || {},
// extend new value over current data
newData = {},
fnName,
transformObj = {};
// overwrite new data
newData[ name ] = value;
$.extend( data, newData );
for ( fnName in data ) {
var transformValue = data[ fnName ],
getFn = $.optoTransform.fnUtils[ fnName ];
transformObj[ fnName ] = getFn( transformValue );
}
// get proper order
// ideally, we could loop through this give an array, but since we only have
// a couple transforms we're keeping track of, we'll do it like so
var translateFn = transformObj.translate || '',
scaleFn = transformObj.scale || '',
valueFns = translateFn + scaleFn;
// set data back in elem
$( elem ).data( 'transform', data );
// sorting so scale always comes before
value = valueFns;
// set name to vendor specific property
elem.style[ $.optoTransform.transformProp ] = valueFns;
}
};
// ==================== scale ===================
$.cssNumber.scale = true;
$.cssHooks.scale = {
set: function( elem, value ) {
if ( typeof value === 'string' ) {
value = parseFloat( value );
}
$.optoTransform.set( elem, 'scale', value )
},
get: function( elem, computed ) {
var transform = $.data( elem, 'transform' );
return transform && transform.scale ? transform.scale : 1;
}
}
$.fx.step.scale = function( fx ) {
$.cssHooks.scale.set( fx.elem, fx.now+fx.unit );
};
// ==================== translate ===================
$.cssNumber.translate = true;
$.cssHooks.translate = {
set: function( elem, value ) {
// all this would be for public ease-of-use,
// but we're leaving it out since this add-on is
// only for internal-plugin use
// if ( typeof value === 'string' ) {
// value = value.split(' ');
// }
//
//
// var i, val;
// for ( i = 0; i < 2; i++ ) {
// val = value[i];
// if ( typeof val === 'string' ) {
// val = parseInt( val );
// }
// }
$.optoTransform.set( elem, 'translate', value )
},
get: function( elem, computed ) {
var transform = $.data( elem, 'transform' );
return transform && transform.translate ? transform.translate : [ 0, 0 ];
}
}
})( jQuery );
/*!
* smartresize: debounced resize event for jQuery
* http://github.com/lrbabe/jquery-smartresize
*
* Copyright (c) 2009 Louis-Remi Babe
* Licensed under the GPL license.
* http://docs.jquery.com/License
*
*/
(function($){
var $event = $.event,
resizeTimeout;
$event.special.smartresize = {
setup: function() {
$(this).bind( "resize", $event.special.smartresize.handler );
},
teardown: function() {
$(this).unbind( "resize", $event.special.smartresize.handler );
},
handler: function( event, execAsap ) {
// Save the context
var context = this,
args = arguments;
// set correct event type
event.type = "smartresize";
if ( resizeTimeout ) { clearTimeout( resizeTimeout ); }
resizeTimeout = setTimeout(function() {
jQuery.event.handle.apply( context, args );
}, execAsap === "execAsap"? 0 : 100 );
}
};
$.fn.smartresize = function( fn ) {
return fn ? this.bind( "smartresize", fn ) : this.trigger( "smartresize", ["execAsap"] );
};
})( jQuery );
/************************************************* /*************************************************
** jQuery Isotope version 0.1 ** jQuery Isotope version 0.1
** Copyright David DeSandro ** Copyright David DeSandro
@ -920,4 +1235,71 @@
})( jQuery ); })( jQuery );
/*!
* jQuery UI Widget 1.8.5
*
* Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Widget
*/
(function( $, undefined ) {
$.widget = $.widget || {};
$.widget.bridge = $.widget.bridge || function( name, object ) {
$.fn[ name ] = function( options ) {
var isMethodCall = typeof options === "string",
args = Array.prototype.slice.call( arguments, 1 ),
returnValue = this;
// allow multiple hashes to be passed on init
options = !isMethodCall && args.length ?
$.extend.apply( null, [ true, options ].concat(args) ) :
options;
// prevent calls to internal methods
if ( isMethodCall && options.charAt( 0 ) === "_" ) {
return returnValue;
}
if ( isMethodCall ) {
this.each(function() {
var instance = $.data( this, name );
if ( !instance ) {
return $.error( "cannot call methods on " + name + " prior to initialization; " +
"attempted to call method '" + options + "'" );
}
if ( !$.isFunction( instance[options] ) ) {
return $.error( "no such method '" + options + "' for " + name + " widget instance" );
}
var methodValue = instance[ options ].apply( instance, args );
if ( methodValue !== instance && methodValue !== undefined ) {
returnValue = methodValue;
return false;
}
});
} else {
this.each(function() {
var instance = $.data( this, name );
if ( instance ) {
instance.option( options || {} )._init();
} else {
$.data( this, name, new object( options, this ) );
}
});
}
return returnValue;
};
};
$.widget.bridge( 'isotope', $.Isotope );
})( jQuery );

124
src/jquery.opto-transform.js

@ -1,124 +0,0 @@
// ========================= jQuery transform extensions ===============================
(function($){
$.optoTransform = {
transformProp : getStyleProperty('transform'),
fnUtils : Modernizr.csstransforms3d ?
{ // 2d transform functions
translate : function ( position ) {
return 'translate3d(' + position[0] + 'px, ' + position[1] + 'px, 0) ';
},
scale : function ( scale ) {
return 'scale3d(' + scale + ', ' + scale + ', 1) ';
}
} :
{ // 3d transform functions
translate : function ( position ) {
return 'translate(' + position[0] + 'px, ' + position[1] + 'px) ';
},
scale : function ( scale ) {
return 'scale(' + scale + ') ';
}
}
,
set : function( elem, name, value ) {
// unpack current transform data
var data = $( elem ).data('transform') || {},
// extend new value over current data
newData = {},
fnName,
transformObj = {};
// overwrite new data
newData[ name ] = value;
$.extend( data, newData );
for ( fnName in data ) {
var transformValue = data[ fnName ],
getFn = $.optoTransform.fnUtils[ fnName ];
transformObj[ fnName ] = getFn( transformValue );
}
// get proper order
// ideally, we could loop through this give an array, but since we only have
// a couple transforms we're keeping track of, we'll do it like so
var translateFn = transformObj.translate || '',
scaleFn = transformObj.scale || '',
valueFns = translateFn + scaleFn;
// set data back in elem
$( elem ).data( 'transform', data );
// sorting so scale always comes before
value = valueFns;
// set name to vendor specific property
elem.style[ $.optoTransform.transformProp ] = valueFns;
}
};
// ==================== scale ===================
$.cssNumber.scale = true;
$.cssHooks.scale = {
set: function( elem, value ) {
if ( typeof value === 'string' ) {
value = parseFloat( value );
}
$.optoTransform.set( elem, 'scale', value )
},
get: function( elem, computed ) {
var transform = $.data( elem, 'transform' );
return transform && transform.scale ? transform.scale : 1;
}
}
$.fx.step.scale = function( fx ) {
$.cssHooks.scale.set( fx.elem, fx.now+fx.unit );
};
// ==================== translate ===================
$.cssNumber.translate = true;
$.cssHooks.translate = {
set: function( elem, value ) {
// all this would be for public ease-of-use,
// but we're leaving it out since this add-on is
// only for internal-plugin use
// if ( typeof value === 'string' ) {
// value = value.split(' ');
// }
//
//
// var i, val;
// for ( i = 0; i < 2; i++ ) {
// val = value[i];
// if ( typeof val === 'string' ) {
// val = parseInt( val );
// }
// }
$.optoTransform.set( elem, 'translate', value )
},
get: function( elem, computed ) {
var transform = $.data( elem, 'transform' );
return transform && transform.translate ? transform.translate : [ 0, 0 ];
}
}
})( jQuery );

41
src/jquery.smartresize.js

@ -1,41 +0,0 @@
/*!
* smartresize: debounced resize event for jQuery
* http://github.com/lrbabe/jquery-smartresize
*
* Copyright (c) 2009 Louis-Remi Babe
* Licensed under the GPL license.
* http://docs.jquery.com/License
*
*/
(function($){
var $event = $.event,
resizeTimeout;
$event.special.smartresize = {
setup: function() {
$(this).bind( "resize", $event.special.smartresize.handler );
},
teardown: function() {
$(this).unbind( "resize", $event.special.smartresize.handler );
},
handler: function( event, execAsap ) {
// Save the context
var context = this,
args = arguments;
// set correct event type
event.type = "smartresize";
if ( resizeTimeout ) { clearTimeout( resizeTimeout ); }
resizeTimeout = setTimeout(function() {
jQuery.event.handle.apply( context, args );
}, execAsap === "execAsap"? 0 : 100 );
}
};
$.fn.smartresize = function( fn ) {
return fn ? this.bind( "smartresize", fn ) : this.trigger( "smartresize", ["execAsap"] );
};
})( jQuery );

64
src/jquery.ui.widget.js vendored

@ -1,64 +0,0 @@
/*!
* jQuery UI Widget 1.8.5
*
* Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* http://docs.jquery.com/UI/Widget
*/
(function( $, undefined ) {
$.widget = $.widget || {};
$.widget.bridge = $.widget.bridge || function( name, object ) {
$.fn[ name ] = function( options ) {
var isMethodCall = typeof options === "string",
args = Array.prototype.slice.call( arguments, 1 ),
returnValue = this;
// allow multiple hashes to be passed on init
options = !isMethodCall && args.length ?
$.extend.apply( null, [ true, options ].concat(args) ) :
options;
// prevent calls to internal methods
if ( isMethodCall && options.charAt( 0 ) === "_" ) {
return returnValue;
}
if ( isMethodCall ) {
this.each(function() {
var instance = $.data( this, name );
if ( !instance ) {
return $.error( "cannot call methods on " + name + " prior to initialization; " +
"attempted to call method '" + options + "'" );
}
if ( !$.isFunction( instance[options] ) ) {
return $.error( "no such method '" + options + "' for " + name + " widget instance" );
}
var methodValue = instance[ options ].apply( instance, args );
if ( methodValue !== instance && methodValue !== undefined ) {
returnValue = methodValue;
return false;
}
});
} else {
this.each(function() {
var instance = $.data( this, name );
if ( instance ) {
instance.option( options || {} )._init();
} else {
$.data( this, name, new object( options, this ) );
}
});
}
return returnValue;
};
};
$.widget.bridge( 'isotope', $.Isotope );
})( jQuery );

140
src/mini-modernizr.js

@ -1,140 +0,0 @@
// ========================= getStyleProperty by kangax ===============================
var getStyleProperty = (function(){
var prefixes = ['Moz', 'Webkit', 'Khtml', 'O', 'Ms'];
var _cache = { };
function getStyleProperty(propName, element) {
element = element || document.documentElement;
var style = element.style,
prefixed,
uPropName;
// check cache only when no element is given
if (arguments.length == 1 && typeof _cache[propName] == 'string') {
return _cache[propName];
}
// test standard property first
if (typeof style[propName] == 'string') {
return (_cache[propName] = propName);
}
// console.log('getting prop', propName)
// capitalize
uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
// test vendor specific properties
for (var i=0, l=prefixes.length; i<l; i++) {
prefixed = prefixes[i] + uPropName;
if (typeof style[prefixed] == 'string') {
return (_cache[propName] = prefixed);
}
}
}
return getStyleProperty;
})();
// ========================= miniModernizr ===============================
// <3<3<3 and thanks to Faruk and Paul for doing the heavy lifting
/*!
* Modernizr v1.6ish: miniModernizr for Isotope
* 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 <html> 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 Isotope',
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');
}
}
]
;
// 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( ' ' );
return miniModernizr;
})(this,this.document);
Loading…
Cancel
Save