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 if(name === true) return jQuery.cache[ id ]
\r
28 // Return the named cache data, or the ID for the element
\r
30 jQuery.cache[ id ][ name ] :
\r
34 removeData: function( elem, name ) {
\r
35 elem = elem == window ?
\r
39 var id = elem[ expando ];
\r
41 // If we want to remove a specific section of the element's data
\r
43 if ( jQuery.cache[ id ] ) {
\r
44 // Remove the section of cache data
\r
45 delete jQuery.cache[ id ][ name ];
\r
47 // If we've removed all the data, remove the element's cache
\r
50 for ( name in jQuery.cache[ id ] )
\r
54 jQuery.removeData( elem );
\r
57 // Otherwise, we want to remove all of the element's data
\r
59 // Clean up the element expando
\r
61 delete elem[ expando ];
\r
63 // IE has trouble directly removing the expando
\r
64 // but it's ok with using removeAttribute
\r
65 if ( elem.removeAttribute )
\r
66 elem.removeAttribute( expando );
\r
69 // Completely remove the data cache
\r
70 delete jQuery.cache[ id ];
\r
73 queue: function( elem, type, data ) {
\r
76 type = (type || "fx") + "queue";
\r
78 var q = jQuery.data( elem, type );
\r
80 if ( !q || jQuery.isArray(data) )
\r
81 q = jQuery.data( elem, type, jQuery.makeArray(data) );
\r
89 dequeue: function( elem, type ){
\r
90 var queue = jQuery.queue( elem, type ),
\r
93 if( !type || type === "fx" )
\r
96 if( fn !== undefined )
\r
97 fn.call(elem, function() { jQuery(elem).dequeue(type); });
\r
102 data: function( key, value ){
\r
103 if(typeof key === "undefined" && this.length) return jQuery.data(this[0], true);
\r
105 var parts = key.split(".");
\r
106 parts[1] = parts[1] ? "." + parts[1] : "";
\r
108 if ( value === undefined ) {
\r
109 var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
\r
111 if ( data === undefined && this.length )
\r
112 data = jQuery.data( this[0], key );
\r
114 return data === undefined && parts[1] ?
\r
115 this.data( parts[0] ) :
\r
118 return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
\r
119 jQuery.data( this, key, value );
\r
123 removeData: function( key ){
\r
124 return this.each(function(){
\r
125 jQuery.removeData( this, key );
\r
128 queue: function(type, data){
\r
129 if ( typeof type !== "string" ) {
\r
134 if ( data === undefined )
\r
135 return jQuery.queue( this[0], type );
\r
137 return this.each(function(i, elem){
\r
138 var queue = jQuery.queue( this, type, data );
\r
140 if( type == "fx" && queue.length == 1 )
\r
141 queue[0].call(this, function() { jQuery(elem).dequeue(type); });
\r
144 dequeue: function(type){
\r
145 return this.each(function(){
\r
146 jQuery.dequeue( this, type );
\r
149 clearQueue: function(type){
\r
150 return this.queue( type || "fx", [] );
\r