1 import { jQuery
} from "./core.js";
2 import { dataPriv
} from "./data/var/dataPriv.js";
4 import "./deferred.js";
5 import "./callbacks.js";
8 queue: function( elem
, type
, data
) {
12 type
= ( type
|| "fx" ) + "queue";
13 queue
= dataPriv
.get( elem
, type
);
15 // Speed up dequeue by getting out quickly if this is just a lookup
17 if ( !queue
|| Array
.isArray( data
) ) {
18 queue
= dataPriv
.access( 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 public - generate a queueHooks object, or return the current one
63 _queueHooks: function( elem
, type
) {
64 var key
= type
+ "queueHooks";
65 return dataPriv
.get( elem
, key
) || dataPriv
.access( elem
, key
, {
66 empty
: jQuery
.Callbacks( "once memory" ).add( function() {
67 dataPriv
.remove( elem
, [ type
+ "queue", key
] );
74 queue: function( type
, data
) {
77 if ( typeof type
!== "string" ) {
83 if ( arguments
.length
< setter
) {
84 return jQuery
.queue( this[ 0 ], type
);
87 return data
=== undefined ?
89 this.each( function() {
90 var queue
= jQuery
.queue( this, type
, data
);
92 // Ensure a hooks for this queue
93 jQuery
._queueHooks( this, type
);
95 if ( type
=== "fx" && queue
[ 0 ] !== "inprogress" ) {
96 jQuery
.dequeue( this, type
);
100 dequeue: function( type
) {
101 return this.each( function() {
102 jQuery
.dequeue( this, type
);
105 clearQueue: function( type
) {
106 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
);
141 export { jQuery
, jQuery as
$ };