mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Highlight effect: refactor.
This commit is contained in:
parent
553c6cf7c1
commit
269a441268
@ -13,36 +13,38 @@
|
|||||||
(function($) {
|
(function($) {
|
||||||
|
|
||||||
$.effects.highlight = function(o) {
|
$.effects.highlight = function(o) {
|
||||||
|
|
||||||
return this.queue(function() {
|
return this.queue(function() {
|
||||||
|
var elem = $(this),
|
||||||
|
props = ['backgroundImage', 'backgroundColor', 'opacity'],
|
||||||
|
mode = $.effects.setMode(elem, o.options.mode || 'show'),
|
||||||
|
animation = {
|
||||||
|
backgroundColor: elem.css('backgroundColor')
|
||||||
|
};
|
||||||
|
|
||||||
// Create element
|
if (mode == 'hide') {
|
||||||
var el = $(this), props = ['backgroundImage','backgroundColor','opacity'];
|
animation.opacity = 0;
|
||||||
|
}
|
||||||
// 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();
|
|
||||||
}});
|
|
||||||
|
|
||||||
|
$.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);
|
})(jQuery);
|
||||||
|
Loading…
Reference in New Issue
Block a user