Created
February 18, 2009 22:10
-
-
Save eventualbuddha/66579 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.fn.clippy = function(text, bgcolor) { | |
if (!bgcolor) { | |
var node = $(this); | |
while (node.css('background-color') == 'transparent' && node.length) { | |
node = node.parent(); | |
} | |
if (!node.length) { | |
bgcolor = '#ffffff'; | |
} else { | |
bgcolor = node.css('background-color'); | |
} | |
} | |
var m = bgcolor.match(/^rgb\(\s*(\d+),\s*(\d+)\s*,\s*(\d+)\s*\)$/i) | |
if (m) { | |
var r = parseInt(m[1], 10), | |
g = parseInt(m[2], 10), | |
b = parseInt(m[3], 10); | |
bgcolor = '#'+r.toString(16)+g.toString(16)+b.toString(16); | |
} | |
$(this) | |
.after($('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="110" height="14" id="clippy"> <param name="movie" value="/clippy.swf"/> <param name="allowScriptAccess" value="always" /> <param name="quality" value="high" /> <param name="scale" value="noscale" /> <param NAME="FlashVars" value="text='+escape(text)+'> <param name="bgcolor" value="'+bgcolor+'"> <embed src="/clippy.swf" width="110" height="14" name="clippy" quality="high" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="text='+escape(text)+'" bgcolor="'+bgcolor+'" /> </object>')) | |
.after(' '); | |
}; | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Was it harв ещ add small usage example. Lost 20 minuts trying to use it. Not every one is very smart. There are some beginners.