forked from brandonaaron/jquery-cssHooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
columns.js
executable file
·43 lines (35 loc) · 1.37 KB
/
columns.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*!
* 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($) {
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 =
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 ) );
},
set: function( elem, value ) {
elem.style[ getCssProperty( prefix, prop ) ] = value;
}
};
});
}
div = divStyle = null;
})(jQuery);