Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Split the queue code out from data.js into a dedicated queue.js file …
…(also split tests accordingly).
- Loading branch information
Showing
8 changed files
with
230 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
jQuery.extend({ | ||
queue: function( elem, type, data ) { | ||
if ( !elem ) { return; } | ||
|
||
type = (type || "fx") + "queue"; | ||
var q = jQuery.data( elem, type ); | ||
|
||
// Speed up dequeue by getting out quickly if this is just a lookup | ||
if ( !data ) { return q || []; } | ||
|
||
if ( !q || jQuery.isArray(data) ) { | ||
q = jQuery.data( elem, type, jQuery.makeArray(data) ); | ||
} else { | ||
q.push( data ); | ||
} | ||
return q; | ||
}, | ||
|
||
dequeue: function( elem, type ){ | ||
type = type || "fx"; | ||
|
||
var queue = jQuery.queue( elem, type ), fn = queue.shift(); | ||
|
||
// If the fx queue is dequeued, always remove the progress sentinel | ||
if ( fn === "inprogress" ) { fn = queue.shift(); } | ||
|
||
if ( fn ) { | ||
// Add a progress sentinel to prevent the fx queue from being | ||
// automatically dequeued | ||
if ( type == "fx" ) { queue.unshift("inprogress"); } | ||
|
||
fn.call(elem, function() { jQuery.dequeue(elem, type); }); | ||
} | ||
} | ||
}); | ||
|
||
jQuery.fn.extend({ | ||
queue: function(type, data){ | ||
if ( typeof type !== "string" ) { | ||
data = type; | ||
type = "fx"; | ||
} | ||
|
||
if ( data === undefined ) { | ||
return jQuery.queue( this[0], type ); | ||
} | ||
return this.each(function(i, elem){ | ||
var queue = jQuery.queue( this, type, data ); | ||
|
||
if ( type == "fx" && queue[0] !== "inprogress" ) { | ||
jQuery.dequeue( this, type ); | ||
} | ||
}); | ||
}, | ||
dequeue: function(type){ | ||
return this.each(function(){ | ||
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 ); | ||
}); | ||
}, | ||
|
||
clearQueue: function(type){ | ||
return this.queue( type || "fx", [] ); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.