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),
_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);
_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);
// 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);