5 ], function( jQuery ) {
8 queue: function( elem, type, data ) {
12 type = ( type || "fx" ) + "queue";
13 queue = jQuery._data( elem, type );
15 // Speed up dequeue by getting out quickly if this is just a lookup
17 if ( !queue || jQuery.isArray(data) ) {
18 queue = jQuery._data( elem, type, jQuery.makeArray(data) );
27 dequeue: function( elem, type ) {
30 var queue = jQuery.queue( elem, type ),
31 startLength = queue.length,
33 hooks = jQuery._queueHooks( elem, type ),
35 jQuery.dequeue( elem, type );
38 // If the fx queue is dequeued, always remove the progress sentinel
39 if ( fn === "inprogress" ) {
46 // Add a progress sentinel to prevent the fx queue from being
47 // automatically dequeued
48 if ( type === "fx" ) {
49 queue.unshift( "inprogress" );
52 // clear up the last queue stop function
54 fn.call( elem, next, hooks );
57 if ( !startLength && hooks ) {
62 // not intended for public consumption - generates a queueHooks object,
63 // or returns the current one
64 _queueHooks: function( elem, type ) {
65 var key = type + "queueHooks";
66 return jQuery._data( elem, key ) || jQuery._data( elem, key, {
67 empty: jQuery.Callbacks("once memory").add(function() {
68 jQuery._removeData( elem, type + "queue" );
69 jQuery._removeData( elem, key );
76 queue: function( type, data ) {
79 if ( typeof type !== "string" ) {
85 if ( arguments.length < setter ) {
86 return jQuery.queue( this[0], type );
89 return data === undefined ?
91 this.each(function() {
92 var queue = jQuery.queue( this, type, data );
94 // ensure a hooks for this queue
95 jQuery._queueHooks( this, type );
97 if ( type === "fx" && queue[0] !== "inprogress" ) {
98 jQuery.dequeue( this, type );
102 dequeue: function( type ) {
103 return this.each(function() {
104 jQuery.dequeue( this, type );
107 clearQueue: function( type ) {
108 return this.queue( type || "fx", [] );
110 // Get a promise resolved when queues of a certain type
111 // are emptied (fx is the type by default)
112 promise: function( type, obj ) {
115 defer = jQuery.Deferred(),
118 resolve = function() {
119 if ( !( --count ) ) {
120 defer.resolveWith( elements, [ elements ] );
124 if ( typeof type !== "string" ) {
131 tmp = jQuery._data( elements[ i ], type + "queueHooks" );
132 if ( tmp && tmp.empty ) {
134 tmp.empty.add( resolve );
138 return defer.promise( obj );