2017-05-13 13:25:33 +02:00
|
|
|
define( [
|
2014-05-12 20:08:19 +02:00
|
|
|
"./core",
|
2017-05-13 13:25:33 +02:00
|
|
|
"./data/var/dataPriv",
|
2014-05-12 20:08:19 +02:00
|
|
|
"./deferred",
|
|
|
|
"./callbacks"
|
2017-05-13 13:25:33 +02:00
|
|
|
], function( jQuery, dataPriv ) {
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
jQuery.extend( {
|
2014-05-12 20:08:19 +02:00
|
|
|
queue: function( elem, type, data ) {
|
|
|
|
var queue;
|
|
|
|
|
|
|
|
if ( elem ) {
|
|
|
|
type = ( type || "fx" ) + "queue";
|
2017-05-13 13:25:33 +02:00
|
|
|
queue = dataPriv.get( elem, type );
|
2014-05-12 20:08:19 +02:00
|
|
|
|
|
|
|
// Speed up dequeue by getting out quickly if this is just a lookup
|
|
|
|
if ( data ) {
|
2017-05-13 13:25:33 +02:00
|
|
|
if ( !queue || Array.isArray( data ) ) {
|
|
|
|
queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
|
2014-05-12 20:08:19 +02:00
|
|
|
} else {
|
|
|
|
queue.push( data );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return queue || [];
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
dequeue: function( elem, type ) {
|
|
|
|
type = type || "fx";
|
|
|
|
|
|
|
|
var queue = jQuery.queue( elem, type ),
|
|
|
|
startLength = queue.length,
|
|
|
|
fn = queue.shift(),
|
|
|
|
hooks = jQuery._queueHooks( elem, type ),
|
|
|
|
next = function() {
|
|
|
|
jQuery.dequeue( elem, type );
|
|
|
|
};
|
|
|
|
|
|
|
|
// If the fx queue is dequeued, always remove the progress sentinel
|
|
|
|
if ( fn === "inprogress" ) {
|
|
|
|
fn = queue.shift();
|
|
|
|
startLength--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( fn ) {
|
|
|
|
|
|
|
|
// Add a progress sentinel to prevent the fx queue from being
|
|
|
|
// automatically dequeued
|
|
|
|
if ( type === "fx" ) {
|
|
|
|
queue.unshift( "inprogress" );
|
|
|
|
}
|
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// Clear up the last queue stop function
|
2014-05-12 20:08:19 +02:00
|
|
|
delete hooks.stop;
|
|
|
|
fn.call( elem, next, hooks );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !startLength && hooks ) {
|
|
|
|
hooks.empty.fire();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// Not public - generate a queueHooks object, or return the current one
|
2014-05-12 20:08:19 +02:00
|
|
|
_queueHooks: function( elem, type ) {
|
|
|
|
var key = type + "queueHooks";
|
2017-05-13 13:25:33 +02:00
|
|
|
return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
|
|
|
|
empty: jQuery.Callbacks( "once memory" ).add( function() {
|
|
|
|
dataPriv.remove( elem, [ type + "queue", key ] );
|
|
|
|
} )
|
|
|
|
} );
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
2017-05-13 13:25:33 +02:00
|
|
|
} );
|
2014-05-12 20:08:19 +02:00
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
jQuery.fn.extend( {
|
2014-05-12 20:08:19 +02:00
|
|
|
queue: function( type, data ) {
|
|
|
|
var setter = 2;
|
|
|
|
|
|
|
|
if ( typeof type !== "string" ) {
|
|
|
|
data = type;
|
|
|
|
type = "fx";
|
|
|
|
setter--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( arguments.length < setter ) {
|
2017-05-13 13:25:33 +02:00
|
|
|
return jQuery.queue( this[ 0 ], type );
|
2014-05-12 20:08:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return data === undefined ?
|
|
|
|
this :
|
2017-05-13 13:25:33 +02:00
|
|
|
this.each( function() {
|
2014-05-12 20:08:19 +02:00
|
|
|
var queue = jQuery.queue( this, type, data );
|
|
|
|
|
2016-05-16 13:33:49 +02:00
|
|
|
// Ensure a hooks for this queue
|
2014-05-12 20:08:19 +02:00
|
|
|
jQuery._queueHooks( this, type );
|
|
|
|
|
2017-05-13 13:25:33 +02:00
|
|
|
if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
|
2014-05-12 20:08:19 +02:00
|
|
|
jQuery.dequeue( this, type );
|
|
|
|
}
|
2017-05-13 13:25:33 +02:00
|
|
|
} );
|
2014-05-12 20:08:19 +02:00
|
|
|
},
|
|
|
|
dequeue: function( type ) {
|
2017-05-13 13:25:33 +02:00
|
|
|
return this.each( function() {
|
2014-05-12 20:08:19 +02:00
|
|
|
jQuery.dequeue( this, type );
|
2017-05-13 13:25:33 +02:00
|
|
|
} );
|
2014-05-12 20:08:19 +02:00
|
|
|
},
|
|
|
|
clearQueue: function( type ) {
|
|
|
|
return this.queue( type || "fx", [] );
|
|
|
|
},
|
2017-05-13 13:25:33 +02:00
|
|
|
|
2014-05-12 20:08:19 +02:00
|
|
|
// Get a promise resolved when queues of a certain type
|
|
|
|
// are emptied (fx is the type by default)
|
|
|
|
promise: function( type, obj ) {
|
|
|
|
var tmp,
|
|
|
|
count = 1,
|
|
|
|
defer = jQuery.Deferred(),
|
|
|
|
elements = this,
|
|
|
|
i = this.length,
|
|
|
|
resolve = function() {
|
|
|
|
if ( !( --count ) ) {
|
|
|
|
defer.resolveWith( elements, [ elements ] );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
if ( typeof type !== "string" ) {
|
|
|
|
obj = type;
|
|
|
|
type = undefined;
|
|
|
|
}
|
|
|
|
type = type || "fx";
|
|
|
|
|
|
|
|
while ( i-- ) {
|
2017-05-13 13:25:33 +02:00
|
|
|
tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
|
2014-05-12 20:08:19 +02:00
|
|
|
if ( tmp && tmp.empty ) {
|
|
|
|
count++;
|
|
|
|
tmp.empty.add( resolve );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
resolve();
|
|
|
|
return defer.promise( obj );
|
|
|
|
}
|
2017-05-13 13:25:33 +02:00
|
|
|
} );
|
2014-05-12 20:08:19 +02:00
|
|
|
|
|
|
|
return jQuery;
|
2017-05-13 13:25:33 +02:00
|
|
|
} );
|