Skip to content
Permalink
Browse files

Highlight effect: refactor.

  • Loading branch information
scottgonzalez committed Jul 21, 2009
1 parent 553c6cf commit 269a4412683dbb05d02de02fb7dd98e23d373ebb
Showing with 30 additions and 28 deletions.
  1. +30 −28 ui/effects.highlight.js
@@ -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);

0 comments on commit 269a441

Please sign in to comment.
You can’t perform that action at this time.