6 ], function( jQuery, dataPriv ) {
9 queue: function( elem, type, data ) {
13 type = ( type || "fx" ) + "queue";
14 queue = dataPriv.get( elem, type );
16 // Speed up dequeue by getting out quickly if this is just a lookup
18 if ( !queue || jQuery.isArray( data ) ) {
19 queue = dataPriv.access( elem, type, jQuery.makeArray(data) );
28 dequeue: function( elem, type ) {
31 var queue = jQuery.queue( elem, type ),
32 startLength = queue.length,
34 hooks = jQuery._queueHooks( elem, type ),
36 jQuery.dequeue( elem, type );
39 // If the fx queue is dequeued, always remove the progress sentinel
40 if ( fn === "inprogress" ) {
47 // Add a progress sentinel to prevent the fx queue from being
48 // automatically dequeued
49 if ( type === "fx" ) {
50 queue.unshift( "inprogress" );
53 // Clear up the last queue stop function
55 fn.call( elem, next, hooks );
58 if ( !startLength && hooks ) {
63 // Not public - generate a queueHooks object, or return the current one
64 _queueHooks: function( elem, type ) {
65 var key = type + "queueHooks";
66 return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
67 empty: jQuery.Callbacks("once memory").add(function() {
68 dataPriv.remove( elem, [ type + "queue", key ] );
75 queue: function( type, data ) {
78 if ( typeof type !== "string" ) {
84 if ( arguments.length < setter ) {
85 return jQuery.queue( this[0], type );
88 return data === undefined ?
90 this.each(function() {
91 var queue = jQuery.queue( this, type, data );
93 // Ensure a hooks for this queue
94 jQuery._queueHooks( this, type );
96 if ( type === "fx" && queue[0] !== "inprogress" ) {
97 jQuery.dequeue( this, type );
101 dequeue: function( type ) {
102 return this.each(function() {
103 jQuery.dequeue( this, type );
106 clearQueue: function( type ) {
107 return this.queue( type || "fx", [] );
109 // Get a promise resolved when queues of a certain type
110 // are emptied (fx is the type by default)
111 promise: function( type, obj ) {
114 defer = jQuery.Deferred(),
117 resolve = function() {
118 if ( !( --count ) ) {
119 defer.resolveWith( elements, [ elements ] );
123 if ( typeof type !== "string" ) {
130 tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
131 if ( tmp && tmp.empty ) {
133 tmp.empty.add( resolve );
137 return defer.promise( obj );