Skip to content

Commit ce08df3

Browse files
committed
Effects: Fixed .show(), .hide(), .toggle() to accept a hash of options again. Fixes #6078 - Effects: Passing an object for parameters no longer works. Fixes #6067 - Dialog show/hide animations do not work.
1 parent a936eb3 commit ce08df3

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

ui/jquery.effects.core.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,20 @@ function _normalizeArguments(effect, options, speed, callback) {
439439
return [effect, options, speed, callback];
440440
}
441441

442+
function standardSpeed( speed ) {
443+
// valid standard speeds
444+
if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
445+
return true;
446+
}
447+
448+
// invalid strings - treat as "normal" speed
449+
if ( typeof speed === "string" && !$.effects[ speed ] ) {
450+
return true;
451+
}
452+
453+
return false;
454+
}
455+
442456
$.fn.extend({
443457
effect: function(effect, options, speed, callback) {
444458
var args = _normalizeArguments.apply(this, arguments),
@@ -455,7 +469,7 @@ $.fn.extend({
455469

456470
_show: $.fn.show,
457471
show: function(speed) {
458-
if (!speed || typeof speed == 'number' || $.fx.speeds[speed] || !$.effects[speed] ) {
472+
if ( standardSpeed( speed ) ) {
459473
return this._show.apply(this, arguments);
460474
} else {
461475
var args = _normalizeArguments.apply(this, arguments);
@@ -466,7 +480,7 @@ $.fn.extend({
466480

467481
_hide: $.fn.hide,
468482
hide: function(speed) {
469-
if (!speed || typeof speed == 'number' || $.fx.speeds[speed] || !$.effects[speed] ) {
483+
if ( standardSpeed( speed ) ) {
470484
return this._hide.apply(this, arguments);
471485
} else {
472486
var args = _normalizeArguments.apply(this, arguments);
@@ -478,8 +492,7 @@ $.fn.extend({
478492
// jQuery core overloads toggle and creates _toggle
479493
__toggle: $.fn.toggle,
480494
toggle: function(speed) {
481-
if (!speed || typeof speed == 'number' || $.fx.speeds[speed] || !$.effects[speed] ||
482-
typeof speed == 'boolean' || $.isFunction(speed)) {
495+
if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
483496
return this.__toggle.apply(this, arguments);
484497
} else {
485498
var args = _normalizeArguments.apply(this, arguments);

0 commit comments

Comments
 (0)