2009-12-06 23:19:33 +01:00
|
|
|
jQuery.extend({
|
|
|
|
queue: function( elem, type, data ) {
|
2009-12-22 01:58:13 +01:00
|
|
|
if ( !elem ) {
|
|
|
|
return;
|
|
|
|
}
|
2009-12-06 23:19:33 +01:00
|
|
|
|
|
|
|
type = (type || "fx") + "queue";
|
|
|
|
var q = jQuery.data( elem, type );
|
|
|
|
|
|
|
|
// Speed up dequeue by getting out quickly if this is just a lookup
|
2009-12-22 01:58:13 +01:00
|
|
|
if ( !data ) {
|
|
|
|
return q || [];
|
|
|
|
}
|
2009-12-06 23:19:33 +01:00
|
|
|
|
|
|
|
if ( !q || jQuery.isArray(data) ) {
|
|
|
|
q = jQuery.data( elem, type, jQuery.makeArray(data) );
|
2009-12-22 01:58:13 +01:00
|
|
|
|
2009-12-06 23:19:33 +01:00
|
|
|
} else {
|
|
|
|
q.push( data );
|
|
|
|
}
|
2009-12-22 01:58:13 +01:00
|
|
|
|
2009-12-06 23:19:33 +01:00
|
|
|
return q;
|
|
|
|
},
|
|
|
|
|
2009-12-22 01:58:13 +01:00
|
|
|
dequeue: function( elem, type ) {
|
2009-12-06 23:19:33 +01:00
|
|
|
type = type || "fx";
|
|
|
|
|
|
|
|
var queue = jQuery.queue( elem, type ), fn = queue.shift();
|
|
|
|
|
|
|
|
// If the fx queue is dequeued, always remove the progress sentinel
|
2009-12-22 01:58:13 +01:00
|
|
|
if ( fn === "inprogress" ) {
|
|
|
|
fn = queue.shift();
|
|
|
|
}
|
2009-12-06 23:19:33 +01:00
|
|
|
|
|
|
|
if ( fn ) {
|
|
|
|
// Add a progress sentinel to prevent the fx queue from being
|
|
|
|
// automatically dequeued
|
2009-12-22 01:58:13 +01:00
|
|
|
if ( type === "fx" ) {
|
|
|
|
queue.unshift("inprogress");
|
|
|
|
}
|
2009-12-06 23:19:33 +01:00
|
|
|
|
2009-12-22 01:58:13 +01:00
|
|
|
fn.call(elem, function() {
|
|
|
|
jQuery.dequeue(elem, type);
|
|
|
|
});
|
2009-12-06 23:19:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
jQuery.fn.extend({
|
2009-12-22 01:58:13 +01:00
|
|
|
queue: function( type, data ) {
|
2009-12-06 23:19:33 +01:00
|
|
|
if ( typeof type !== "string" ) {
|
|
|
|
data = type;
|
|
|
|
type = "fx";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( data === undefined ) {
|
|
|
|
return jQuery.queue( this[0], type );
|
|
|
|
}
|
2009-12-22 01:58:13 +01:00
|
|
|
return this.each(function( i, elem ) {
|
2009-12-06 23:19:33 +01:00
|
|
|
var queue = jQuery.queue( this, type, data );
|
|
|
|
|
2009-12-22 00:02:02 +01:00
|
|
|
if ( type === "fx" && queue[0] !== "inprogress" ) {
|
2009-12-06 23:19:33 +01:00
|
|
|
jQuery.dequeue( this, type );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2009-12-22 01:58:13 +01:00
|
|
|
dequeue: function( type ) {
|
|
|
|
return this.each(function() {
|
2009-12-06 23:19:33 +01:00
|
|
|
jQuery.dequeue( this, type );
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
// Based off of the plugin by Clint Helfers, with permission.
|
|
|
|
// http://blindsignals.com/index.php/2009/07/jquery-delay/
|
|
|
|
delay: function( time, type ) {
|
|
|
|
time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
|
|
|
|
type = type || "fx";
|
|
|
|
|
|
|
|
return this.queue( type, function() {
|
|
|
|
var elem = this;
|
|
|
|
setTimeout(function() {
|
|
|
|
jQuery.dequeue( elem, type );
|
|
|
|
}, time );
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2009-12-22 01:58:13 +01:00
|
|
|
clearQueue: function( type ) {
|
2009-12-06 23:19:33 +01:00
|
|
|
return this.queue( type || "fx", [] );
|
|
|
|
}
|
|
|
|
});
|