Skip to content

Commit

Permalink
Effects: Fixed .show(), .hide(), .toggle() to accept a hash of option…
Browse files Browse the repository at this point in the history
…s again. Fixes #6078 - Effects: Passing an object for parameters no longer works. Fixes #6067 - Dialog show/hide animations do not work.
  • Loading branch information
scottgonzalez committed Sep 20, 2010
1 parent a936eb3 commit ce08df3
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions ui/jquery.effects.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,20 @@ function _normalizeArguments(effect, options, speed, callback) {
return [effect, options, speed, callback];
}

function standardSpeed( speed ) {
// valid standard speeds
if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
return true;
}

// invalid strings - treat as "normal" speed
if ( typeof speed === "string" && !$.effects[ speed ] ) {
return true;
}

return false;
}

$.fn.extend({
effect: function(effect, options, speed, callback) {
var args = _normalizeArguments.apply(this, arguments),
Expand All @@ -455,7 +469,7 @@ $.fn.extend({

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

_hide: $.fn.hide,
hide: function(speed) {
if (!speed || typeof speed == 'number' || $.fx.speeds[speed] || !$.effects[speed] ) {
if ( standardSpeed( speed ) ) {
return this._hide.apply(this, arguments);
} else {
var args = _normalizeArguments.apply(this, arguments);
Expand All @@ -478,8 +492,7 @@ $.fn.extend({
// jQuery core overloads toggle and creates _toggle
__toggle: $.fn.toggle,
toggle: function(speed) {
if (!speed || typeof speed == 'number' || $.fx.speeds[speed] || !$.effects[speed] ||
typeof speed == 'boolean' || $.isFunction(speed)) {
if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
return this.__toggle.apply(this, arguments);
} else {
var args = _normalizeArguments.apply(this, arguments);
Expand Down

0 comments on commit ce08df3

Please sign in to comment.