diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/data.js | 74 | ||||
-rw-r--r-- | src/queue.js | 78 |
2 files changed, 78 insertions, 74 deletions
diff --git a/src/data.js b/src/data.js index 3e6eb19f6..1d993fe58 100644 --- a/src/data.js +++ b/src/data.js @@ -77,40 +77,6 @@ jQuery.extend({ // Completely remove the data cache delete cache[ id ]; } - }, - - 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); }); - } } }); @@ -143,45 +109,5 @@ jQuery.fn.extend({ return this.each(function(){ jQuery.removeData( this, key ); }); - }, - 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", [] ); } }); diff --git a/src/queue.js b/src/queue.js new file mode 100644 index 000000000..e636ffb41 --- /dev/null +++ b/src/queue.js @@ -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", [] ); + } +}); |