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 ) {
83 if ( !elem ) { return; }
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 );
142 removeData: function( key ){
143 return this.each(function(){
144 jQuery.removeData( this, key );
147 queue: function(type, data){
148 if ( typeof type !== "string" ) {
153 if ( data === undefined ) {
154 return jQuery.queue( this[0], type );
156 return this.each(function(i, elem){
157 var queue = jQuery.queue( this, type, data );
159 if ( type == "fx" && queue[0] !== "inprogress" ) {
160 jQuery.dequeue( this, type );
164 dequeue: function(type){
165 return this.each(function(){
166 jQuery.dequeue( this, type );
169 clearQueue: function(type){
170 return this.queue( type || "fx", [] );