-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.textblur.js
executable file
·55 lines (38 loc) · 1.44 KB
/
jquery.textblur.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
/*
* JQuery TextBlur
* https://github.com/ottonascarella/TextBlur
* Copyright (c) 2011 Otto Nascarella
* licensed under the GPL 2 license.
* http://www.gnu.org/licenses/gpl-2.0.html
*/
;(function($, undefined) {
var get, set, p = $('<p>')[0];
if (!!p.style.textShadow) {
return; /// there's no textShadow? Exit plugin register...
} else {
$.cssHooks['textBlur'] = {
get: function(elem, computed, extra) {
var shadow = $(elem).data("textBlur") || 0;
return shadow;
},
set: function(elem, value) {
var style = elem.style, color;
if ( !$(elem).data("textShadow") ) $(elem).data('textShadow', $(elem).css("textShadow")); /// backs up original text-shadow css, if exists.
if ( !$(elem).data('color') ) $(elem).data('color', $(elem).css('color')); /// backs up original color
color = $(elem).data("color");
if (value !== 0) {
style.color = 'rgba(0,0,0,0)'; /// some opera versions don't show element if color is "transparent". IE10 does not show either way. :(
style.textShadow = '0 0 ' + parseInt(value, 10) + 'px ' + color;
$(elem).data("textBlur", value);
} else {
style.color = color;
style.textShadow = $(elem).data("textShadow");
$(elem).removeData('color').removeData('textShadow').removeData("textBlur");
}
}
}; // end of css hooks
$.fx.step['textBlur'] = function(fx){
$.cssHooks['textBlur'].set(fx.elem, fx.now);
};
} /// end of else.
})(jQuery);