2010-09-08 17:54:33 +00:00
|
|
|
(function( jQuery ) {
|
|
|
|
|
2009-12-06 22:19:33 +00:00
|
|
|
jQuery.extend({
|
|
|
|
queue: function( elem, type, data ) {
|
2009-12-22 00:58:13 +00:00
|
|
|
if ( !elem ) {
|
|
|
|
return;
|
|
|
|
}
|
2009-12-06 22:19:33 +00:00
|
|
|
|
|
|
|
type = (type || "fx") + "queue";
|
2011-01-09 21:52:33 +00:00
|
|
|
var q = jQuery._data( elem, type );
|
2009-12-06 22:19:33 +00:00
|
|
|
|
|
|
|
// Speed up dequeue by getting out quickly if this is just a lookup
|
2009-12-22 00:58:13 +00:00
|
|
|
if ( !data ) {
|
|
|
|
return q || [];
|
|
|
|
}
|
2009-12-06 22:19:33 +00:00
|
|
|
|
|
|
|
if ( !q || jQuery.isArray(data) ) {
|
2011-01-09 21:52:33 +00:00
|
|
|
q = jQuery._data( elem, type, jQuery.makeArray(data) );
|
2009-12-22 00:58:13 +00:00
|
|
|
|
2009-12-06 22:19:33 +00:00
|
|
|
} else {
|
|
|
|
q.push( data );
|
|
|
|
}
|
2009-12-22 00:58:13 +00:00
|
|
|
|
2009-12-06 22:19:33 +00:00
|
|
|
return q;
|
|
|
|
},
|
|
|
|
|
2009-12-22 00:58:13 +00:00
|
|
|
dequeue: function( elem, type ) {
|
2009-12-06 22:19:33 +00:00
|
|
|
type = type || "fx";
|
|
|
|
|
2010-11-09 16:09:07 +00:00
|
|
|
var queue = jQuery.queue( elem, type ),
|
|
|
|
fn = queue.shift();
|
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();
|
|
|
|
}
|
2009-12-06 22:19:33 +00:00
|
|
|
|
|
|
|
if ( fn ) {
|
|
|
|
// Add a progress sentinel to prevent the fx queue from being
|
|
|
|
// automatically dequeued
|
2009-12-22 00:58:13 +00:00
|
|
|
if ( type === "fx" ) {
|
|
|
|
queue.unshift("inprogress");
|
|
|
|
}
|
2009-12-06 22:19:33 +00:00
|
|
|
|
2009-12-22 00:58:13 +00:00
|
|
|
fn.call(elem, function() {
|
|
|
|
jQuery.dequeue(elem, type);
|
|
|
|
});
|
2009-12-06 22:19:33 +00:00
|
|
|
}
|
2011-01-09 21:58:23 +00:00
|
|
|
|
|
|
|
if ( !queue.length ) {
|
|
|
|
jQuery.removeData( elem, type + "queue", true );
|
|
|
|
}
|
2009-12-06 22:19:33 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
jQuery.fn.extend({
|
2009-12-22 00:58:13 +00:00
|
|
|
queue: function( type, data ) {
|
2009-12-06 22:19:33 +00:00
|
|
|
if ( typeof type !== "string" ) {
|
|
|
|
data = type;
|
|
|
|
type = "fx";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( data === undefined ) {
|
|
|
|
return jQuery.queue( this[0], type );
|
|
|
|
}
|
2010-09-20 14:41:58 +00:00
|
|
|
return this.each(function( i ) {
|
2009-12-06 22:19:33 +00:00
|
|
|
var queue = jQuery.queue( this, type, data );
|
|
|
|
|
2009-12-21 23:02:02 +00:00
|
|
|
if ( type === "fx" && queue[0] !== "inprogress" ) {
|
2009-12-06 22:19:33 +00:00
|
|
|
jQuery.dequeue( this, type );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2009-12-22 00:58:13 +00:00
|
|
|
dequeue: function( type ) {
|
|
|
|
return this.each(function() {
|
2009-12-06 22:19:33 +00: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 00:58:13 +00:00
|
|
|
clearQueue: function( type ) {
|
2009-12-06 22:19:33 +00:00
|
|
|
return this.queue( type || "fx", [] );
|
|
|
|
}
|
|
|
|
});
|
2010-09-08 17:54:33 +00:00
|
|
|
|
|
|
|
})( jQuery );
|