1 var expando = "jQuery" + now(), uuid = 0, windowData = {};
9 data: function( elem, name, data ) {
10 elem = elem == window ?
14 var id = elem[ expando ], cache = jQuery.cache, thisCache;
16 // Handle the case where there's no name immediately
21 // Compute a unique ID for the element
26 // Avoid generating a new cache unless none exists and we
27 // want to manipulate it.
29 thisCache = cache[ id ];
30 } else if ( typeof data === "undefined" ) {
31 thisCache = emptyObject;
33 thisCache = cache[ id ] = {};
36 // Prevent overriding the named cache with undefined values
37 if ( data !== undefined ) {
39 thisCache[ name ] = data;
42 return name ? thisCache[ name ] : thisCache;
45 removeData: function( elem, name ) {
46 elem = elem == window ?
50 var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
52 // If we want to remove a specific section of the element's data
55 // Remove the section of cache data
56 delete thisCache[ name ];
58 // If we've removed all the data, remove the element's cache
59 if ( jQuery.isEmptyObject(thisCache) ) {
60 jQuery.removeData( elem );
64 // Otherwise, we want to remove all of the element's data
66 // Clean up the element expando
68 delete elem[ expando ];
70 // IE has trouble directly removing the expando
71 // but it's ok with using removeAttribute
72 if ( elem.removeAttribute ) {
73 elem.removeAttribute( expando );
77 // Completely remove the data cache
82 queue: function( elem, type, data ) {
85 type = (type || "fx") + "queue";
86 var q = jQuery.data( elem, type );
88 // Speed up dequeue by getting out quickly if this is just a lookup
89 if( !data ) return q || [];
91 if ( !q || jQuery.isArray(data) )
92 q = jQuery.data( elem, type, jQuery.makeArray(data) );
99 dequeue: function( elem, type ){
102 var queue = jQuery.queue( elem, type ), fn = queue.shift();
104 // If the fx queue is dequeued, always remove the progress sentinel
105 if( fn === "inprogress" ) fn = queue.shift();
108 // Add a progress sentinel to prevent the fx queue from being
109 // automatically dequeued
110 if( type == "fx" ) queue.unshift("inprogress");
112 fn.call(elem, function() { jQuery.dequeue(elem, type); });
118 data: function( key, value ){
119 if ( typeof key === "undefined" && this.length ) {
120 return jQuery.data( this[0] );
123 var parts = key.split(".");
124 parts[1] = parts[1] ? "." + parts[1] : "";
126 if ( value === undefined ) {
127 var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
129 if ( data === undefined && this.length )
130 data = jQuery.data( this[0], key );
132 return data === undefined && parts[1] ?
133 this.data( parts[0] ) :
136 return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
137 jQuery.data( this, key, value );
141 removeData: function( key ){
142 return this.each(function(){
143 jQuery.removeData( this, key );
146 queue: function(type, data){
147 if ( typeof type !== "string" ) {
152 if ( data === undefined )
153 return jQuery.queue( this[0], type );
155 return this.each(function(i, elem){
156 var queue = jQuery.queue( this, type, data );
158 if( type == "fx" && queue[0] !== "inprogress" )
159 jQuery.dequeue( this, type )
162 dequeue: function(type){
163 return this.each(function(){
164 jQuery.dequeue( this, type );
167 clearQueue: function(type){
168 return this.queue( type || "fx", [] );