mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Effects core: Reorganized method overloading.
This commit is contained in:
parent
4175ca180a
commit
83eafe63d9
@ -155,18 +155,7 @@ function _normalizeArguments(effect, options, speed, callback) {
|
|||||||
return [effect, options, speed, callback];
|
return [effect, options, speed, callback];
|
||||||
}
|
}
|
||||||
|
|
||||||
//Extend the methods of jQuery
|
|
||||||
$.fn.extend({
|
$.fn.extend({
|
||||||
|
|
||||||
//Save old methods
|
|
||||||
_show: $.fn.show,
|
|
||||||
_hide: $.fn.hide,
|
|
||||||
__toggle: $.fn.toggle,
|
|
||||||
_addClass: $.fn.addClass,
|
|
||||||
_removeClass: $.fn.removeClass,
|
|
||||||
_toggleClass: $.fn.toggleClass,
|
|
||||||
|
|
||||||
// New effect methods
|
|
||||||
effect: function(effect, options, speed, callback) {
|
effect: function(effect, options, speed, callback) {
|
||||||
var args = _normalizeArguments.apply(this, arguments),
|
var args = _normalizeArguments.apply(this, arguments),
|
||||||
// TODO: make effects takes actual parameters instead of a hash
|
// TODO: make effects takes actual parameters instead of a hash
|
||||||
@ -180,6 +169,7 @@ $.fn.extend({
|
|||||||
return effectMethod && !$.fx.off ? effectMethod.call(this, args2) : this;
|
return effectMethod && !$.fx.off ? effectMethod.call(this, args2) : this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_show: $.fn.show,
|
||||||
show: function(speed) {
|
show: function(speed) {
|
||||||
if (!speed || typeof speed == 'number' || $.fx.speeds[speed]) {
|
if (!speed || typeof speed == 'number' || $.fx.speeds[speed]) {
|
||||||
return this._show.apply(this, arguments);
|
return this._show.apply(this, arguments);
|
||||||
@ -190,6 +180,7 @@ $.fn.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_hide: $.fn.hide,
|
||||||
hide: function(speed) {
|
hide: function(speed) {
|
||||||
if (!speed || typeof speed == 'number' || $.fx.speeds[speed]) {
|
if (!speed || typeof speed == 'number' || $.fx.speeds[speed]) {
|
||||||
return this._hide.apply(this, arguments);
|
return this._hide.apply(this, arguments);
|
||||||
@ -200,6 +191,8 @@ $.fn.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// jQuery core overloads toggle and create _toggle
|
||||||
|
__toggle: $.fn.toggle,
|
||||||
toggle: function(speed) {
|
toggle: function(speed) {
|
||||||
if (!speed || typeof speed == 'number' || $.fx.speeds[speed] ||
|
if (!speed || typeof speed == 'number' || $.fx.speeds[speed] ||
|
||||||
typeof speed == 'boolean' || $.isFunction(speed)) {
|
typeof speed == 'boolean' || $.isFunction(speed)) {
|
||||||
@ -211,15 +204,21 @@ $.fn.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_addClass: $.fn.addClass,
|
||||||
addClass: function(classNames, speed, easing, callback) {
|
addClass: function(classNames, speed, easing, callback) {
|
||||||
return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
|
return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_removeClass: $.fn.removeClass,
|
||||||
removeClass: function(classNames,speed,easing,callback) {
|
removeClass: function(classNames,speed,easing,callback) {
|
||||||
return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);
|
return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_toggleClass: $.fn.toggleClass,
|
||||||
toggleClass: function(classNames,speed,easing,callback) {
|
toggleClass: function(classNames,speed,easing,callback) {
|
||||||
return ( (typeof speed !== "boolean") && speed ) ? $.effects.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames, speed);
|
return ( (typeof speed !== "boolean") && speed ) ? $.effects.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames, speed);
|
||||||
},
|
},
|
||||||
|
|
||||||
morph: function(remove,add,speed,easing,callback) {
|
morph: function(remove,add,speed,easing,callback) {
|
||||||
return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);
|
return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user