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