Blame view

bower_components/jquery/src/effects.js 16.5 KB
c5169e0e   Renato De Donato   a new hope
1
  define([
74249687   Luigi Serra   Cross browser con...
2
  	"./core",
c5169e0e   Renato De Donato   a new hope
3
  	"./var/pnum",
74249687   Luigi Serra   Cross browser con...
4
  	"./css/var/cssExpand",
74249687   Luigi Serra   Cross browser con...
5
  	"./css/var/isHidden",
74249687   Luigi Serra   Cross browser con...
6
  	"./css/defaultDisplay",
c5169e0e   Renato De Donato   a new hope
7
  	"./data/var/data_priv",
74249687   Luigi Serra   Cross browser con...
8
9
10
11
12
13
14
  
  	"./core/init",
  	"./effects/Tween",
  	"./queue",
  	"./css",
  	"./deferred",
  	"./traversing"
c5169e0e   Renato De Donato   a new hope
15
  ], function( jQuery, pnum, cssExpand, isHidden, defaultDisplay, data_priv ) {
74249687   Luigi Serra   Cross browser con...
16
17
18
19
  
  var
  	fxNow, timerId,
  	rfxtypes = /^(?:toggle|show|hide)$/,
c5169e0e   Renato De Donato   a new hope
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
  	rfxnum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ),
  	rrun = /queueHooks$/,
  	animationPrefilters = [ defaultPrefilter ],
  	tweeners = {
  		"*": [ function( prop, value ) {
  			var tween = this.createTween( prop, value ),
  				target = tween.cur(),
  				parts = rfxnum.exec( value ),
  				unit = parts && parts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  
  				// Starting value computation is required for potential unit mismatches
  				start = ( jQuery.cssNumber[ prop ] || unit !== "px" && +target ) &&
  					rfxnum.exec( jQuery.css( tween.elem, prop ) ),
  				scale = 1,
  				maxIterations = 20;
  
  			if ( start && start[ 3 ] !== unit ) {
  				// Trust units reported by jQuery.css
  				unit = unit || start[ 3 ];
  
  				// Make sure we update the tween properties later on
  				parts = parts || [];
  
  				// Iteratively approximate from a nonzero starting point
  				start = +target || 1;
  
  				do {
  					// If previous iteration zeroed out, double until we get *something*.
  					// Use string for doubling so we don't accidentally see scale as unchanged below
  					scale = scale || ".5";
  
  					// Adjust and apply
  					start = start / scale;
  					jQuery.style( tween.elem, prop, start + unit );
  
  				// Update scale, tolerating zero or NaN from tween.cur(),
  				// break the loop if scale is unchanged or perfect, or if we've just had enough
  				} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
  			}
  
  			// Update tween properties
  			if ( parts ) {
  				start = tween.start = +start || +target || 0;
  				tween.unit = unit;
  				// If a +=/-= token was provided, we're doing a relative animation
  				tween.end = parts[ 1 ] ?
  					start + ( parts[ 1 ] + 1 ) * parts[ 2 ] :
  					+parts[ 2 ];
  			}
  
  			return tween;
  		} ]
  	};
74249687   Luigi Serra   Cross browser con...
73
74
75
  
  // Animations created synchronously will run synchronously
  function createFxNow() {
c5169e0e   Renato De Donato   a new hope
76
  	setTimeout(function() {
74249687   Luigi Serra   Cross browser con...
77
  		fxNow = undefined;
c5169e0e   Renato De Donato   a new hope
78
  	});
74249687   Luigi Serra   Cross browser con...
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  	return ( fxNow = jQuery.now() );
  }
  
  // Generate parameters to create a standard animation
  function genFx( type, includeWidth ) {
  	var which,
  		i = 0,
  		attrs = { height: type };
  
  	// If we include width, step value is 1 to do all cssExpand values,
  	// otherwise step value is 2 to skip over Left and Right
  	includeWidth = includeWidth ? 1 : 0;
  	for ( ; i < 4 ; i += 2 - includeWidth ) {
  		which = cssExpand[ i ];
  		attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  	}
  
  	if ( includeWidth ) {
  		attrs.opacity = attrs.width = type;
  	}
  
  	return attrs;
  }
  
  function createTween( value, prop, animation ) {
  	var tween,
c5169e0e   Renato De Donato   a new hope
105
  		collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
74249687   Luigi Serra   Cross browser con...
106
107
108
  		index = 0,
  		length = collection.length;
  	for ( ; index < length; index++ ) {
c5169e0e   Renato De Donato   a new hope
109
  		if ( (tween = collection[ index ].call( animation, prop, value )) ) {
74249687   Luigi Serra   Cross browser con...
110
111
112
113
114
115
116
117
118
119
120
121
122
123
  
  			// We're done with this property
  			return tween;
  		}
  	}
  }
  
  function defaultPrefilter( elem, props, opts ) {
  	/* jshint validthis: true */
  	var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
  		anim = this,
  		orig = {},
  		style = elem.style,
  		hidden = elem.nodeType && isHidden( elem ),
c5169e0e   Renato De Donato   a new hope
124
  		dataShow = data_priv.get( elem, "fxshow" );
74249687   Luigi Serra   Cross browser con...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
  
  	// Handle queue: false promises
  	if ( !opts.queue ) {
  		hooks = jQuery._queueHooks( elem, "fx" );
  		if ( hooks.unqueued == null ) {
  			hooks.unqueued = 0;
  			oldfire = hooks.empty.fire;
  			hooks.empty.fire = function() {
  				if ( !hooks.unqueued ) {
  					oldfire();
  				}
  			};
  		}
  		hooks.unqueued++;
  
c5169e0e   Renato De Donato   a new hope
140
  		anim.always(function() {
74249687   Luigi Serra   Cross browser con...
141
  			// Ensure the complete handler is called before this completes
c5169e0e   Renato De Donato   a new hope
142
  			anim.always(function() {
74249687   Luigi Serra   Cross browser con...
143
144
145
146
  				hooks.unqueued--;
  				if ( !jQuery.queue( elem, "fx" ).length ) {
  					hooks.empty.fire();
  				}
c5169e0e   Renato De Donato   a new hope
147
148
  			});
  		});
74249687   Luigi Serra   Cross browser con...
149
150
151
152
  	}
  
  	// Height/width overflow pass
  	if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
74249687   Luigi Serra   Cross browser con...
153
154
155
156
157
158
159
160
161
162
163
164
  		// Make sure that nothing sneaks out
  		// Record all 3 overflow attributes because IE9-10 do not
  		// change the overflow attribute when overflowX and
  		// overflowY are set to the same value
  		opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  
  		// Set display property to inline-block for height/width
  		// animations on inline elements that are having width/height animated
  		display = jQuery.css( elem, "display" );
  
  		// Test default display if display is currently "none"
  		checkDisplay = display === "none" ?
c5169e0e   Renato De Donato   a new hope
165
  			data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
74249687   Luigi Serra   Cross browser con...
166
167
168
169
170
171
172
173
  
  		if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
  			style.display = "inline-block";
  		}
  	}
  
  	if ( opts.overflow ) {
  		style.overflow = "hidden";
c5169e0e   Renato De Donato   a new hope
174
  		anim.always(function() {
74249687   Luigi Serra   Cross browser con...
175
176
177
  			style.overflow = opts.overflow[ 0 ];
  			style.overflowX = opts.overflow[ 1 ];
  			style.overflowY = opts.overflow[ 2 ];
c5169e0e   Renato De Donato   a new hope
178
  		});
74249687   Luigi Serra   Cross browser con...
179
180
181
182
183
184
185
186
187
188
  	}
  
  	// show/hide pass
  	for ( prop in props ) {
  		value = props[ prop ];
  		if ( rfxtypes.exec( value ) ) {
  			delete props[ prop ];
  			toggle = toggle || value === "toggle";
  			if ( value === ( hidden ? "hide" : "show" ) ) {
  
c5169e0e   Renato De Donato   a new hope
189
  				// If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
74249687   Luigi Serra   Cross browser con...
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
  				if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  					hidden = true;
  				} else {
  					continue;
  				}
  			}
  			orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  
  		// Any non-fx value stops us from restoring the original display value
  		} else {
  			display = undefined;
  		}
  	}
  
  	if ( !jQuery.isEmptyObject( orig ) ) {
  		if ( dataShow ) {
  			if ( "hidden" in dataShow ) {
  				hidden = dataShow.hidden;
  			}
  		} else {
c5169e0e   Renato De Donato   a new hope
210
  			dataShow = data_priv.access( elem, "fxshow", {} );
74249687   Luigi Serra   Cross browser con...
211
212
213
214
215
216
217
218
219
  		}
  
  		// Store state if its toggle - enables .stop().toggle() to "reverse"
  		if ( toggle ) {
  			dataShow.hidden = !hidden;
  		}
  		if ( hidden ) {
  			jQuery( elem ).show();
  		} else {
c5169e0e   Renato De Donato   a new hope
220
  			anim.done(function() {
74249687   Luigi Serra   Cross browser con...
221
  				jQuery( elem ).hide();
c5169e0e   Renato De Donato   a new hope
222
  			});
74249687   Luigi Serra   Cross browser con...
223
  		}
c5169e0e   Renato De Donato   a new hope
224
  		anim.done(function() {
74249687   Luigi Serra   Cross browser con...
225
226
  			var prop;
  
c5169e0e   Renato De Donato   a new hope
227
  			data_priv.remove( elem, "fxshow" );
74249687   Luigi Serra   Cross browser con...
228
229
230
  			for ( prop in orig ) {
  				jQuery.style( elem, prop, orig[ prop ] );
  			}
c5169e0e   Renato De Donato   a new hope
231
  		});
74249687   Luigi Serra   Cross browser con...
232
233
234
235
236
237
238
239
240
241
242
243
244
  		for ( prop in orig ) {
  			tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  
  			if ( !( prop in dataShow ) ) {
  				dataShow[ prop ] = tween.start;
  				if ( hidden ) {
  					tween.end = tween.start;
  					tween.start = prop === "width" || prop === "height" ? 1 : 0;
  				}
  			}
  		}
  
  	// If this is a noop like .hide().hide(), restore an overwritten display value
c5169e0e   Renato De Donato   a new hope
245
  	} else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
74249687   Luigi Serra   Cross browser con...
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
  		style.display = display;
  	}
  }
  
  function propFilter( props, specialEasing ) {
  	var index, name, easing, value, hooks;
  
  	// camelCase, specialEasing and expand cssHook pass
  	for ( index in props ) {
  		name = jQuery.camelCase( index );
  		easing = specialEasing[ name ];
  		value = props[ index ];
  		if ( jQuery.isArray( value ) ) {
  			easing = value[ 1 ];
  			value = props[ index ] = value[ 0 ];
  		}
  
  		if ( index !== name ) {
  			props[ name ] = value;
  			delete props[ index ];
  		}
  
  		hooks = jQuery.cssHooks[ name ];
  		if ( hooks && "expand" in hooks ) {
  			value = hooks.expand( value );
  			delete props[ name ];
  
  			// Not quite $.extend, this won't overwrite existing keys.
  			// Reusing 'index' because we have the correct "name"
  			for ( index in value ) {
  				if ( !( index in props ) ) {
  					props[ index ] = value[ index ];
  					specialEasing[ index ] = easing;
  				}
  			}
  		} else {
  			specialEasing[ name ] = easing;
  		}
  	}
  }
  
  function Animation( elem, properties, options ) {
  	var result,
  		stopped,
  		index = 0,
c5169e0e   Renato De Donato   a new hope
291
  		length = animationPrefilters.length,
74249687   Luigi Serra   Cross browser con...
292
  		deferred = jQuery.Deferred().always( function() {
74249687   Luigi Serra   Cross browser con...
293
294
  			// Don't match elem in the :animated selector
  			delete tick.elem;
c5169e0e   Renato De Donato   a new hope
295
  		}),
74249687   Luigi Serra   Cross browser con...
296
297
298
299
300
301
  		tick = function() {
  			if ( stopped ) {
  				return false;
  			}
  			var currentTime = fxNow || createFxNow(),
  				remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
74249687   Luigi Serra   Cross browser con...
302
303
304
305
306
307
308
309
310
311
312
  				// Support: Android 2.3
  				// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  				temp = remaining / animation.duration || 0,
  				percent = 1 - temp,
  				index = 0,
  				length = animation.tweens.length;
  
  			for ( ; index < length ; index++ ) {
  				animation.tweens[ index ].run( percent );
  			}
  
c5169e0e   Renato De Donato   a new hope
313
  			deferred.notifyWith( elem, [ animation, percent, remaining ]);
74249687   Luigi Serra   Cross browser con...
314
315
316
317
318
319
320
321
  
  			if ( percent < 1 && length ) {
  				return remaining;
  			} else {
  				deferred.resolveWith( elem, [ animation ] );
  				return false;
  			}
  		},
c5169e0e   Renato De Donato   a new hope
322
  		animation = deferred.promise({
74249687   Luigi Serra   Cross browser con...
323
324
  			elem: elem,
  			props: jQuery.extend( {}, properties ),
c5169e0e   Renato De Donato   a new hope
325
  			opts: jQuery.extend( true, { specialEasing: {} }, options ),
74249687   Luigi Serra   Cross browser con...
326
327
328
329
330
331
332
333
334
335
336
337
338
  			originalProperties: properties,
  			originalOptions: options,
  			startTime: fxNow || createFxNow(),
  			duration: options.duration,
  			tweens: [],
  			createTween: function( prop, end ) {
  				var tween = jQuery.Tween( elem, animation.opts, prop, end,
  						animation.opts.specialEasing[ prop ] || animation.opts.easing );
  				animation.tweens.push( tween );
  				return tween;
  			},
  			stop: function( gotoEnd ) {
  				var index = 0,
74249687   Luigi Serra   Cross browser con...
339
340
341
342
343
344
345
346
347
348
349
350
351
  					// If we are going to the end, we want to run all the tweens
  					// otherwise we skip this part
  					length = gotoEnd ? animation.tweens.length : 0;
  				if ( stopped ) {
  					return this;
  				}
  				stopped = true;
  				for ( ; index < length ; index++ ) {
  					animation.tweens[ index ].run( 1 );
  				}
  
  				// Resolve when we played the last frame; otherwise, reject
  				if ( gotoEnd ) {
74249687   Luigi Serra   Cross browser con...
352
353
354
355
356
357
  					deferred.resolveWith( elem, [ animation, gotoEnd ] );
  				} else {
  					deferred.rejectWith( elem, [ animation, gotoEnd ] );
  				}
  				return this;
  			}
c5169e0e   Renato De Donato   a new hope
358
  		}),
74249687   Luigi Serra   Cross browser con...
359
360
361
362
363
  		props = animation.props;
  
  	propFilter( props, animation.opts.specialEasing );
  
  	for ( ; index < length ; index++ ) {
c5169e0e   Renato De Donato   a new hope
364
  		result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
74249687   Luigi Serra   Cross browser con...
365
  		if ( result ) {
74249687   Luigi Serra   Cross browser con...
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
  			return result;
  		}
  	}
  
  	jQuery.map( props, createTween, animation );
  
  	if ( jQuery.isFunction( animation.opts.start ) ) {
  		animation.opts.start.call( elem, animation );
  	}
  
  	jQuery.fx.timer(
  		jQuery.extend( tick, {
  			elem: elem,
  			anim: animation,
  			queue: animation.opts.queue
c5169e0e   Renato De Donato   a new hope
381
  		})
74249687   Luigi Serra   Cross browser con...
382
383
384
385
386
387
388
389
390
391
  	);
  
  	// attach callbacks from options
  	return animation.progress( animation.opts.progress )
  		.done( animation.opts.done, animation.opts.complete )
  		.fail( animation.opts.fail )
  		.always( animation.opts.always );
  }
  
  jQuery.Animation = jQuery.extend( Animation, {
74249687   Luigi Serra   Cross browser con...
392
393
394
395
396
397
  
  	tweener: function( props, callback ) {
  		if ( jQuery.isFunction( props ) ) {
  			callback = props;
  			props = [ "*" ];
  		} else {
c5169e0e   Renato De Donato   a new hope
398
  			props = props.split(" ");
74249687   Luigi Serra   Cross browser con...
399
400
401
402
403
404
405
406
  		}
  
  		var prop,
  			index = 0,
  			length = props.length;
  
  		for ( ; index < length ; index++ ) {
  			prop = props[ index ];
c5169e0e   Renato De Donato   a new hope
407
408
  			tweeners[ prop ] = tweeners[ prop ] || [];
  			tweeners[ prop ].unshift( callback );
74249687   Luigi Serra   Cross browser con...
409
410
411
  		}
  	},
  
74249687   Luigi Serra   Cross browser con...
412
413
  	prefilter: function( callback, prepend ) {
  		if ( prepend ) {
c5169e0e   Renato De Donato   a new hope
414
  			animationPrefilters.unshift( callback );
74249687   Luigi Serra   Cross browser con...
415
  		} else {
c5169e0e   Renato De Donato   a new hope
416
  			animationPrefilters.push( callback );
74249687   Luigi Serra   Cross browser con...
417
418
  		}
  	}
c5169e0e   Renato De Donato   a new hope
419
  });
74249687   Luigi Serra   Cross browser con...
420
421
422
423
424
425
426
427
428
  
  jQuery.speed = function( speed, easing, fn ) {
  	var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  		complete: fn || !fn && easing ||
  			jQuery.isFunction( speed ) && speed,
  		duration: speed,
  		easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
  	};
  
c5169e0e   Renato De Donato   a new hope
429
430
  	opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
  		opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
74249687   Luigi Serra   Cross browser con...
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
  
  	// Normalize opt.queue - true/undefined/null -> "fx"
  	if ( opt.queue == null || opt.queue === true ) {
  		opt.queue = "fx";
  	}
  
  	// Queueing
  	opt.old = opt.complete;
  
  	opt.complete = function() {
  		if ( jQuery.isFunction( opt.old ) ) {
  			opt.old.call( this );
  		}
  
  		if ( opt.queue ) {
  			jQuery.dequeue( this, opt.queue );
  		}
  	};
  
  	return opt;
  };
  
c5169e0e   Renato De Donato   a new hope
453
  jQuery.fn.extend({
74249687   Luigi Serra   Cross browser con...
454
455
456
457
458
459
  	fadeTo: function( speed, to, easing, callback ) {
  
  		// Show any hidden elements after setting opacity to 0
  		return this.filter( isHidden ).css( "opacity", 0 ).show()
  
  			// Animate to the value specified
c5169e0e   Renato De Donato   a new hope
460
  			.end().animate({ opacity: to }, speed, easing, callback );
74249687   Luigi Serra   Cross browser con...
461
462
463
464
465
  	},
  	animate: function( prop, speed, easing, callback ) {
  		var empty = jQuery.isEmptyObject( prop ),
  			optall = jQuery.speed( speed, easing, callback ),
  			doAnimation = function() {
74249687   Luigi Serra   Cross browser con...
466
467
468
469
  				// Operate on a copy of prop so per-property easing won't be lost
  				var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  
  				// Empty animations, or finishing resolves immediately
c5169e0e   Renato De Donato   a new hope
470
  				if ( empty || data_priv.get( this, "finish" ) ) {
74249687   Luigi Serra   Cross browser con...
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
  					anim.stop( true );
  				}
  			};
  			doAnimation.finish = doAnimation;
  
  		return empty || optall.queue === false ?
  			this.each( doAnimation ) :
  			this.queue( optall.queue, doAnimation );
  	},
  	stop: function( type, clearQueue, gotoEnd ) {
  		var stopQueue = function( hooks ) {
  			var stop = hooks.stop;
  			delete hooks.stop;
  			stop( gotoEnd );
  		};
  
  		if ( typeof type !== "string" ) {
  			gotoEnd = clearQueue;
  			clearQueue = type;
  			type = undefined;
  		}
  		if ( clearQueue && type !== false ) {
  			this.queue( type || "fx", [] );
  		}
  
c5169e0e   Renato De Donato   a new hope
496
  		return this.each(function() {
74249687   Luigi Serra   Cross browser con...
497
498
499
  			var dequeue = true,
  				index = type != null && type + "queueHooks",
  				timers = jQuery.timers,
c5169e0e   Renato De Donato   a new hope
500
  				data = data_priv.get( this );
74249687   Luigi Serra   Cross browser con...
501
502
503
504
505
506
507
508
509
510
511
512
513
514
  
  			if ( index ) {
  				if ( data[ index ] && data[ index ].stop ) {
  					stopQueue( data[ index ] );
  				}
  			} else {
  				for ( index in data ) {
  					if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  						stopQueue( data[ index ] );
  					}
  				}
  			}
  
  			for ( index = timers.length; index--; ) {
c5169e0e   Renato De Donato   a new hope
515
  				if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) {
74249687   Luigi Serra   Cross browser con...
516
517
518
519
520
521
522
523
524
525
526
527
  					timers[ index ].anim.stop( gotoEnd );
  					dequeue = false;
  					timers.splice( index, 1 );
  				}
  			}
  
  			// Start the next in the queue if the last step wasn't forced.
  			// Timers currently will call their complete callbacks, which
  			// will dequeue but only if they were gotoEnd.
  			if ( dequeue || !gotoEnd ) {
  				jQuery.dequeue( this, type );
  			}
c5169e0e   Renato De Donato   a new hope
528
  		});
74249687   Luigi Serra   Cross browser con...
529
530
531
532
533
  	},
  	finish: function( type ) {
  		if ( type !== false ) {
  			type = type || "fx";
  		}
c5169e0e   Renato De Donato   a new hope
534
  		return this.each(function() {
74249687   Luigi Serra   Cross browser con...
535
  			var index,
c5169e0e   Renato De Donato   a new hope
536
  				data = data_priv.get( this ),
74249687   Luigi Serra   Cross browser con...
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
  				queue = data[ type + "queue" ],
  				hooks = data[ type + "queueHooks" ],
  				timers = jQuery.timers,
  				length = queue ? queue.length : 0;
  
  			// Enable finishing flag on private data
  			data.finish = true;
  
  			// Empty the queue first
  			jQuery.queue( this, type, [] );
  
  			if ( hooks && hooks.stop ) {
  				hooks.stop.call( this, true );
  			}
  
  			// Look for any active animations, and finish them
  			for ( index = timers.length; index--; ) {
  				if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  					timers[ index ].anim.stop( true );
  					timers.splice( index, 1 );
  				}
  			}
  
  			// Look for any animations in the old queue and finish them
  			for ( index = 0; index < length; index++ ) {
  				if ( queue[ index ] && queue[ index ].finish ) {
  					queue[ index ].finish.call( this );
  				}
  			}
  
  			// Turn off finishing flag
  			delete data.finish;
c5169e0e   Renato De Donato   a new hope
569
  		});
74249687   Luigi Serra   Cross browser con...
570
  	}
c5169e0e   Renato De Donato   a new hope
571
  });
74249687   Luigi Serra   Cross browser con...
572
  
c5169e0e   Renato De Donato   a new hope
573
  jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
74249687   Luigi Serra   Cross browser con...
574
575
576
577
578
579
  	var cssFn = jQuery.fn[ name ];
  	jQuery.fn[ name ] = function( speed, easing, callback ) {
  		return speed == null || typeof speed === "boolean" ?
  			cssFn.apply( this, arguments ) :
  			this.animate( genFx( name, true ), speed, easing, callback );
  	};
c5169e0e   Renato De Donato   a new hope
580
  });
74249687   Luigi Serra   Cross browser con...
581
582
  
  // Generate shortcuts for custom animations
c5169e0e   Renato De Donato   a new hope
583
584
585
586
  jQuery.each({
  	slideDown: genFx("show"),
  	slideUp: genFx("hide"),
  	slideToggle: genFx("toggle"),
74249687   Luigi Serra   Cross browser con...
587
588
589
590
591
592
593
  	fadeIn: { opacity: "show" },
  	fadeOut: { opacity: "hide" },
  	fadeToggle: { opacity: "toggle" }
  }, function( name, props ) {
  	jQuery.fn[ name ] = function( speed, easing, callback ) {
  		return this.animate( props, speed, easing, callback );
  	};
c5169e0e   Renato De Donato   a new hope
594
  });
74249687   Luigi Serra   Cross browser con...
595
596
597
598
599
600
601
602
603
604
605
  
  jQuery.timers = [];
  jQuery.fx.tick = function() {
  	var timer,
  		i = 0,
  		timers = jQuery.timers;
  
  	fxNow = jQuery.now();
  
  	for ( ; i < timers.length; i++ ) {
  		timer = timers[ i ];
74249687   Luigi Serra   Cross browser con...
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
  		// Checks the timer has not already been removed
  		if ( !timer() && timers[ i ] === timer ) {
  			timers.splice( i--, 1 );
  		}
  	}
  
  	if ( !timers.length ) {
  		jQuery.fx.stop();
  	}
  	fxNow = undefined;
  };
  
  jQuery.fx.timer = function( timer ) {
  	jQuery.timers.push( timer );
  	if ( timer() ) {
  		jQuery.fx.start();
  	} else {
  		jQuery.timers.pop();
  	}
  };
  
  jQuery.fx.interval = 13;
c5169e0e   Renato De Donato   a new hope
628
  
74249687   Luigi Serra   Cross browser con...
629
630
  jQuery.fx.start = function() {
  	if ( !timerId ) {
c5169e0e   Renato De Donato   a new hope
631
  		timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
74249687   Luigi Serra   Cross browser con...
632
633
634
635
  	}
  };
  
  jQuery.fx.stop = function() {
c5169e0e   Renato De Donato   a new hope
636
  	clearInterval( timerId );
74249687   Luigi Serra   Cross browser con...
637
638
639
640
641
642
  	timerId = null;
  };
  
  jQuery.fx.speeds = {
  	slow: 600,
  	fast: 200,
74249687   Luigi Serra   Cross browser con...
643
644
645
646
647
  	// Default speed
  	_default: 400
  };
  
  return jQuery;
c5169e0e   Renato De Donato   a new hope
648
  });