Skip to content
This repository has been archived by the owner on Aug 6, 2019. It is now read-only.

Commit

Permalink
Updated Columns hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Ellis committed Aug 18, 2011
1 parent 956de80 commit 46bbcb1
Showing 1 changed file with 24 additions and 31 deletions.
55 changes: 24 additions & 31 deletions columns.js
@@ -1,37 +1,31 @@
/*! Copyright (c) 2010 Tom Ellis (http://www.webmuse.co.uk) /*!
* Licensed under the MIT License (license.txt). * Copyright (c) 2011 Tom Ellis (http://www.webmuse.co.uk)
* Columns cssHook for jQuery
* Limitations:
- Works with jQuery 1.4.3 and higher
* Licensed under the MIT License (LICENSE.txt).
*/ */
(function($) { (function($) {
// Multiple Columns set and get hooks

if( !$.cssHooks )
{
$.error( "jQuery 1.4.3+ is needed for this plugin to work" );
}


var div = document.createElement("div"); var div = document.createElement("div"),

divStyle = div.style,
var rWhitespace = /\s/, rWhitespace = /\s/,
column = "Column", column = "Column",
props = "Span Count Gap Width RuleColor RuleStyle RuleWidth".split(rWhitespace), props = "Span Count Gap Width RuleColor RuleStyle RuleWidth".split(rWhitespace),
prefix = div.style.WebkitColumnGap === ''? 'Webkit' : (div.style.MozColumnGap === '' ? 'Moz' : ''); prefix = divStyle.WebkitColumnGap === ''? 'Webkit' : (divStyle.MozColumnGap === '' ? 'Moz' : ''),
getCssProperty = function( prefix, prop ) {
return prefix + ( (prefix === '') ? column.toLowerCase() : column ) + prop;
};


$.support.columnCount = $.support.columnCount =
div.style.WebkitColumnCount === ''? 'WebkitColumnCount' : divStyle.columnCount === '' ? 'columnCount' :
(div.style.MozColumnCount === ''? 'MozColumnCount' : (divStyle.MozColumnCount === ''? 'MozColumnCount' :
(div.style.columnCount === ''? 'columnCount' : false)); (divStyle.WebkitColumnCount === ''? 'WebkitColumnCount' : false));



if ( $.support.columnCount && $.support.columnCount !== "columnCount" ) {
function getCssProperty( prefix, prop )
{
return prefix + ( (prefix === '') ? column.toLowerCase() : column ) + prop;
}

if ( $.support.columnCount && $.support.columnCount !== "columnCount" )
{
$.each(props, function( i, prop ) {



$.each(props, function( i, prop ) {

$.cssHooks["column" + prop ] = { $.cssHooks["column" + prop ] = {
get: function( elem, computed, extra ) { get: function( elem, computed, extra ) {
return $.css(elem, getCssProperty( prefix, prop ) ); return $.css(elem, getCssProperty( prefix, prop ) );
Expand All @@ -40,11 +34,10 @@
elem.style[ getCssProperty( prefix, prop ) ] = value; elem.style[ getCssProperty( prefix, prop ) ] = value;
} }
}; };

});


});
} }


div = null; div = divStyle = null;


})(jQuery); })(jQuery);

0 comments on commit 46bbcb1

Please sign in to comment.