Permalink
Browse files

Updated Columns hook

  • Loading branch information...
Tom Ellis
Tom Ellis committed Aug 18, 2011
1 parent 956de80 commit 46bbcb1a6ac878f9a5a7a35860f45c2700f74fd2
Showing with 24 additions and 31 deletions.
  1. +24 −31 columns.js
View
@@ -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($) {
- // 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 rWhitespace = /\s/,
- column = "Column",
- props = "Span Count Gap Width RuleColor RuleStyle RuleWidth".split(rWhitespace),
- prefix = div.style.WebkitColumnGap === ''? 'Webkit' : (div.style.MozColumnGap === '' ? 'Moz' : '');
+ var div = document.createElement("div"),
+ divStyle = div.style,
+ rWhitespace = /\s/,
+ column = "Column",
+ props = "Span Count Gap Width RuleColor RuleStyle RuleWidth".split(rWhitespace),
+ prefix = divStyle.WebkitColumnGap === ''? 'Webkit' : (divStyle.MozColumnGap === '' ? 'Moz' : ''),
+ getCssProperty = function( prefix, prop ) {
+ return prefix + ( (prefix === '') ? column.toLowerCase() : column ) + prop;
+ };
$.support.columnCount =
- div.style.WebkitColumnCount === ''? 'WebkitColumnCount' :
- (div.style.MozColumnCount === ''? 'MozColumnCount' :
- (div.style.columnCount === ''? 'columnCount' : false));
-
-
- function getCssProperty( prefix, prop )
- {
- return prefix + ( (prefix === '') ? column.toLowerCase() : column ) + prop;
- }
-
- if ( $.support.columnCount && $.support.columnCount !== "columnCount" )
- {
- $.each(props, function( i, prop ) {
+ divStyle.columnCount === '' ? 'columnCount' :
+ (divStyle.MozColumnCount === ''? 'MozColumnCount' :
+ (divStyle.WebkitColumnCount === ''? 'WebkitColumnCount' : false));
+
+ if ( $.support.columnCount && $.support.columnCount !== "columnCount" ) {
-
+ $.each(props, function( i, prop ) {
+
$.cssHooks["column" + prop ] = {
get: function( elem, computed, extra ) {
return $.css(elem, getCssProperty( prefix, prop ) );
@@ -40,11 +34,10 @@
elem.style[ getCssProperty( prefix, prop ) ] = value;
}
};
-
- });
+ });
}
- div = null;
+ div = divStyle = null;
})(jQuery);

0 comments on commit 46bbcb1

Please sign in to comment.