/* created by martin hintzmann 2008 martin [a] hintzmann.dk * mit (http://www.opensource.org/licenses/mit-license.php) licensed. * * version: 0.2 * requires: jquery 1.2+ * http://plugins.jquery.com/project/textshadow * */ (function($) { $.fn.textshadow = function(option) { if (!$.browser.msie) return; var ie6 = $.browser.version < 7; return this.each(function() { var el = $(this); var shadow = el.textshadowparse(this.currentstyle["text-shadow"]); shadow = $.extend(shadow, option); el.textshadowremove(); if (shadow.x == 0 && shadow.y == 0 && shadow.radius == 0) return; if (el.css("position")=="static") { el.css({position:"relative"}); } el.css({zindex:"0"}); if (ie6) { el.css({zoom:"1"}); } var span=document.createelement("span"); $(span).addclass("jquerytextshadow"); $(span).html(el.html()); $(span).css({ padding: this.currentstyle["padding"], width: el.width(), position: "absolute", zindex: "-1", color: shadow.color!=null?shadow.color:el.css("color"), left: (-parseint(shadow.radius)+parseint(shadow.x))+"px", top: (-parseint(shadow.radius)+parseint(shadow.y))+"px" }); if (shadow.radius != 0) { if (shadow.opacity != null) { $(span).css("filter", "progid:dximagetransform.microsoft.blur(pixelradius="+parseint(shadow.radius)+", enabled='true', makeshadow='true', shadowopacity="+shadow.opacity+")"); } else { $(span).css("filter", "progid:dximagetransform.microsoft.blur(pixelradius="+parseint(shadow.radius)+", enabled='true')"); } } el.append(span); }); }; $.fn.textshadowparse = function(value) { value = string(value) .replace(/^\s+|\s+$/gi, '') .replace(/\s*!\s*important/i, '') .replace(/\(\s*([^,\)]+)\s*,\s*([^,\)]+)\s*,\s*([^,\)]+)\s*,\s*([^\)]+)\s*\)/g, '($1/$2/$3/$4)') .replace(/\(\s*([^,\)]+)\s*,\s*([^,\)]+)\s*,\s*([^\)]+)\s*\)/g, '($1/$2/$3)') var shadow = { x : 0, y : 0, radius : 0, color : null }; if (value.length > 1 || value[0].tolowercase() != 'none') { value = value.replace(/\//g, ','); var color; if ( value.match(/(\#[0-9a-f]{6}|\#[0-9a-f]{3}|(rgb|hsb)a?\([^\)]*\)|\b[a-z]+\b)/i) && (color = regexp.$1) ) { shadow.color = color.replace(/^\s+/, ''); value = value.replace(shadow.color, ''); } value = value .replace(/^\s+|\s+$/g, '') .split(/\s+/) .map(function(item) { return (item || '').replace(/^0[a-z]*$/, '') ? item : 0 ; }); switch (value.length) { case 1: shadow.x = shadow.y = value[0]; break; case 2: shadow.x = value[0]; shadow.y = value[1]; break; case 3: shadow.x = value[0]; shadow.y = value[1]; shadow.radius = value[2]; break; } if ((!shadow.x && !shadow.y && !shadow.radius) || shadow.color == 'transparent') { shadow.x = shadow.y = shadow.radius = 0; shadow.color = null; } } return shadow; }; $.fn.textshadowremove = function() { if (!$.browser.msie) return; return this.each(function() { $(this).children("span.jquerytextshadow").remove(); }); }; })(jquery); if(typeof array.prototype.map == 'undefined') { array.prototype.map = function(fnc) { var a = new array(this.length); for (var i = 0; i < this.length; i++) { a[i] = fnc(this[i]); } return a; } }