public
Last active

  • Download Gist
jquery.clippy.js
JavaScript
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
(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('&nbsp;');
};
})(jQuery);

Was it harв ещ add small usage example. Lost 20 minuts trying to use it. Not every one is very smart. There are some beginners.

@Serhioromano: How about sharing your results? Thank you!

Yes, is there somewhere a demo?

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.