]> git.sur5r.net Git - contagged/blob - scripts/interface/ifxhighlight.js
Make it possible to disable private contacts
[contagged] / scripts / interface / ifxhighlight.js
1 /**
2  * Interface Elements for jQuery
3  * FX - Highlight
4  * 
5  * http://interface.eyecon.ro
6  * 
7  * Copyright (c) 2006 Stefan Petre
8  * Dual licensed under the MIT (MIT-LICENSE.txt) 
9  * and GPL (GPL-LICENSE.txt) licenses.
10  *   
11  *
12  */
13
14
15 /**
16  * @name Highlight
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.
22  * @type jQuery
23  * @cat Plugins/Interface
24  * @author Stefan Petre
25  */
26 jQuery.fn.Highlight = function(speed, color, callback, easing) {
27         return this.queue(
28                 'interfaceColorFX',
29                 function()
30                 {
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;
39                         }
40                         jQuery(this).css('backgroundColor', color);
41                         
42                         
43                         /* In IE, style is a object.. */
44                         if(typeof this.oldStyleAttr == 'object') this.oldStyleAttr = this.oldStyleAttr["cssText"];
45                         
46                         jQuery(this).animate(
47                                 {'backgroundColor':oldColor},
48                                 speed,
49                                 easing,
50                                 function() {
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;
55                                         } else {
56                                                 jQuery(this).attr("style", this.oldStyleAttr);  
57                                         }
58                                         if (callback)
59                                                 callback.apply(this);
60                                 }
61                         );
62                 }
63         );
64 };