r2952 commited - Highlight effect: refactor.

r2952 commited - Highlight effect: refactor.


Revision: 2952
Author: scott.gonzalez
Date: Mon Jul 20 21:21:50 2009
Log: Highlight effect: refactor.
http://code.google.com/p/jquery-ui/source/detail?r=2952
Modified:
/trunk/ui/effects.highlight.js
=======================================
--- /trunk/ui/effects.highlight.js    Tue May 12 01:51:48 2009
+++ /trunk/ui/effects.highlight.js    Mon Jul 20 21:21:50 2009
@@ -13,36 +13,38 @@
(function($) {
$.effects.highlight = function(o) {
-
    return this.queue(function() {
-
-        // Create element
-        var el = $(this), props =
['backgroundImage','backgroundColor','opacity'];
-
-        // Set options
-        var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
-        var color = o.options.color || "#ffff99"; // Default highlight color
-        var oldColor = el.css("backgroundColor");
-
-        // Adjust
-        $.effects.save(el, props); el.show(); // Save & Show
-        el.css({backgroundImage: 'none', backgroundColor: color}); // Shift
-
-        // Animation
-        var animation = {backgroundColor: oldColor };
-        if (mode == "hide") animation['opacity'] = 0;
-
-        // Animate
-        el.animate(animation, { queue: false, duration: o.duration, easing:
o.options.easing, complete: function() {
-            if(mode == "hide") el.hide();
-            $.effects.restore(el, props);
-            if (mode == "show" && !$.support.opacity)
this.style.removeAttribute('filter');
-            if(o.callback) o.callback.apply(this, arguments);
-            el.dequeue();
-        }});
-
+        var elem = $(this),
+            props = ['backgroundImage', 'backgroundColor', 'opacity'],
+            mode = $.effects.setMode(elem, o.options.mode || 'show'),
+            animation = {
+                backgroundColor: elem.css('backgroundColor')
+            };
+
+        if (mode == 'hide') {
+            animation.opacity = 0;
+        }
+
+        $.effects.save(elem, props);
+        elem
+            .show()
+            .css({
+                backgroundImage: 'none',
+                backgroundColor: o.options.color || '#ffff99'
+            })
+            .animate(animation, {
+                queue: false,
+                duration: o.duration,
+                easing: o.options.easing,
+                complete: function() {
+                    (mode == 'hide' && elem.hide());
+                    $.effects.restore(elem, props);
+                    (mode == 'show' && !$.support.opacity &&
this.style.removeAttribute('filter'));
+                    (o.callback && o.callback.apply(this, arguments));
+                    elem.dequeue();
+                }
+            });
    });
-
};
})(jQuery);