1 var expando = "jQuery" + now(), uuid = 0, windowData = {};
\r
8 data: function( elem, name, data ) {
\r
9 elem = elem == window ?
\r
13 var id = elem[ expando ], cache = jQuery.cache;
\r
15 // Compute a unique ID for the element
\r
16 if(!id) id = elem[ expando ] = ++uuid;
\r
18 // Only generate the data cache if we're
\r
19 // trying to access or manipulate it
\r
20 if ( name && !cache[ id ] )
\r
23 var thisCache = cache[ id ];
\r
25 // Prevent overriding the named cache with undefined values
\r
26 if ( data !== undefined ) thisCache[ name ] = data;
\r
28 if(name === true) return thisCache
\r
29 else if(name) return thisCache[name]
\r
33 removeData: function( elem, name ) {
\r
34 elem = elem == window ?
\r
38 var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
\r
40 // If we want to remove a specific section of the element's data
\r
43 // Remove the section of cache data
\r
44 delete thisCache[ name ];
\r
46 // If we've removed all the data, remove the element's cache
\r
47 if( jQuery.isEmptyObject(thisCache) )
\r
48 jQuery.removeData( elem );
\r
51 // Otherwise, we want to remove all of the element's data
\r
53 // Clean up the element expando
\r
55 delete elem[ expando ];
\r
57 // IE has trouble directly removing the expando
\r
58 // but it's ok with using removeAttribute
\r
59 if ( elem.removeAttribute )
\r
60 elem.removeAttribute( expando );
\r
63 // Completely remove the data cache
\r
67 queue: function( elem, type, data ) {
\r
70 type = (type || "fx") + "queue";
\r
71 var q = jQuery.data( elem, type );
\r
73 // Speed up dequeue by getting out quickly if this is just a lookup
\r
74 if( !data ) return q || [];
\r
76 if ( !q || jQuery.isArray(data) )
\r
77 q = jQuery.data( elem, type, jQuery.makeArray(data) );
\r
84 dequeue: function( elem, type ){
\r
85 type = type || "fx";
\r
87 var queue = jQuery.queue( elem, type ), fn = queue.shift();
\r
89 // If the fx queue is dequeued, always remove the progress sentinel
\r
90 if( fn === "inprogress" ) fn = queue.shift();
\r
93 // Add a progress sentinel to prevent the fx queue from being
\r
94 // automatically dequeued
\r
95 if( type == "fx" ) queue.unshift("inprogress");
\r
97 fn.call(elem, function() { jQuery.dequeue(elem, type); });
\r
103 data: function( key, value ){
\r
104 if(typeof key === "undefined" && this.length) return jQuery.data(this[0], true);
\r
106 var parts = key.split(".");
\r
107 parts[1] = parts[1] ? "." + parts[1] : "";
\r
109 if ( value === undefined ) {
\r
110 var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
\r
112 if ( data === undefined && this.length )
\r
113 data = jQuery.data( this[0], key );
\r
115 return data === undefined && parts[1] ?
\r
116 this.data( parts[0] ) :
\r
119 return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
\r
120 jQuery.data( this, key, value );
\r
124 removeData: function( key ){
\r
125 return this.each(function(){
\r
126 jQuery.removeData( this, key );
\r
129 queue: function(type, data){
\r
130 if ( typeof type !== "string" ) {
\r
135 if ( data === undefined )
\r
136 return jQuery.queue( this[0], type );
\r
138 return this.each(function(i, elem){
\r
139 var queue = jQuery.queue( this, type, data );
\r
141 if( type == "fx" && queue[0] !== "inprogress" )
\r
142 jQuery.dequeue( this, type )
\r
145 dequeue: function(type){
\r
146 return this.each(function(){
\r
147 jQuery.dequeue( this, type );
\r
150 clearQueue: function(type){
\r
151 return this.queue( type || "fx", [] );
\r