2015-08-16 06:59:58 +00:00
|
|
|
define( [
|
2013-08-15 18:15:49 +00:00
|
|
|
"./core",
|
2014-07-17 17:25:59 +00:00
|
|
|
"./data/var/dataPriv",
|
2013-08-15 18:15:49 +00:00
|
|
|
"./deferred",
|
|
|
|
"./callbacks"
|
2014-07-17 17:25:59 +00:00
|
|
|
], function( jQuery, dataPriv ) {
|
2013-08-15 18:15:49 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
jQuery.extend( {
|
2011-04-11 11:40:14 +00:00
|
|
|
queue: function( elem, type, data ) {
|
2012-05-23 03:04:45 +00:00
|
|
|
var queue;
|
|
|
|
|
2011-04-11 11:40:14 +00:00
|
|
|
if ( elem ) {
|
2011-10-27 19:34:05 +00:00
|
|
|
type = ( type || "fx" ) + "queue";
|
2014-07-17 17:25:59 +00:00
|
|
|
queue = dataPriv.get( elem, type );
|
2011-09-12 23:48:44 +00:00
|
|
|
|
2011-04-11 11:40:14 +00:00
|
|
|
// Speed up dequeue by getting out quickly if this is just a lookup
|
|
|
|
if ( data ) {
|
2013-04-08 19:35:16 +00:00
|
|
|
if ( !queue || jQuery.isArray( data ) ) {
|
2015-08-16 06:59:58 +00:00
|
|
|
queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
|
2011-04-11 11:40:14 +00:00
|
|
|
} else {
|
2012-05-23 03:04:45 +00:00
|
|
|
queue.push( data );
|
2011-04-11 11:40:14 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-23 03:04:45 +00:00
|
|
|
return queue || [];
|
2011-04-11 11:40:14 +00:00
|
|
|
}
|
2009-12-06 22:19:33 +00:00
|
|
|
},
|
|
|
|
|
2009-12-22 00:58:13 +00:00
|
|
|
dequeue: function( elem, type ) {
|
2011-04-11 23:09:35 +00:00
|
|
|
type = type || "fx";
|
|
|
|
|
2010-11-09 16:09:07 +00:00
|
|
|
var queue = jQuery.queue( elem, type ),
|
2012-08-13 17:43:49 +00:00
|
|
|
startLength = queue.length,
|
2011-09-28 15:55:29 +00:00
|
|
|
fn = queue.shift(),
|
2012-05-23 03:04:45 +00:00
|
|
|
hooks = jQuery._queueHooks( elem, type ),
|
|
|
|
next = function() {
|
|
|
|
jQuery.dequeue( elem, type );
|
|
|
|
};
|
2009-12-06 22:19:33 +00:00
|
|
|
|
|
|
|
// If the fx queue is dequeued, always remove the progress sentinel
|
2009-12-22 00:58:13 +00:00
|
|
|
if ( fn === "inprogress" ) {
|
|
|
|
fn = queue.shift();
|
2012-08-13 17:43:49 +00:00
|
|
|
startLength--;
|
2009-12-22 00:58:13 +00:00
|
|
|
}
|
2009-12-06 22:19:33 +00:00
|
|
|
|
|
|
|
if ( fn ) {
|
2012-05-23 03:04:45 +00:00
|
|
|
|
2009-12-06 22:19:33 +00:00
|
|
|
// Add a progress sentinel to prevent the fx queue from being
|
|
|
|
// automatically dequeued
|
2009-12-22 00:58:13 +00:00
|
|
|
if ( type === "fx" ) {
|
2011-09-28 15:55:29 +00:00
|
|
|
queue.unshift( "inprogress" );
|
2009-12-22 00:58:13 +00:00
|
|
|
}
|
2009-12-06 22:19:33 +00:00
|
|
|
|
2014-04-25 22:26:36 +00:00
|
|
|
// Clear up the last queue stop function
|
2012-05-23 03:04:45 +00:00
|
|
|
delete hooks.stop;
|
|
|
|
fn.call( elem, next, hooks );
|
2009-12-06 22:19:33 +00:00
|
|
|
}
|
2012-08-13 17:43:49 +00:00
|
|
|
|
|
|
|
if ( !startLength && hooks ) {
|
2012-05-23 03:04:45 +00:00
|
|
|
hooks.empty.fire();
|
2011-01-09 21:58:23 +00:00
|
|
|
}
|
2012-05-23 03:04:45 +00:00
|
|
|
},
|
|
|
|
|
2014-04-25 22:26:36 +00:00
|
|
|
// Not public - generate a queueHooks object, or return the current one
|
2012-05-23 03:04:45 +00:00
|
|
|
_queueHooks: function( elem, type ) {
|
|
|
|
var key = type + "queueHooks";
|
2014-07-17 17:25:59 +00:00
|
|
|
return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
|
2015-08-16 06:59:58 +00:00
|
|
|
empty: jQuery.Callbacks( "once memory" ).add( function() {
|
2014-07-17 17:25:59 +00:00
|
|
|
dataPriv.remove( elem, [ type + "queue", key ] );
|
2015-08-16 06:59:58 +00:00
|
|
|
} )
|
|
|
|
} );
|
2009-12-06 22:19:33 +00:00
|
|
|
}
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2009-12-06 22:19:33 +00:00
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
jQuery.fn.extend( {
|
2009-12-22 00:58:13 +00:00
|
|
|
queue: function( type, data ) {
|
2011-12-06 20:25:38 +00:00
|
|
|
var setter = 2;
|
|
|
|
|
2009-12-06 22:19:33 +00:00
|
|
|
if ( typeof type !== "string" ) {
|
|
|
|
data = type;
|
|
|
|
type = "fx";
|
2011-12-06 20:25:38 +00:00
|
|
|
setter--;
|
2009-12-06 22:19:33 +00:00
|
|
|
}
|
|
|
|
|
2011-12-06 20:25:38 +00:00
|
|
|
if ( arguments.length < setter ) {
|
2015-08-16 06:59:58 +00:00
|
|
|
return jQuery.queue( this[ 0 ], type );
|
2009-12-06 22:19:33 +00:00
|
|
|
}
|
|
|
|
|
2011-12-06 20:25:38 +00:00
|
|
|
return data === undefined ?
|
|
|
|
this :
|
2015-08-16 06:59:58 +00:00
|
|
|
this.each( function() {
|
2011-12-06 20:25:38 +00:00
|
|
|
var queue = jQuery.queue( this, type, data );
|
|
|
|
|
2014-04-25 22:26:36 +00:00
|
|
|
// Ensure a hooks for this queue
|
2012-05-23 03:04:45 +00:00
|
|
|
jQuery._queueHooks( this, type );
|
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
|
2011-12-06 20:25:38 +00:00
|
|
|
jQuery.dequeue( this, type );
|
|
|
|
}
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2009-12-06 22:19:33 +00:00
|
|
|
},
|
2009-12-22 00:58:13 +00:00
|
|
|
dequeue: function( type ) {
|
2015-08-16 06:59:58 +00:00
|
|
|
return this.each( function() {
|
2009-12-06 22:19:33 +00:00
|
|
|
jQuery.dequeue( this, type );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2009-12-06 22:19:33 +00:00
|
|
|
},
|
2009-12-22 00:58:13 +00:00
|
|
|
clearQueue: function( type ) {
|
2009-12-06 22:19:33 +00:00
|
|
|
return this.queue( type || "fx", [] );
|
2011-04-07 04:00:52 +00:00
|
|
|
},
|
2015-08-16 06:59:58 +00:00
|
|
|
|
2011-04-07 04:00:52 +00:00
|
|
|
// Get a promise resolved when queues of a certain type
|
|
|
|
// are emptied (fx is the type by default)
|
2012-06-29 01:39:58 +00:00
|
|
|
promise: function( type, obj ) {
|
2012-05-23 03:04:45 +00:00
|
|
|
var tmp,
|
|
|
|
count = 1,
|
|
|
|
defer = jQuery.Deferred(),
|
|
|
|
elements = this,
|
|
|
|
i = this.length,
|
|
|
|
resolve = function() {
|
|
|
|
if ( !( --count ) ) {
|
|
|
|
defer.resolveWith( elements, [ elements ] );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-04-07 04:00:52 +00:00
|
|
|
if ( typeof type !== "string" ) {
|
2012-06-29 01:39:58 +00:00
|
|
|
obj = type;
|
2011-04-07 04:00:52 +00:00
|
|
|
type = undefined;
|
|
|
|
}
|
|
|
|
type = type || "fx";
|
2012-05-23 03:04:45 +00:00
|
|
|
|
2013-09-11 01:08:01 +00:00
|
|
|
while ( i-- ) {
|
2014-07-17 17:25:59 +00:00
|
|
|
tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
|
2012-08-13 17:43:49 +00:00
|
|
|
if ( tmp && tmp.empty ) {
|
2011-04-07 04:00:52 +00:00
|
|
|
count++;
|
2012-05-23 03:04:45 +00:00
|
|
|
tmp.empty.add( resolve );
|
2011-04-07 04:00:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
resolve();
|
2012-06-29 01:39:58 +00:00
|
|
|
return defer.promise( obj );
|
2009-12-06 22:19:33 +00:00
|
|
|
}
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2013-08-15 18:15:49 +00:00
|
|
|
|
2013-09-09 01:25:27 +00:00
|
|
|
return jQuery;
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|