This repository has been archived by the owner on Aug 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
/
textshadow.js
64 lines (56 loc) · 1.58 KB
/
textshadow.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
(function($) {
var propStr = 'textShadow',
colorStr = 'Color',
props = (colorStr + " X Y Blur").split(' '),
support = $.support,
rWhitespace = /\s/,
div = document.createElement('div'),
divStyle = div.style;
support.textShadow = (divStyle.textShadow === '');
div = divStyle = null;
if ($.cssHooks && support.textShadow) {
$.each(props, function(i, suffix) {
var hook = propStr + suffix;
$.cssHooks[hook] = {
get: function(elem, computed, extra) {
return (function(elem, pos, prop) {
var shadow = $.css(elem, propStr),
color = $.color.normalize(shadow),
ret;
if (prop === colorStr) {
ret = 'rgb'
+ (color.alpha ? 'a' : '') + '('
+ color.r + ', '
+ color.g + ', '
+ color.b
+ (color.alpha ? ', ' + color.alpha : '')
+ ')';
}
else {
ret = $.trim(shadow.replace(color.source, '')).split(rWhitespace)[pos - 1];
}
return ret;
})(elem, i, suffix);
},
set: function(elem, value) {
elem.style.textShadow = (function(string, value, index) {
var color_part = $.style(elem, propStr + colorStr),
parts = string.replace(color_part, '').split(rWhitespace),
ret;
if (index === 0) {
color_part = value;
} else {
parts[index] = value;
}
return color_part + parts.join(' ');
})($.css(elem, propStr), value, i);
}
};
if (suffix !== colorStr) {
$.fx.step[hook] = function(fx) {
$.cssHooks[hook].set(fx.elem, fx.now + fx.unit);
};
}
});
}
})(jQuery);