1 var expando = "jQuery" + now(), uuid = 0, windowData = {};
\r
6 data: function( elem, name, data ) {
\r
7 elem = elem == window ?
\r
11 var id = elem[ expando ];
\r
13 // Compute a unique ID for the element
\r
15 id = elem[ expando ] = ++uuid;
\r
17 // Only generate the data cache if we're
\r
18 // trying to access or manipulate it
\r
19 if ( name && !jQuery.cache[ id ] )
\r
20 jQuery.cache[ id ] = {};
\r
22 // Prevent overriding the named cache with undefined values
\r
23 if ( data !== undefined )
\r
24 jQuery.cache[ id ][ name ] = data;
\r
26 // Return the named cache data, or the ID for the element
\r
28 jQuery.cache[ id ][ name ] :
\r
32 removeData: function( elem, name ) {
\r
33 elem = elem == window ?
\r
37 var id = elem[ expando ];
\r
39 // If we want to remove a specific section of the element's data
\r
41 if ( jQuery.cache[ id ] ) {
\r
42 // Remove the section of cache data
\r
43 delete jQuery.cache[ id ][ name ];
\r
45 // If we've removed all the data, remove the element's cache
\r
48 for ( name in jQuery.cache[ id ] )
\r
52 jQuery.removeData( elem );
\r
55 // Otherwise, we want to remove all of the element's data
\r
57 // Clean up the element expando
\r
59 delete elem[ expando ];
\r
61 // IE has trouble directly removing the expando
\r
62 // but it's ok with using removeAttribute
\r
63 if ( elem.removeAttribute )
\r
64 elem.removeAttribute( expando );
\r
67 // Completely remove the data cache
\r
68 delete jQuery.cache[ id ];
\r
71 queue: function( elem, type, data ) {
\r
74 type = (type || "fx") + "queue";
\r
76 var q = jQuery.data( elem, type );
\r
78 if ( !q || jQuery.isArray(data) )
\r
79 q = jQuery.data( elem, type, jQuery.makeArray(data) );
\r
87 dequeue: function( elem, type ){
\r
88 var queue = jQuery.queue( elem, type ),
\r
91 if( !type || type === "fx" )
\r
94 if( fn !== undefined )
\r
100 data: function( key, value ){
\r
101 var parts = key.split(".");
\r
102 parts[1] = parts[1] ? "." + parts[1] : "";
\r
104 if ( value === undefined ) {
\r
105 var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
\r
107 if ( data === undefined && this.length )
\r
108 data = jQuery.data( this[0], key );
\r
110 return data === undefined && parts[1] ?
\r
111 this.data( parts[0] ) :
\r
114 return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
\r
115 jQuery.data( this, key, value );
\r
119 removeData: function( key ){
\r
120 return this.each(function(){
\r
121 jQuery.removeData( this, key );
\r
124 queue: function(type, data){
\r
125 if ( typeof type !== "string" ) {
\r
130 if ( data === undefined )
\r
131 return jQuery.queue( this[0], type );
\r
133 return this.each(function(){
\r
134 var queue = jQuery.queue( this, type, data );
\r
136 if( type == "fx" && queue.length == 1 )
\r
137 queue[0].call(this);
\r
140 dequeue: function(type){
\r
141 return this.each(function(){
\r
142 jQuery.dequeue( this, type );
\r
146 var expando = "jQuery" + now(), uuid = 0, windowData = {};
\r
151 data: function( elem, name, data ) {
\r
152 elem = elem == window ?
\r
156 var id = elem[ expando ];
\r
158 // Compute a unique ID for the element
\r
160 id = elem[ expando ] = ++uuid;
\r
162 // Only generate the data cache if we're
\r
163 // trying to access or manipulate it
\r
164 if ( name && !jQuery.cache[ id ] )
\r
165 jQuery.cache[ id ] = {};
\r
167 // Prevent overriding the named cache with undefined values
\r
168 if ( data !== undefined )
\r
169 jQuery.cache[ id ][ name ] = data;
\r
171 // Return the named cache data, or the ID for the element
\r
173 jQuery.cache[ id ][ name ] :
\r
177 removeData: function( elem, name ) {
\r
178 elem = elem == window ?
\r
182 var id = elem[ expando ];
\r
184 // If we want to remove a specific section of the element's data
\r
186 if ( jQuery.cache[ id ] ) {
\r
187 // Remove the section of cache data
\r
188 delete jQuery.cache[ id ][ name ];
\r
190 // If we've removed all the data, remove the element's cache
\r
193 for ( name in jQuery.cache[ id ] )
\r
197 jQuery.removeData( elem );
\r
200 // Otherwise, we want to remove all of the element's data
\r
202 // Clean up the element expando
\r
204 delete elem[ expando ];
\r
206 // IE has trouble directly removing the expando
\r
207 // but it's ok with using removeAttribute
\r
208 if ( elem.removeAttribute )
\r
209 elem.removeAttribute( expando );
\r
212 // Completely remove the data cache
\r
213 delete jQuery.cache[ id ];
\r
216 queue: function( elem, type, data ) {
\r
219 type = (type || "fx") + "queue";
\r
221 var q = jQuery.data( elem, type );
\r
223 if ( !q || jQuery.isArray(data) )
\r
224 q = jQuery.data( elem, type, jQuery.makeArray(data) );
\r
232 dequeue: function( elem, type ){
\r
233 var queue = jQuery.queue( elem, type ),
\r
234 fn = queue.shift();
\r
236 if( !type || type === "fx" )
\r
239 if( fn !== undefined )
\r
245 data: function( key, value ){
\r
246 var parts = key.split(".");
\r
247 parts[1] = parts[1] ? "." + parts[1] : "";
\r
249 if ( value === undefined ) {
\r
250 var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
\r
252 if ( data === undefined && this.length )
\r
253 data = jQuery.data( this[0], key );
\r
255 return data === undefined && parts[1] ?
\r
256 this.data( parts[0] ) :
\r
259 return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
\r
260 jQuery.data( this, key, value );
\r
264 removeData: function( key ){
\r
265 return this.each(function(){
\r
266 jQuery.removeData( this, key );
\r
269 queue: function(type, data){
\r
270 if ( typeof type !== "string" ) {
\r
275 if ( data === undefined )
\r
276 return jQuery.queue( this[0], type );
\r
278 return this.each(function(){
\r
279 var queue = jQuery.queue( this, type, data );
\r
281 if( type == "fx" && queue.length == 1 )
\r
282 queue[0].call(this);
\r
285 dequeue: function(type){
\r
286 return this.each(function(){
\r
287 jQuery.dequeue( this, type );
\r