@@ -1106,14 +1106,29 @@ function _normalizeArguments( effect, options, speed, callback ) {
1106
1106
return effect ;
1107
1107
}
1108
1108
1109
- function standardSpeed ( speed ) {
1110
- // valid standard speeds
1111
- if ( ! speed || typeof speed === "number" || $ . fx . speeds [ speed ] ) {
1109
+ function standardAnimationOption ( option ) {
1110
+ // Valid standard speeds (nothing, number, named speed)
1111
+ if ( ! option || typeof option === "number" || $ . fx . speeds [ option ] ) {
1112
1112
return true ;
1113
1113
}
1114
1114
1115
- // invalid strings - treat as "normal" speed
1116
- return typeof speed === "string" && ! $ . effects . effect [ speed ] ;
1115
+ // Invalid strings - treat as "normal" speed
1116
+ if ( typeof option === "string" && ! $ . effects . effect [ option ] ) {
1117
+ return true ;
1118
+ }
1119
+
1120
+ // Complete callback
1121
+ if ( $ . isFunction ( option ) ) {
1122
+ return true ;
1123
+ }
1124
+
1125
+ // Options hash (but not naming an effect)
1126
+ if ( typeof option === "object" && ! option . effect ) {
1127
+ return true ;
1128
+ }
1129
+
1130
+ // Didn't match any standard API
1131
+ return false ;
1117
1132
}
1118
1133
1119
1134
$ . fn . extend ( {
@@ -1163,39 +1178,41 @@ $.fn.extend({
1163
1178
return queue === false ? this . each ( run ) : this . queue ( queue || "fx" , run ) ;
1164
1179
} ,
1165
1180
1166
- _show : $ . fn . show ,
1167
- show : function ( speed ) {
1168
- if ( standardSpeed ( speed ) ) {
1169
- return this . _show . apply ( this , arguments ) ;
1170
- } else {
1171
- var args = _normalizeArguments . apply ( this , arguments ) ;
1172
- args . mode = "show" ;
1173
- return this . effect . call ( this , args ) ;
1174
- }
1175
- } ,
1181
+ show : ( function ( orig ) {
1182
+ return function ( option ) {
1183
+ if ( standardAnimationOption ( option ) ) {
1184
+ return orig . apply ( this , arguments ) ;
1185
+ } else {
1186
+ var args = _normalizeArguments . apply ( this , arguments ) ;
1187
+ args . mode = "show" ;
1188
+ return this . effect . call ( this , args ) ;
1189
+ }
1190
+ } ;
1191
+ } ) ( $ . fn . show ) ,
1176
1192
1177
- _hide : $ . fn . hide ,
1178
- hide : function ( speed ) {
1179
- if ( standardSpeed ( speed ) ) {
1180
- return this . _hide . apply ( this , arguments ) ;
1181
- } else {
1182
- var args = _normalizeArguments . apply ( this , arguments ) ;
1183
- args . mode = "hide" ;
1184
- return this . effect . call ( this , args ) ;
1185
- }
1186
- } ,
1193
+ hide : ( function ( orig ) {
1194
+ return function ( option ) {
1195
+ if ( standardAnimationOption ( option ) ) {
1196
+ return orig . apply ( this , arguments ) ;
1197
+ } else {
1198
+ var args = _normalizeArguments . apply ( this , arguments ) ;
1199
+ args . mode = "hide" ;
1200
+ return this . effect . call ( this , args ) ;
1201
+ }
1202
+ } ;
1203
+ } ) ( $ . fn . hide ) ,
1187
1204
1188
- // jQuery core overloads toggle and creates _toggle
1189
- __toggle : $ . fn . toggle ,
1190
- toggle : function ( speed ) {
1191
- if ( standardSpeed ( speed ) || typeof speed === "boolean" || $ . isFunction ( speed ) ) {
1192
- return this . __toggle . apply ( this , arguments ) ;
1193
- } else {
1194
- var args = _normalizeArguments . apply ( this , arguments ) ;
1195
- args . mode = "toggle" ;
1196
- return this . effect . call ( this , args ) ;
1197
- }
1198
- } ,
1205
+ toggle : ( function ( orig ) {
1206
+ return function ( option ) {
1207
+ if ( standardAnimationOption ( option ) || typeof option === "boolean" ) {
1208
+ return orig . apply ( this , arguments ) ;
1209
+ } else {
1210
+ var args = _normalizeArguments . apply ( this , arguments ) ;
1211
+ args . mode = "toggle" ;
1212
+ return this . effect . call ( this , args ) ;
1213
+ }
1214
+ } ;
1215
+ } ) ( $ . fn . toggle ) ,
1199
1216
1200
1217
// helper functions
1201
1218
cssUnit : function ( key ) {
0 commit comments