2 * Interface Elements for jQuery
5 * http://interface.eyecon.ro
7 * Copyright (c) 2006 Stefan Petre
8 * Dual licensed under the MIT (MIT-LICENSE.txt)
9 * and GPL (GPL-LICENSE.txt) licenses.
17 * @description Animates the backgroudn color to create a highlight animation
18 * @param Mixed speed animation speed, integer for miliseconds, string ['slow' | 'normal' | 'fast']
19 * @param String color color to highlight from
20 * @param Function callback (optional) A function to be executed whenever the animation completes.
21 * @param String easing (optional) The name of the easing effect that you want to use.
23 * @cat Plugins/Interface
24 * @author Stefan Petre
26 jQuery.fn.Highlight = function(speed, color, callback, easing) {
31 this.oldStyleAttr = jQuery(this).attr("style") || '';
32 easing = typeof callback == 'string' ? callback : easing||null;
33 callback = typeof callback == 'function' ? callback : null;
34 var oldColor = jQuery(this).css('backgroundColor');
35 var parentEl = this.parentNode;
36 while(oldColor == 'transparent' && parentEl) {
37 oldColor = jQuery(parentEl).css('backgroundColor');
38 parentEl = parentEl.parentNode;
40 jQuery(this).css('backgroundColor', color);
43 /* In IE, style is a object.. */
44 if(typeof this.oldStyleAttr == 'object') this.oldStyleAttr = this.oldStyleAttr["cssText"];
47 {'backgroundColor':oldColor},
51 jQuery.dequeue(this, 'interfaceColorFX');
52 if(typeof jQuery(this).attr("style") == 'object') {
53 jQuery(this).attr("style")["cssText"] = "";
54 jQuery(this).attr("style")["cssText"] = this.oldStyleAttr;
56 jQuery(this).attr("style", this.oldStyleAttr);