annotate jquery-ui/development-bundle/jquery-1.5.1.js @ 0:b2e4605f20b2

beta version
author dwinter
date Thu, 30 Jun 2011 09:07:49 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1 /*!
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2 * jQuery JavaScript Library v1.5.1
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3 * http://jquery.com/
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4 *
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5 * Copyright 2011, John Resig
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6 * Dual licensed under the MIT or GPL Version 2 licenses.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7 * http://jquery.org/license
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8 *
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
9 * Includes Sizzle.js
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
10 * http://sizzlejs.com/
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
11 * Copyright 2011, The Dojo Foundation
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
12 * Released under the MIT, BSD, and GPL Licenses.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
13 *
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
14 * Date: Wed Feb 23 13:55:29 2011 -0500
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
15 */
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
16 (function( window, undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
17
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
18 // Use the correct document accordingly with window argument (sandbox)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
19 var document = window.document;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
20 var jQuery = (function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
21
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
22 // Define a local copy of jQuery
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
23 var jQuery = function( selector, context ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
24 // The jQuery object is actually just the init constructor 'enhanced'
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
25 return new jQuery.fn.init( selector, context, rootjQuery );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
26 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
27
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
28 // Map over jQuery in case of overwrite
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
29 _jQuery = window.jQuery,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
30
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
31 // Map over the $ in case of overwrite
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
32 _$ = window.$,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
33
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
34 // A central reference to the root jQuery(document)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
35 rootjQuery,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
36
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
37 // A simple way to check for HTML strings or ID strings
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
38 // (both of which we optimize for)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
39 quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
40
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
41 // Check if a string has a non-whitespace character in it
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
42 rnotwhite = /\S/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
43
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
44 // Used for trimming whitespace
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
45 trimLeft = /^\s+/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
46 trimRight = /\s+$/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
47
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
48 // Check for digits
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
49 rdigit = /\d/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
50
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
51 // Match a standalone tag
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
52 rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
53
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
54 // JSON RegExp
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
55 rvalidchars = /^[\],:{}\s]*$/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
56 rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
57 rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
58 rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
59
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
60 // Useragent RegExp
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
61 rwebkit = /(webkit)[ \/]([\w.]+)/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
62 ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
63 rmsie = /(msie) ([\w.]+)/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
64 rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
65
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
66 // Keep a UserAgent string for use with jQuery.browser
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
67 userAgent = navigator.userAgent,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
68
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
69 // For matching the engine and version of the browser
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
70 browserMatch,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
71
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
72 // Has the ready events already been bound?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
73 readyBound = false,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
74
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
75 // The deferred used on DOM ready
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
76 readyList,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
77
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
78 // Promise methods
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
79 promiseMethods = "then done fail isResolved isRejected promise".split( " " ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
80
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
81 // The ready event handler
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
82 DOMContentLoaded,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
83
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
84 // Save a reference to some core methods
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
85 toString = Object.prototype.toString,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
86 hasOwn = Object.prototype.hasOwnProperty,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
87 push = Array.prototype.push,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
88 slice = Array.prototype.slice,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
89 trim = String.prototype.trim,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
90 indexOf = Array.prototype.indexOf,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
91
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
92 // [[Class]] -> type pairs
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
93 class2type = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
94
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
95 jQuery.fn = jQuery.prototype = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
96 constructor: jQuery,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
97 init: function( selector, context, rootjQuery ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
98 var match, elem, ret, doc;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
99
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
100 // Handle $(""), $(null), or $(undefined)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
101 if ( !selector ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
102 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
103 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
104
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
105 // Handle $(DOMElement)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
106 if ( selector.nodeType ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
107 this.context = this[0] = selector;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
108 this.length = 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
109 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
110 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
111
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
112 // The body element only exists once, optimize finding it
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
113 if ( selector === "body" && !context && document.body ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
114 this.context = document;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
115 this[0] = document.body;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
116 this.selector = "body";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
117 this.length = 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
118 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
119 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
120
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
121 // Handle HTML strings
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
122 if ( typeof selector === "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
123 // Are we dealing with HTML string or an ID?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
124 match = quickExpr.exec( selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
125
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
126 // Verify a match, and that no context was specified for #id
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
127 if ( match && (match[1] || !context) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
128
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
129 // HANDLE: $(html) -> $(array)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
130 if ( match[1] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
131 context = context instanceof jQuery ? context[0] : context;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
132 doc = (context ? context.ownerDocument || context : document);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
133
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
134 // If a single string is passed in and it's a single tag
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
135 // just do a createElement and skip the rest
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
136 ret = rsingleTag.exec( selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
137
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
138 if ( ret ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
139 if ( jQuery.isPlainObject( context ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
140 selector = [ document.createElement( ret[1] ) ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
141 jQuery.fn.attr.call( selector, context, true );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
142
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
143 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
144 selector = [ doc.createElement( ret[1] ) ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
145 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
146
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
147 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
148 ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
149 selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
150 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
151
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
152 return jQuery.merge( this, selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
153
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
154 // HANDLE: $("#id")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
155 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
156 elem = document.getElementById( match[2] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
157
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
158 // Check parentNode to catch when Blackberry 4.6 returns
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
159 // nodes that are no longer in the document #6963
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
160 if ( elem && elem.parentNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
161 // Handle the case where IE and Opera return items
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
162 // by name instead of ID
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
163 if ( elem.id !== match[2] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
164 return rootjQuery.find( selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
165 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
166
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
167 // Otherwise, we inject the element directly into the jQuery object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
168 this.length = 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
169 this[0] = elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
170 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
171
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
172 this.context = document;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
173 this.selector = selector;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
174 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
175 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
176
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
177 // HANDLE: $(expr, $(...))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
178 } else if ( !context || context.jquery ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
179 return (context || rootjQuery).find( selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
180
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
181 // HANDLE: $(expr, context)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
182 // (which is just equivalent to: $(context).find(expr)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
183 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
184 return this.constructor( context ).find( selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
185 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
186
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
187 // HANDLE: $(function)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
188 // Shortcut for document ready
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
189 } else if ( jQuery.isFunction( selector ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
190 return rootjQuery.ready( selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
191 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
192
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
193 if (selector.selector !== undefined) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
194 this.selector = selector.selector;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
195 this.context = selector.context;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
196 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
197
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
198 return jQuery.makeArray( selector, this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
199 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
200
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
201 // Start with an empty selector
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
202 selector: "",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
203
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
204 // The current version of jQuery being used
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
205 jquery: "1.5.1",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
206
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
207 // The default length of a jQuery object is 0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
208 length: 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
209
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
210 // The number of elements contained in the matched element set
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
211 size: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
212 return this.length;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
213 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
214
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
215 toArray: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
216 return slice.call( this, 0 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
217 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
218
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
219 // Get the Nth element in the matched element set OR
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
220 // Get the whole matched element set as a clean array
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
221 get: function( num ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
222 return num == null ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
223
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
224 // Return a 'clean' array
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
225 this.toArray() :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
226
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
227 // Return just the object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
228 ( num < 0 ? this[ this.length + num ] : this[ num ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
229 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
230
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
231 // Take an array of elements and push it onto the stack
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
232 // (returning the new matched element set)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
233 pushStack: function( elems, name, selector ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
234 // Build a new jQuery matched element set
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
235 var ret = this.constructor();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
236
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
237 if ( jQuery.isArray( elems ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
238 push.apply( ret, elems );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
239
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
240 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
241 jQuery.merge( ret, elems );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
242 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
243
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
244 // Add the old object onto the stack (as a reference)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
245 ret.prevObject = this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
246
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
247 ret.context = this.context;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
248
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
249 if ( name === "find" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
250 ret.selector = this.selector + (this.selector ? " " : "") + selector;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
251 } else if ( name ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
252 ret.selector = this.selector + "." + name + "(" + selector + ")";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
253 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
254
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
255 // Return the newly-formed element set
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
256 return ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
257 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
258
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
259 // Execute a callback for every element in the matched set.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
260 // (You can seed the arguments with an array of args, but this is
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
261 // only used internally.)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
262 each: function( callback, args ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
263 return jQuery.each( this, callback, args );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
264 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
265
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
266 ready: function( fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
267 // Attach the listeners
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
268 jQuery.bindReady();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
269
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
270 // Add the callback
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
271 readyList.done( fn );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
272
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
273 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
274 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
275
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
276 eq: function( i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
277 return i === -1 ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
278 this.slice( i ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
279 this.slice( i, +i + 1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
280 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
281
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
282 first: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
283 return this.eq( 0 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
284 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
285
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
286 last: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
287 return this.eq( -1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
288 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
289
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
290 slice: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
291 return this.pushStack( slice.apply( this, arguments ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
292 "slice", slice.call(arguments).join(",") );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
293 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
294
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
295 map: function( callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
296 return this.pushStack( jQuery.map(this, function( elem, i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
297 return callback.call( elem, i, elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
298 }));
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
299 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
300
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
301 end: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
302 return this.prevObject || this.constructor(null);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
303 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
304
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
305 // For internal use only.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
306 // Behaves like an Array's method, not like a jQuery method.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
307 push: push,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
308 sort: [].sort,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
309 splice: [].splice
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
310 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
311
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
312 // Give the init function the jQuery prototype for later instantiation
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
313 jQuery.fn.init.prototype = jQuery.fn;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
314
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
315 jQuery.extend = jQuery.fn.extend = function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
316 var options, name, src, copy, copyIsArray, clone,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
317 target = arguments[0] || {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
318 i = 1,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
319 length = arguments.length,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
320 deep = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
321
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
322 // Handle a deep copy situation
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
323 if ( typeof target === "boolean" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
324 deep = target;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
325 target = arguments[1] || {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
326 // skip the boolean and the target
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
327 i = 2;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
328 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
329
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
330 // Handle case when target is a string or something (possible in deep copy)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
331 if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
332 target = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
333 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
334
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
335 // extend jQuery itself if only one argument is passed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
336 if ( length === i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
337 target = this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
338 --i;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
339 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
340
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
341 for ( ; i < length; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
342 // Only deal with non-null/undefined values
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
343 if ( (options = arguments[ i ]) != null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
344 // Extend the base object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
345 for ( name in options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
346 src = target[ name ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
347 copy = options[ name ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
348
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
349 // Prevent never-ending loop
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
350 if ( target === copy ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
351 continue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
352 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
353
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
354 // Recurse if we're merging plain objects or arrays
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
355 if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
356 if ( copyIsArray ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
357 copyIsArray = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
358 clone = src && jQuery.isArray(src) ? src : [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
359
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
360 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
361 clone = src && jQuery.isPlainObject(src) ? src : {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
362 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
363
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
364 // Never move original objects, clone them
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
365 target[ name ] = jQuery.extend( deep, clone, copy );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
366
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
367 // Don't bring in undefined values
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
368 } else if ( copy !== undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
369 target[ name ] = copy;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
370 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
371 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
372 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
373 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
374
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
375 // Return the modified object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
376 return target;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
377 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
378
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
379 jQuery.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
380 noConflict: function( deep ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
381 window.$ = _$;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
382
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
383 if ( deep ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
384 window.jQuery = _jQuery;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
385 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
386
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
387 return jQuery;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
388 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
389
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
390 // Is the DOM ready to be used? Set to true once it occurs.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
391 isReady: false,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
392
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
393 // A counter to track how many items to wait for before
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
394 // the ready event fires. See #6781
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
395 readyWait: 1,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
396
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
397 // Handle when the DOM is ready
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
398 ready: function( wait ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
399 // A third-party is pushing the ready event forwards
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
400 if ( wait === true ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
401 jQuery.readyWait--;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
402 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
403
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
404 // Make sure that the DOM is not already loaded
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
405 if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
406 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
407 if ( !document.body ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
408 return setTimeout( jQuery.ready, 1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
409 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
410
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
411 // Remember that the DOM is ready
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
412 jQuery.isReady = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
413
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
414 // If a normal DOM Ready event fired, decrement, and wait if need be
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
415 if ( wait !== true && --jQuery.readyWait > 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
416 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
417 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
418
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
419 // If there are functions bound, to execute
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
420 readyList.resolveWith( document, [ jQuery ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
421
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
422 // Trigger any bound ready events
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
423 if ( jQuery.fn.trigger ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
424 jQuery( document ).trigger( "ready" ).unbind( "ready" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
425 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
426 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
427 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
428
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
429 bindReady: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
430 if ( readyBound ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
431 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
432 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
433
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
434 readyBound = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
435
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
436 // Catch cases where $(document).ready() is called after the
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
437 // browser event has already occurred.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
438 if ( document.readyState === "complete" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
439 // Handle it asynchronously to allow scripts the opportunity to delay ready
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
440 return setTimeout( jQuery.ready, 1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
441 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
442
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
443 // Mozilla, Opera and webkit nightlies currently support this event
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
444 if ( document.addEventListener ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
445 // Use the handy event callback
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
446 document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
447
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
448 // A fallback to window.onload, that will always work
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
449 window.addEventListener( "load", jQuery.ready, false );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
450
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
451 // If IE event model is used
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
452 } else if ( document.attachEvent ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
453 // ensure firing before onload,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
454 // maybe late but safe also for iframes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
455 document.attachEvent("onreadystatechange", DOMContentLoaded);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
456
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
457 // A fallback to window.onload, that will always work
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
458 window.attachEvent( "onload", jQuery.ready );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
459
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
460 // If IE and not a frame
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
461 // continually check to see if the document is ready
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
462 var toplevel = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
463
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
464 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
465 toplevel = window.frameElement == null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
466 } catch(e) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
467
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
468 if ( document.documentElement.doScroll && toplevel ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
469 doScrollCheck();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
470 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
471 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
472 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
473
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
474 // See test/unit/core.js for details concerning isFunction.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
475 // Since version 1.3, DOM methods and functions like alert
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
476 // aren't supported. They return false on IE (#2968).
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
477 isFunction: function( obj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
478 return jQuery.type(obj) === "function";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
479 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
480
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
481 isArray: Array.isArray || function( obj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
482 return jQuery.type(obj) === "array";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
483 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
484
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
485 // A crude way of determining if an object is a window
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
486 isWindow: function( obj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
487 return obj && typeof obj === "object" && "setInterval" in obj;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
488 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
489
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
490 isNaN: function( obj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
491 return obj == null || !rdigit.test( obj ) || isNaN( obj );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
492 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
493
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
494 type: function( obj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
495 return obj == null ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
496 String( obj ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
497 class2type[ toString.call(obj) ] || "object";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
498 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
499
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
500 isPlainObject: function( obj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
501 // Must be an Object.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
502 // Because of IE, we also have to check the presence of the constructor property.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
503 // Make sure that DOM nodes and window objects don't pass through, as well
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
504 if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
505 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
506 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
507
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
508 // Not own constructor property must be Object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
509 if ( obj.constructor &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
510 !hasOwn.call(obj, "constructor") &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
511 !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
512 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
513 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
514
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
515 // Own properties are enumerated firstly, so to speed up,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
516 // if last one is own, then all properties are own.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
517
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
518 var key;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
519 for ( key in obj ) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
520
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
521 return key === undefined || hasOwn.call( obj, key );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
522 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
523
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
524 isEmptyObject: function( obj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
525 for ( var name in obj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
526 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
527 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
528 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
529 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
530
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
531 error: function( msg ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
532 throw msg;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
533 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
534
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
535 parseJSON: function( data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
536 if ( typeof data !== "string" || !data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
537 return null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
538 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
539
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
540 // Make sure leading/trailing whitespace is removed (IE can't handle it)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
541 data = jQuery.trim( data );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
542
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
543 // Make sure the incoming data is actual JSON
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
544 // Logic borrowed from http://json.org/json2.js
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
545 if ( rvalidchars.test(data.replace(rvalidescape, "@")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
546 .replace(rvalidtokens, "]")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
547 .replace(rvalidbraces, "")) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
548
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
549 // Try to use the native JSON parser first
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
550 return window.JSON && window.JSON.parse ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
551 window.JSON.parse( data ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
552 (new Function("return " + data))();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
553
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
554 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
555 jQuery.error( "Invalid JSON: " + data );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
556 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
557 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
558
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
559 // Cross-browser xml parsing
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
560 // (xml & tmp used internally)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
561 parseXML: function( data , xml , tmp ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
562
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
563 if ( window.DOMParser ) { // Standard
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
564 tmp = new DOMParser();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
565 xml = tmp.parseFromString( data , "text/xml" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
566 } else { // IE
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
567 xml = new ActiveXObject( "Microsoft.XMLDOM" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
568 xml.async = "false";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
569 xml.loadXML( data );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
570 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
571
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
572 tmp = xml.documentElement;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
573
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
574 if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
575 jQuery.error( "Invalid XML: " + data );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
576 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
577
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
578 return xml;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
579 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
580
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
581 noop: function() {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
582
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
583 // Evalulates a script in a global context
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
584 globalEval: function( data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
585 if ( data && rnotwhite.test(data) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
586 // Inspired by code by Andrea Giammarchi
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
587 // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
588 var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
589 script = document.createElement( "script" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
590
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
591 if ( jQuery.support.scriptEval() ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
592 script.appendChild( document.createTextNode( data ) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
593 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
594 script.text = data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
595 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
596
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
597 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
598 // This arises when a base node is used (#2709).
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
599 head.insertBefore( script, head.firstChild );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
600 head.removeChild( script );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
601 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
602 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
603
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
604 nodeName: function( elem, name ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
605 return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
606 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
607
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
608 // args is for internal usage only
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
609 each: function( object, callback, args ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
610 var name, i = 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
611 length = object.length,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
612 isObj = length === undefined || jQuery.isFunction(object);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
613
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
614 if ( args ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
615 if ( isObj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
616 for ( name in object ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
617 if ( callback.apply( object[ name ], args ) === false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
618 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
619 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
620 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
621 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
622 for ( ; i < length; ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
623 if ( callback.apply( object[ i++ ], args ) === false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
624 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
625 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
626 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
627 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
628
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
629 // A special, fast, case for the most common use of each
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
630 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
631 if ( isObj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
632 for ( name in object ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
633 if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
634 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
635 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
636 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
637 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
638 for ( var value = object[0];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
639 i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
640 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
641 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
642
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
643 return object;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
644 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
645
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
646 // Use native String.trim function wherever possible
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
647 trim: trim ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
648 function( text ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
649 return text == null ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
650 "" :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
651 trim.call( text );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
652 } :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
653
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
654 // Otherwise use our own trimming functionality
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
655 function( text ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
656 return text == null ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
657 "" :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
658 text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
659 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
660
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
661 // results is for internal usage only
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
662 makeArray: function( array, results ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
663 var ret = results || [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
664
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
665 if ( array != null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
666 // The window, strings (and functions) also have 'length'
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
667 // The extra typeof function check is to prevent crashes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
668 // in Safari 2 (See: #3039)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
669 // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
670 var type = jQuery.type(array);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
671
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
672 if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
673 push.call( ret, array );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
674 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
675 jQuery.merge( ret, array );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
676 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
677 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
678
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
679 return ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
680 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
681
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
682 inArray: function( elem, array ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
683 if ( array.indexOf ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
684 return array.indexOf( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
685 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
686
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
687 for ( var i = 0, length = array.length; i < length; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
688 if ( array[ i ] === elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
689 return i;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
690 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
691 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
692
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
693 return -1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
694 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
695
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
696 merge: function( first, second ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
697 var i = first.length,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
698 j = 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
699
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
700 if ( typeof second.length === "number" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
701 for ( var l = second.length; j < l; j++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
702 first[ i++ ] = second[ j ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
703 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
704
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
705 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
706 while ( second[j] !== undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
707 first[ i++ ] = second[ j++ ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
708 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
709 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
710
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
711 first.length = i;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
712
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
713 return first;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
714 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
715
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
716 grep: function( elems, callback, inv ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
717 var ret = [], retVal;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
718 inv = !!inv;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
719
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
720 // Go through the array, only saving the items
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
721 // that pass the validator function
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
722 for ( var i = 0, length = elems.length; i < length; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
723 retVal = !!callback( elems[ i ], i );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
724 if ( inv !== retVal ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
725 ret.push( elems[ i ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
726 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
727 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
728
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
729 return ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
730 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
731
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
732 // arg is for internal usage only
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
733 map: function( elems, callback, arg ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
734 var ret = [], value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
735
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
736 // Go through the array, translating each of the items to their
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
737 // new value (or values).
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
738 for ( var i = 0, length = elems.length; i < length; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
739 value = callback( elems[ i ], i, arg );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
740
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
741 if ( value != null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
742 ret[ ret.length ] = value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
743 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
744 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
745
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
746 // Flatten any nested arrays
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
747 return ret.concat.apply( [], ret );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
748 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
749
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
750 // A global GUID counter for objects
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
751 guid: 1,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
752
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
753 proxy: function( fn, proxy, thisObject ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
754 if ( arguments.length === 2 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
755 if ( typeof proxy === "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
756 thisObject = fn;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
757 fn = thisObject[ proxy ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
758 proxy = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
759
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
760 } else if ( proxy && !jQuery.isFunction( proxy ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
761 thisObject = proxy;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
762 proxy = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
763 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
764 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
765
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
766 if ( !proxy && fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
767 proxy = function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
768 return fn.apply( thisObject || this, arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
769 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
770 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
771
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
772 // Set the guid of unique handler to the same of original handler, so it can be removed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
773 if ( fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
774 proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
775 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
776
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
777 // So proxy can be declared as an argument
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
778 return proxy;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
779 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
780
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
781 // Mutifunctional method to get and set values to a collection
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
782 // The value/s can be optionally by executed if its a function
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
783 access: function( elems, key, value, exec, fn, pass ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
784 var length = elems.length;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
785
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
786 // Setting many attributes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
787 if ( typeof key === "object" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
788 for ( var k in key ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
789 jQuery.access( elems, k, key[k], exec, fn, value );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
790 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
791 return elems;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
792 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
793
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
794 // Setting one attribute
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
795 if ( value !== undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
796 // Optionally, function values get executed if exec is true
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
797 exec = !pass && exec && jQuery.isFunction(value);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
798
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
799 for ( var i = 0; i < length; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
800 fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
801 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
802
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
803 return elems;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
804 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
805
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
806 // Getting an attribute
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
807 return length ? fn( elems[0], key ) : undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
808 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
809
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
810 now: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
811 return (new Date()).getTime();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
812 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
813
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
814 // Create a simple deferred (one callbacks list)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
815 _Deferred: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
816 var // callbacks list
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
817 callbacks = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
818 // stored [ context , args ]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
819 fired,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
820 // to avoid firing when already doing so
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
821 firing,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
822 // flag to know if the deferred has been cancelled
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
823 cancelled,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
824 // the deferred itself
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
825 deferred = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
826
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
827 // done( f1, f2, ...)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
828 done: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
829 if ( !cancelled ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
830 var args = arguments,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
831 i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
832 length,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
833 elem,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
834 type,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
835 _fired;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
836 if ( fired ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
837 _fired = fired;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
838 fired = 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
839 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
840 for ( i = 0, length = args.length; i < length; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
841 elem = args[ i ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
842 type = jQuery.type( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
843 if ( type === "array" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
844 deferred.done.apply( deferred, elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
845 } else if ( type === "function" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
846 callbacks.push( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
847 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
848 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
849 if ( _fired ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
850 deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
851 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
852 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
853 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
854 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
855
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
856 // resolve with given context and args
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
857 resolveWith: function( context, args ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
858 if ( !cancelled && !fired && !firing ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
859 firing = 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
860 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
861 while( callbacks[ 0 ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
862 callbacks.shift().apply( context, args );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
863 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
864 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
865 // We have to add a catch block for
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
866 // IE prior to 8 or else the finally
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
867 // block will never get executed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
868 catch (e) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
869 throw e;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
870 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
871 finally {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
872 fired = [ context, args ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
873 firing = 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
874 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
875 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
876 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
877 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
878
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
879 // resolve with this as context and given arguments
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
880 resolve: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
881 deferred.resolveWith( jQuery.isFunction( this.promise ) ? this.promise() : this, arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
882 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
883 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
884
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
885 // Has this deferred been resolved?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
886 isResolved: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
887 return !!( firing || fired );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
888 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
889
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
890 // Cancel
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
891 cancel: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
892 cancelled = 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
893 callbacks = [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
894 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
895 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
896 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
897
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
898 return deferred;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
899 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
900
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
901 // Full fledged deferred (two callbacks list)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
902 Deferred: function( func ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
903 var deferred = jQuery._Deferred(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
904 failDeferred = jQuery._Deferred(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
905 promise;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
906 // Add errorDeferred methods, then and promise
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
907 jQuery.extend( deferred, {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
908 then: function( doneCallbacks, failCallbacks ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
909 deferred.done( doneCallbacks ).fail( failCallbacks );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
910 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
911 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
912 fail: failDeferred.done,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
913 rejectWith: failDeferred.resolveWith,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
914 reject: failDeferred.resolve,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
915 isRejected: failDeferred.isResolved,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
916 // Get a promise for this deferred
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
917 // If obj is provided, the promise aspect is added to the object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
918 promise: function( obj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
919 if ( obj == null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
920 if ( promise ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
921 return promise;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
922 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
923 promise = obj = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
924 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
925 var i = promiseMethods.length;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
926 while( i-- ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
927 obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
928 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
929 return obj;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
930 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
931 } );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
932 // Make sure only one callback list will be used
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
933 deferred.done( failDeferred.cancel ).fail( deferred.cancel );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
934 // Unexpose cancel
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
935 delete deferred.cancel;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
936 // Call given func if any
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
937 if ( func ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
938 func.call( deferred, deferred );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
939 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
940 return deferred;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
941 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
942
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
943 // Deferred helper
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
944 when: function( object ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
945 var lastIndex = arguments.length,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
946 deferred = lastIndex <= 1 && object && jQuery.isFunction( object.promise ) ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
947 object :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
948 jQuery.Deferred(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
949 promise = deferred.promise();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
950
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
951 if ( lastIndex > 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
952 var array = slice.call( arguments, 0 ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
953 count = lastIndex,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
954 iCallback = function( index ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
955 return function( value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
956 array[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
957 if ( !( --count ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
958 deferred.resolveWith( promise, array );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
959 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
960 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
961 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
962 while( ( lastIndex-- ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
963 object = array[ lastIndex ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
964 if ( object && jQuery.isFunction( object.promise ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
965 object.promise().then( iCallback(lastIndex), deferred.reject );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
966 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
967 --count;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
968 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
969 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
970 if ( !count ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
971 deferred.resolveWith( promise, array );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
972 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
973 } else if ( deferred !== object ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
974 deferred.resolve( object );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
975 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
976 return promise;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
977 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
978
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
979 // Use of jQuery.browser is frowned upon.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
980 // More details: http://docs.jquery.com/Utilities/jQuery.browser
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
981 uaMatch: function( ua ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
982 ua = ua.toLowerCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
983
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
984 var match = rwebkit.exec( ua ) ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
985 ropera.exec( ua ) ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
986 rmsie.exec( ua ) ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
987 ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
988 [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
989
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
990 return { browser: match[1] || "", version: match[2] || "0" };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
991 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
992
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
993 sub: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
994 function jQuerySubclass( selector, context ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
995 return new jQuerySubclass.fn.init( selector, context );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
996 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
997 jQuery.extend( true, jQuerySubclass, this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
998 jQuerySubclass.superclass = this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
999 jQuerySubclass.fn = jQuerySubclass.prototype = this();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1000 jQuerySubclass.fn.constructor = jQuerySubclass;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1001 jQuerySubclass.subclass = this.subclass;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1002 jQuerySubclass.fn.init = function init( selector, context ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1003 if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1004 context = jQuerySubclass(context);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1005 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1006
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1007 return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1008 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1009 jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1010 var rootjQuerySubclass = jQuerySubclass(document);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1011 return jQuerySubclass;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1012 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1013
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1014 browser: {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1015 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1016
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1017 // Create readyList deferred
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1018 readyList = jQuery._Deferred();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1019
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1020 // Populate the class2type map
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1021 jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1022 class2type[ "[object " + name + "]" ] = name.toLowerCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1023 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1024
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1025 browserMatch = jQuery.uaMatch( userAgent );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1026 if ( browserMatch.browser ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1027 jQuery.browser[ browserMatch.browser ] = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1028 jQuery.browser.version = browserMatch.version;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1029 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1030
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1031 // Deprecated, use jQuery.browser.webkit instead
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1032 if ( jQuery.browser.webkit ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1033 jQuery.browser.safari = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1034 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1035
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1036 if ( indexOf ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1037 jQuery.inArray = function( elem, array ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1038 return indexOf.call( array, elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1039 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1040 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1041
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1042 // IE doesn't match non-breaking spaces with \s
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1043 if ( rnotwhite.test( "\xA0" ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1044 trimLeft = /^[\s\xA0]+/;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1045 trimRight = /[\s\xA0]+$/;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1046 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1047
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1048 // All jQuery objects should point back to these
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1049 rootjQuery = jQuery(document);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1050
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1051 // Cleanup functions for the document ready method
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1052 if ( document.addEventListener ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1053 DOMContentLoaded = function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1054 document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1055 jQuery.ready();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1056 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1057
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1058 } else if ( document.attachEvent ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1059 DOMContentLoaded = function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1060 // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1061 if ( document.readyState === "complete" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1062 document.detachEvent( "onreadystatechange", DOMContentLoaded );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1063 jQuery.ready();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1064 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1065 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1066 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1067
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1068 // The DOM ready check for Internet Explorer
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1069 function doScrollCheck() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1070 if ( jQuery.isReady ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1071 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1072 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1073
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1074 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1075 // If IE is used, use the trick by Diego Perini
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1076 // http://javascript.nwbox.com/IEContentLoaded/
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1077 document.documentElement.doScroll("left");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1078 } catch(e) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1079 setTimeout( doScrollCheck, 1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1080 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1081 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1082
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1083 // and execute any waiting functions
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1084 jQuery.ready();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1085 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1086
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1087 // Expose jQuery to the global object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1088 return jQuery;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1089
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1090 })();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1091
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1092
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1093 (function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1094
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1095 jQuery.support = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1096
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1097 var div = document.createElement("div");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1098
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1099 div.style.display = "none";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1100 div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1101
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1102 var all = div.getElementsByTagName("*"),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1103 a = div.getElementsByTagName("a")[0],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1104 select = document.createElement("select"),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1105 opt = select.appendChild( document.createElement("option") ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1106 input = div.getElementsByTagName("input")[0];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1107
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1108 // Can't get basic test support
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1109 if ( !all || !all.length || !a ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1110 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1111 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1112
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1113 jQuery.support = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1114 // IE strips leading whitespace when .innerHTML is used
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1115 leadingWhitespace: div.firstChild.nodeType === 3,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1116
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1117 // Make sure that tbody elements aren't automatically inserted
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1118 // IE will insert them into empty tables
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1119 tbody: !div.getElementsByTagName("tbody").length,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1120
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1121 // Make sure that link elements get serialized correctly by innerHTML
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1122 // This requires a wrapper element in IE
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1123 htmlSerialize: !!div.getElementsByTagName("link").length,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1124
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1125 // Get the style information from getAttribute
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1126 // (IE uses .cssText insted)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1127 style: /red/.test( a.getAttribute("style") ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1128
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1129 // Make sure that URLs aren't manipulated
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1130 // (IE normalizes it by default)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1131 hrefNormalized: a.getAttribute("href") === "/a",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1132
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1133 // Make sure that element opacity exists
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1134 // (IE uses filter instead)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1135 // Use a regex to work around a WebKit issue. See #5145
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1136 opacity: /^0.55$/.test( a.style.opacity ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1137
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1138 // Verify style float existence
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1139 // (IE uses styleFloat instead of cssFloat)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1140 cssFloat: !!a.style.cssFloat,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1141
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1142 // Make sure that if no value is specified for a checkbox
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1143 // that it defaults to "on".
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1144 // (WebKit defaults to "" instead)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1145 checkOn: input.value === "on",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1146
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1147 // Make sure that a selected-by-default option has a working selected property.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1148 // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1149 optSelected: opt.selected,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1150
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1151 // Will be defined later
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1152 deleteExpando: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1153 optDisabled: false,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1154 checkClone: false,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1155 noCloneEvent: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1156 noCloneChecked: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1157 boxModel: null,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1158 inlineBlockNeedsLayout: false,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1159 shrinkWrapBlocks: false,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1160 reliableHiddenOffsets: true
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1161 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1162
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1163 input.checked = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1164 jQuery.support.noCloneChecked = input.cloneNode( true ).checked;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1165
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1166 // Make sure that the options inside disabled selects aren't marked as disabled
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1167 // (WebKit marks them as diabled)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1168 select.disabled = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1169 jQuery.support.optDisabled = !opt.disabled;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1170
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1171 var _scriptEval = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1172 jQuery.support.scriptEval = function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1173 if ( _scriptEval === null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1174 var root = document.documentElement,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1175 script = document.createElement("script"),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1176 id = "script" + jQuery.now();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1177
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1178 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1179 script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1180 } catch(e) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1181
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1182 root.insertBefore( script, root.firstChild );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1183
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1184 // Make sure that the execution of code works by injecting a script
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1185 // tag with appendChild/createTextNode
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1186 // (IE doesn't support this, fails, and uses .text instead)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1187 if ( window[ id ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1188 _scriptEval = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1189 delete window[ id ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1190 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1191 _scriptEval = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1192 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1193
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1194 root.removeChild( script );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1195 // release memory in IE
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1196 root = script = id = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1197 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1198
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1199 return _scriptEval;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1200 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1201
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1202 // Test to see if it's possible to delete an expando from an element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1203 // Fails in Internet Explorer
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1204 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1205 delete div.test;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1206
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1207 } catch(e) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1208 jQuery.support.deleteExpando = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1209 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1210
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1211 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1212 div.attachEvent("onclick", function click() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1213 // Cloning a node shouldn't copy over any
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1214 // bound event handlers (IE does this)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1215 jQuery.support.noCloneEvent = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1216 div.detachEvent("onclick", click);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1217 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1218 div.cloneNode(true).fireEvent("onclick");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1219 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1220
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1221 div = document.createElement("div");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1222 div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1223
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1224 var fragment = document.createDocumentFragment();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1225 fragment.appendChild( div.firstChild );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1226
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1227 // WebKit doesn't clone checked state correctly in fragments
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1228 jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1229
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1230 // Figure out if the W3C box model works as expected
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1231 // document.body must exist before we can do this
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1232 jQuery(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1233 var div = document.createElement("div"),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1234 body = document.getElementsByTagName("body")[0];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1235
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1236 // Frameset documents with no body should not run this code
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1237 if ( !body ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1238 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1239 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1240
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1241 div.style.width = div.style.paddingLeft = "1px";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1242 body.appendChild( div );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1243 jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1244
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1245 if ( "zoom" in div.style ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1246 // Check if natively block-level elements act like inline-block
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1247 // elements when setting their display to 'inline' and giving
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1248 // them layout
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1249 // (IE < 8 does this)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1250 div.style.display = "inline";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1251 div.style.zoom = 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1252 jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1253
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1254 // Check if elements with layout shrink-wrap their children
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1255 // (IE 6 does this)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1256 div.style.display = "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1257 div.innerHTML = "<div style='width:4px;'></div>";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1258 jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1259 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1260
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1261 div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1262 var tds = div.getElementsByTagName("td");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1263
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1264 // Check if table cells still have offsetWidth/Height when they are set
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1265 // to display:none and there are still other visible table cells in a
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1266 // table row; if so, offsetWidth/Height are not reliable for use when
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1267 // determining if an element has been hidden directly using
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1268 // display:none (it is still safe to use offsets if a parent element is
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1269 // hidden; don safety goggles and see bug #4512 for more information).
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1270 // (only IE 8 fails this test)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1271 jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1272
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1273 tds[0].style.display = "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1274 tds[1].style.display = "none";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1275
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1276 // Check if empty table cells still have offsetWidth/Height
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1277 // (IE < 8 fail this test)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1278 jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1279 div.innerHTML = "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1280
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1281 body.removeChild( div ).style.display = "none";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1282 div = tds = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1283 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1284
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1285 // Technique from Juriy Zaytsev
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1286 // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1287 var eventSupported = function( eventName ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1288 var el = document.createElement("div");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1289 eventName = "on" + eventName;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1290
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1291 // We only care about the case where non-standard event systems
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1292 // are used, namely in IE. Short-circuiting here helps us to
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1293 // avoid an eval call (in setAttribute) which can cause CSP
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1294 // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1295 if ( !el.attachEvent ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1296 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1297 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1298
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1299 var isSupported = (eventName in el);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1300 if ( !isSupported ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1301 el.setAttribute(eventName, "return;");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1302 isSupported = typeof el[eventName] === "function";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1303 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1304 el = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1305
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1306 return isSupported;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1307 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1308
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1309 jQuery.support.submitBubbles = eventSupported("submit");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1310 jQuery.support.changeBubbles = eventSupported("change");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1311
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1312 // release memory in IE
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1313 div = all = a = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1314 })();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1315
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1316
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1317
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1318 var rbrace = /^(?:\{.*\}|\[.*\])$/;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1319
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1320 jQuery.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1321 cache: {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1322
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1323 // Please use with caution
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1324 uuid: 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1325
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1326 // Unique for each copy of jQuery on the page
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1327 // Non-digits removed to match rinlinejQuery
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1328 expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1329
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1330 // The following elements throw uncatchable exceptions if you
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1331 // attempt to add expando properties to them.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1332 noData: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1333 "embed": true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1334 // Ban all objects except for Flash (which handle expandos)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1335 "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1336 "applet": true
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1337 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1338
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1339 hasData: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1340 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1341
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1342 return !!elem && !isEmptyDataObject( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1343 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1344
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1345 data: function( elem, name, data, pvt /* Internal Use Only */ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1346 if ( !jQuery.acceptData( elem ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1347 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1348 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1349
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1350 var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1351
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1352 // We have to handle DOM nodes and JS objects differently because IE6-7
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1353 // can't GC object references properly across the DOM-JS boundary
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1354 isNode = elem.nodeType,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1355
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1356 // Only DOM nodes need the global jQuery cache; JS object data is
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1357 // attached directly to the object so GC can occur automatically
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1358 cache = isNode ? jQuery.cache : elem,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1359
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1360 // Only defining an ID for JS objects if its cache already exists allows
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1361 // the code to shortcut on the same path as a DOM node with no cache
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1362 id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1363
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1364 // Avoid doing any more work than we need to when trying to get data on an
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1365 // object that has no data at all
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1366 if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1367 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1368 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1369
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1370 if ( !id ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1371 // Only DOM nodes need a new unique ID for each element since their data
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1372 // ends up in the global cache
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1373 if ( isNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1374 elem[ jQuery.expando ] = id = ++jQuery.uuid;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1375 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1376 id = jQuery.expando;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1377 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1378 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1379
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1380 if ( !cache[ id ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1381 cache[ id ] = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1382
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1383 // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1384 // metadata on plain JS objects when the object is serialized using
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1385 // JSON.stringify
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1386 if ( !isNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1387 cache[ id ].toJSON = jQuery.noop;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1388 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1389 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1390
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1391 // An object can be passed to jQuery.data instead of a key/value pair; this gets
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1392 // shallow copied over onto the existing cache
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1393 if ( typeof name === "object" || typeof name === "function" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1394 if ( pvt ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1395 cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1396 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1397 cache[ id ] = jQuery.extend(cache[ id ], name);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1398 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1399 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1400
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1401 thisCache = cache[ id ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1402
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1403 // Internal jQuery data is stored in a separate object inside the object's data
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1404 // cache in order to avoid key collisions between internal data and user-defined
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1405 // data
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1406 if ( pvt ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1407 if ( !thisCache[ internalKey ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1408 thisCache[ internalKey ] = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1409 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1410
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1411 thisCache = thisCache[ internalKey ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1412 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1413
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1414 if ( data !== undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1415 thisCache[ name ] = data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1416 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1417
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1418 // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1419 // not attempt to inspect the internal events object using jQuery.data, as this
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1420 // internal data object is undocumented and subject to change.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1421 if ( name === "events" && !thisCache[name] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1422 return thisCache[ internalKey ] && thisCache[ internalKey ].events;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1423 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1424
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1425 return getByName ? thisCache[ name ] : thisCache;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1426 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1427
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1428 removeData: function( elem, name, pvt /* Internal Use Only */ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1429 if ( !jQuery.acceptData( elem ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1430 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1431 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1432
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1433 var internalKey = jQuery.expando, isNode = elem.nodeType,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1434
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1435 // See jQuery.data for more information
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1436 cache = isNode ? jQuery.cache : elem,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1437
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1438 // See jQuery.data for more information
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1439 id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1440
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1441 // If there is already no cache entry for this object, there is no
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1442 // purpose in continuing
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1443 if ( !cache[ id ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1444 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1445 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1446
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1447 if ( name ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1448 var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1449
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1450 if ( thisCache ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1451 delete thisCache[ name ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1452
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1453 // If there is no data left in the cache, we want to continue
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1454 // and let the cache object itself get destroyed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1455 if ( !isEmptyDataObject(thisCache) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1456 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1457 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1458 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1459 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1460
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1461 // See jQuery.data for more information
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1462 if ( pvt ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1463 delete cache[ id ][ internalKey ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1464
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1465 // Don't destroy the parent cache unless the internal data object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1466 // had been the only thing left in it
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1467 if ( !isEmptyDataObject(cache[ id ]) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1468 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1469 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1470 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1471
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1472 var internalCache = cache[ id ][ internalKey ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1473
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1474 // Browsers that fail expando deletion also refuse to delete expandos on
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1475 // the window, but it will allow it on all other JS objects; other browsers
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1476 // don't care
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1477 if ( jQuery.support.deleteExpando || cache != window ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1478 delete cache[ id ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1479 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1480 cache[ id ] = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1481 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1482
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1483 // We destroyed the entire user cache at once because it's faster than
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1484 // iterating through each key, but we need to continue to persist internal
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1485 // data if it existed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1486 if ( internalCache ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1487 cache[ id ] = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1488 // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1489 // metadata on plain JS objects when the object is serialized using
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1490 // JSON.stringify
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1491 if ( !isNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1492 cache[ id ].toJSON = jQuery.noop;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1493 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1494
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1495 cache[ id ][ internalKey ] = internalCache;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1496
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1497 // Otherwise, we need to eliminate the expando on the node to avoid
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1498 // false lookups in the cache for entries that no longer exist
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1499 } else if ( isNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1500 // IE does not allow us to delete expando properties from nodes,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1501 // nor does it have a removeAttribute function on Document nodes;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1502 // we must handle all of these cases
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1503 if ( jQuery.support.deleteExpando ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1504 delete elem[ jQuery.expando ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1505 } else if ( elem.removeAttribute ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1506 elem.removeAttribute( jQuery.expando );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1507 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1508 elem[ jQuery.expando ] = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1509 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1510 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1511 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1512
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1513 // For internal use only.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1514 _data: function( elem, name, data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1515 return jQuery.data( elem, name, data, true );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1516 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1517
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1518 // A method for determining if a DOM node can handle the data expando
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1519 acceptData: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1520 if ( elem.nodeName ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1521 var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1522
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1523 if ( match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1524 return !(match === true || elem.getAttribute("classid") !== match);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1525 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1526 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1527
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1528 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1529 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1530 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1531
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1532 jQuery.fn.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1533 data: function( key, value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1534 var data = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1535
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1536 if ( typeof key === "undefined" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1537 if ( this.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1538 data = jQuery.data( this[0] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1539
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1540 if ( this[0].nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1541 var attr = this[0].attributes, name;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1542 for ( var i = 0, l = attr.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1543 name = attr[i].name;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1544
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1545 if ( name.indexOf( "data-" ) === 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1546 name = name.substr( 5 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1547 dataAttr( this[0], name, data[ name ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1548 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1549 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1550 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1551 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1552
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1553 return data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1554
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1555 } else if ( typeof key === "object" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1556 return this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1557 jQuery.data( this, key );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1558 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1559 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1560
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1561 var parts = key.split(".");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1562 parts[1] = parts[1] ? "." + parts[1] : "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1563
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1564 if ( value === undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1565 data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1566
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1567 // Try to fetch any internally stored data first
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1568 if ( data === undefined && this.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1569 data = jQuery.data( this[0], key );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1570 data = dataAttr( this[0], key, data );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1571 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1572
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1573 return data === undefined && parts[1] ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1574 this.data( parts[0] ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1575 data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1576
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1577 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1578 return this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1579 var $this = jQuery( this ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1580 args = [ parts[0], value ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1581
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1582 $this.triggerHandler( "setData" + parts[1] + "!", args );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1583 jQuery.data( this, key, value );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1584 $this.triggerHandler( "changeData" + parts[1] + "!", args );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1585 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1586 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1587 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1588
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1589 removeData: function( key ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1590 return this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1591 jQuery.removeData( this, key );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1592 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1593 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1594 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1595
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1596 function dataAttr( elem, key, data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1597 // If nothing was found internally, try to fetch any
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1598 // data from the HTML5 data-* attribute
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1599 if ( data === undefined && elem.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1600 data = elem.getAttribute( "data-" + key );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1601
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1602 if ( typeof data === "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1603 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1604 data = data === "true" ? true :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1605 data === "false" ? false :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1606 data === "null" ? null :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1607 !jQuery.isNaN( data ) ? parseFloat( data ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1608 rbrace.test( data ) ? jQuery.parseJSON( data ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1609 data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1610 } catch( e ) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1611
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1612 // Make sure we set the data so it isn't changed later
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1613 jQuery.data( elem, key, data );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1614
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1615 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1616 data = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1617 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1618 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1619
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1620 return data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1621 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1622
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1623 // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1624 // property to be considered empty objects; this property always exists in
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1625 // order to make sure JSON.stringify does not expose internal metadata
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1626 function isEmptyDataObject( obj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1627 for ( var name in obj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1628 if ( name !== "toJSON" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1629 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1630 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1631 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1632
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1633 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1634 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1635
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1636
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1637
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1638
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1639 jQuery.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1640 queue: function( elem, type, data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1641 if ( !elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1642 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1643 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1644
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1645 type = (type || "fx") + "queue";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1646 var q = jQuery._data( elem, type );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1647
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1648 // Speed up dequeue by getting out quickly if this is just a lookup
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1649 if ( !data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1650 return q || [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1651 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1652
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1653 if ( !q || jQuery.isArray(data) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1654 q = jQuery._data( elem, type, jQuery.makeArray(data) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1655
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1656 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1657 q.push( data );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1658 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1659
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1660 return q;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1661 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1662
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1663 dequeue: function( elem, type ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1664 type = type || "fx";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1665
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1666 var queue = jQuery.queue( elem, type ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1667 fn = queue.shift();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1668
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1669 // If the fx queue is dequeued, always remove the progress sentinel
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1670 if ( fn === "inprogress" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1671 fn = queue.shift();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1672 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1673
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1674 if ( fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1675 // Add a progress sentinel to prevent the fx queue from being
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1676 // automatically dequeued
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1677 if ( type === "fx" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1678 queue.unshift("inprogress");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1679 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1680
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1681 fn.call(elem, function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1682 jQuery.dequeue(elem, type);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1683 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1684 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1685
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1686 if ( !queue.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1687 jQuery.removeData( elem, type + "queue", true );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1688 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1689 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1690 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1691
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1692 jQuery.fn.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1693 queue: function( type, data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1694 if ( typeof type !== "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1695 data = type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1696 type = "fx";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1697 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1698
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1699 if ( data === undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1700 return jQuery.queue( this[0], type );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1701 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1702 return this.each(function( i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1703 var queue = jQuery.queue( this, type, data );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1704
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1705 if ( type === "fx" && queue[0] !== "inprogress" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1706 jQuery.dequeue( this, type );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1707 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1708 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1709 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1710 dequeue: function( type ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1711 return this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1712 jQuery.dequeue( this, type );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1713 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1714 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1715
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1716 // Based off of the plugin by Clint Helfers, with permission.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1717 // http://blindsignals.com/index.php/2009/07/jquery-delay/
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1718 delay: function( time, type ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1719 time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1720 type = type || "fx";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1721
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1722 return this.queue( type, function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1723 var elem = this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1724 setTimeout(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1725 jQuery.dequeue( elem, type );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1726 }, time );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1727 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1728 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1729
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1730 clearQueue: function( type ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1731 return this.queue( type || "fx", [] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1732 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1733 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1734
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1735
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1736
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1737
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1738 var rclass = /[\n\t\r]/g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1739 rspaces = /\s+/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1740 rreturn = /\r/g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1741 rspecialurl = /^(?:href|src|style)$/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1742 rtype = /^(?:button|input)$/i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1743 rfocusable = /^(?:button|input|object|select|textarea)$/i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1744 rclickable = /^a(?:rea)?$/i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1745 rradiocheck = /^(?:radio|checkbox)$/i;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1746
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1747 jQuery.props = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1748 "for": "htmlFor",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1749 "class": "className",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1750 readonly: "readOnly",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1751 maxlength: "maxLength",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1752 cellspacing: "cellSpacing",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1753 rowspan: "rowSpan",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1754 colspan: "colSpan",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1755 tabindex: "tabIndex",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1756 usemap: "useMap",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1757 frameborder: "frameBorder"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1758 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1759
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1760 jQuery.fn.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1761 attr: function( name, value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1762 return jQuery.access( this, name, value, true, jQuery.attr );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1763 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1764
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1765 removeAttr: function( name, fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1766 return this.each(function(){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1767 jQuery.attr( this, name, "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1768 if ( this.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1769 this.removeAttribute( name );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1770 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1771 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1772 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1773
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1774 addClass: function( value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1775 if ( jQuery.isFunction(value) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1776 return this.each(function(i) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1777 var self = jQuery(this);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1778 self.addClass( value.call(this, i, self.attr("class")) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1779 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1780 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1781
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1782 if ( value && typeof value === "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1783 var classNames = (value || "").split( rspaces );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1784
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1785 for ( var i = 0, l = this.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1786 var elem = this[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1787
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1788 if ( elem.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1789 if ( !elem.className ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1790 elem.className = value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1791
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1792 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1793 var className = " " + elem.className + " ",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1794 setClass = elem.className;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1795
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1796 for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1797 if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1798 setClass += " " + classNames[c];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1799 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1800 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1801 elem.className = jQuery.trim( setClass );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1802 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1803 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1804 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1805 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1806
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1807 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1808 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1809
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1810 removeClass: function( value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1811 if ( jQuery.isFunction(value) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1812 return this.each(function(i) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1813 var self = jQuery(this);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1814 self.removeClass( value.call(this, i, self.attr("class")) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1815 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1816 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1817
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1818 if ( (value && typeof value === "string") || value === undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1819 var classNames = (value || "").split( rspaces );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1820
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1821 for ( var i = 0, l = this.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1822 var elem = this[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1823
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1824 if ( elem.nodeType === 1 && elem.className ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1825 if ( value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1826 var className = (" " + elem.className + " ").replace(rclass, " ");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1827 for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1828 className = className.replace(" " + classNames[c] + " ", " ");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1829 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1830 elem.className = jQuery.trim( className );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1831
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1832 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1833 elem.className = "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1834 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1835 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1836 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1837 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1838
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1839 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1840 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1841
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1842 toggleClass: function( value, stateVal ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1843 var type = typeof value,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1844 isBool = typeof stateVal === "boolean";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1845
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1846 if ( jQuery.isFunction( value ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1847 return this.each(function(i) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1848 var self = jQuery(this);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1849 self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1850 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1851 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1852
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1853 return this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1854 if ( type === "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1855 // toggle individual class names
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1856 var className,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1857 i = 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1858 self = jQuery( this ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1859 state = stateVal,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1860 classNames = value.split( rspaces );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1861
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1862 while ( (className = classNames[ i++ ]) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1863 // check each className given, space seperated list
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1864 state = isBool ? state : !self.hasClass( className );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1865 self[ state ? "addClass" : "removeClass" ]( className );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1866 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1867
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1868 } else if ( type === "undefined" || type === "boolean" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1869 if ( this.className ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1870 // store className if set
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1871 jQuery._data( this, "__className__", this.className );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1872 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1873
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1874 // toggle whole className
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1875 this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1876 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1877 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1878 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1879
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1880 hasClass: function( selector ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1881 var className = " " + selector + " ";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1882 for ( var i = 0, l = this.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1883 if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1884 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1885 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1886 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1887
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1888 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1889 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1890
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1891 val: function( value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1892 if ( !arguments.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1893 var elem = this[0];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1894
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1895 if ( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1896 if ( jQuery.nodeName( elem, "option" ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1897 // attributes.value is undefined in Blackberry 4.7 but
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1898 // uses .value. See #6932
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1899 var val = elem.attributes.value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1900 return !val || val.specified ? elem.value : elem.text;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1901 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1902
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1903 // We need to handle select boxes special
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1904 if ( jQuery.nodeName( elem, "select" ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1905 var index = elem.selectedIndex,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1906 values = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1907 options = elem.options,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1908 one = elem.type === "select-one";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1909
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1910 // Nothing was selected
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1911 if ( index < 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1912 return null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1913 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1914
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1915 // Loop through all the selected options
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1916 for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1917 var option = options[ i ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1918
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1919 // Don't return options that are disabled or in a disabled optgroup
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1920 if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1921 (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1922
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1923 // Get the specific value for the option
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1924 value = jQuery(option).val();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1925
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1926 // We don't need an array for one selects
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1927 if ( one ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1928 return value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1929 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1930
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1931 // Multi-Selects return an array
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1932 values.push( value );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1933 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1934 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1935
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1936 // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1937 if ( one && !values.length && options.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1938 return jQuery( options[ index ] ).val();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1939 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1940
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1941 return values;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1942 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1943
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1944 // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1945 if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1946 return elem.getAttribute("value") === null ? "on" : elem.value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1947 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1948
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1949 // Everything else, we just grab the value
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1950 return (elem.value || "").replace(rreturn, "");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1951
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1952 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1953
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1954 return undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1955 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1956
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1957 var isFunction = jQuery.isFunction(value);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1958
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1959 return this.each(function(i) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1960 var self = jQuery(this), val = value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1961
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1962 if ( this.nodeType !== 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1963 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1964 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1965
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1966 if ( isFunction ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1967 val = value.call(this, i, self.val());
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1968 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1969
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1970 // Treat null/undefined as ""; convert numbers to string
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1971 if ( val == null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1972 val = "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1973 } else if ( typeof val === "number" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1974 val += "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1975 } else if ( jQuery.isArray(val) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1976 val = jQuery.map(val, function (value) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1977 return value == null ? "" : value + "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1978 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1979 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1980
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1981 if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1982 this.checked = jQuery.inArray( self.val(), val ) >= 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1983
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1984 } else if ( jQuery.nodeName( this, "select" ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1985 var values = jQuery.makeArray(val);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1986
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1987 jQuery( "option", this ).each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1988 this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1989 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1990
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1991 if ( !values.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1992 this.selectedIndex = -1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1993 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1994
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1995 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1996 this.value = val;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1997 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1998 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1999 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2000 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2001
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2002 jQuery.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2003 attrFn: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2004 val: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2005 css: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2006 html: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2007 text: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2008 data: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2009 width: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2010 height: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2011 offset: true
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2012 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2013
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2014 attr: function( elem, name, value, pass ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2015 // don't get/set attributes on text, comment and attribute nodes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2016 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2017 return undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2018 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2019
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2020 if ( pass && name in jQuery.attrFn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2021 return jQuery(elem)[name](value);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2022 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2023
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2024 var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2025 // Whether we are setting (or getting)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2026 set = value !== undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2027
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2028 // Try to normalize/fix the name
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2029 name = notxml && jQuery.props[ name ] || name;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2030
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2031 // Only do all the following if this is a node (faster for style)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2032 if ( elem.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2033 // These attributes require special treatment
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2034 var special = rspecialurl.test( name );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2035
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2036 // Safari mis-reports the default selected property of an option
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2037 // Accessing the parent's selectedIndex property fixes it
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2038 if ( name === "selected" && !jQuery.support.optSelected ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2039 var parent = elem.parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2040 if ( parent ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2041 parent.selectedIndex;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2042
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2043 // Make sure that it also works with optgroups, see #5701
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2044 if ( parent.parentNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2045 parent.parentNode.selectedIndex;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2046 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2047 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2048 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2049
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2050 // If applicable, access the attribute via the DOM 0 way
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2051 // 'in' checks fail in Blackberry 4.7 #6931
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2052 if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2053 if ( set ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2054 // We can't allow the type property to be changed (since it causes problems in IE)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2055 if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2056 jQuery.error( "type property can't be changed" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2057 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2058
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2059 if ( value === null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2060 if ( elem.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2061 elem.removeAttribute( name );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2062 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2063
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2064 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2065 elem[ name ] = value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2066 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2067 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2068
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2069 // browsers index elements by id/name on forms, give priority to attributes.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2070 if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2071 return elem.getAttributeNode( name ).nodeValue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2072 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2073
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2074 // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2075 // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2076 if ( name === "tabIndex" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2077 var attributeNode = elem.getAttributeNode( "tabIndex" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2078
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2079 return attributeNode && attributeNode.specified ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2080 attributeNode.value :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2081 rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2082 0 :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2083 undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2084 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2085
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2086 return elem[ name ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2087 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2088
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2089 if ( !jQuery.support.style && notxml && name === "style" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2090 if ( set ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2091 elem.style.cssText = "" + value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2092 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2093
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2094 return elem.style.cssText;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2095 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2096
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2097 if ( set ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2098 // convert the value to a string (all browsers do this but IE) see #1070
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2099 elem.setAttribute( name, "" + value );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2100 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2101
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2102 // Ensure that missing attributes return undefined
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2103 // Blackberry 4.7 returns "" from getAttribute #6938
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2104 if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2105 return undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2106 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2107
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2108 var attr = !jQuery.support.hrefNormalized && notxml && special ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2109 // Some attributes require a special call on IE
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2110 elem.getAttribute( name, 2 ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2111 elem.getAttribute( name );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2112
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2113 // Non-existent attributes return null, we normalize to undefined
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2114 return attr === null ? undefined : attr;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2115 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2116 // Handle everything which isn't a DOM element node
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2117 if ( set ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2118 elem[ name ] = value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2119 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2120 return elem[ name ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2121 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2122 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2123
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2124
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2125
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2126
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2127 var rnamespaces = /\.(.*)$/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2128 rformElems = /^(?:textarea|input|select)$/i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2129 rperiod = /\./g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2130 rspace = / /g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2131 rescape = /[^\w\s.|`]/g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2132 fcleanup = function( nm ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2133 return nm.replace(rescape, "\\$&");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2134 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2135
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2136 /*
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2137 * A number of helper functions used for managing events.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2138 * Many of the ideas behind this code originated from
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2139 * Dean Edwards' addEvent library.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2140 */
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2141 jQuery.event = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2142
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2143 // Bind an event to an element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2144 // Original by Dean Edwards
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2145 add: function( elem, types, handler, data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2146 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2147 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2148 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2149
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2150 // TODO :: Use a try/catch until it's safe to pull this out (likely 1.6)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2151 // Minor release fix for bug #8018
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2152 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2153 // For whatever reason, IE has trouble passing the window object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2154 // around, causing it to be cloned in the process
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2155 if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2156 elem = window;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2157 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2158 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2159 catch ( e ) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2160
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2161 if ( handler === false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2162 handler = returnFalse;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2163 } else if ( !handler ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2164 // Fixes bug #7229. Fix recommended by jdalton
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2165 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2166 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2167
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2168 var handleObjIn, handleObj;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2169
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2170 if ( handler.handler ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2171 handleObjIn = handler;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2172 handler = handleObjIn.handler;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2173 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2174
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2175 // Make sure that the function being executed has a unique ID
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2176 if ( !handler.guid ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2177 handler.guid = jQuery.guid++;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2178 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2179
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2180 // Init the element's event structure
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2181 var elemData = jQuery._data( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2182
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2183 // If no elemData is found then we must be trying to bind to one of the
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2184 // banned noData elements
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2185 if ( !elemData ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2186 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2187 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2188
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2189 var events = elemData.events,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2190 eventHandle = elemData.handle;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2191
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2192 if ( !events ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2193 elemData.events = events = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2194 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2195
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2196 if ( !eventHandle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2197 elemData.handle = eventHandle = function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2198 // Handle the second event of a trigger and when
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2199 // an event is called after a page has unloaded
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2200 return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2201 jQuery.event.handle.apply( eventHandle.elem, arguments ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2202 undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2203 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2204 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2205
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2206 // Add elem as a property of the handle function
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2207 // This is to prevent a memory leak with non-native events in IE.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2208 eventHandle.elem = elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2209
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2210 // Handle multiple events separated by a space
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2211 // jQuery(...).bind("mouseover mouseout", fn);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2212 types = types.split(" ");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2213
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2214 var type, i = 0, namespaces;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2215
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2216 while ( (type = types[ i++ ]) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2217 handleObj = handleObjIn ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2218 jQuery.extend({}, handleObjIn) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2219 { handler: handler, data: data };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2220
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2221 // Namespaced event handlers
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2222 if ( type.indexOf(".") > -1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2223 namespaces = type.split(".");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2224 type = namespaces.shift();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2225 handleObj.namespace = namespaces.slice(0).sort().join(".");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2226
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2227 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2228 namespaces = [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2229 handleObj.namespace = "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2230 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2231
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2232 handleObj.type = type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2233 if ( !handleObj.guid ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2234 handleObj.guid = handler.guid;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2235 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2236
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2237 // Get the current list of functions bound to this event
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2238 var handlers = events[ type ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2239 special = jQuery.event.special[ type ] || {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2240
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2241 // Init the event handler queue
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2242 if ( !handlers ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2243 handlers = events[ type ] = [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2244
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2245 // Check for a special event handler
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2246 // Only use addEventListener/attachEvent if the special
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2247 // events handler returns false
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2248 if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2249 // Bind the global event handler to the element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2250 if ( elem.addEventListener ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2251 elem.addEventListener( type, eventHandle, false );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2252
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2253 } else if ( elem.attachEvent ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2254 elem.attachEvent( "on" + type, eventHandle );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2255 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2256 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2257 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2258
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2259 if ( special.add ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2260 special.add.call( elem, handleObj );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2261
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2262 if ( !handleObj.handler.guid ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2263 handleObj.handler.guid = handler.guid;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2264 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2265 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2266
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2267 // Add the function to the element's handler list
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2268 handlers.push( handleObj );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2269
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2270 // Keep track of which events have been used, for global triggering
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2271 jQuery.event.global[ type ] = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2272 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2273
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2274 // Nullify elem to prevent memory leaks in IE
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2275 elem = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2276 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2277
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2278 global: {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2279
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2280 // Detach an event or set of events from an element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2281 remove: function( elem, types, handler, pos ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2282 // don't do events on text and comment nodes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2283 if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2284 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2285 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2286
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2287 if ( handler === false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2288 handler = returnFalse;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2289 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2290
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2291 var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2292 elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2293 events = elemData && elemData.events;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2294
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2295 if ( !elemData || !events ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2296 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2297 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2298
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2299 // types is actually an event object here
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2300 if ( types && types.type ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2301 handler = types.handler;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2302 types = types.type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2303 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2304
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2305 // Unbind all events for the element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2306 if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2307 types = types || "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2308
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2309 for ( type in events ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2310 jQuery.event.remove( elem, type + types );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2311 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2312
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2313 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2314 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2315
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2316 // Handle multiple events separated by a space
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2317 // jQuery(...).unbind("mouseover mouseout", fn);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2318 types = types.split(" ");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2319
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2320 while ( (type = types[ i++ ]) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2321 origType = type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2322 handleObj = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2323 all = type.indexOf(".") < 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2324 namespaces = [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2325
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2326 if ( !all ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2327 // Namespaced event handlers
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2328 namespaces = type.split(".");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2329 type = namespaces.shift();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2330
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2331 namespace = new RegExp("(^|\\.)" +
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2332 jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2333 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2334
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2335 eventType = events[ type ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2336
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2337 if ( !eventType ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2338 continue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2339 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2340
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2341 if ( !handler ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2342 for ( j = 0; j < eventType.length; j++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2343 handleObj = eventType[ j ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2344
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2345 if ( all || namespace.test( handleObj.namespace ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2346 jQuery.event.remove( elem, origType, handleObj.handler, j );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2347 eventType.splice( j--, 1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2348 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2349 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2350
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2351 continue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2352 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2353
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2354 special = jQuery.event.special[ type ] || {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2355
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2356 for ( j = pos || 0; j < eventType.length; j++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2357 handleObj = eventType[ j ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2358
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2359 if ( handler.guid === handleObj.guid ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2360 // remove the given handler for the given type
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2361 if ( all || namespace.test( handleObj.namespace ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2362 if ( pos == null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2363 eventType.splice( j--, 1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2364 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2365
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2366 if ( special.remove ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2367 special.remove.call( elem, handleObj );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2368 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2369 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2370
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2371 if ( pos != null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2372 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2373 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2374 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2375 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2376
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2377 // remove generic event handler if no more handlers exist
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2378 if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2379 if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2380 jQuery.removeEvent( elem, type, elemData.handle );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2381 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2382
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2383 ret = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2384 delete events[ type ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2385 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2386 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2387
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2388 // Remove the expando if it's no longer used
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2389 if ( jQuery.isEmptyObject( events ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2390 var handle = elemData.handle;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2391 if ( handle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2392 handle.elem = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2393 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2394
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2395 delete elemData.events;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2396 delete elemData.handle;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2397
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2398 if ( jQuery.isEmptyObject( elemData ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2399 jQuery.removeData( elem, undefined, true );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2400 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2401 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2402 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2403
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2404 // bubbling is internal
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2405 trigger: function( event, data, elem /*, bubbling */ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2406 // Event object or event type
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2407 var type = event.type || event,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2408 bubbling = arguments[3];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2409
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2410 if ( !bubbling ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2411 event = typeof event === "object" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2412 // jQuery.Event object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2413 event[ jQuery.expando ] ? event :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2414 // Object literal
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2415 jQuery.extend( jQuery.Event(type), event ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2416 // Just the event type (string)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2417 jQuery.Event(type);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2418
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2419 if ( type.indexOf("!") >= 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2420 event.type = type = type.slice(0, -1);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2421 event.exclusive = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2422 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2423
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2424 // Handle a global trigger
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2425 if ( !elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2426 // Don't bubble custom events when global (to avoid too much overhead)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2427 event.stopPropagation();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2428
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2429 // Only trigger if we've ever bound an event for it
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2430 if ( jQuery.event.global[ type ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2431 // XXX This code smells terrible. event.js should not be directly
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2432 // inspecting the data cache
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2433 jQuery.each( jQuery.cache, function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2434 // internalKey variable is just used to make it easier to find
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2435 // and potentially change this stuff later; currently it just
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2436 // points to jQuery.expando
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2437 var internalKey = jQuery.expando,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2438 internalCache = this[ internalKey ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2439 if ( internalCache && internalCache.events && internalCache.events[ type ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2440 jQuery.event.trigger( event, data, internalCache.handle.elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2441 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2442 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2443 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2444 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2445
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2446 // Handle triggering a single element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2447
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2448 // don't do events on text and comment nodes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2449 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2450 return undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2451 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2452
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2453 // Clean up in case it is reused
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2454 event.result = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2455 event.target = elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2456
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2457 // Clone the incoming data, if any
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2458 data = jQuery.makeArray( data );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2459 data.unshift( event );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2460 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2461
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2462 event.currentTarget = elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2463
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2464 // Trigger the event, it is assumed that "handle" is a function
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2465 var handle = jQuery._data( elem, "handle" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2466
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2467 if ( handle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2468 handle.apply( elem, data );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2469 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2470
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2471 var parent = elem.parentNode || elem.ownerDocument;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2472
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2473 // Trigger an inline bound script
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2474 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2475 if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2476 if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2477 event.result = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2478 event.preventDefault();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2479 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2480 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2481
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2482 // prevent IE from throwing an error for some elements with some event types, see #3533
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2483 } catch (inlineError) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2484
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2485 if ( !event.isPropagationStopped() && parent ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2486 jQuery.event.trigger( event, data, parent, true );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2487
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2488 } else if ( !event.isDefaultPrevented() ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2489 var old,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2490 target = event.target,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2491 targetType = type.replace( rnamespaces, "" ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2492 isClick = jQuery.nodeName( target, "a" ) && targetType === "click",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2493 special = jQuery.event.special[ targetType ] || {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2494
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2495 if ( (!special._default || special._default.call( elem, event ) === false) &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2496 !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2497
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2498 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2499 if ( target[ targetType ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2500 // Make sure that we don't accidentally re-trigger the onFOO events
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2501 old = target[ "on" + targetType ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2502
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2503 if ( old ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2504 target[ "on" + targetType ] = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2505 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2506
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2507 jQuery.event.triggered = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2508 target[ targetType ]();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2509 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2510
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2511 // prevent IE from throwing an error for some elements with some event types, see #3533
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2512 } catch (triggerError) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2513
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2514 if ( old ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2515 target[ "on" + targetType ] = old;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2516 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2517
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2518 jQuery.event.triggered = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2519 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2520 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2521 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2522
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2523 handle: function( event ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2524 var all, handlers, namespaces, namespace_re, events,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2525 namespace_sort = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2526 args = jQuery.makeArray( arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2527
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2528 event = args[0] = jQuery.event.fix( event || window.event );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2529 event.currentTarget = this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2530
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2531 // Namespaced event handlers
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2532 all = event.type.indexOf(".") < 0 && !event.exclusive;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2533
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2534 if ( !all ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2535 namespaces = event.type.split(".");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2536 event.type = namespaces.shift();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2537 namespace_sort = namespaces.slice(0).sort();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2538 namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2539 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2540
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2541 event.namespace = event.namespace || namespace_sort.join(".");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2542
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2543 events = jQuery._data(this, "events");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2544
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2545 handlers = (events || {})[ event.type ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2546
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2547 if ( events && handlers ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2548 // Clone the handlers to prevent manipulation
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2549 handlers = handlers.slice(0);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2550
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2551 for ( var j = 0, l = handlers.length; j < l; j++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2552 var handleObj = handlers[ j ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2553
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2554 // Filter the functions by class
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2555 if ( all || namespace_re.test( handleObj.namespace ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2556 // Pass in a reference to the handler function itself
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2557 // So that we can later remove it
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2558 event.handler = handleObj.handler;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2559 event.data = handleObj.data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2560 event.handleObj = handleObj;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2561
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2562 var ret = handleObj.handler.apply( this, args );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2563
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2564 if ( ret !== undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2565 event.result = ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2566 if ( ret === false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2567 event.preventDefault();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2568 event.stopPropagation();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2569 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2570 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2571
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2572 if ( event.isImmediatePropagationStopped() ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2573 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2574 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2575 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2576 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2577 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2578
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2579 return event.result;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2580 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2581
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2582 props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2583
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2584 fix: function( event ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2585 if ( event[ jQuery.expando ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2586 return event;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2587 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2588
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2589 // store a copy of the original event object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2590 // and "clone" to set read-only properties
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2591 var originalEvent = event;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2592 event = jQuery.Event( originalEvent );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2593
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2594 for ( var i = this.props.length, prop; i; ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2595 prop = this.props[ --i ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2596 event[ prop ] = originalEvent[ prop ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2597 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2598
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2599 // Fix target property, if necessary
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2600 if ( !event.target ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2601 // Fixes #1925 where srcElement might not be defined either
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2602 event.target = event.srcElement || document;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2603 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2604
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2605 // check if target is a textnode (safari)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2606 if ( event.target.nodeType === 3 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2607 event.target = event.target.parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2608 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2609
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2610 // Add relatedTarget, if necessary
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2611 if ( !event.relatedTarget && event.fromElement ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2612 event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2613 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2614
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2615 // Calculate pageX/Y if missing and clientX/Y available
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2616 if ( event.pageX == null && event.clientX != null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2617 var doc = document.documentElement,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2618 body = document.body;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2619
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2620 event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2621 event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2622 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2623
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2624 // Add which for key events
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2625 if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2626 event.which = event.charCode != null ? event.charCode : event.keyCode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2627 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2628
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2629 // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2630 if ( !event.metaKey && event.ctrlKey ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2631 event.metaKey = event.ctrlKey;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2632 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2633
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2634 // Add which for click: 1 === left; 2 === middle; 3 === right
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2635 // Note: button is not normalized, so don't use it
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2636 if ( !event.which && event.button !== undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2637 event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2638 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2639
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2640 return event;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2641 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2642
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2643 // Deprecated, use jQuery.guid instead
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2644 guid: 1E8,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2645
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2646 // Deprecated, use jQuery.proxy instead
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2647 proxy: jQuery.proxy,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2648
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2649 special: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2650 ready: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2651 // Make sure the ready event is setup
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2652 setup: jQuery.bindReady,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2653 teardown: jQuery.noop
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2654 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2655
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2656 live: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2657 add: function( handleObj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2658 jQuery.event.add( this,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2659 liveConvert( handleObj.origType, handleObj.selector ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2660 jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2661 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2662
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2663 remove: function( handleObj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2664 jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2665 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2666 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2667
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2668 beforeunload: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2669 setup: function( data, namespaces, eventHandle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2670 // We only want to do this special case on windows
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2671 if ( jQuery.isWindow( this ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2672 this.onbeforeunload = eventHandle;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2673 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2674 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2675
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2676 teardown: function( namespaces, eventHandle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2677 if ( this.onbeforeunload === eventHandle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2678 this.onbeforeunload = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2679 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2680 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2681 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2682 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2683 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2684
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2685 jQuery.removeEvent = document.removeEventListener ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2686 function( elem, type, handle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2687 if ( elem.removeEventListener ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2688 elem.removeEventListener( type, handle, false );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2689 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2690 } :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2691 function( elem, type, handle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2692 if ( elem.detachEvent ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2693 elem.detachEvent( "on" + type, handle );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2694 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2695 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2696
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2697 jQuery.Event = function( src ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2698 // Allow instantiation without the 'new' keyword
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2699 if ( !this.preventDefault ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2700 return new jQuery.Event( src );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2701 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2702
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2703 // Event object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2704 if ( src && src.type ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2705 this.originalEvent = src;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2706 this.type = src.type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2707
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2708 // Events bubbling up the document may have been marked as prevented
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2709 // by a handler lower down the tree; reflect the correct value.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2710 this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2711 src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2712
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2713 // Event type
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2714 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2715 this.type = src;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2716 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2717
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2718 // timeStamp is buggy for some events on Firefox(#3843)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2719 // So we won't rely on the native value
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2720 this.timeStamp = jQuery.now();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2721
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2722 // Mark it as fixed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2723 this[ jQuery.expando ] = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2724 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2725
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2726 function returnFalse() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2727 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2728 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2729 function returnTrue() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2730 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2731 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2732
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2733 // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2734 // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2735 jQuery.Event.prototype = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2736 preventDefault: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2737 this.isDefaultPrevented = returnTrue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2738
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2739 var e = this.originalEvent;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2740 if ( !e ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2741 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2742 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2743
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2744 // if preventDefault exists run it on the original event
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2745 if ( e.preventDefault ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2746 e.preventDefault();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2747
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2748 // otherwise set the returnValue property of the original event to false (IE)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2749 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2750 e.returnValue = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2751 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2752 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2753 stopPropagation: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2754 this.isPropagationStopped = returnTrue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2755
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2756 var e = this.originalEvent;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2757 if ( !e ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2758 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2759 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2760 // if stopPropagation exists run it on the original event
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2761 if ( e.stopPropagation ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2762 e.stopPropagation();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2763 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2764 // otherwise set the cancelBubble property of the original event to true (IE)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2765 e.cancelBubble = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2766 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2767 stopImmediatePropagation: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2768 this.isImmediatePropagationStopped = returnTrue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2769 this.stopPropagation();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2770 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2771 isDefaultPrevented: returnFalse,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2772 isPropagationStopped: returnFalse,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2773 isImmediatePropagationStopped: returnFalse
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2774 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2775
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2776 // Checks if an event happened on an element within another element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2777 // Used in jQuery.event.special.mouseenter and mouseleave handlers
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2778 var withinElement = function( event ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2779 // Check if mouse(over|out) are still within the same parent element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2780 var parent = event.relatedTarget;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2781
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2782 // Firefox sometimes assigns relatedTarget a XUL element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2783 // which we cannot access the parentNode property of
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2784 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2785
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2786 // Chrome does something similar, the parentNode property
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2787 // can be accessed but is null.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2788 if ( parent !== document && !parent.parentNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2789 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2790 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2791 // Traverse up the tree
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2792 while ( parent && parent !== this ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2793 parent = parent.parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2794 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2795
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2796 if ( parent !== this ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2797 // set the correct event type
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2798 event.type = event.data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2799
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2800 // handle event if we actually just moused on to a non sub-element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2801 jQuery.event.handle.apply( this, arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2802 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2803
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2804 // assuming we've left the element since we most likely mousedover a xul element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2805 } catch(e) { }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2806 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2807
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2808 // In case of event delegation, we only need to rename the event.type,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2809 // liveHandler will take care of the rest.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2810 delegate = function( event ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2811 event.type = event.data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2812 jQuery.event.handle.apply( this, arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2813 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2814
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2815 // Create mouseenter and mouseleave events
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2816 jQuery.each({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2817 mouseenter: "mouseover",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2818 mouseleave: "mouseout"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2819 }, function( orig, fix ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2820 jQuery.event.special[ orig ] = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2821 setup: function( data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2822 jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2823 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2824 teardown: function( data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2825 jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2826 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2827 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2828 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2829
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2830 // submit delegation
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2831 if ( !jQuery.support.submitBubbles ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2832
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2833 jQuery.event.special.submit = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2834 setup: function( data, namespaces ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2835 if ( this.nodeName && this.nodeName.toLowerCase() !== "form" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2836 jQuery.event.add(this, "click.specialSubmit", function( e ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2837 var elem = e.target,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2838 type = elem.type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2839
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2840 if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2841 trigger( "submit", this, arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2842 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2843 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2844
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2845 jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2846 var elem = e.target,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2847 type = elem.type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2848
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2849 if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2850 trigger( "submit", this, arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2851 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2852 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2853
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2854 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2855 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2856 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2857 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2858
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2859 teardown: function( namespaces ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2860 jQuery.event.remove( this, ".specialSubmit" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2861 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2862 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2863
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2864 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2865
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2866 // change delegation, happens here so we have bind.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2867 if ( !jQuery.support.changeBubbles ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2868
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2869 var changeFilters,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2870
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2871 getVal = function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2872 var type = elem.type, val = elem.value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2873
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2874 if ( type === "radio" || type === "checkbox" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2875 val = elem.checked;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2876
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2877 } else if ( type === "select-multiple" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2878 val = elem.selectedIndex > -1 ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2879 jQuery.map( elem.options, function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2880 return elem.selected;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2881 }).join("-") :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2882 "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2883
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2884 } else if ( elem.nodeName.toLowerCase() === "select" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2885 val = elem.selectedIndex;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2886 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2887
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2888 return val;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2889 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2890
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2891 testChange = function testChange( e ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2892 var elem = e.target, data, val;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2893
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2894 if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2895 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2896 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2897
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2898 data = jQuery._data( elem, "_change_data" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2899 val = getVal(elem);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2900
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2901 // the current data will be also retrieved by beforeactivate
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2902 if ( e.type !== "focusout" || elem.type !== "radio" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2903 jQuery._data( elem, "_change_data", val );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2904 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2905
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2906 if ( data === undefined || val === data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2907 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2908 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2909
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2910 if ( data != null || val ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2911 e.type = "change";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2912 e.liveFired = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2913 jQuery.event.trigger( e, arguments[1], elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2914 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2915 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2916
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2917 jQuery.event.special.change = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2918 filters: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2919 focusout: testChange,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2920
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2921 beforedeactivate: testChange,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2922
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2923 click: function( e ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2924 var elem = e.target, type = elem.type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2925
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2926 if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2927 testChange.call( this, e );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2928 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2929 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2930
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2931 // Change has to be called before submit
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2932 // Keydown will be called before keypress, which is used in submit-event delegation
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2933 keydown: function( e ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2934 var elem = e.target, type = elem.type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2935
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2936 if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2937 (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2938 type === "select-multiple" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2939 testChange.call( this, e );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2940 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2941 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2942
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2943 // Beforeactivate happens also before the previous element is blurred
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2944 // with this event you can't trigger a change event, but you can store
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2945 // information
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2946 beforeactivate: function( e ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2947 var elem = e.target;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2948 jQuery._data( elem, "_change_data", getVal(elem) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2949 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2950 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2951
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2952 setup: function( data, namespaces ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2953 if ( this.type === "file" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2954 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2955 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2956
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2957 for ( var type in changeFilters ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2958 jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2959 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2960
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2961 return rformElems.test( this.nodeName );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2962 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2963
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2964 teardown: function( namespaces ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2965 jQuery.event.remove( this, ".specialChange" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2966
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2967 return rformElems.test( this.nodeName );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2968 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2969 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2970
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2971 changeFilters = jQuery.event.special.change.filters;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2972
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2973 // Handle when the input is .focus()'d
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2974 changeFilters.focus = changeFilters.beforeactivate;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2975 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2976
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2977 function trigger( type, elem, args ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2978 // Piggyback on a donor event to simulate a different one.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2979 // Fake originalEvent to avoid donor's stopPropagation, but if the
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2980 // simulated event prevents default then we do the same on the donor.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2981 // Don't pass args or remember liveFired; they apply to the donor event.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2982 var event = jQuery.extend( {}, args[ 0 ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2983 event.type = type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2984 event.originalEvent = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2985 event.liveFired = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2986 jQuery.event.handle.call( elem, event );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2987 if ( event.isDefaultPrevented() ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2988 args[ 0 ].preventDefault();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2989 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2990 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2991
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2992 // Create "bubbling" focus and blur events
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2993 if ( document.addEventListener ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2994 jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2995 jQuery.event.special[ fix ] = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2996 setup: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2997 this.addEventListener( orig, handler, true );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2998 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2999 teardown: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3000 this.removeEventListener( orig, handler, true );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3001 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3002 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3003
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3004 function handler( e ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3005 e = jQuery.event.fix( e );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3006 e.type = fix;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3007 return jQuery.event.handle.call( this, e );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3008 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3009 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3010 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3011
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3012 jQuery.each(["bind", "one"], function( i, name ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3013 jQuery.fn[ name ] = function( type, data, fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3014 // Handle object literals
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3015 if ( typeof type === "object" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3016 for ( var key in type ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3017 this[ name ](key, data, type[key], fn);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3018 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3019 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3020 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3021
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3022 if ( jQuery.isFunction( data ) || data === false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3023 fn = data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3024 data = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3025 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3026
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3027 var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3028 jQuery( this ).unbind( event, handler );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3029 return fn.apply( this, arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3030 }) : fn;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3031
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3032 if ( type === "unload" && name !== "one" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3033 this.one( type, data, fn );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3034
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3035 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3036 for ( var i = 0, l = this.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3037 jQuery.event.add( this[i], type, handler, data );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3038 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3039 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3040
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3041 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3042 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3043 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3044
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3045 jQuery.fn.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3046 unbind: function( type, fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3047 // Handle object literals
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3048 if ( typeof type === "object" && !type.preventDefault ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3049 for ( var key in type ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3050 this.unbind(key, type[key]);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3051 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3052
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3053 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3054 for ( var i = 0, l = this.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3055 jQuery.event.remove( this[i], type, fn );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3056 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3057 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3058
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3059 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3060 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3061
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3062 delegate: function( selector, types, data, fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3063 return this.live( types, data, fn, selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3064 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3065
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3066 undelegate: function( selector, types, fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3067 if ( arguments.length === 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3068 return this.unbind( "live" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3069
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3070 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3071 return this.die( types, null, fn, selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3072 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3073 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3074
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3075 trigger: function( type, data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3076 return this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3077 jQuery.event.trigger( type, data, this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3078 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3079 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3080
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3081 triggerHandler: function( type, data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3082 if ( this[0] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3083 var event = jQuery.Event( type );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3084 event.preventDefault();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3085 event.stopPropagation();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3086 jQuery.event.trigger( event, data, this[0] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3087 return event.result;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3088 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3089 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3090
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3091 toggle: function( fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3092 // Save reference to arguments for access in closure
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3093 var args = arguments,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3094 i = 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3095
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3096 // link all the functions, so any of them can unbind this click handler
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3097 while ( i < args.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3098 jQuery.proxy( fn, args[ i++ ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3099 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3100
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3101 return this.click( jQuery.proxy( fn, function( event ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3102 // Figure out which function to execute
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3103 var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3104 jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3105
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3106 // Make sure that clicks stop
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3107 event.preventDefault();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3108
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3109 // and execute the function
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3110 return args[ lastToggle ].apply( this, arguments ) || false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3111 }));
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3112 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3113
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3114 hover: function( fnOver, fnOut ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3115 return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3116 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3117 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3118
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3119 var liveMap = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3120 focus: "focusin",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3121 blur: "focusout",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3122 mouseenter: "mouseover",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3123 mouseleave: "mouseout"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3124 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3125
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3126 jQuery.each(["live", "die"], function( i, name ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3127 jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3128 var type, i = 0, match, namespaces, preType,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3129 selector = origSelector || this.selector,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3130 context = origSelector ? this : jQuery( this.context );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3131
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3132 if ( typeof types === "object" && !types.preventDefault ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3133 for ( var key in types ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3134 context[ name ]( key, data, types[key], selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3135 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3136
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3137 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3138 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3139
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3140 if ( jQuery.isFunction( data ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3141 fn = data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3142 data = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3143 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3144
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3145 types = (types || "").split(" ");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3146
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3147 while ( (type = types[ i++ ]) != null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3148 match = rnamespaces.exec( type );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3149 namespaces = "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3150
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3151 if ( match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3152 namespaces = match[0];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3153 type = type.replace( rnamespaces, "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3154 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3155
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3156 if ( type === "hover" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3157 types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3158 continue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3159 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3160
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3161 preType = type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3162
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3163 if ( type === "focus" || type === "blur" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3164 types.push( liveMap[ type ] + namespaces );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3165 type = type + namespaces;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3166
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3167 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3168 type = (liveMap[ type ] || type) + namespaces;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3169 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3170
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3171 if ( name === "live" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3172 // bind live handler
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3173 for ( var j = 0, l = context.length; j < l; j++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3174 jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3175 { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3176 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3177
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3178 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3179 // unbind live handler
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3180 context.unbind( "live." + liveConvert( type, selector ), fn );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3181 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3182 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3183
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3184 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3185 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3186 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3187
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3188 function liveHandler( event ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3189 var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3190 elems = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3191 selectors = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3192 events = jQuery._data( this, "events" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3193
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3194 // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3195 if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3196 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3197 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3198
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3199 if ( event.namespace ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3200 namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3201 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3202
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3203 event.liveFired = this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3204
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3205 var live = events.live.slice(0);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3206
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3207 for ( j = 0; j < live.length; j++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3208 handleObj = live[j];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3209
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3210 if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3211 selectors.push( handleObj.selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3212
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3213 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3214 live.splice( j--, 1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3215 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3216 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3217
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3218 match = jQuery( event.target ).closest( selectors, event.currentTarget );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3219
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3220 for ( i = 0, l = match.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3221 close = match[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3222
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3223 for ( j = 0; j < live.length; j++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3224 handleObj = live[j];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3225
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3226 if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3227 elem = close.elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3228 related = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3229
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3230 // Those two events require additional checking
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3231 if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3232 event.type = handleObj.preType;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3233 related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3234 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3235
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3236 if ( !related || related !== elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3237 elems.push({ elem: elem, handleObj: handleObj, level: close.level });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3238 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3239 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3240 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3241 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3242
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3243 for ( i = 0, l = elems.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3244 match = elems[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3245
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3246 if ( maxLevel && match.level > maxLevel ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3247 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3248 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3249
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3250 event.currentTarget = match.elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3251 event.data = match.handleObj.data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3252 event.handleObj = match.handleObj;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3253
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3254 ret = match.handleObj.origHandler.apply( match.elem, arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3255
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3256 if ( ret === false || event.isPropagationStopped() ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3257 maxLevel = match.level;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3258
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3259 if ( ret === false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3260 stop = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3261 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3262 if ( event.isImmediatePropagationStopped() ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3263 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3264 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3265 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3266 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3267
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3268 return stop;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3269 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3270
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3271 function liveConvert( type, selector ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3272 return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3273 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3274
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3275 jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3276 "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3277 "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3278
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3279 // Handle event binding
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3280 jQuery.fn[ name ] = function( data, fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3281 if ( fn == null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3282 fn = data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3283 data = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3284 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3285
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3286 return arguments.length > 0 ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3287 this.bind( name, data, fn ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3288 this.trigger( name );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3289 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3290
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3291 if ( jQuery.attrFn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3292 jQuery.attrFn[ name ] = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3293 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3294 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3295
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3296
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3297 /*!
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3298 * Sizzle CSS Selector Engine
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3299 * Copyright 2011, The Dojo Foundation
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3300 * Released under the MIT, BSD, and GPL Licenses.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3301 * More information: http://sizzlejs.com/
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3302 */
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3303 (function(){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3304
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3305 var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3306 done = 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3307 toString = Object.prototype.toString,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3308 hasDuplicate = false,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3309 baseHasDuplicate = true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3310 rBackslash = /\\/g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3311 rNonWord = /\W/;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3312
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3313 // Here we check if the JavaScript engine is using some sort of
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3314 // optimization where it does not always call our comparision
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3315 // function. If that is the case, discard the hasDuplicate value.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3316 // Thus far that includes Google Chrome.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3317 [0, 0].sort(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3318 baseHasDuplicate = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3319 return 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3320 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3321
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3322 var Sizzle = function( selector, context, results, seed ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3323 results = results || [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3324 context = context || document;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3325
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3326 var origContext = context;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3327
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3328 if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3329 return [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3330 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3331
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3332 if ( !selector || typeof selector !== "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3333 return results;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3334 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3335
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3336 var m, set, checkSet, extra, ret, cur, pop, i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3337 prune = true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3338 contextXML = Sizzle.isXML( context ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3339 parts = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3340 soFar = selector;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3341
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3342 // Reset the position of the chunker regexp (start from head)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3343 do {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3344 chunker.exec( "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3345 m = chunker.exec( soFar );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3346
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3347 if ( m ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3348 soFar = m[3];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3349
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3350 parts.push( m[1] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3351
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3352 if ( m[2] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3353 extra = m[3];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3354 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3355 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3356 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3357 } while ( m );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3358
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3359 if ( parts.length > 1 && origPOS.exec( selector ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3360
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3361 if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3362 set = posProcess( parts[0] + parts[1], context );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3363
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3364 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3365 set = Expr.relative[ parts[0] ] ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3366 [ context ] :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3367 Sizzle( parts.shift(), context );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3368
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3369 while ( parts.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3370 selector = parts.shift();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3371
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3372 if ( Expr.relative[ selector ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3373 selector += parts.shift();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3374 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3375
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3376 set = posProcess( selector, set );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3377 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3378 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3379
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3380 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3381 // Take a shortcut and set the context if the root selector is an ID
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3382 // (but not if it'll be faster if the inner selector is an ID)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3383 if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3384 Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3385
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3386 ret = Sizzle.find( parts.shift(), context, contextXML );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3387 context = ret.expr ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3388 Sizzle.filter( ret.expr, ret.set )[0] :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3389 ret.set[0];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3390 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3391
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3392 if ( context ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3393 ret = seed ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3394 { expr: parts.pop(), set: makeArray(seed) } :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3395 Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3396
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3397 set = ret.expr ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3398 Sizzle.filter( ret.expr, ret.set ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3399 ret.set;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3400
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3401 if ( parts.length > 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3402 checkSet = makeArray( set );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3403
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3404 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3405 prune = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3406 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3407
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3408 while ( parts.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3409 cur = parts.pop();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3410 pop = cur;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3411
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3412 if ( !Expr.relative[ cur ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3413 cur = "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3414 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3415 pop = parts.pop();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3416 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3417
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3418 if ( pop == null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3419 pop = context;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3420 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3421
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3422 Expr.relative[ cur ]( checkSet, pop, contextXML );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3423 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3424
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3425 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3426 checkSet = parts = [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3427 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3428 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3429
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3430 if ( !checkSet ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3431 checkSet = set;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3432 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3433
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3434 if ( !checkSet ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3435 Sizzle.error( cur || selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3436 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3437
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3438 if ( toString.call(checkSet) === "[object Array]" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3439 if ( !prune ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3440 results.push.apply( results, checkSet );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3441
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3442 } else if ( context && context.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3443 for ( i = 0; checkSet[i] != null; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3444 if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3445 results.push( set[i] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3446 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3447 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3448
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3449 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3450 for ( i = 0; checkSet[i] != null; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3451 if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3452 results.push( set[i] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3453 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3454 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3455 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3456
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3457 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3458 makeArray( checkSet, results );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3459 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3460
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3461 if ( extra ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3462 Sizzle( extra, origContext, results, seed );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3463 Sizzle.uniqueSort( results );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3464 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3465
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3466 return results;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3467 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3468
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3469 Sizzle.uniqueSort = function( results ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3470 if ( sortOrder ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3471 hasDuplicate = baseHasDuplicate;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3472 results.sort( sortOrder );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3473
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3474 if ( hasDuplicate ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3475 for ( var i = 1; i < results.length; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3476 if ( results[i] === results[ i - 1 ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3477 results.splice( i--, 1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3478 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3479 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3480 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3481 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3482
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3483 return results;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3484 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3485
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3486 Sizzle.matches = function( expr, set ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3487 return Sizzle( expr, null, null, set );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3488 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3489
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3490 Sizzle.matchesSelector = function( node, expr ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3491 return Sizzle( expr, null, null, [node] ).length > 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3492 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3493
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3494 Sizzle.find = function( expr, context, isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3495 var set;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3496
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3497 if ( !expr ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3498 return [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3499 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3500
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3501 for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3502 var match,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3503 type = Expr.order[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3504
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3505 if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3506 var left = match[1];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3507 match.splice( 1, 1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3508
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3509 if ( left.substr( left.length - 1 ) !== "\\" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3510 match[1] = (match[1] || "").replace( rBackslash, "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3511 set = Expr.find[ type ]( match, context, isXML );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3512
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3513 if ( set != null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3514 expr = expr.replace( Expr.match[ type ], "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3515 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3516 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3517 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3518 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3519 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3520
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3521 if ( !set ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3522 set = typeof context.getElementsByTagName !== "undefined" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3523 context.getElementsByTagName( "*" ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3524 [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3525 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3526
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3527 return { set: set, expr: expr };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3528 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3529
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3530 Sizzle.filter = function( expr, set, inplace, not ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3531 var match, anyFound,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3532 old = expr,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3533 result = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3534 curLoop = set,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3535 isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3536
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3537 while ( expr && set.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3538 for ( var type in Expr.filter ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3539 if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3540 var found, item,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3541 filter = Expr.filter[ type ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3542 left = match[1];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3543
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3544 anyFound = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3545
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3546 match.splice(1,1);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3547
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3548 if ( left.substr( left.length - 1 ) === "\\" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3549 continue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3550 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3551
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3552 if ( curLoop === result ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3553 result = [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3554 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3555
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3556 if ( Expr.preFilter[ type ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3557 match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3558
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3559 if ( !match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3560 anyFound = found = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3561
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3562 } else if ( match === true ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3563 continue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3564 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3565 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3566
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3567 if ( match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3568 for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3569 if ( item ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3570 found = filter( item, match, i, curLoop );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3571 var pass = not ^ !!found;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3572
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3573 if ( inplace && found != null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3574 if ( pass ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3575 anyFound = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3576
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3577 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3578 curLoop[i] = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3579 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3580
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3581 } else if ( pass ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3582 result.push( item );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3583 anyFound = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3584 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3585 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3586 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3587 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3588
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3589 if ( found !== undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3590 if ( !inplace ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3591 curLoop = result;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3592 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3593
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3594 expr = expr.replace( Expr.match[ type ], "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3595
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3596 if ( !anyFound ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3597 return [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3598 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3599
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3600 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3601 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3602 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3603 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3604
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3605 // Improper expression
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3606 if ( expr === old ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3607 if ( anyFound == null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3608 Sizzle.error( expr );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3609
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3610 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3611 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3612 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3613 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3614
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3615 old = expr;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3616 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3617
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3618 return curLoop;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3619 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3620
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3621 Sizzle.error = function( msg ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3622 throw "Syntax error, unrecognized expression: " + msg;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3623 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3624
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3625 var Expr = Sizzle.selectors = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3626 order: [ "ID", "NAME", "TAG" ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3627
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3628 match: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3629 ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3630 CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3631 NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3632 ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3633 TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3634 CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3635 POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3636 PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3637 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3638
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3639 leftMatch: {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3640
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3641 attrMap: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3642 "class": "className",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3643 "for": "htmlFor"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3644 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3645
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3646 attrHandle: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3647 href: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3648 return elem.getAttribute( "href" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3649 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3650 type: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3651 return elem.getAttribute( "type" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3652 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3653 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3654
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3655 relative: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3656 "+": function(checkSet, part){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3657 var isPartStr = typeof part === "string",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3658 isTag = isPartStr && !rNonWord.test( part ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3659 isPartStrNotTag = isPartStr && !isTag;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3660
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3661 if ( isTag ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3662 part = part.toLowerCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3663 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3664
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3665 for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3666 if ( (elem = checkSet[i]) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3667 while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3668
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3669 checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3670 elem || false :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3671 elem === part;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3672 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3673 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3674
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3675 if ( isPartStrNotTag ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3676 Sizzle.filter( part, checkSet, true );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3677 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3678 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3679
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3680 ">": function( checkSet, part ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3681 var elem,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3682 isPartStr = typeof part === "string",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3683 i = 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3684 l = checkSet.length;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3685
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3686 if ( isPartStr && !rNonWord.test( part ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3687 part = part.toLowerCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3688
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3689 for ( ; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3690 elem = checkSet[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3691
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3692 if ( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3693 var parent = elem.parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3694 checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3695 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3696 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3697
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3698 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3699 for ( ; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3700 elem = checkSet[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3701
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3702 if ( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3703 checkSet[i] = isPartStr ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3704 elem.parentNode :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3705 elem.parentNode === part;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3706 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3707 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3708
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3709 if ( isPartStr ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3710 Sizzle.filter( part, checkSet, true );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3711 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3712 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3713 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3714
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3715 "": function(checkSet, part, isXML){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3716 var nodeCheck,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3717 doneName = done++,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3718 checkFn = dirCheck;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3719
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3720 if ( typeof part === "string" && !rNonWord.test( part ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3721 part = part.toLowerCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3722 nodeCheck = part;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3723 checkFn = dirNodeCheck;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3724 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3725
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3726 checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3727 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3728
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3729 "~": function( checkSet, part, isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3730 var nodeCheck,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3731 doneName = done++,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3732 checkFn = dirCheck;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3733
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3734 if ( typeof part === "string" && !rNonWord.test( part ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3735 part = part.toLowerCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3736 nodeCheck = part;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3737 checkFn = dirNodeCheck;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3738 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3739
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3740 checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3741 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3742 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3743
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3744 find: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3745 ID: function( match, context, isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3746 if ( typeof context.getElementById !== "undefined" && !isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3747 var m = context.getElementById(match[1]);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3748 // Check parentNode to catch when Blackberry 4.6 returns
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3749 // nodes that are no longer in the document #6963
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3750 return m && m.parentNode ? [m] : [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3751 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3752 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3753
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3754 NAME: function( match, context ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3755 if ( typeof context.getElementsByName !== "undefined" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3756 var ret = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3757 results = context.getElementsByName( match[1] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3758
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3759 for ( var i = 0, l = results.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3760 if ( results[i].getAttribute("name") === match[1] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3761 ret.push( results[i] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3762 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3763 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3764
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3765 return ret.length === 0 ? null : ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3766 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3767 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3768
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3769 TAG: function( match, context ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3770 if ( typeof context.getElementsByTagName !== "undefined" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3771 return context.getElementsByTagName( match[1] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3772 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3773 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3774 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3775 preFilter: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3776 CLASS: function( match, curLoop, inplace, result, not, isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3777 match = " " + match[1].replace( rBackslash, "" ) + " ";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3778
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3779 if ( isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3780 return match;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3781 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3782
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3783 for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3784 if ( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3785 if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3786 if ( !inplace ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3787 result.push( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3788 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3789
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3790 } else if ( inplace ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3791 curLoop[i] = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3792 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3793 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3794 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3795
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3796 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3797 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3798
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3799 ID: function( match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3800 return match[1].replace( rBackslash, "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3801 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3802
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3803 TAG: function( match, curLoop ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3804 return match[1].replace( rBackslash, "" ).toLowerCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3805 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3806
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3807 CHILD: function( match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3808 if ( match[1] === "nth" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3809 if ( !match[2] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3810 Sizzle.error( match[0] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3811 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3812
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3813 match[2] = match[2].replace(/^\+|\s*/g, '');
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3814
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3815 // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3816 var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3817 match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3818 !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3819
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3820 // calculate the numbers (first)n+(last) including if they are negative
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3821 match[2] = (test[1] + (test[2] || 1)) - 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3822 match[3] = test[3] - 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3823 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3824 else if ( match[2] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3825 Sizzle.error( match[0] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3826 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3827
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3828 // TODO: Move to normal caching system
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3829 match[0] = done++;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3830
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3831 return match;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3832 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3833
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3834 ATTR: function( match, curLoop, inplace, result, not, isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3835 var name = match[1] = match[1].replace( rBackslash, "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3836
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3837 if ( !isXML && Expr.attrMap[name] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3838 match[1] = Expr.attrMap[name];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3839 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3840
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3841 // Handle if an un-quoted value was used
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3842 match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3843
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3844 if ( match[2] === "~=" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3845 match[4] = " " + match[4] + " ";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3846 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3847
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3848 return match;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3849 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3850
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3851 PSEUDO: function( match, curLoop, inplace, result, not ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3852 if ( match[1] === "not" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3853 // If we're dealing with a complex expression, or a simple one
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3854 if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3855 match[3] = Sizzle(match[3], null, null, curLoop);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3856
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3857 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3858 var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3859
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3860 if ( !inplace ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3861 result.push.apply( result, ret );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3862 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3863
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3864 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3865 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3866
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3867 } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3868 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3869 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3870
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3871 return match;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3872 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3873
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3874 POS: function( match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3875 match.unshift( true );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3876
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3877 return match;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3878 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3879 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3880
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3881 filters: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3882 enabled: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3883 return elem.disabled === false && elem.type !== "hidden";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3884 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3885
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3886 disabled: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3887 return elem.disabled === true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3888 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3889
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3890 checked: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3891 return elem.checked === true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3892 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3893
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3894 selected: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3895 // Accessing this property makes selected-by-default
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3896 // options in Safari work properly
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3897 if ( elem.parentNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3898 elem.parentNode.selectedIndex;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3899 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3900
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3901 return elem.selected === true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3902 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3903
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3904 parent: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3905 return !!elem.firstChild;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3906 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3907
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3908 empty: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3909 return !elem.firstChild;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3910 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3911
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3912 has: function( elem, i, match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3913 return !!Sizzle( match[3], elem ).length;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3914 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3915
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3916 header: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3917 return (/h\d/i).test( elem.nodeName );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3918 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3919
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3920 text: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3921 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3922 // use getAttribute instead to test this case
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3923 return "text" === elem.getAttribute( 'type' );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3924 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3925 radio: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3926 return "radio" === elem.type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3927 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3928
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3929 checkbox: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3930 return "checkbox" === elem.type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3931 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3932
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3933 file: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3934 return "file" === elem.type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3935 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3936 password: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3937 return "password" === elem.type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3938 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3939
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3940 submit: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3941 return "submit" === elem.type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3942 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3943
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3944 image: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3945 return "image" === elem.type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3946 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3947
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3948 reset: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3949 return "reset" === elem.type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3950 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3951
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3952 button: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3953 return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3954 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3955
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3956 input: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3957 return (/input|select|textarea|button/i).test( elem.nodeName );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3958 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3959 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3960 setFilters: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3961 first: function( elem, i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3962 return i === 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3963 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3964
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3965 last: function( elem, i, match, array ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3966 return i === array.length - 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3967 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3968
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3969 even: function( elem, i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3970 return i % 2 === 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3971 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3972
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3973 odd: function( elem, i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3974 return i % 2 === 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3975 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3976
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3977 lt: function( elem, i, match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3978 return i < match[3] - 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3979 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3980
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3981 gt: function( elem, i, match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3982 return i > match[3] - 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3983 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3984
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3985 nth: function( elem, i, match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3986 return match[3] - 0 === i;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3987 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3988
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3989 eq: function( elem, i, match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3990 return match[3] - 0 === i;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3991 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3992 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3993 filter: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3994 PSEUDO: function( elem, match, i, array ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3995 var name = match[1],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3996 filter = Expr.filters[ name ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3997
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3998 if ( filter ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3999 return filter( elem, i, match, array );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4000
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4001 } else if ( name === "contains" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4002 return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4003
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4004 } else if ( name === "not" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4005 var not = match[3];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4006
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4007 for ( var j = 0, l = not.length; j < l; j++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4008 if ( not[j] === elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4009 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4010 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4011 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4012
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4013 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4014
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4015 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4016 Sizzle.error( name );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4017 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4018 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4019
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4020 CHILD: function( elem, match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4021 var type = match[1],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4022 node = elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4023
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4024 switch ( type ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4025 case "only":
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4026 case "first":
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4027 while ( (node = node.previousSibling) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4028 if ( node.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4029 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4030 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4031 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4032
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4033 if ( type === "first" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4034 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4035 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4036
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4037 node = elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4038
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4039 case "last":
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4040 while ( (node = node.nextSibling) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4041 if ( node.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4042 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4043 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4044 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4045
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4046 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4047
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4048 case "nth":
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4049 var first = match[2],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4050 last = match[3];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4051
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4052 if ( first === 1 && last === 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4053 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4054 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4055
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4056 var doneName = match[0],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4057 parent = elem.parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4058
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4059 if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4060 var count = 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4061
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4062 for ( node = parent.firstChild; node; node = node.nextSibling ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4063 if ( node.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4064 node.nodeIndex = ++count;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4065 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4066 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4067
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4068 parent.sizcache = doneName;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4069 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4070
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4071 var diff = elem.nodeIndex - last;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4072
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4073 if ( first === 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4074 return diff === 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4075
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4076 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4077 return ( diff % first === 0 && diff / first >= 0 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4078 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4079 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4080 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4081
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4082 ID: function( elem, match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4083 return elem.nodeType === 1 && elem.getAttribute("id") === match;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4084 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4085
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4086 TAG: function( elem, match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4087 return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4088 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4089
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4090 CLASS: function( elem, match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4091 return (" " + (elem.className || elem.getAttribute("class")) + " ")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4092 .indexOf( match ) > -1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4093 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4094
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4095 ATTR: function( elem, match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4096 var name = match[1],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4097 result = Expr.attrHandle[ name ] ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4098 Expr.attrHandle[ name ]( elem ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4099 elem[ name ] != null ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4100 elem[ name ] :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4101 elem.getAttribute( name ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4102 value = result + "",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4103 type = match[2],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4104 check = match[4];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4105
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4106 return result == null ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4107 type === "!=" :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4108 type === "=" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4109 value === check :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4110 type === "*=" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4111 value.indexOf(check) >= 0 :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4112 type === "~=" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4113 (" " + value + " ").indexOf(check) >= 0 :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4114 !check ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4115 value && result !== false :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4116 type === "!=" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4117 value !== check :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4118 type === "^=" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4119 value.indexOf(check) === 0 :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4120 type === "$=" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4121 value.substr(value.length - check.length) === check :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4122 type === "|=" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4123 value === check || value.substr(0, check.length + 1) === check + "-" :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4124 false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4125 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4126
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4127 POS: function( elem, match, i, array ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4128 var name = match[2],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4129 filter = Expr.setFilters[ name ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4130
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4131 if ( filter ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4132 return filter( elem, i, match, array );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4133 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4134 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4135 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4136 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4137
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4138 var origPOS = Expr.match.POS,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4139 fescape = function(all, num){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4140 return "\\" + (num - 0 + 1);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4141 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4142
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4143 for ( var type in Expr.match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4144 Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4145 Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4146 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4147
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4148 var makeArray = function( array, results ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4149 array = Array.prototype.slice.call( array, 0 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4150
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4151 if ( results ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4152 results.push.apply( results, array );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4153 return results;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4154 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4155
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4156 return array;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4157 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4158
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4159 // Perform a simple check to determine if the browser is capable of
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4160 // converting a NodeList to an array using builtin methods.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4161 // Also verifies that the returned array holds DOM nodes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4162 // (which is not the case in the Blackberry browser)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4163 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4164 Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4165
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4166 // Provide a fallback method if it does not work
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4167 } catch( e ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4168 makeArray = function( array, results ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4169 var i = 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4170 ret = results || [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4171
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4172 if ( toString.call(array) === "[object Array]" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4173 Array.prototype.push.apply( ret, array );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4174
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4175 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4176 if ( typeof array.length === "number" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4177 for ( var l = array.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4178 ret.push( array[i] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4179 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4180
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4181 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4182 for ( ; array[i]; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4183 ret.push( array[i] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4184 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4185 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4186 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4187
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4188 return ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4189 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4190 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4191
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4192 var sortOrder, siblingCheck;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4193
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4194 if ( document.documentElement.compareDocumentPosition ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4195 sortOrder = function( a, b ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4196 if ( a === b ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4197 hasDuplicate = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4198 return 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4199 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4200
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4201 if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4202 return a.compareDocumentPosition ? -1 : 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4203 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4204
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4205 return a.compareDocumentPosition(b) & 4 ? -1 : 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4206 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4207
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4208 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4209 sortOrder = function( a, b ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4210 var al, bl,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4211 ap = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4212 bp = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4213 aup = a.parentNode,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4214 bup = b.parentNode,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4215 cur = aup;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4216
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4217 // The nodes are identical, we can exit early
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4218 if ( a === b ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4219 hasDuplicate = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4220 return 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4221
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4222 // If the nodes are siblings (or identical) we can do a quick check
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4223 } else if ( aup === bup ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4224 return siblingCheck( a, b );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4225
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4226 // If no parents were found then the nodes are disconnected
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4227 } else if ( !aup ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4228 return -1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4229
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4230 } else if ( !bup ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4231 return 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4232 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4233
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4234 // Otherwise they're somewhere else in the tree so we need
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4235 // to build up a full list of the parentNodes for comparison
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4236 while ( cur ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4237 ap.unshift( cur );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4238 cur = cur.parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4239 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4240
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4241 cur = bup;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4242
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4243 while ( cur ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4244 bp.unshift( cur );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4245 cur = cur.parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4246 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4247
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4248 al = ap.length;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4249 bl = bp.length;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4250
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4251 // Start walking down the tree looking for a discrepancy
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4252 for ( var i = 0; i < al && i < bl; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4253 if ( ap[i] !== bp[i] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4254 return siblingCheck( ap[i], bp[i] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4255 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4256 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4257
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4258 // We ended someplace up the tree so do a sibling check
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4259 return i === al ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4260 siblingCheck( a, bp[i], -1 ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4261 siblingCheck( ap[i], b, 1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4262 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4263
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4264 siblingCheck = function( a, b, ret ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4265 if ( a === b ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4266 return ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4267 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4268
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4269 var cur = a.nextSibling;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4270
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4271 while ( cur ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4272 if ( cur === b ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4273 return -1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4274 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4275
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4276 cur = cur.nextSibling;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4277 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4278
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4279 return 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4280 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4281 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4282
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4283 // Utility function for retreiving the text value of an array of DOM nodes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4284 Sizzle.getText = function( elems ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4285 var ret = "", elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4286
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4287 for ( var i = 0; elems[i]; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4288 elem = elems[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4289
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4290 // Get the text from text nodes and CDATA nodes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4291 if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4292 ret += elem.nodeValue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4293
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4294 // Traverse everything else, except comment nodes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4295 } else if ( elem.nodeType !== 8 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4296 ret += Sizzle.getText( elem.childNodes );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4297 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4298 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4299
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4300 return ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4301 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4302
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4303 // Check to see if the browser returns elements by name when
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4304 // querying by getElementById (and provide a workaround)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4305 (function(){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4306 // We're going to inject a fake input element with a specified name
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4307 var form = document.createElement("div"),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4308 id = "script" + (new Date()).getTime(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4309 root = document.documentElement;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4310
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4311 form.innerHTML = "<a name='" + id + "'/>";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4312
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4313 // Inject it into the root element, check its status, and remove it quickly
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4314 root.insertBefore( form, root.firstChild );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4315
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4316 // The workaround has to do additional checks after a getElementById
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4317 // Which slows things down for other browsers (hence the branching)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4318 if ( document.getElementById( id ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4319 Expr.find.ID = function( match, context, isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4320 if ( typeof context.getElementById !== "undefined" && !isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4321 var m = context.getElementById(match[1]);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4322
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4323 return m ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4324 m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4325 [m] :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4326 undefined :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4327 [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4328 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4329 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4330
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4331 Expr.filter.ID = function( elem, match ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4332 var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4333
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4334 return elem.nodeType === 1 && node && node.nodeValue === match;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4335 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4336 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4337
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4338 root.removeChild( form );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4339
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4340 // release memory in IE
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4341 root = form = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4342 })();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4343
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4344 (function(){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4345 // Check to see if the browser returns only elements
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4346 // when doing getElementsByTagName("*")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4347
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4348 // Create a fake element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4349 var div = document.createElement("div");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4350 div.appendChild( document.createComment("") );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4351
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4352 // Make sure no comments are found
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4353 if ( div.getElementsByTagName("*").length > 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4354 Expr.find.TAG = function( match, context ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4355 var results = context.getElementsByTagName( match[1] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4356
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4357 // Filter out possible comments
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4358 if ( match[1] === "*" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4359 var tmp = [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4360
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4361 for ( var i = 0; results[i]; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4362 if ( results[i].nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4363 tmp.push( results[i] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4364 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4365 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4366
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4367 results = tmp;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4368 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4369
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4370 return results;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4371 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4372 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4373
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4374 // Check to see if an attribute returns normalized href attributes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4375 div.innerHTML = "<a href='#'></a>";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4376
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4377 if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4378 div.firstChild.getAttribute("href") !== "#" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4379
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4380 Expr.attrHandle.href = function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4381 return elem.getAttribute( "href", 2 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4382 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4383 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4384
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4385 // release memory in IE
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4386 div = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4387 })();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4388
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4389 if ( document.querySelectorAll ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4390 (function(){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4391 var oldSizzle = Sizzle,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4392 div = document.createElement("div"),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4393 id = "__sizzle__";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4394
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4395 div.innerHTML = "<p class='TEST'></p>";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4396
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4397 // Safari can't handle uppercase or unicode characters when
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4398 // in quirks mode.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4399 if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4400 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4401 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4402
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4403 Sizzle = function( query, context, extra, seed ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4404 context = context || document;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4405
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4406 // Only use querySelectorAll on non-XML documents
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4407 // (ID selectors don't work in non-HTML documents)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4408 if ( !seed && !Sizzle.isXML(context) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4409 // See if we find a selector to speed up
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4410 var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4411
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4412 if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4413 // Speed-up: Sizzle("TAG")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4414 if ( match[1] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4415 return makeArray( context.getElementsByTagName( query ), extra );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4416
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4417 // Speed-up: Sizzle(".CLASS")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4418 } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4419 return makeArray( context.getElementsByClassName( match[2] ), extra );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4420 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4421 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4422
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4423 if ( context.nodeType === 9 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4424 // Speed-up: Sizzle("body")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4425 // The body element only exists once, optimize finding it
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4426 if ( query === "body" && context.body ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4427 return makeArray( [ context.body ], extra );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4428
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4429 // Speed-up: Sizzle("#ID")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4430 } else if ( match && match[3] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4431 var elem = context.getElementById( match[3] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4432
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4433 // Check parentNode to catch when Blackberry 4.6 returns
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4434 // nodes that are no longer in the document #6963
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4435 if ( elem && elem.parentNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4436 // Handle the case where IE and Opera return items
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4437 // by name instead of ID
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4438 if ( elem.id === match[3] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4439 return makeArray( [ elem ], extra );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4440 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4441
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4442 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4443 return makeArray( [], extra );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4444 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4445 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4446
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4447 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4448 return makeArray( context.querySelectorAll(query), extra );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4449 } catch(qsaError) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4450
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4451 // qSA works strangely on Element-rooted queries
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4452 // We can work around this by specifying an extra ID on the root
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4453 // and working up from there (Thanks to Andrew Dupont for the technique)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4454 // IE 8 doesn't work on object elements
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4455 } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4456 var oldContext = context,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4457 old = context.getAttribute( "id" ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4458 nid = old || id,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4459 hasParent = context.parentNode,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4460 relativeHierarchySelector = /^\s*[+~]/.test( query );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4461
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4462 if ( !old ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4463 context.setAttribute( "id", nid );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4464 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4465 nid = nid.replace( /'/g, "\\$&" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4466 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4467 if ( relativeHierarchySelector && hasParent ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4468 context = context.parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4469 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4470
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4471 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4472 if ( !relativeHierarchySelector || hasParent ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4473 return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4474 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4475
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4476 } catch(pseudoError) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4477 } finally {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4478 if ( !old ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4479 oldContext.removeAttribute( "id" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4480 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4481 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4482 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4483 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4484
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4485 return oldSizzle(query, context, extra, seed);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4486 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4487
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4488 for ( var prop in oldSizzle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4489 Sizzle[ prop ] = oldSizzle[ prop ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4490 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4491
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4492 // release memory in IE
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4493 div = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4494 })();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4495 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4496
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4497 (function(){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4498 var html = document.documentElement,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4499 matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4500 pseudoWorks = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4501
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4502 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4503 // This should fail with an exception
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4504 // Gecko does not error, returns false instead
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4505 matches.call( document.documentElement, "[test!='']:sizzle" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4506
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4507 } catch( pseudoError ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4508 pseudoWorks = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4509 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4510
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4511 if ( matches ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4512 Sizzle.matchesSelector = function( node, expr ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4513 // Make sure that attribute selectors are quoted
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4514 expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4515
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4516 if ( !Sizzle.isXML( node ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4517 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4518 if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4519 return matches.call( node, expr );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4520 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4521 } catch(e) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4522 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4523
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4524 return Sizzle(expr, null, null, [node]).length > 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4525 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4526 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4527 })();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4528
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4529 (function(){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4530 var div = document.createElement("div");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4531
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4532 div.innerHTML = "<div class='test e'></div><div class='test'></div>";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4533
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4534 // Opera can't find a second classname (in 9.6)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4535 // Also, make sure that getElementsByClassName actually exists
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4536 if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4537 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4538 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4539
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4540 // Safari caches class attributes, doesn't catch changes (in 3.2)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4541 div.lastChild.className = "e";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4542
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4543 if ( div.getElementsByClassName("e").length === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4544 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4545 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4546
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4547 Expr.order.splice(1, 0, "CLASS");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4548 Expr.find.CLASS = function( match, context, isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4549 if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4550 return context.getElementsByClassName(match[1]);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4551 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4552 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4553
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4554 // release memory in IE
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4555 div = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4556 })();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4557
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4558 function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4559 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4560 var elem = checkSet[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4561
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4562 if ( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4563 var match = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4564
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4565 elem = elem[dir];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4566
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4567 while ( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4568 if ( elem.sizcache === doneName ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4569 match = checkSet[elem.sizset];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4570 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4571 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4572
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4573 if ( elem.nodeType === 1 && !isXML ){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4574 elem.sizcache = doneName;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4575 elem.sizset = i;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4576 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4577
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4578 if ( elem.nodeName.toLowerCase() === cur ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4579 match = elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4580 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4581 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4582
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4583 elem = elem[dir];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4584 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4585
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4586 checkSet[i] = match;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4587 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4588 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4589 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4590
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4591 function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4592 for ( var i = 0, l = checkSet.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4593 var elem = checkSet[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4594
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4595 if ( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4596 var match = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4597
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4598 elem = elem[dir];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4599
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4600 while ( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4601 if ( elem.sizcache === doneName ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4602 match = checkSet[elem.sizset];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4603 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4604 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4605
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4606 if ( elem.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4607 if ( !isXML ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4608 elem.sizcache = doneName;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4609 elem.sizset = i;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4610 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4611
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4612 if ( typeof cur !== "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4613 if ( elem === cur ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4614 match = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4615 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4616 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4617
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4618 } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4619 match = elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4620 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4621 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4622 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4623
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4624 elem = elem[dir];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4625 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4626
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4627 checkSet[i] = match;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4628 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4629 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4630 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4631
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4632 if ( document.documentElement.contains ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4633 Sizzle.contains = function( a, b ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4634 return a !== b && (a.contains ? a.contains(b) : true);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4635 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4636
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4637 } else if ( document.documentElement.compareDocumentPosition ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4638 Sizzle.contains = function( a, b ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4639 return !!(a.compareDocumentPosition(b) & 16);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4640 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4641
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4642 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4643 Sizzle.contains = function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4644 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4645 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4646 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4647
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4648 Sizzle.isXML = function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4649 // documentElement is verified for cases where it doesn't yet exist
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4650 // (such as loading iframes in IE - #4833)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4651 var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4652
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4653 return documentElement ? documentElement.nodeName !== "HTML" : false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4654 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4655
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4656 var posProcess = function( selector, context ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4657 var match,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4658 tmpSet = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4659 later = "",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4660 root = context.nodeType ? [context] : context;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4661
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4662 // Position selectors must be done after the filter
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4663 // And so must :not(positional) so we move all PSEUDOs to the end
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4664 while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4665 later += match[0];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4666 selector = selector.replace( Expr.match.PSEUDO, "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4667 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4668
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4669 selector = Expr.relative[selector] ? selector + "*" : selector;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4670
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4671 for ( var i = 0, l = root.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4672 Sizzle( selector, root[i], tmpSet );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4673 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4674
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4675 return Sizzle.filter( later, tmpSet );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4676 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4677
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4678 // EXPOSE
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4679 jQuery.find = Sizzle;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4680 jQuery.expr = Sizzle.selectors;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4681 jQuery.expr[":"] = jQuery.expr.filters;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4682 jQuery.unique = Sizzle.uniqueSort;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4683 jQuery.text = Sizzle.getText;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4684 jQuery.isXMLDoc = Sizzle.isXML;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4685 jQuery.contains = Sizzle.contains;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4686
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4687
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4688 })();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4689
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4690
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4691 var runtil = /Until$/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4692 rparentsprev = /^(?:parents|prevUntil|prevAll)/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4693 // Note: This RegExp should be improved, or likely pulled from Sizzle
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4694 rmultiselector = /,/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4695 isSimple = /^.[^:#\[\.,]*$/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4696 slice = Array.prototype.slice,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4697 POS = jQuery.expr.match.POS,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4698 // methods guaranteed to produce a unique set when starting from a unique set
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4699 guaranteedUnique = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4700 children: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4701 contents: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4702 next: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4703 prev: true
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4704 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4705
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4706 jQuery.fn.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4707 find: function( selector ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4708 var ret = this.pushStack( "", "find", selector ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4709 length = 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4710
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4711 for ( var i = 0, l = this.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4712 length = ret.length;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4713 jQuery.find( selector, this[i], ret );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4714
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4715 if ( i > 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4716 // Make sure that the results are unique
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4717 for ( var n = length; n < ret.length; n++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4718 for ( var r = 0; r < length; r++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4719 if ( ret[r] === ret[n] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4720 ret.splice(n--, 1);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4721 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4722 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4723 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4724 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4725 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4726 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4727
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4728 return ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4729 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4730
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4731 has: function( target ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4732 var targets = jQuery( target );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4733 return this.filter(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4734 for ( var i = 0, l = targets.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4735 if ( jQuery.contains( this, targets[i] ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4736 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4737 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4738 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4739 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4740 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4741
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4742 not: function( selector ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4743 return this.pushStack( winnow(this, selector, false), "not", selector);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4744 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4745
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4746 filter: function( selector ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4747 return this.pushStack( winnow(this, selector, true), "filter", selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4748 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4749
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4750 is: function( selector ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4751 return !!selector && jQuery.filter( selector, this ).length > 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4752 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4753
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4754 closest: function( selectors, context ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4755 var ret = [], i, l, cur = this[0];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4756
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4757 if ( jQuery.isArray( selectors ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4758 var match, selector,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4759 matches = {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4760 level = 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4761
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4762 if ( cur && selectors.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4763 for ( i = 0, l = selectors.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4764 selector = selectors[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4765
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4766 if ( !matches[selector] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4767 matches[selector] = jQuery.expr.match.POS.test( selector ) ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4768 jQuery( selector, context || this.context ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4769 selector;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4770 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4771 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4772
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4773 while ( cur && cur.ownerDocument && cur !== context ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4774 for ( selector in matches ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4775 match = matches[selector];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4776
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4777 if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4778 ret.push({ selector: selector, elem: cur, level: level });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4779 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4780 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4781
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4782 cur = cur.parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4783 level++;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4784 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4785 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4786
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4787 return ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4788 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4789
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4790 var pos = POS.test( selectors ) ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4791 jQuery( selectors, context || this.context ) : null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4792
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4793 for ( i = 0, l = this.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4794 cur = this[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4795
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4796 while ( cur ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4797 if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4798 ret.push( cur );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4799 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4800
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4801 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4802 cur = cur.parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4803 if ( !cur || !cur.ownerDocument || cur === context ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4804 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4805 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4806 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4807 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4808 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4809
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4810 ret = ret.length > 1 ? jQuery.unique(ret) : ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4811
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4812 return this.pushStack( ret, "closest", selectors );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4813 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4814
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4815 // Determine the position of an element within
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4816 // the matched set of elements
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4817 index: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4818 if ( !elem || typeof elem === "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4819 return jQuery.inArray( this[0],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4820 // If it receives a string, the selector is used
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4821 // If it receives nothing, the siblings are used
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4822 elem ? jQuery( elem ) : this.parent().children() );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4823 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4824 // Locate the position of the desired element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4825 return jQuery.inArray(
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4826 // If it receives a jQuery object, the first element is used
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4827 elem.jquery ? elem[0] : elem, this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4828 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4829
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4830 add: function( selector, context ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4831 var set = typeof selector === "string" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4832 jQuery( selector, context ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4833 jQuery.makeArray( selector ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4834 all = jQuery.merge( this.get(), set );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4835
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4836 return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4837 all :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4838 jQuery.unique( all ) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4839 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4840
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4841 andSelf: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4842 return this.add( this.prevObject );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4843 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4844 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4845
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4846 // A painfully simple check to see if an element is disconnected
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4847 // from a document (should be improved, where feasible).
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4848 function isDisconnected( node ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4849 return !node || !node.parentNode || node.parentNode.nodeType === 11;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4850 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4851
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4852 jQuery.each({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4853 parent: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4854 var parent = elem.parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4855 return parent && parent.nodeType !== 11 ? parent : null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4856 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4857 parents: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4858 return jQuery.dir( elem, "parentNode" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4859 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4860 parentsUntil: function( elem, i, until ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4861 return jQuery.dir( elem, "parentNode", until );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4862 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4863 next: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4864 return jQuery.nth( elem, 2, "nextSibling" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4865 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4866 prev: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4867 return jQuery.nth( elem, 2, "previousSibling" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4868 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4869 nextAll: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4870 return jQuery.dir( elem, "nextSibling" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4871 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4872 prevAll: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4873 return jQuery.dir( elem, "previousSibling" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4874 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4875 nextUntil: function( elem, i, until ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4876 return jQuery.dir( elem, "nextSibling", until );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4877 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4878 prevUntil: function( elem, i, until ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4879 return jQuery.dir( elem, "previousSibling", until );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4880 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4881 siblings: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4882 return jQuery.sibling( elem.parentNode.firstChild, elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4883 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4884 children: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4885 return jQuery.sibling( elem.firstChild );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4886 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4887 contents: function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4888 return jQuery.nodeName( elem, "iframe" ) ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4889 elem.contentDocument || elem.contentWindow.document :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4890 jQuery.makeArray( elem.childNodes );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4891 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4892 }, function( name, fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4893 jQuery.fn[ name ] = function( until, selector ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4894 var ret = jQuery.map( this, fn, until ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4895 // The variable 'args' was introduced in
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4896 // https://github.com/jquery/jquery/commit/52a0238
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4897 // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4898 // http://code.google.com/p/v8/issues/detail?id=1050
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4899 args = slice.call(arguments);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4900
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4901 if ( !runtil.test( name ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4902 selector = until;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4903 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4904
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4905 if ( selector && typeof selector === "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4906 ret = jQuery.filter( selector, ret );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4907 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4908
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4909 ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4910
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4911 if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4912 ret = ret.reverse();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4913 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4914
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4915 return this.pushStack( ret, name, args.join(",") );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4916 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4917 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4918
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4919 jQuery.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4920 filter: function( expr, elems, not ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4921 if ( not ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4922 expr = ":not(" + expr + ")";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4923 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4924
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4925 return elems.length === 1 ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4926 jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4927 jQuery.find.matches(expr, elems);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4928 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4929
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4930 dir: function( elem, dir, until ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4931 var matched = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4932 cur = elem[ dir ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4933
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4934 while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4935 if ( cur.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4936 matched.push( cur );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4937 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4938 cur = cur[dir];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4939 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4940 return matched;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4941 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4942
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4943 nth: function( cur, result, dir, elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4944 result = result || 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4945 var num = 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4946
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4947 for ( ; cur; cur = cur[dir] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4948 if ( cur.nodeType === 1 && ++num === result ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4949 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4950 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4951 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4952
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4953 return cur;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4954 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4955
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4956 sibling: function( n, elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4957 var r = [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4958
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4959 for ( ; n; n = n.nextSibling ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4960 if ( n.nodeType === 1 && n !== elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4961 r.push( n );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4962 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4963 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4964
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4965 return r;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4966 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4967 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4968
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4969 // Implement the identical functionality for filter and not
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4970 function winnow( elements, qualifier, keep ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4971 if ( jQuery.isFunction( qualifier ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4972 return jQuery.grep(elements, function( elem, i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4973 var retVal = !!qualifier.call( elem, i, elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4974 return retVal === keep;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4975 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4976
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4977 } else if ( qualifier.nodeType ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4978 return jQuery.grep(elements, function( elem, i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4979 return (elem === qualifier) === keep;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4980 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4981
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4982 } else if ( typeof qualifier === "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4983 var filtered = jQuery.grep(elements, function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4984 return elem.nodeType === 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4985 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4986
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4987 if ( isSimple.test( qualifier ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4988 return jQuery.filter(qualifier, filtered, !keep);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4989 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4990 qualifier = jQuery.filter( qualifier, filtered );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4991 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4992 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4993
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4994 return jQuery.grep(elements, function( elem, i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4995 return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4996 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4997 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4998
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4999
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5000
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5001
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5002 var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5003 rleadingWhitespace = /^\s+/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5004 rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5005 rtagName = /<([\w:]+)/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5006 rtbody = /<tbody/i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5007 rhtml = /<|&#?\w+;/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5008 rnocache = /<(?:script|object|embed|option|style)/i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5009 // checked="checked" or checked
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5010 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5011 wrapMap = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5012 option: [ 1, "<select multiple='multiple'>", "</select>" ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5013 legend: [ 1, "<fieldset>", "</fieldset>" ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5014 thead: [ 1, "<table>", "</table>" ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5015 tr: [ 2, "<table><tbody>", "</tbody></table>" ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5016 td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5017 col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5018 area: [ 1, "<map>", "</map>" ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5019 _default: [ 0, "", "" ]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5020 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5021
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5022 wrapMap.optgroup = wrapMap.option;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5023 wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5024 wrapMap.th = wrapMap.td;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5025
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5026 // IE can't serialize <link> and <script> tags normally
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5027 if ( !jQuery.support.htmlSerialize ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5028 wrapMap._default = [ 1, "div<div>", "</div>" ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5029 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5030
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5031 jQuery.fn.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5032 text: function( text ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5033 if ( jQuery.isFunction(text) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5034 return this.each(function(i) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5035 var self = jQuery( this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5036
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5037 self.text( text.call(this, i, self.text()) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5038 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5039 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5040
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5041 if ( typeof text !== "object" && text !== undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5042 return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5043 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5044
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5045 return jQuery.text( this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5046 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5047
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5048 wrapAll: function( html ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5049 if ( jQuery.isFunction( html ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5050 return this.each(function(i) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5051 jQuery(this).wrapAll( html.call(this, i) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5052 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5053 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5054
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5055 if ( this[0] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5056 // The elements to wrap the target around
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5057 var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5058
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5059 if ( this[0].parentNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5060 wrap.insertBefore( this[0] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5061 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5062
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5063 wrap.map(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5064 var elem = this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5065
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5066 while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5067 elem = elem.firstChild;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5068 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5069
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5070 return elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5071 }).append(this);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5072 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5073
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5074 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5075 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5076
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5077 wrapInner: function( html ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5078 if ( jQuery.isFunction( html ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5079 return this.each(function(i) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5080 jQuery(this).wrapInner( html.call(this, i) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5081 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5082 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5083
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5084 return this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5085 var self = jQuery( this ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5086 contents = self.contents();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5087
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5088 if ( contents.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5089 contents.wrapAll( html );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5090
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5091 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5092 self.append( html );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5093 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5094 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5095 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5096
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5097 wrap: function( html ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5098 return this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5099 jQuery( this ).wrapAll( html );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5100 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5101 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5102
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5103 unwrap: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5104 return this.parent().each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5105 if ( !jQuery.nodeName( this, "body" ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5106 jQuery( this ).replaceWith( this.childNodes );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5107 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5108 }).end();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5109 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5110
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5111 append: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5112 return this.domManip(arguments, true, function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5113 if ( this.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5114 this.appendChild( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5115 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5116 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5117 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5118
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5119 prepend: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5120 return this.domManip(arguments, true, function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5121 if ( this.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5122 this.insertBefore( elem, this.firstChild );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5123 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5124 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5125 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5126
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5127 before: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5128 if ( this[0] && this[0].parentNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5129 return this.domManip(arguments, false, function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5130 this.parentNode.insertBefore( elem, this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5131 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5132 } else if ( arguments.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5133 var set = jQuery(arguments[0]);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5134 set.push.apply( set, this.toArray() );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5135 return this.pushStack( set, "before", arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5136 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5137 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5138
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5139 after: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5140 if ( this[0] && this[0].parentNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5141 return this.domManip(arguments, false, function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5142 this.parentNode.insertBefore( elem, this.nextSibling );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5143 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5144 } else if ( arguments.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5145 var set = this.pushStack( this, "after", arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5146 set.push.apply( set, jQuery(arguments[0]).toArray() );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5147 return set;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5148 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5149 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5150
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5151 // keepData is for internal use only--do not document
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5152 remove: function( selector, keepData ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5153 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5154 if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5155 if ( !keepData && elem.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5156 jQuery.cleanData( elem.getElementsByTagName("*") );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5157 jQuery.cleanData( [ elem ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5158 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5159
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5160 if ( elem.parentNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5161 elem.parentNode.removeChild( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5162 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5163 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5164 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5165
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5166 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5167 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5168
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5169 empty: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5170 for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5171 // Remove element nodes and prevent memory leaks
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5172 if ( elem.nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5173 jQuery.cleanData( elem.getElementsByTagName("*") );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5174 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5175
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5176 // Remove any remaining nodes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5177 while ( elem.firstChild ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5178 elem.removeChild( elem.firstChild );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5179 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5180 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5181
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5182 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5183 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5184
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5185 clone: function( dataAndEvents, deepDataAndEvents ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5186 dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5187 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5188
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5189 return this.map( function () {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5190 return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5191 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5192 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5193
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5194 html: function( value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5195 if ( value === undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5196 return this[0] && this[0].nodeType === 1 ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5197 this[0].innerHTML.replace(rinlinejQuery, "") :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5198 null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5199
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5200 // See if we can take a shortcut and just use innerHTML
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5201 } else if ( typeof value === "string" && !rnocache.test( value ) &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5202 (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5203 !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5204
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5205 value = value.replace(rxhtmlTag, "<$1></$2>");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5206
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5207 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5208 for ( var i = 0, l = this.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5209 // Remove element nodes and prevent memory leaks
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5210 if ( this[i].nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5211 jQuery.cleanData( this[i].getElementsByTagName("*") );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5212 this[i].innerHTML = value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5213 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5214 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5215
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5216 // If using innerHTML throws an exception, use the fallback method
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5217 } catch(e) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5218 this.empty().append( value );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5219 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5220
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5221 } else if ( jQuery.isFunction( value ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5222 this.each(function(i){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5223 var self = jQuery( this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5224
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5225 self.html( value.call(this, i, self.html()) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5226 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5227
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5228 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5229 this.empty().append( value );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5230 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5231
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5232 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5233 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5234
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5235 replaceWith: function( value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5236 if ( this[0] && this[0].parentNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5237 // Make sure that the elements are removed from the DOM before they are inserted
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5238 // this can help fix replacing a parent with child elements
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5239 if ( jQuery.isFunction( value ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5240 return this.each(function(i) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5241 var self = jQuery(this), old = self.html();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5242 self.replaceWith( value.call( this, i, old ) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5243 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5244 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5245
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5246 if ( typeof value !== "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5247 value = jQuery( value ).detach();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5248 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5249
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5250 return this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5251 var next = this.nextSibling,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5252 parent = this.parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5253
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5254 jQuery( this ).remove();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5255
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5256 if ( next ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5257 jQuery(next).before( value );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5258 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5259 jQuery(parent).append( value );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5260 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5261 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5262 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5263 return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5264 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5265 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5266
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5267 detach: function( selector ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5268 return this.remove( selector, true );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5269 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5270
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5271 domManip: function( args, table, callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5272 var results, first, fragment, parent,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5273 value = args[0],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5274 scripts = [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5275
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5276 // We can't cloneNode fragments that contain checked, in WebKit
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5277 if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5278 return this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5279 jQuery(this).domManip( args, table, callback, true );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5280 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5281 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5282
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5283 if ( jQuery.isFunction(value) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5284 return this.each(function(i) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5285 var self = jQuery(this);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5286 args[0] = value.call(this, i, table ? self.html() : undefined);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5287 self.domManip( args, table, callback );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5288 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5289 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5290
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5291 if ( this[0] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5292 parent = value && value.parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5293
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5294 // If we're in a fragment, just use that instead of building a new one
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5295 if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5296 results = { fragment: parent };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5297
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5298 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5299 results = jQuery.buildFragment( args, this, scripts );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5300 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5301
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5302 fragment = results.fragment;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5303
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5304 if ( fragment.childNodes.length === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5305 first = fragment = fragment.firstChild;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5306 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5307 first = fragment.firstChild;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5308 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5309
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5310 if ( first ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5311 table = table && jQuery.nodeName( first, "tr" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5312
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5313 for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5314 callback.call(
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5315 table ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5316 root(this[i], first) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5317 this[i],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5318 // Make sure that we do not leak memory by inadvertently discarding
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5319 // the original fragment (which might have attached data) instead of
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5320 // using it; in addition, use the original fragment object for the last
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5321 // item instead of first because it can end up being emptied incorrectly
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5322 // in certain situations (Bug #8070).
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5323 // Fragments from the fragment cache must always be cloned and never used
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5324 // in place.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5325 results.cacheable || (l > 1 && i < lastIndex) ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5326 jQuery.clone( fragment, true, true ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5327 fragment
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5328 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5329 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5330 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5331
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5332 if ( scripts.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5333 jQuery.each( scripts, evalScript );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5334 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5335 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5336
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5337 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5338 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5339 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5340
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5341 function root( elem, cur ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5342 return jQuery.nodeName(elem, "table") ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5343 (elem.getElementsByTagName("tbody")[0] ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5344 elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5345 elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5346 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5347
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5348 function cloneCopyEvent( src, dest ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5349
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5350 if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5351 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5352 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5353
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5354 var internalKey = jQuery.expando,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5355 oldData = jQuery.data( src ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5356 curData = jQuery.data( dest, oldData );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5357
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5358 // Switch to use the internal data object, if it exists, for the next
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5359 // stage of data copying
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5360 if ( (oldData = oldData[ internalKey ]) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5361 var events = oldData.events;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5362 curData = curData[ internalKey ] = jQuery.extend({}, oldData);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5363
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5364 if ( events ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5365 delete curData.handle;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5366 curData.events = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5367
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5368 for ( var type in events ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5369 for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5370 jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5371 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5372 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5373 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5374 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5375 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5376
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5377 function cloneFixAttributes(src, dest) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5378 // We do not need to do anything for non-Elements
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5379 if ( dest.nodeType !== 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5380 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5381 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5382
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5383 var nodeName = dest.nodeName.toLowerCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5384
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5385 // clearAttributes removes the attributes, which we don't want,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5386 // but also removes the attachEvent events, which we *do* want
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5387 dest.clearAttributes();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5388
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5389 // mergeAttributes, in contrast, only merges back on the
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5390 // original attributes, not the events
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5391 dest.mergeAttributes(src);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5392
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5393 // IE6-8 fail to clone children inside object elements that use
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5394 // the proprietary classid attribute value (rather than the type
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5395 // attribute) to identify the type of content to display
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5396 if ( nodeName === "object" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5397 dest.outerHTML = src.outerHTML;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5398
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5399 } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5400 // IE6-8 fails to persist the checked state of a cloned checkbox
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5401 // or radio button. Worse, IE6-7 fail to give the cloned element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5402 // a checked appearance if the defaultChecked value isn't also set
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5403 if ( src.checked ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5404 dest.defaultChecked = dest.checked = src.checked;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5405 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5406
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5407 // IE6-7 get confused and end up setting the value of a cloned
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5408 // checkbox/radio button to an empty string instead of "on"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5409 if ( dest.value !== src.value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5410 dest.value = src.value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5411 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5412
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5413 // IE6-8 fails to return the selected option to the default selected
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5414 // state when cloning options
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5415 } else if ( nodeName === "option" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5416 dest.selected = src.defaultSelected;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5417
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5418 // IE6-8 fails to set the defaultValue to the correct value when
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5419 // cloning other types of input fields
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5420 } else if ( nodeName === "input" || nodeName === "textarea" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5421 dest.defaultValue = src.defaultValue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5422 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5423
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5424 // Event data gets referenced instead of copied if the expando
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5425 // gets copied too
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5426 dest.removeAttribute( jQuery.expando );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5427 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5428
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5429 jQuery.buildFragment = function( args, nodes, scripts ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5430 var fragment, cacheable, cacheresults,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5431 doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5432
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5433 // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5434 // Cloning options loses the selected state, so don't cache them
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5435 // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5436 // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5437 if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5438 args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5439
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5440 cacheable = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5441 cacheresults = jQuery.fragments[ args[0] ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5442 if ( cacheresults ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5443 if ( cacheresults !== 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5444 fragment = cacheresults;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5445 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5446 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5447 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5448
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5449 if ( !fragment ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5450 fragment = doc.createDocumentFragment();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5451 jQuery.clean( args, doc, fragment, scripts );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5452 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5453
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5454 if ( cacheable ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5455 jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5456 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5457
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5458 return { fragment: fragment, cacheable: cacheable };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5459 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5460
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5461 jQuery.fragments = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5462
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5463 jQuery.each({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5464 appendTo: "append",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5465 prependTo: "prepend",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5466 insertBefore: "before",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5467 insertAfter: "after",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5468 replaceAll: "replaceWith"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5469 }, function( name, original ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5470 jQuery.fn[ name ] = function( selector ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5471 var ret = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5472 insert = jQuery( selector ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5473 parent = this.length === 1 && this[0].parentNode;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5474
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5475 if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5476 insert[ original ]( this[0] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5477 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5478
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5479 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5480 for ( var i = 0, l = insert.length; i < l; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5481 var elems = (i > 0 ? this.clone(true) : this).get();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5482 jQuery( insert[i] )[ original ]( elems );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5483 ret = ret.concat( elems );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5484 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5485
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5486 return this.pushStack( ret, name, insert.selector );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5487 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5488 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5489 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5490
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5491 function getAll( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5492 if ( "getElementsByTagName" in elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5493 return elem.getElementsByTagName( "*" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5494
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5495 } else if ( "querySelectorAll" in elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5496 return elem.querySelectorAll( "*" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5497
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5498 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5499 return [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5500 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5501 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5502
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5503 jQuery.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5504 clone: function( elem, dataAndEvents, deepDataAndEvents ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5505 var clone = elem.cloneNode(true),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5506 srcElements,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5507 destElements,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5508 i;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5509
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5510 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5511 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5512 // IE copies events bound via attachEvent when using cloneNode.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5513 // Calling detachEvent on the clone will also remove the events
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5514 // from the original. In order to get around this, we use some
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5515 // proprietary methods to clear the events. Thanks to MooTools
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5516 // guys for this hotness.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5517
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5518 cloneFixAttributes( elem, clone );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5519
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5520 // Using Sizzle here is crazy slow, so we use getElementsByTagName
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5521 // instead
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5522 srcElements = getAll( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5523 destElements = getAll( clone );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5524
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5525 // Weird iteration because IE will replace the length property
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5526 // with an element if you are cloning the body and one of the
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5527 // elements on the page has a name or id of "length"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5528 for ( i = 0; srcElements[i]; ++i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5529 cloneFixAttributes( srcElements[i], destElements[i] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5530 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5531 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5532
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5533 // Copy the events from the original to the clone
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5534 if ( dataAndEvents ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5535 cloneCopyEvent( elem, clone );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5536
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5537 if ( deepDataAndEvents ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5538 srcElements = getAll( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5539 destElements = getAll( clone );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5540
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5541 for ( i = 0; srcElements[i]; ++i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5542 cloneCopyEvent( srcElements[i], destElements[i] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5543 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5544 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5545 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5546
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5547 // Return the cloned set
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5548 return clone;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5549 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5550 clean: function( elems, context, fragment, scripts ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5551 context = context || document;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5552
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5553 // !context.createElement fails in IE with an error but returns typeof 'object'
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5554 if ( typeof context.createElement === "undefined" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5555 context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5556 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5557
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5558 var ret = [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5559
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5560 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5561 if ( typeof elem === "number" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5562 elem += "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5563 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5564
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5565 if ( !elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5566 continue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5567 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5568
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5569 // Convert html string into DOM nodes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5570 if ( typeof elem === "string" && !rhtml.test( elem ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5571 elem = context.createTextNode( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5572
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5573 } else if ( typeof elem === "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5574 // Fix "XHTML"-style tags in all browsers
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5575 elem = elem.replace(rxhtmlTag, "<$1></$2>");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5576
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5577 // Trim whitespace, otherwise indexOf won't work as expected
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5578 var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5579 wrap = wrapMap[ tag ] || wrapMap._default,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5580 depth = wrap[0],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5581 div = context.createElement("div");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5582
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5583 // Go to html and back, then peel off extra wrappers
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5584 div.innerHTML = wrap[1] + elem + wrap[2];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5585
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5586 // Move to the right depth
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5587 while ( depth-- ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5588 div = div.lastChild;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5589 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5590
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5591 // Remove IE's autoinserted <tbody> from table fragments
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5592 if ( !jQuery.support.tbody ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5593
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5594 // String was a <table>, *may* have spurious <tbody>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5595 var hasBody = rtbody.test(elem),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5596 tbody = tag === "table" && !hasBody ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5597 div.firstChild && div.firstChild.childNodes :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5598
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5599 // String was a bare <thead> or <tfoot>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5600 wrap[1] === "<table>" && !hasBody ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5601 div.childNodes :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5602 [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5603
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5604 for ( var j = tbody.length - 1; j >= 0 ; --j ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5605 if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5606 tbody[ j ].parentNode.removeChild( tbody[ j ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5607 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5608 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5609
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5610 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5611
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5612 // IE completely kills leading whitespace when innerHTML is used
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5613 if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5614 div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5615 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5616
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5617 elem = div.childNodes;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5618 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5619
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5620 if ( elem.nodeType ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5621 ret.push( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5622 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5623 ret = jQuery.merge( ret, elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5624 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5625 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5626
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5627 if ( fragment ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5628 for ( i = 0; ret[i]; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5629 if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5630 scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5631
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5632 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5633 if ( ret[i].nodeType === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5634 ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5635 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5636 fragment.appendChild( ret[i] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5637 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5638 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5639 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5640
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5641 return ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5642 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5643
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5644 cleanData: function( elems ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5645 var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5646 deleteExpando = jQuery.support.deleteExpando;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5647
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5648 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5649 if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5650 continue;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5651 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5652
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5653 id = elem[ jQuery.expando ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5654
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5655 if ( id ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5656 data = cache[ id ] && cache[ id ][ internalKey ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5657
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5658 if ( data && data.events ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5659 for ( var type in data.events ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5660 if ( special[ type ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5661 jQuery.event.remove( elem, type );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5662
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5663 // This is a shortcut to avoid jQuery.event.remove's overhead
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5664 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5665 jQuery.removeEvent( elem, type, data.handle );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5666 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5667 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5668
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5669 // Null the DOM reference to avoid IE6/7/8 leak (#7054)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5670 if ( data.handle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5671 data.handle.elem = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5672 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5673 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5674
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5675 if ( deleteExpando ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5676 delete elem[ jQuery.expando ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5677
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5678 } else if ( elem.removeAttribute ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5679 elem.removeAttribute( jQuery.expando );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5680 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5681
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5682 delete cache[ id ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5683 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5684 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5685 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5686 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5687
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5688 function evalScript( i, elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5689 if ( elem.src ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5690 jQuery.ajax({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5691 url: elem.src,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5692 async: false,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5693 dataType: "script"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5694 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5695 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5696 jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5697 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5698
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5699 if ( elem.parentNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5700 elem.parentNode.removeChild( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5701 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5702 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5703
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5704
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5705
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5706
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5707 var ralpha = /alpha\([^)]*\)/i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5708 ropacity = /opacity=([^)]*)/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5709 rdashAlpha = /-([a-z])/ig,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5710 rupper = /([A-Z])/g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5711 rnumpx = /^-?\d+(?:px)?$/i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5712 rnum = /^-?\d/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5713
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5714 cssShow = { position: "absolute", visibility: "hidden", display: "block" },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5715 cssWidth = [ "Left", "Right" ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5716 cssHeight = [ "Top", "Bottom" ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5717 curCSS,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5718
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5719 getComputedStyle,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5720 currentStyle,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5721
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5722 fcamelCase = function( all, letter ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5723 return letter.toUpperCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5724 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5725
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5726 jQuery.fn.css = function( name, value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5727 // Setting 'undefined' is a no-op
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5728 if ( arguments.length === 2 && value === undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5729 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5730 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5731
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5732 return jQuery.access( this, name, value, true, function( elem, name, value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5733 return value !== undefined ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5734 jQuery.style( elem, name, value ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5735 jQuery.css( elem, name );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5736 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5737 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5738
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5739 jQuery.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5740 // Add in style property hooks for overriding the default
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5741 // behavior of getting and setting a style property
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5742 cssHooks: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5743 opacity: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5744 get: function( elem, computed ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5745 if ( computed ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5746 // We should always get a number back from opacity
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5747 var ret = curCSS( elem, "opacity", "opacity" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5748 return ret === "" ? "1" : ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5749
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5750 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5751 return elem.style.opacity;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5752 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5753 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5754 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5755 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5756
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5757 // Exclude the following css properties to add px
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5758 cssNumber: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5759 "zIndex": true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5760 "fontWeight": true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5761 "opacity": true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5762 "zoom": true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5763 "lineHeight": true
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5764 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5765
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5766 // Add in properties whose names you wish to fix before
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5767 // setting or getting the value
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5768 cssProps: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5769 // normalize float css property
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5770 "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5771 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5772
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5773 // Get and set the style property on a DOM Node
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5774 style: function( elem, name, value, extra ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5775 // Don't set styles on text and comment nodes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5776 if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5777 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5778 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5779
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5780 // Make sure that we're working with the right name
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5781 var ret, origName = jQuery.camelCase( name ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5782 style = elem.style, hooks = jQuery.cssHooks[ origName ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5783
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5784 name = jQuery.cssProps[ origName ] || origName;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5785
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5786 // Check if we're setting a value
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5787 if ( value !== undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5788 // Make sure that NaN and null values aren't set. See: #7116
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5789 if ( typeof value === "number" && isNaN( value ) || value == null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5790 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5791 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5792
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5793 // If a number was passed in, add 'px' to the (except for certain CSS properties)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5794 if ( typeof value === "number" && !jQuery.cssNumber[ origName ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5795 value += "px";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5796 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5797
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5798 // If a hook was provided, use that value, otherwise just set the specified value
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5799 if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5800 // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5801 // Fixes bug #5509
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5802 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5803 style[ name ] = value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5804 } catch(e) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5805 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5806
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5807 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5808 // If a hook was provided get the non-computed value from there
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5809 if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5810 return ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5811 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5812
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5813 // Otherwise just get the value from the style object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5814 return style[ name ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5815 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5816 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5817
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5818 css: function( elem, name, extra ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5819 // Make sure that we're working with the right name
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5820 var ret, origName = jQuery.camelCase( name ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5821 hooks = jQuery.cssHooks[ origName ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5822
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5823 name = jQuery.cssProps[ origName ] || origName;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5824
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5825 // If a hook was provided get the computed value from there
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5826 if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5827 return ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5828
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5829 // Otherwise, if a way to get the computed value exists, use that
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5830 } else if ( curCSS ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5831 return curCSS( elem, name, origName );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5832 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5833 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5834
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5835 // A method for quickly swapping in/out CSS properties to get correct calculations
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5836 swap: function( elem, options, callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5837 var old = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5838
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5839 // Remember the old values, and insert the new ones
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5840 for ( var name in options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5841 old[ name ] = elem.style[ name ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5842 elem.style[ name ] = options[ name ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5843 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5844
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5845 callback.call( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5846
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5847 // Revert the old values
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5848 for ( name in options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5849 elem.style[ name ] = old[ name ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5850 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5851 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5852
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5853 camelCase: function( string ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5854 return string.replace( rdashAlpha, fcamelCase );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5855 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5856 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5857
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5858 // DEPRECATED, Use jQuery.css() instead
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5859 jQuery.curCSS = jQuery.css;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5860
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5861 jQuery.each(["height", "width"], function( i, name ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5862 jQuery.cssHooks[ name ] = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5863 get: function( elem, computed, extra ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5864 var val;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5865
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5866 if ( computed ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5867 if ( elem.offsetWidth !== 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5868 val = getWH( elem, name, extra );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5869
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5870 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5871 jQuery.swap( elem, cssShow, function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5872 val = getWH( elem, name, extra );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5873 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5874 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5875
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5876 if ( val <= 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5877 val = curCSS( elem, name, name );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5878
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5879 if ( val === "0px" && currentStyle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5880 val = currentStyle( elem, name, name );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5881 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5882
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5883 if ( val != null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5884 // Should return "auto" instead of 0, use 0 for
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5885 // temporary backwards-compat
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5886 return val === "" || val === "auto" ? "0px" : val;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5887 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5888 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5889
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5890 if ( val < 0 || val == null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5891 val = elem.style[ name ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5892
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5893 // Should return "auto" instead of 0, use 0 for
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5894 // temporary backwards-compat
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5895 return val === "" || val === "auto" ? "0px" : val;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5896 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5897
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5898 return typeof val === "string" ? val : val + "px";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5899 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5900 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5901
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5902 set: function( elem, value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5903 if ( rnumpx.test( value ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5904 // ignore negative width and height values #1599
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5905 value = parseFloat(value);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5906
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5907 if ( value >= 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5908 return value + "px";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5909 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5910
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5911 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5912 return value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5913 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5914 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5915 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5916 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5917
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5918 if ( !jQuery.support.opacity ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5919 jQuery.cssHooks.opacity = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5920 get: function( elem, computed ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5921 // IE uses filters for opacity
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5922 return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5923 (parseFloat(RegExp.$1) / 100) + "" :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5924 computed ? "1" : "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5925 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5926
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5927 set: function( elem, value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5928 var style = elem.style;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5929
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5930 // IE has trouble with opacity if it does not have layout
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5931 // Force it by setting the zoom level
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5932 style.zoom = 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5933
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5934 // Set the alpha filter to set the opacity
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5935 var opacity = jQuery.isNaN(value) ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5936 "" :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5937 "alpha(opacity=" + value * 100 + ")",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5938 filter = style.filter || "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5939
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5940 style.filter = ralpha.test(filter) ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5941 filter.replace(ralpha, opacity) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5942 style.filter + ' ' + opacity;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5943 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5944 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5945 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5946
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5947 if ( document.defaultView && document.defaultView.getComputedStyle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5948 getComputedStyle = function( elem, newName, name ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5949 var ret, defaultView, computedStyle;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5950
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5951 name = name.replace( rupper, "-$1" ).toLowerCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5952
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5953 if ( !(defaultView = elem.ownerDocument.defaultView) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5954 return undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5955 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5956
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5957 if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5958 ret = computedStyle.getPropertyValue( name );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5959 if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5960 ret = jQuery.style( elem, name );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5961 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5962 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5963
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5964 return ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5965 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5966 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5967
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5968 if ( document.documentElement.currentStyle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5969 currentStyle = function( elem, name ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5970 var left,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5971 ret = elem.currentStyle && elem.currentStyle[ name ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5972 rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5973 style = elem.style;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5974
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5975 // From the awesome hack by Dean Edwards
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5976 // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5977
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5978 // If we're not dealing with a regular pixel number
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5979 // but a number that has a weird ending, we need to convert it to pixels
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5980 if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5981 // Remember the original values
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5982 left = style.left;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5983
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5984 // Put in the new values to get a computed value out
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5985 if ( rsLeft ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5986 elem.runtimeStyle.left = elem.currentStyle.left;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5987 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5988 style.left = name === "fontSize" ? "1em" : (ret || 0);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5989 ret = style.pixelLeft + "px";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5990
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5991 // Revert the changed values
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5992 style.left = left;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5993 if ( rsLeft ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5994 elem.runtimeStyle.left = rsLeft;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5995 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5996 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5997
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5998 return ret === "" ? "auto" : ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5999 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6000 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6001
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6002 curCSS = getComputedStyle || currentStyle;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6003
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6004 function getWH( elem, name, extra ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6005 var which = name === "width" ? cssWidth : cssHeight,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6006 val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6007
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6008 if ( extra === "border" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6009 return val;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6010 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6011
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6012 jQuery.each( which, function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6013 if ( !extra ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6014 val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6015 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6016
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6017 if ( extra === "margin" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6018 val += parseFloat(jQuery.css( elem, "margin" + this )) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6019
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6020 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6021 val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6022 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6023 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6024
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6025 return val;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6026 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6027
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6028 if ( jQuery.expr && jQuery.expr.filters ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6029 jQuery.expr.filters.hidden = function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6030 var width = elem.offsetWidth,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6031 height = elem.offsetHeight;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6032
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6033 return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6034 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6035
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6036 jQuery.expr.filters.visible = function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6037 return !jQuery.expr.filters.hidden( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6038 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6039 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6040
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6041
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6042
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6043
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6044 var r20 = /%20/g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6045 rbracket = /\[\]$/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6046 rCRLF = /\r?\n/g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6047 rhash = /#.*$/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6048 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6049 rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6050 // #7653, #8125, #8152: local protocol detection
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6051 rlocalProtocol = /(?:^file|^widget|\-extension):$/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6052 rnoContent = /^(?:GET|HEAD)$/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6053 rprotocol = /^\/\//,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6054 rquery = /\?/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6055 rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6056 rselectTextarea = /^(?:select|textarea)/i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6057 rspacesAjax = /\s+/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6058 rts = /([?&])_=[^&]*/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6059 rucHeaders = /(^|\-)([a-z])/g,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6060 rucHeadersFunc = function( _, $1, $2 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6061 return $1 + $2.toUpperCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6062 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6063 rurl = /^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6064
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6065 // Keep a copy of the old load method
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6066 _load = jQuery.fn.load,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6067
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6068 /* Prefilters
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6069 * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6070 * 2) These are called:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6071 * - BEFORE asking for a transport
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6072 * - AFTER param serialization (s.data is a string if s.processData is true)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6073 * 3) key is the dataType
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6074 * 4) the catchall symbol "*" can be used
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6075 * 5) execution will start with transport dataType and THEN continue down to "*" if needed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6076 */
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6077 prefilters = {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6078
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6079 /* Transports bindings
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6080 * 1) key is the dataType
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6081 * 2) the catchall symbol "*" can be used
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6082 * 3) selection will start with transport dataType and THEN go to "*" if needed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6083 */
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6084 transports = {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6085
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6086 // Document location
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6087 ajaxLocation,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6088
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6089 // Document location segments
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6090 ajaxLocParts;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6091
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6092 // #8138, IE may throw an exception when accessing
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6093 // a field from document.location if document.domain has been set
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6094 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6095 ajaxLocation = document.location.href;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6096 } catch( e ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6097 // Use the href attribute of an A element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6098 // since IE will modify it given document.location
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6099 ajaxLocation = document.createElement( "a" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6100 ajaxLocation.href = "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6101 ajaxLocation = ajaxLocation.href;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6102 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6103
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6104 // Segment location into parts
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6105 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6106
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6107 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6108 function addToPrefiltersOrTransports( structure ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6109
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6110 // dataTypeExpression is optional and defaults to "*"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6111 return function( dataTypeExpression, func ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6112
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6113 if ( typeof dataTypeExpression !== "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6114 func = dataTypeExpression;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6115 dataTypeExpression = "*";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6116 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6117
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6118 if ( jQuery.isFunction( func ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6119 var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6120 i = 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6121 length = dataTypes.length,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6122 dataType,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6123 list,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6124 placeBefore;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6125
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6126 // For each dataType in the dataTypeExpression
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6127 for(; i < length; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6128 dataType = dataTypes[ i ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6129 // We control if we're asked to add before
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6130 // any existing element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6131 placeBefore = /^\+/.test( dataType );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6132 if ( placeBefore ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6133 dataType = dataType.substr( 1 ) || "*";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6134 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6135 list = structure[ dataType ] = structure[ dataType ] || [];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6136 // then we add to the structure accordingly
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6137 list[ placeBefore ? "unshift" : "push" ]( func );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6138 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6139 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6140 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6141 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6142
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6143 //Base inspection function for prefilters and transports
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6144 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6145 dataType /* internal */, inspected /* internal */ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6146
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6147 dataType = dataType || options.dataTypes[ 0 ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6148 inspected = inspected || {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6149
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6150 inspected[ dataType ] = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6151
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6152 var list = structure[ dataType ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6153 i = 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6154 length = list ? list.length : 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6155 executeOnly = ( structure === prefilters ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6156 selection;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6157
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6158 for(; i < length && ( executeOnly || !selection ); i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6159 selection = list[ i ]( options, originalOptions, jqXHR );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6160 // If we got redirected to another dataType
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6161 // we try there if executing only and not done already
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6162 if ( typeof selection === "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6163 if ( !executeOnly || inspected[ selection ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6164 selection = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6165 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6166 options.dataTypes.unshift( selection );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6167 selection = inspectPrefiltersOrTransports(
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6168 structure, options, originalOptions, jqXHR, selection, inspected );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6169 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6170 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6171 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6172 // If we're only executing or nothing was selected
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6173 // we try the catchall dataType if not done already
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6174 if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6175 selection = inspectPrefiltersOrTransports(
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6176 structure, options, originalOptions, jqXHR, "*", inspected );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6177 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6178 // unnecessary when only executing (prefilters)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6179 // but it'll be ignored by the caller in that case
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6180 return selection;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6181 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6182
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6183 jQuery.fn.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6184 load: function( url, params, callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6185 if ( typeof url !== "string" && _load ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6186 return _load.apply( this, arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6187
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6188 // Don't do a request if no elements are being requested
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6189 } else if ( !this.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6190 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6191 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6192
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6193 var off = url.indexOf( " " );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6194 if ( off >= 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6195 var selector = url.slice( off, url.length );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6196 url = url.slice( 0, off );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6197 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6198
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6199 // Default to a GET request
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6200 var type = "GET";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6201
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6202 // If the second parameter was provided
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6203 if ( params ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6204 // If it's a function
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6205 if ( jQuery.isFunction( params ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6206 // We assume that it's the callback
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6207 callback = params;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6208 params = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6209
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6210 // Otherwise, build a param string
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6211 } else if ( typeof params === "object" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6212 params = jQuery.param( params, jQuery.ajaxSettings.traditional );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6213 type = "POST";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6214 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6215 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6216
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6217 var self = this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6218
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6219 // Request the remote document
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6220 jQuery.ajax({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6221 url: url,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6222 type: type,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6223 dataType: "html",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6224 data: params,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6225 // Complete callback (responseText is used internally)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6226 complete: function( jqXHR, status, responseText ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6227 // Store the response as specified by the jqXHR object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6228 responseText = jqXHR.responseText;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6229 // If successful, inject the HTML into all the matched elements
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6230 if ( jqXHR.isResolved() ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6231 // #4825: Get the actual response in case
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6232 // a dataFilter is present in ajaxSettings
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6233 jqXHR.done(function( r ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6234 responseText = r;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6235 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6236 // See if a selector was specified
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6237 self.html( selector ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6238 // Create a dummy div to hold the results
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6239 jQuery("<div>")
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6240 // inject the contents of the document in, removing the scripts
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6241 // to avoid any 'Permission Denied' errors in IE
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6242 .append(responseText.replace(rscript, ""))
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6243
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6244 // Locate the specified elements
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6245 .find(selector) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6246
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6247 // If not, just inject the full result
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6248 responseText );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6249 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6250
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6251 if ( callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6252 self.each( callback, [ responseText, status, jqXHR ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6253 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6254 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6255 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6256
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6257 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6258 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6259
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6260 serialize: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6261 return jQuery.param( this.serializeArray() );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6262 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6263
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6264 serializeArray: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6265 return this.map(function(){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6266 return this.elements ? jQuery.makeArray( this.elements ) : this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6267 })
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6268 .filter(function(){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6269 return this.name && !this.disabled &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6270 ( this.checked || rselectTextarea.test( this.nodeName ) ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6271 rinput.test( this.type ) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6272 })
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6273 .map(function( i, elem ){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6274 var val = jQuery( this ).val();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6275
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6276 return val == null ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6277 null :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6278 jQuery.isArray( val ) ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6279 jQuery.map( val, function( val, i ){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6280 return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6281 }) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6282 { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6283 }).get();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6284 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6285 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6286
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6287 // Attach a bunch of functions for handling common AJAX events
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6288 jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6289 jQuery.fn[ o ] = function( f ){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6290 return this.bind( o, f );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6291 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6292 } );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6293
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6294 jQuery.each( [ "get", "post" ], function( i, method ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6295 jQuery[ method ] = function( url, data, callback, type ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6296 // shift arguments if data argument was omitted
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6297 if ( jQuery.isFunction( data ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6298 type = type || callback;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6299 callback = data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6300 data = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6301 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6302
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6303 return jQuery.ajax({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6304 type: method,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6305 url: url,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6306 data: data,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6307 success: callback,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6308 dataType: type
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6309 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6310 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6311 } );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6312
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6313 jQuery.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6314
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6315 getScript: function( url, callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6316 return jQuery.get( url, undefined, callback, "script" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6317 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6318
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6319 getJSON: function( url, data, callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6320 return jQuery.get( url, data, callback, "json" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6321 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6322
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6323 // Creates a full fledged settings object into target
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6324 // with both ajaxSettings and settings fields.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6325 // If target is omitted, writes into ajaxSettings.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6326 ajaxSetup: function ( target, settings ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6327 if ( !settings ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6328 // Only one parameter, we extend ajaxSettings
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6329 settings = target;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6330 target = jQuery.extend( true, jQuery.ajaxSettings, settings );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6331 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6332 // target was provided, we extend into it
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6333 jQuery.extend( true, target, jQuery.ajaxSettings, settings );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6334 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6335 // Flatten fields we don't want deep extended
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6336 for( var field in { context: 1, url: 1 } ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6337 if ( field in settings ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6338 target[ field ] = settings[ field ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6339 } else if( field in jQuery.ajaxSettings ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6340 target[ field ] = jQuery.ajaxSettings[ field ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6341 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6342 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6343 return target;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6344 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6345
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6346 ajaxSettings: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6347 url: ajaxLocation,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6348 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6349 global: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6350 type: "GET",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6351 contentType: "application/x-www-form-urlencoded",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6352 processData: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6353 async: true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6354 /*
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6355 timeout: 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6356 data: null,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6357 dataType: null,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6358 username: null,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6359 password: null,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6360 cache: null,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6361 traditional: false,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6362 headers: {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6363 crossDomain: null,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6364 */
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6365
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6366 accepts: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6367 xml: "application/xml, text/xml",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6368 html: "text/html",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6369 text: "text/plain",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6370 json: "application/json, text/javascript",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6371 "*": "*/*"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6372 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6373
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6374 contents: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6375 xml: /xml/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6376 html: /html/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6377 json: /json/
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6378 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6379
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6380 responseFields: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6381 xml: "responseXML",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6382 text: "responseText"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6383 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6384
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6385 // List of data converters
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6386 // 1) key format is "source_type destination_type" (a single space in-between)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6387 // 2) the catchall symbol "*" can be used for source_type
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6388 converters: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6389
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6390 // Convert anything to text
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6391 "* text": window.String,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6392
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6393 // Text to html (true = no transformation)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6394 "text html": true,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6395
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6396 // Evaluate text as a json expression
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6397 "text json": jQuery.parseJSON,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6398
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6399 // Parse text as xml
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6400 "text xml": jQuery.parseXML
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6401 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6402 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6403
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6404 ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6405 ajaxTransport: addToPrefiltersOrTransports( transports ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6406
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6407 // Main method
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6408 ajax: function( url, options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6409
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6410 // If url is an object, simulate pre-1.5 signature
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6411 if ( typeof url === "object" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6412 options = url;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6413 url = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6414 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6415
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6416 // Force options to be an object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6417 options = options || {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6418
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6419 var // Create the final options object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6420 s = jQuery.ajaxSetup( {}, options ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6421 // Callbacks context
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6422 callbackContext = s.context || s,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6423 // Context for global events
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6424 // It's the callbackContext if one was provided in the options
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6425 // and if it's a DOM node or a jQuery collection
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6426 globalEventContext = callbackContext !== s &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6427 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6428 jQuery( callbackContext ) : jQuery.event,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6429 // Deferreds
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6430 deferred = jQuery.Deferred(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6431 completeDeferred = jQuery._Deferred(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6432 // Status-dependent callbacks
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6433 statusCode = s.statusCode || {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6434 // ifModified key
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6435 ifModifiedKey,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6436 // Headers (they are sent all at once)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6437 requestHeaders = {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6438 // Response headers
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6439 responseHeadersString,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6440 responseHeaders,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6441 // transport
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6442 transport,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6443 // timeout handle
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6444 timeoutTimer,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6445 // Cross-domain detection vars
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6446 parts,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6447 // The jqXHR state
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6448 state = 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6449 // To know if global events are to be dispatched
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6450 fireGlobals,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6451 // Loop variable
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6452 i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6453 // Fake xhr
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6454 jqXHR = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6455
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6456 readyState: 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6457
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6458 // Caches the header
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6459 setRequestHeader: function( name, value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6460 if ( !state ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6461 requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6462 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6463 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6464 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6465
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6466 // Raw string
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6467 getAllResponseHeaders: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6468 return state === 2 ? responseHeadersString : null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6469 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6470
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6471 // Builds headers hashtable if needed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6472 getResponseHeader: function( key ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6473 var match;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6474 if ( state === 2 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6475 if ( !responseHeaders ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6476 responseHeaders = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6477 while( ( match = rheaders.exec( responseHeadersString ) ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6478 responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6479 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6480 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6481 match = responseHeaders[ key.toLowerCase() ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6482 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6483 return match === undefined ? null : match;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6484 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6485
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6486 // Overrides response content-type header
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6487 overrideMimeType: function( type ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6488 if ( !state ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6489 s.mimeType = type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6490 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6491 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6492 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6493
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6494 // Cancel the request
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6495 abort: function( statusText ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6496 statusText = statusText || "abort";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6497 if ( transport ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6498 transport.abort( statusText );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6499 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6500 done( 0, statusText );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6501 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6502 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6503 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6504
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6505 // Callback for when everything is done
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6506 // It is defined here because jslint complains if it is declared
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6507 // at the end of the function (which would be more logical and readable)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6508 function done( status, statusText, responses, headers ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6509
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6510 // Called once
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6511 if ( state === 2 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6512 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6513 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6514
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6515 // State is "done" now
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6516 state = 2;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6517
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6518 // Clear timeout if it exists
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6519 if ( timeoutTimer ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6520 clearTimeout( timeoutTimer );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6521 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6522
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6523 // Dereference transport for early garbage collection
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6524 // (no matter how long the jqXHR object will be used)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6525 transport = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6526
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6527 // Cache response headers
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6528 responseHeadersString = headers || "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6529
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6530 // Set readyState
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6531 jqXHR.readyState = status ? 4 : 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6532
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6533 var isSuccess,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6534 success,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6535 error,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6536 response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6537 lastModified,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6538 etag;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6539
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6540 // If successful, handle type chaining
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6541 if ( status >= 200 && status < 300 || status === 304 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6542
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6543 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6544 if ( s.ifModified ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6545
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6546 if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6547 jQuery.lastModified[ ifModifiedKey ] = lastModified;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6548 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6549 if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6550 jQuery.etag[ ifModifiedKey ] = etag;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6551 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6552 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6553
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6554 // If not modified
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6555 if ( status === 304 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6556
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6557 statusText = "notmodified";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6558 isSuccess = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6559
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6560 // If we have data
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6561 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6562
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6563 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6564 success = ajaxConvert( s, response );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6565 statusText = "success";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6566 isSuccess = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6567 } catch(e) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6568 // We have a parsererror
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6569 statusText = "parsererror";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6570 error = e;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6571 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6572 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6573 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6574 // We extract error from statusText
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6575 // then normalize statusText and status for non-aborts
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6576 error = statusText;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6577 if( !statusText || status ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6578 statusText = "error";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6579 if ( status < 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6580 status = 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6581 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6582 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6583 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6584
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6585 // Set data for the fake xhr object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6586 jqXHR.status = status;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6587 jqXHR.statusText = statusText;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6588
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6589 // Success/Error
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6590 if ( isSuccess ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6591 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6592 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6593 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6594 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6595
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6596 // Status-dependent callbacks
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6597 jqXHR.statusCode( statusCode );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6598 statusCode = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6599
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6600 if ( fireGlobals ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6601 globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6602 [ jqXHR, s, isSuccess ? success : error ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6603 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6604
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6605 // Complete
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6606 completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6607
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6608 if ( fireGlobals ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6609 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6610 // Handle the global AJAX counter
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6611 if ( !( --jQuery.active ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6612 jQuery.event.trigger( "ajaxStop" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6613 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6614 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6615 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6616
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6617 // Attach deferreds
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6618 deferred.promise( jqXHR );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6619 jqXHR.success = jqXHR.done;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6620 jqXHR.error = jqXHR.fail;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6621 jqXHR.complete = completeDeferred.done;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6622
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6623 // Status-dependent callbacks
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6624 jqXHR.statusCode = function( map ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6625 if ( map ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6626 var tmp;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6627 if ( state < 2 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6628 for( tmp in map ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6629 statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6630 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6631 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6632 tmp = map[ jqXHR.status ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6633 jqXHR.then( tmp, tmp );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6634 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6635 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6636 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6637 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6638
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6639 // Remove hash character (#7531: and string promotion)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6640 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6641 // We also use the url parameter if available
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6642 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6643
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6644 // Extract dataTypes list
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6645 s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6646
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6647 // Determine if a cross-domain request is in order
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6648 if ( !s.crossDomain ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6649 parts = rurl.exec( s.url.toLowerCase() );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6650 s.crossDomain = !!( parts &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6651 ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6652 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6653 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6654 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6655 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6656
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6657 // Convert data if not already a string
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6658 if ( s.data && s.processData && typeof s.data !== "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6659 s.data = jQuery.param( s.data, s.traditional );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6660 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6661
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6662 // Apply prefilters
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6663 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6664
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6665 // If request was aborted inside a prefiler, stop there
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6666 if ( state === 2 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6667 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6668 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6669
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6670 // We can fire global events as of now if asked to
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6671 fireGlobals = s.global;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6672
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6673 // Uppercase the type
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6674 s.type = s.type.toUpperCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6675
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6676 // Determine if request has content
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6677 s.hasContent = !rnoContent.test( s.type );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6678
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6679 // Watch for a new set of requests
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6680 if ( fireGlobals && jQuery.active++ === 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6681 jQuery.event.trigger( "ajaxStart" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6682 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6683
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6684 // More options handling for requests with no content
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6685 if ( !s.hasContent ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6686
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6687 // If data is available, append data to url
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6688 if ( s.data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6689 s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6690 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6691
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6692 // Get ifModifiedKey before adding the anti-cache parameter
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6693 ifModifiedKey = s.url;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6694
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6695 // Add anti-cache in url if needed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6696 if ( s.cache === false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6697
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6698 var ts = jQuery.now(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6699 // try replacing _= if it is there
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6700 ret = s.url.replace( rts, "$1_=" + ts );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6701
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6702 // if nothing was replaced, add timestamp to the end
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6703 s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6704 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6705 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6706
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6707 // Set the correct header, if data is being sent
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6708 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6709 requestHeaders[ "Content-Type" ] = s.contentType;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6710 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6711
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6712 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6713 if ( s.ifModified ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6714 ifModifiedKey = ifModifiedKey || s.url;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6715 if ( jQuery.lastModified[ ifModifiedKey ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6716 requestHeaders[ "If-Modified-Since" ] = jQuery.lastModified[ ifModifiedKey ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6717 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6718 if ( jQuery.etag[ ifModifiedKey ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6719 requestHeaders[ "If-None-Match" ] = jQuery.etag[ ifModifiedKey ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6720 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6721 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6722
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6723 // Set the Accepts header for the server, depending on the dataType
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6724 requestHeaders.Accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6725 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6726 s.accepts[ "*" ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6727
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6728 // Check for headers option
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6729 for ( i in s.headers ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6730 jqXHR.setRequestHeader( i, s.headers[ i ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6731 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6732
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6733 // Allow custom headers/mimetypes and early abort
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6734 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6735 // Abort if not done already
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6736 jqXHR.abort();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6737 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6738
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6739 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6740
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6741 // Install callbacks on deferreds
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6742 for ( i in { success: 1, error: 1, complete: 1 } ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6743 jqXHR[ i ]( s[ i ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6744 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6745
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6746 // Get transport
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6747 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6748
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6749 // If no transport, we auto-abort
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6750 if ( !transport ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6751 done( -1, "No Transport" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6752 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6753 jqXHR.readyState = 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6754 // Send global event
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6755 if ( fireGlobals ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6756 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6757 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6758 // Timeout
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6759 if ( s.async && s.timeout > 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6760 timeoutTimer = setTimeout( function(){
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6761 jqXHR.abort( "timeout" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6762 }, s.timeout );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6763 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6764
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6765 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6766 state = 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6767 transport.send( requestHeaders, done );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6768 } catch (e) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6769 // Propagate exception as error if not done
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6770 if ( status < 2 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6771 done( -1, e );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6772 // Simply rethrow otherwise
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6773 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6774 jQuery.error( e );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6775 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6776 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6777 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6778
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6779 return jqXHR;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6780 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6781
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6782 // Serialize an array of form elements or a set of
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6783 // key/values into a query string
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6784 param: function( a, traditional ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6785 var s = [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6786 add = function( key, value ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6787 // If value is a function, invoke it and return its value
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6788 value = jQuery.isFunction( value ) ? value() : value;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6789 s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6790 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6791
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6792 // Set traditional to true for jQuery <= 1.3.2 behavior.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6793 if ( traditional === undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6794 traditional = jQuery.ajaxSettings.traditional;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6795 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6796
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6797 // If an array was passed in, assume that it is an array of form elements.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6798 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6799 // Serialize the form elements
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6800 jQuery.each( a, function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6801 add( this.name, this.value );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6802 } );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6803
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6804 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6805 // If traditional, encode the "old" way (the way 1.3.2 or older
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6806 // did it), otherwise encode params recursively.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6807 for ( var prefix in a ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6808 buildParams( prefix, a[ prefix ], traditional, add );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6809 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6810 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6811
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6812 // Return the resulting serialization
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6813 return s.join( "&" ).replace( r20, "+" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6814 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6815 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6816
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6817 function buildParams( prefix, obj, traditional, add ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6818 if ( jQuery.isArray( obj ) && obj.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6819 // Serialize array item.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6820 jQuery.each( obj, function( i, v ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6821 if ( traditional || rbracket.test( prefix ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6822 // Treat each array item as a scalar.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6823 add( prefix, v );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6824
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6825 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6826 // If array item is non-scalar (array or object), encode its
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6827 // numeric index to resolve deserialization ambiguity issues.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6828 // Note that rack (as of 1.0.0) can't currently deserialize
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6829 // nested arrays properly, and attempting to do so may cause
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6830 // a server error. Possible fixes are to modify rack's
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6831 // deserialization algorithm or to provide an option or flag
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6832 // to force array serialization to be shallow.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6833 buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6834 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6835 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6836
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6837 } else if ( !traditional && obj != null && typeof obj === "object" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6838 // If we see an array here, it is empty and should be treated as an empty
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6839 // object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6840 if ( jQuery.isArray( obj ) || jQuery.isEmptyObject( obj ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6841 add( prefix, "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6842
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6843 // Serialize object item.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6844 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6845 for ( var name in obj ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6846 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6847 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6848 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6849
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6850 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6851 // Serialize scalar item.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6852 add( prefix, obj );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6853 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6854 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6855
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6856 // This is still on the jQuery object... for now
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6857 // Want to move this to jQuery.ajax some day
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6858 jQuery.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6859
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6860 // Counter for holding the number of active queries
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6861 active: 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6862
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6863 // Last-Modified header cache for next request
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6864 lastModified: {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6865 etag: {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6866
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6867 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6868
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6869 /* Handles responses to an ajax request:
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6870 * - sets all responseXXX fields accordingly
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6871 * - finds the right dataType (mediates between content-type and expected dataType)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6872 * - returns the corresponding response
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6873 */
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6874 function ajaxHandleResponses( s, jqXHR, responses ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6875
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6876 var contents = s.contents,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6877 dataTypes = s.dataTypes,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6878 responseFields = s.responseFields,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6879 ct,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6880 type,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6881 finalDataType,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6882 firstDataType;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6883
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6884 // Fill responseXXX fields
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6885 for( type in responseFields ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6886 if ( type in responses ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6887 jqXHR[ responseFields[type] ] = responses[ type ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6888 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6889 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6890
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6891 // Remove auto dataType and get content-type in the process
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6892 while( dataTypes[ 0 ] === "*" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6893 dataTypes.shift();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6894 if ( ct === undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6895 ct = s.mimeType || jqXHR.getResponseHeader( "content-type" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6896 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6897 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6898
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6899 // Check if we're dealing with a known content-type
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6900 if ( ct ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6901 for ( type in contents ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6902 if ( contents[ type ] && contents[ type ].test( ct ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6903 dataTypes.unshift( type );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6904 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6905 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6906 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6907 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6908
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6909 // Check to see if we have a response for the expected dataType
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6910 if ( dataTypes[ 0 ] in responses ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6911 finalDataType = dataTypes[ 0 ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6912 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6913 // Try convertible dataTypes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6914 for ( type in responses ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6915 if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6916 finalDataType = type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6917 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6918 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6919 if ( !firstDataType ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6920 firstDataType = type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6921 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6922 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6923 // Or just use first one
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6924 finalDataType = finalDataType || firstDataType;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6925 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6926
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6927 // If we found a dataType
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6928 // We add the dataType to the list if needed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6929 // and return the corresponding response
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6930 if ( finalDataType ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6931 if ( finalDataType !== dataTypes[ 0 ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6932 dataTypes.unshift( finalDataType );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6933 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6934 return responses[ finalDataType ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6935 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6936 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6937
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6938 // Chain conversions given the request and the original response
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6939 function ajaxConvert( s, response ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6940
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6941 // Apply the dataFilter if provided
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6942 if ( s.dataFilter ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6943 response = s.dataFilter( response, s.dataType );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6944 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6945
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6946 var dataTypes = s.dataTypes,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6947 converters = {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6948 i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6949 key,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6950 length = dataTypes.length,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6951 tmp,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6952 // Current and previous dataTypes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6953 current = dataTypes[ 0 ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6954 prev,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6955 // Conversion expression
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6956 conversion,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6957 // Conversion function
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6958 conv,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6959 // Conversion functions (transitive conversion)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6960 conv1,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6961 conv2;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6962
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6963 // For each dataType in the chain
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6964 for( i = 1; i < length; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6965
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6966 // Create converters map
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6967 // with lowercased keys
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6968 if ( i === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6969 for( key in s.converters ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6970 if( typeof key === "string" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6971 converters[ key.toLowerCase() ] = s.converters[ key ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6972 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6973 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6974 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6975
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6976 // Get the dataTypes
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6977 prev = current;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6978 current = dataTypes[ i ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6979
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6980 // If current is auto dataType, update it to prev
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6981 if( current === "*" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6982 current = prev;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6983 // If no auto and dataTypes are actually different
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6984 } else if ( prev !== "*" && prev !== current ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6985
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6986 // Get the converter
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6987 conversion = prev + " " + current;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6988 conv = converters[ conversion ] || converters[ "* " + current ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6989
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6990 // If there is no direct converter, search transitively
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6991 if ( !conv ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6992 conv2 = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6993 for( conv1 in converters ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6994 tmp = conv1.split( " " );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6995 if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6996 conv2 = converters[ tmp[1] + " " + current ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6997 if ( conv2 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6998 conv1 = converters[ conv1 ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6999 if ( conv1 === true ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7000 conv = conv2;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7001 } else if ( conv2 === true ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7002 conv = conv1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7003 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7004 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7005 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7006 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7007 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7008 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7009 // If we found no converter, dispatch an error
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7010 if ( !( conv || conv2 ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7011 jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7012 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7013 // If found converter is not an equivalence
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7014 if ( conv !== true ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7015 // Convert with 1 or 2 converters accordingly
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7016 response = conv ? conv( response ) : conv2( conv1(response) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7017 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7018 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7019 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7020 return response;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7021 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7022
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7023
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7024
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7025
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7026 var jsc = jQuery.now(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7027 jsre = /(\=)\?(&|$)|()\?\?()/i;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7028
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7029 // Default jsonp settings
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7030 jQuery.ajaxSetup({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7031 jsonp: "callback",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7032 jsonpCallback: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7033 return jQuery.expando + "_" + ( jsc++ );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7034 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7035 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7036
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7037 // Detect, normalize options and install callbacks for jsonp requests
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7038 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7039
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7040 var dataIsString = ( typeof s.data === "string" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7041
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7042 if ( s.dataTypes[ 0 ] === "jsonp" ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7043 originalSettings.jsonpCallback ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7044 originalSettings.jsonp != null ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7045 s.jsonp !== false && ( jsre.test( s.url ) ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7046 dataIsString && jsre.test( s.data ) ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7047
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7048 var responseContainer,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7049 jsonpCallback = s.jsonpCallback =
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7050 jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7051 previous = window[ jsonpCallback ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7052 url = s.url,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7053 data = s.data,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7054 replace = "$1" + jsonpCallback + "$2",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7055 cleanUp = function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7056 // Set callback back to previous value
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7057 window[ jsonpCallback ] = previous;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7058 // Call if it was a function and we have a response
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7059 if ( responseContainer && jQuery.isFunction( previous ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7060 window[ jsonpCallback ]( responseContainer[ 0 ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7061 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7062 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7063
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7064 if ( s.jsonp !== false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7065 url = url.replace( jsre, replace );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7066 if ( s.url === url ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7067 if ( dataIsString ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7068 data = data.replace( jsre, replace );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7069 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7070 if ( s.data === data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7071 // Add callback manually
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7072 url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7073 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7074 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7075 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7076
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7077 s.url = url;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7078 s.data = data;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7079
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7080 // Install callback
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7081 window[ jsonpCallback ] = function( response ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7082 responseContainer = [ response ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7083 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7084
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7085 // Install cleanUp function
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7086 jqXHR.then( cleanUp, cleanUp );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7087
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7088 // Use data converter to retrieve json after script execution
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7089 s.converters["script json"] = function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7090 if ( !responseContainer ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7091 jQuery.error( jsonpCallback + " was not called" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7092 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7093 return responseContainer[ 0 ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7094 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7095
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7096 // force json dataType
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7097 s.dataTypes[ 0 ] = "json";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7098
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7099 // Delegate to script
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7100 return "script";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7101 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7102 } );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7103
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7104
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7105
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7106
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7107 // Install script dataType
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7108 jQuery.ajaxSetup({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7109 accepts: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7110 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7111 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7112 contents: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7113 script: /javascript|ecmascript/
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7114 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7115 converters: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7116 "text script": function( text ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7117 jQuery.globalEval( text );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7118 return text;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7119 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7120 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7121 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7122
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7123 // Handle cache's special case and global
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7124 jQuery.ajaxPrefilter( "script", function( s ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7125 if ( s.cache === undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7126 s.cache = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7127 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7128 if ( s.crossDomain ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7129 s.type = "GET";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7130 s.global = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7131 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7132 } );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7133
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7134 // Bind script tag hack transport
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7135 jQuery.ajaxTransport( "script", function(s) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7136
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7137 // This transport only deals with cross domain requests
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7138 if ( s.crossDomain ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7139
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7140 var script,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7141 head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7142
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7143 return {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7144
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7145 send: function( _, callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7146
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7147 script = document.createElement( "script" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7148
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7149 script.async = "async";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7150
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7151 if ( s.scriptCharset ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7152 script.charset = s.scriptCharset;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7153 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7154
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7155 script.src = s.url;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7156
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7157 // Attach handlers for all browsers
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7158 script.onload = script.onreadystatechange = function( _, isAbort ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7159
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7160 if ( !script.readyState || /loaded|complete/.test( script.readyState ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7161
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7162 // Handle memory leak in IE
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7163 script.onload = script.onreadystatechange = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7164
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7165 // Remove the script
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7166 if ( head && script.parentNode ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7167 head.removeChild( script );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7168 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7169
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7170 // Dereference the script
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7171 script = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7172
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7173 // Callback if not abort
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7174 if ( !isAbort ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7175 callback( 200, "success" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7176 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7177 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7178 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7179 // Use insertBefore instead of appendChild to circumvent an IE6 bug.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7180 // This arises when a base node is used (#2709 and #4378).
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7181 head.insertBefore( script, head.firstChild );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7182 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7183
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7184 abort: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7185 if ( script ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7186 script.onload( 0, 1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7187 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7188 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7189 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7190 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7191 } );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7192
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7193
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7194
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7195
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7196 var // #5280: next active xhr id and list of active xhrs' callbacks
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7197 xhrId = jQuery.now(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7198 xhrCallbacks,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7199
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7200 // XHR used to determine supports properties
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7201 testXHR;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7202
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7203 // #5280: Internet Explorer will keep connections alive if we don't abort on unload
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7204 function xhrOnUnloadAbort() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7205 jQuery( window ).unload(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7206 // Abort all pending requests
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7207 for ( var key in xhrCallbacks ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7208 xhrCallbacks[ key ]( 0, 1 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7209 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7210 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7211 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7212
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7213 // Functions to create xhrs
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7214 function createStandardXHR() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7215 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7216 return new window.XMLHttpRequest();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7217 } catch( e ) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7218 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7219
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7220 function createActiveXHR() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7221 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7222 return new window.ActiveXObject( "Microsoft.XMLHTTP" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7223 } catch( e ) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7224 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7225
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7226 // Create the request object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7227 // (This is still attached to ajaxSettings for backward compatibility)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7228 jQuery.ajaxSettings.xhr = window.ActiveXObject ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7229 /* Microsoft failed to properly
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7230 * implement the XMLHttpRequest in IE7 (can't request local files),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7231 * so we use the ActiveXObject when it is available
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7232 * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7233 * we need a fallback.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7234 */
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7235 function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7236 return !this.isLocal && createStandardXHR() || createActiveXHR();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7237 } :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7238 // For all other browsers, use the standard XMLHttpRequest object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7239 createStandardXHR;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7240
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7241 // Test if we can create an xhr object
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7242 testXHR = jQuery.ajaxSettings.xhr();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7243 jQuery.support.ajax = !!testXHR;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7244
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7245 // Does this browser support crossDomain XHR requests
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7246 jQuery.support.cors = testXHR && ( "withCredentials" in testXHR );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7247
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7248 // No need for the temporary xhr anymore
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7249 testXHR = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7250
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7251 // Create transport if the browser can provide an xhr
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7252 if ( jQuery.support.ajax ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7253
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7254 jQuery.ajaxTransport(function( s ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7255 // Cross domain only allowed if supported through XMLHttpRequest
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7256 if ( !s.crossDomain || jQuery.support.cors ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7257
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7258 var callback;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7259
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7260 return {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7261 send: function( headers, complete ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7262
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7263 // Get a new xhr
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7264 var xhr = s.xhr(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7265 handle,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7266 i;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7267
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7268 // Open the socket
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7269 // Passing null username, generates a login popup on Opera (#2865)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7270 if ( s.username ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7271 xhr.open( s.type, s.url, s.async, s.username, s.password );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7272 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7273 xhr.open( s.type, s.url, s.async );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7274 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7275
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7276 // Apply custom fields if provided
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7277 if ( s.xhrFields ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7278 for ( i in s.xhrFields ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7279 xhr[ i ] = s.xhrFields[ i ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7280 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7281 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7282
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7283 // Override mime type if needed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7284 if ( s.mimeType && xhr.overrideMimeType ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7285 xhr.overrideMimeType( s.mimeType );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7286 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7287
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7288 // Requested-With header
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7289 // Not set for crossDomain requests with no content
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7290 // (see why at http://trac.dojotoolkit.org/ticket/9486)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7291 // Won't change header if already provided
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7292 if ( !( s.crossDomain && !s.hasContent ) && !headers["X-Requested-With"] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7293 headers[ "X-Requested-With" ] = "XMLHttpRequest";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7294 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7295
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7296 // Need an extra try/catch for cross domain requests in Firefox 3
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7297 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7298 for ( i in headers ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7299 xhr.setRequestHeader( i, headers[ i ] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7300 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7301 } catch( _ ) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7302
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7303 // Do send the request
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7304 // This may raise an exception which is actually
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7305 // handled in jQuery.ajax (so no try/catch here)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7306 xhr.send( ( s.hasContent && s.data ) || null );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7307
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7308 // Listener
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7309 callback = function( _, isAbort ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7310
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7311 var status,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7312 statusText,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7313 responseHeaders,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7314 responses,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7315 xml;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7316
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7317 // Firefox throws exceptions when accessing properties
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7318 // of an xhr when a network error occured
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7319 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7320 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7321
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7322 // Was never called and is aborted or complete
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7323 if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7324
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7325 // Only called once
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7326 callback = undefined;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7327
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7328 // Do not keep as active anymore
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7329 if ( handle ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7330 xhr.onreadystatechange = jQuery.noop;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7331 delete xhrCallbacks[ handle ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7332 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7333
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7334 // If it's an abort
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7335 if ( isAbort ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7336 // Abort it manually if needed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7337 if ( xhr.readyState !== 4 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7338 xhr.abort();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7339 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7340 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7341 status = xhr.status;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7342 responseHeaders = xhr.getAllResponseHeaders();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7343 responses = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7344 xml = xhr.responseXML;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7345
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7346 // Construct response list
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7347 if ( xml && xml.documentElement /* #4958 */ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7348 responses.xml = xml;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7349 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7350 responses.text = xhr.responseText;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7351
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7352 // Firefox throws an exception when accessing
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7353 // statusText for faulty cross-domain requests
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7354 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7355 statusText = xhr.statusText;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7356 } catch( e ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7357 // We normalize with Webkit giving an empty statusText
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7358 statusText = "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7359 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7360
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7361 // Filter status for non standard behaviors
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7362
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7363 // If the request is local and we have data: assume a success
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7364 // (success with no data won't get notified, that's the best we
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7365 // can do given current implementations)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7366 if ( !status && s.isLocal && !s.crossDomain ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7367 status = responses.text ? 200 : 404;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7368 // IE - #1450: sometimes returns 1223 when it should be 204
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7369 } else if ( status === 1223 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7370 status = 204;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7371 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7372 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7373 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7374 } catch( firefoxAccessException ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7375 if ( !isAbort ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7376 complete( -1, firefoxAccessException );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7377 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7378 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7379
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7380 // Call complete if needed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7381 if ( responses ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7382 complete( status, statusText, responses, responseHeaders );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7383 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7384 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7385
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7386 // if we're in sync mode or it's in cache
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7387 // and has been retrieved directly (IE6 & IE7)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7388 // we need to manually fire the callback
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7389 if ( !s.async || xhr.readyState === 4 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7390 callback();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7391 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7392 // Create the active xhrs callbacks list if needed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7393 // and attach the unload handler
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7394 if ( !xhrCallbacks ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7395 xhrCallbacks = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7396 xhrOnUnloadAbort();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7397 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7398 // Add to list of active xhrs callbacks
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7399 handle = xhrId++;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7400 xhr.onreadystatechange = xhrCallbacks[ handle ] = callback;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7401 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7402 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7403
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7404 abort: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7405 if ( callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7406 callback(0,1);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7407 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7408 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7409 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7410 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7411 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7412 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7413
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7414
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7415
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7416
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7417 var elemdisplay = {},
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7418 rfxtypes = /^(?:toggle|show|hide)$/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7419 rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7420 timerId,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7421 fxAttrs = [
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7422 // height animations
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7423 [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7424 // width animations
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7425 [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7426 // opacity animations
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7427 [ "opacity" ]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7428 ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7429
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7430 jQuery.fn.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7431 show: function( speed, easing, callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7432 var elem, display;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7433
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7434 if ( speed || speed === 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7435 return this.animate( genFx("show", 3), speed, easing, callback);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7436
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7437 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7438 for ( var i = 0, j = this.length; i < j; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7439 elem = this[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7440 display = elem.style.display;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7441
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7442 // Reset the inline display of this element to learn if it is
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7443 // being hidden by cascaded rules or not
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7444 if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7445 display = elem.style.display = "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7446 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7447
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7448 // Set elements which have been overridden with display: none
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7449 // in a stylesheet to whatever the default browser style is
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7450 // for such an element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7451 if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7452 jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7453 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7454 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7455
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7456 // Set the display of most of the elements in a second loop
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7457 // to avoid the constant reflow
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7458 for ( i = 0; i < j; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7459 elem = this[i];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7460 display = elem.style.display;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7461
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7462 if ( display === "" || display === "none" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7463 elem.style.display = jQuery._data(elem, "olddisplay") || "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7464 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7465 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7466
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7467 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7468 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7469 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7470
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7471 hide: function( speed, easing, callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7472 if ( speed || speed === 0 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7473 return this.animate( genFx("hide", 3), speed, easing, callback);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7474
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7475 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7476 for ( var i = 0, j = this.length; i < j; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7477 var display = jQuery.css( this[i], "display" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7478
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7479 if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7480 jQuery._data( this[i], "olddisplay", display );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7481 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7482 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7483
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7484 // Set the display of the elements in a second loop
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7485 // to avoid the constant reflow
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7486 for ( i = 0; i < j; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7487 this[i].style.display = "none";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7488 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7489
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7490 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7491 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7492 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7493
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7494 // Save the old toggle function
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7495 _toggle: jQuery.fn.toggle,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7496
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7497 toggle: function( fn, fn2, callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7498 var bool = typeof fn === "boolean";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7499
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7500 if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7501 this._toggle.apply( this, arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7502
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7503 } else if ( fn == null || bool ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7504 this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7505 var state = bool ? fn : jQuery(this).is(":hidden");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7506 jQuery(this)[ state ? "show" : "hide" ]();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7507 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7508
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7509 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7510 this.animate(genFx("toggle", 3), fn, fn2, callback);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7511 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7512
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7513 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7514 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7515
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7516 fadeTo: function( speed, to, easing, callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7517 return this.filter(":hidden").css("opacity", 0).show().end()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7518 .animate({opacity: to}, speed, easing, callback);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7519 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7520
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7521 animate: function( prop, speed, easing, callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7522 var optall = jQuery.speed(speed, easing, callback);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7523
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7524 if ( jQuery.isEmptyObject( prop ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7525 return this.each( optall.complete );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7526 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7527
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7528 return this[ optall.queue === false ? "each" : "queue" ](function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7529 // XXX 'this' does not always have a nodeName when running the
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7530 // test suite
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7531
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7532 var opt = jQuery.extend({}, optall), p,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7533 isElement = this.nodeType === 1,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7534 hidden = isElement && jQuery(this).is(":hidden"),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7535 self = this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7536
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7537 for ( p in prop ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7538 var name = jQuery.camelCase( p );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7539
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7540 if ( p !== name ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7541 prop[ name ] = prop[ p ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7542 delete prop[ p ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7543 p = name;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7544 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7545
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7546 if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7547 return opt.complete.call(this);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7548 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7549
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7550 if ( isElement && ( p === "height" || p === "width" ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7551 // Make sure that nothing sneaks out
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7552 // Record all 3 overflow attributes because IE does not
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7553 // change the overflow attribute when overflowX and
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7554 // overflowY are set to the same value
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7555 opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7556
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7557 // Set display property to inline-block for height/width
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7558 // animations on inline elements that are having width/height
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7559 // animated
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7560 if ( jQuery.css( this, "display" ) === "inline" &&
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7561 jQuery.css( this, "float" ) === "none" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7562 if ( !jQuery.support.inlineBlockNeedsLayout ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7563 this.style.display = "inline-block";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7564
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7565 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7566 var display = defaultDisplay(this.nodeName);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7567
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7568 // inline-level elements accept inline-block;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7569 // block-level elements need to be inline with layout
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7570 if ( display === "inline" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7571 this.style.display = "inline-block";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7572
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7573 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7574 this.style.display = "inline";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7575 this.style.zoom = 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7576 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7577 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7578 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7579 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7580
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7581 if ( jQuery.isArray( prop[p] ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7582 // Create (if needed) and add to specialEasing
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7583 (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7584 prop[p] = prop[p][0];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7585 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7586 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7587
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7588 if ( opt.overflow != null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7589 this.style.overflow = "hidden";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7590 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7591
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7592 opt.curAnim = jQuery.extend({}, prop);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7593
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7594 jQuery.each( prop, function( name, val ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7595 var e = new jQuery.fx( self, opt, name );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7596
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7597 if ( rfxtypes.test(val) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7598 e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7599
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7600 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7601 var parts = rfxnum.exec(val),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7602 start = e.cur();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7603
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7604 if ( parts ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7605 var end = parseFloat( parts[2] ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7606 unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7607
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7608 // We need to compute starting value
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7609 if ( unit !== "px" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7610 jQuery.style( self, name, (end || 1) + unit);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7611 start = ((end || 1) / e.cur()) * start;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7612 jQuery.style( self, name, start + unit);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7613 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7614
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7615 // If a +=/-= token was provided, we're doing a relative animation
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7616 if ( parts[1] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7617 end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7618 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7619
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7620 e.custom( start, end, unit );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7621
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7622 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7623 e.custom( start, val, "" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7624 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7625 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7626 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7627
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7628 // For JS strict compliance
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7629 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7630 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7631 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7632
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7633 stop: function( clearQueue, gotoEnd ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7634 var timers = jQuery.timers;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7635
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7636 if ( clearQueue ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7637 this.queue([]);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7638 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7639
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7640 this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7641 // go in reverse order so anything added to the queue during the loop is ignored
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7642 for ( var i = timers.length - 1; i >= 0; i-- ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7643 if ( timers[i].elem === this ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7644 if (gotoEnd) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7645 // force the next step to be the last
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7646 timers[i](true);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7647 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7648
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7649 timers.splice(i, 1);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7650 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7651 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7652 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7653
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7654 // start the next in the queue if the last step wasn't forced
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7655 if ( !gotoEnd ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7656 this.dequeue();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7657 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7658
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7659 return this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7660 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7661
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7662 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7663
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7664 function genFx( type, num ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7665 var obj = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7666
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7667 jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7668 obj[ this ] = type;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7669 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7670
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7671 return obj;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7672 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7673
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7674 // Generate shortcuts for custom animations
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7675 jQuery.each({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7676 slideDown: genFx("show", 1),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7677 slideUp: genFx("hide", 1),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7678 slideToggle: genFx("toggle", 1),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7679 fadeIn: { opacity: "show" },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7680 fadeOut: { opacity: "hide" },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7681 fadeToggle: { opacity: "toggle" }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7682 }, function( name, props ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7683 jQuery.fn[ name ] = function( speed, easing, callback ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7684 return this.animate( props, speed, easing, callback );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7685 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7686 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7687
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7688 jQuery.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7689 speed: function( speed, easing, fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7690 var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7691 complete: fn || !fn && easing ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7692 jQuery.isFunction( speed ) && speed,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7693 duration: speed,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7694 easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7695 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7696
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7697 opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7698 opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7699
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7700 // Queueing
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7701 opt.old = opt.complete;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7702 opt.complete = function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7703 if ( opt.queue !== false ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7704 jQuery(this).dequeue();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7705 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7706 if ( jQuery.isFunction( opt.old ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7707 opt.old.call( this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7708 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7709 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7710
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7711 return opt;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7712 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7713
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7714 easing: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7715 linear: function( p, n, firstNum, diff ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7716 return firstNum + diff * p;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7717 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7718 swing: function( p, n, firstNum, diff ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7719 return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7720 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7721 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7722
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7723 timers: [],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7724
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7725 fx: function( elem, options, prop ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7726 this.options = options;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7727 this.elem = elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7728 this.prop = prop;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7729
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7730 if ( !options.orig ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7731 options.orig = {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7732 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7733 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7734
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7735 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7736
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7737 jQuery.fx.prototype = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7738 // Simple function for setting a style value
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7739 update: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7740 if ( this.options.step ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7741 this.options.step.call( this.elem, this.now, this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7742 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7743
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7744 (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7745 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7746
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7747 // Get the current size
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7748 cur: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7749 if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7750 return this.elem[ this.prop ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7751 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7752
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7753 var parsed,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7754 r = jQuery.css( this.elem, this.prop );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7755 // Empty strings, null, undefined and "auto" are converted to 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7756 // complex values such as "rotate(1rad)" are returned as is,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7757 // simple values such as "10px" are parsed to Float.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7758 return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7759 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7760
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7761 // Start an animation from one number to another
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7762 custom: function( from, to, unit ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7763 var self = this,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7764 fx = jQuery.fx;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7765
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7766 this.startTime = jQuery.now();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7767 this.start = from;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7768 this.end = to;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7769 this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7770 this.now = this.start;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7771 this.pos = this.state = 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7772
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7773 function t( gotoEnd ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7774 return self.step(gotoEnd);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7775 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7776
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7777 t.elem = this.elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7778
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7779 if ( t() && jQuery.timers.push(t) && !timerId ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7780 timerId = setInterval(fx.tick, fx.interval);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7781 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7782 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7783
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7784 // Simple 'show' function
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7785 show: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7786 // Remember where we started, so that we can go back to it later
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7787 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7788 this.options.show = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7789
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7790 // Begin the animation
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7791 // Make sure that we start at a small width/height to avoid any
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7792 // flash of content
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7793 this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7794
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7795 // Start by showing the element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7796 jQuery( this.elem ).show();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7797 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7798
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7799 // Simple 'hide' function
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7800 hide: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7801 // Remember where we started, so that we can go back to it later
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7802 this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7803 this.options.hide = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7804
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7805 // Begin the animation
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7806 this.custom(this.cur(), 0);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7807 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7808
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7809 // Each step of an animation
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7810 step: function( gotoEnd ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7811 var t = jQuery.now(), done = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7812
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7813 if ( gotoEnd || t >= this.options.duration + this.startTime ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7814 this.now = this.end;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7815 this.pos = this.state = 1;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7816 this.update();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7817
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7818 this.options.curAnim[ this.prop ] = true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7819
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7820 for ( var i in this.options.curAnim ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7821 if ( this.options.curAnim[i] !== true ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7822 done = false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7823 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7824 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7825
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7826 if ( done ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7827 // Reset the overflow
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7828 if ( this.options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7829 var elem = this.elem,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7830 options = this.options;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7831
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7832 jQuery.each( [ "", "X", "Y" ], function (index, value) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7833 elem.style[ "overflow" + value ] = options.overflow[index];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7834 } );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7835 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7836
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7837 // Hide the element if the "hide" operation was done
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7838 if ( this.options.hide ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7839 jQuery(this.elem).hide();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7840 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7841
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7842 // Reset the properties, if the item has been hidden or shown
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7843 if ( this.options.hide || this.options.show ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7844 for ( var p in this.options.curAnim ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7845 jQuery.style( this.elem, p, this.options.orig[p] );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7846 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7847 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7848
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7849 // Execute the complete function
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7850 this.options.complete.call( this.elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7851 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7852
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7853 return false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7854
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7855 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7856 var n = t - this.startTime;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7857 this.state = n / this.options.duration;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7858
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7859 // Perform the easing function, defaults to swing
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7860 var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7861 var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7862 this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7863 this.now = this.start + ((this.end - this.start) * this.pos);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7864
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7865 // Perform the next step of the animation
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7866 this.update();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7867 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7868
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7869 return true;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7870 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7871 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7872
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7873 jQuery.extend( jQuery.fx, {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7874 tick: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7875 var timers = jQuery.timers;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7876
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7877 for ( var i = 0; i < timers.length; i++ ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7878 if ( !timers[i]() ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7879 timers.splice(i--, 1);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7880 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7881 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7882
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7883 if ( !timers.length ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7884 jQuery.fx.stop();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7885 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7886 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7887
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7888 interval: 13,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7889
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7890 stop: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7891 clearInterval( timerId );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7892 timerId = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7893 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7894
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7895 speeds: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7896 slow: 600,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7897 fast: 200,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7898 // Default speed
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7899 _default: 400
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7900 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7901
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7902 step: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7903 opacity: function( fx ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7904 jQuery.style( fx.elem, "opacity", fx.now );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7905 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7906
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7907 _default: function( fx ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7908 if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7909 fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7910 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7911 fx.elem[ fx.prop ] = fx.now;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7912 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7913 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7914 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7915 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7916
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7917 if ( jQuery.expr && jQuery.expr.filters ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7918 jQuery.expr.filters.animated = function( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7919 return jQuery.grep(jQuery.timers, function( fn ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7920 return elem === fn.elem;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7921 }).length;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7922 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7923 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7924
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7925 function defaultDisplay( nodeName ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7926 if ( !elemdisplay[ nodeName ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7927 var elem = jQuery("<" + nodeName + ">").appendTo("body"),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7928 display = elem.css("display");
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7929
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7930 elem.remove();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7931
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7932 if ( display === "none" || display === "" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7933 display = "block";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7934 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7935
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7936 elemdisplay[ nodeName ] = display;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7937 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7938
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7939 return elemdisplay[ nodeName ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7940 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7941
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7942
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7943
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7944
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7945 var rtable = /^t(?:able|d|h)$/i,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7946 rroot = /^(?:body|html)$/i;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7947
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7948 if ( "getBoundingClientRect" in document.documentElement ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7949 jQuery.fn.offset = function( options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7950 var elem = this[0], box;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7951
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7952 if ( options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7953 return this.each(function( i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7954 jQuery.offset.setOffset( this, options, i );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7955 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7956 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7957
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7958 if ( !elem || !elem.ownerDocument ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7959 return null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7960 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7961
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7962 if ( elem === elem.ownerDocument.body ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7963 return jQuery.offset.bodyOffset( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7964 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7965
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7966 try {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7967 box = elem.getBoundingClientRect();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7968 } catch(e) {}
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7969
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7970 var doc = elem.ownerDocument,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7971 docElem = doc.documentElement;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7972
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7973 // Make sure we're not dealing with a disconnected DOM node
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7974 if ( !box || !jQuery.contains( docElem, elem ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7975 return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7976 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7977
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7978 var body = doc.body,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7979 win = getWindow(doc),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7980 clientTop = docElem.clientTop || body.clientTop || 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7981 clientLeft = docElem.clientLeft || body.clientLeft || 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7982 scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7983 scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7984 top = box.top + scrollTop - clientTop,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7985 left = box.left + scrollLeft - clientLeft;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7986
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7987 return { top: top, left: left };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7988 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7989
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7990 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7991 jQuery.fn.offset = function( options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7992 var elem = this[0];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7993
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7994 if ( options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7995 return this.each(function( i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7996 jQuery.offset.setOffset( this, options, i );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7997 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7998 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7999
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8000 if ( !elem || !elem.ownerDocument ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8001 return null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8002 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8003
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8004 if ( elem === elem.ownerDocument.body ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8005 return jQuery.offset.bodyOffset( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8006 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8007
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8008 jQuery.offset.initialize();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8009
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8010 var computedStyle,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8011 offsetParent = elem.offsetParent,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8012 prevOffsetParent = elem,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8013 doc = elem.ownerDocument,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8014 docElem = doc.documentElement,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8015 body = doc.body,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8016 defaultView = doc.defaultView,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8017 prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8018 top = elem.offsetTop,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8019 left = elem.offsetLeft;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8020
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8021 while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8022 if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8023 break;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8024 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8025
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8026 computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8027 top -= elem.scrollTop;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8028 left -= elem.scrollLeft;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8029
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8030 if ( elem === offsetParent ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8031 top += elem.offsetTop;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8032 left += elem.offsetLeft;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8033
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8034 if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8035 top += parseFloat( computedStyle.borderTopWidth ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8036 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8037 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8038
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8039 prevOffsetParent = offsetParent;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8040 offsetParent = elem.offsetParent;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8041 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8042
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8043 if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8044 top += parseFloat( computedStyle.borderTopWidth ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8045 left += parseFloat( computedStyle.borderLeftWidth ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8046 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8047
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8048 prevComputedStyle = computedStyle;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8049 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8050
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8051 if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8052 top += body.offsetTop;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8053 left += body.offsetLeft;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8054 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8055
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8056 if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8057 top += Math.max( docElem.scrollTop, body.scrollTop );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8058 left += Math.max( docElem.scrollLeft, body.scrollLeft );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8059 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8060
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8061 return { top: top, left: left };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8062 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8063 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8064
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8065 jQuery.offset = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8066 initialize: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8067 var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8068 html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8069
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8070 jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8071
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8072 container.innerHTML = html;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8073 body.insertBefore( container, body.firstChild );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8074 innerDiv = container.firstChild;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8075 checkDiv = innerDiv.firstChild;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8076 td = innerDiv.nextSibling.firstChild.firstChild;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8077
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8078 this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8079 this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8080
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8081 checkDiv.style.position = "fixed";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8082 checkDiv.style.top = "20px";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8083
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8084 // safari subtracts parent border width here which is 5px
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8085 this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8086 checkDiv.style.position = checkDiv.style.top = "";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8087
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8088 innerDiv.style.overflow = "hidden";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8089 innerDiv.style.position = "relative";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8090
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8091 this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8092
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8093 this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8094
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8095 body.removeChild( container );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8096 body = container = innerDiv = checkDiv = table = td = null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8097 jQuery.offset.initialize = jQuery.noop;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8098 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8099
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8100 bodyOffset: function( body ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8101 var top = body.offsetTop,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8102 left = body.offsetLeft;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8103
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8104 jQuery.offset.initialize();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8105
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8106 if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8107 top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8108 left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8109 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8110
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8111 return { top: top, left: left };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8112 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8113
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8114 setOffset: function( elem, options, i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8115 var position = jQuery.css( elem, "position" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8116
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8117 // set position first, in-case top/left are set even on static elem
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8118 if ( position === "static" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8119 elem.style.position = "relative";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8120 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8121
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8122 var curElem = jQuery( elem ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8123 curOffset = curElem.offset(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8124 curCSSTop = jQuery.css( elem, "top" ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8125 curCSSLeft = jQuery.css( elem, "left" ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8126 calculatePosition = (position === "absolute" && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8127 props = {}, curPosition = {}, curTop, curLeft;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8128
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8129 // need to be able to calculate position if either top or left is auto and position is absolute
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8130 if ( calculatePosition ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8131 curPosition = curElem.position();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8132 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8133
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8134 curTop = calculatePosition ? curPosition.top : parseInt( curCSSTop, 10 ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8135 curLeft = calculatePosition ? curPosition.left : parseInt( curCSSLeft, 10 ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8136
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8137 if ( jQuery.isFunction( options ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8138 options = options.call( elem, i, curOffset );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8139 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8140
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8141 if (options.top != null) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8142 props.top = (options.top - curOffset.top) + curTop;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8143 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8144 if (options.left != null) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8145 props.left = (options.left - curOffset.left) + curLeft;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8146 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8147
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8148 if ( "using" in options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8149 options.using.call( elem, props );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8150 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8151 curElem.css( props );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8152 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8153 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8154 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8155
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8156
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8157 jQuery.fn.extend({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8158 position: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8159 if ( !this[0] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8160 return null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8161 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8162
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8163 var elem = this[0],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8164
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8165 // Get *real* offsetParent
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8166 offsetParent = this.offsetParent(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8167
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8168 // Get correct offsets
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8169 offset = this.offset(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8170 parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8171
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8172 // Subtract element margins
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8173 // note: when an element has margin: auto the offsetLeft and marginLeft
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8174 // are the same in Safari causing offset.left to incorrectly be 0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8175 offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8176 offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8177
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8178 // Add offsetParent borders
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8179 parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8180 parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8181
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8182 // Subtract the two offsets
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8183 return {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8184 top: offset.top - parentOffset.top,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8185 left: offset.left - parentOffset.left
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8186 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8187 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8188
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8189 offsetParent: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8190 return this.map(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8191 var offsetParent = this.offsetParent || document.body;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8192 while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8193 offsetParent = offsetParent.offsetParent;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8194 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8195 return offsetParent;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8196 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8197 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8198 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8199
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8200
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8201 // Create scrollLeft and scrollTop methods
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8202 jQuery.each( ["Left", "Top"], function( i, name ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8203 var method = "scroll" + name;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8204
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8205 jQuery.fn[ method ] = function(val) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8206 var elem = this[0], win;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8207
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8208 if ( !elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8209 return null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8210 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8211
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8212 if ( val !== undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8213 // Set the scroll offset
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8214 return this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8215 win = getWindow( this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8216
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8217 if ( win ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8218 win.scrollTo(
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8219 !i ? val : jQuery(win).scrollLeft(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8220 i ? val : jQuery(win).scrollTop()
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8221 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8222
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8223 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8224 this[ method ] = val;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8225 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8226 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8227 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8228 win = getWindow( elem );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8229
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8230 // Return the scroll offset
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8231 return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8232 jQuery.support.boxModel && win.document.documentElement[ method ] ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8233 win.document.body[ method ] :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8234 elem[ method ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8235 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8236 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8237 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8238
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8239 function getWindow( elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8240 return jQuery.isWindow( elem ) ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8241 elem :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8242 elem.nodeType === 9 ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8243 elem.defaultView || elem.parentWindow :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8244 false;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8245 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8246
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8247
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8248
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8249
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8250 // Create innerHeight, innerWidth, outerHeight and outerWidth methods
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8251 jQuery.each([ "Height", "Width" ], function( i, name ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8252
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8253 var type = name.toLowerCase();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8254
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8255 // innerHeight and innerWidth
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8256 jQuery.fn["inner" + name] = function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8257 return this[0] ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8258 parseFloat( jQuery.css( this[0], type, "padding" ) ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8259 null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8260 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8261
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8262 // outerHeight and outerWidth
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8263 jQuery.fn["outer" + name] = function( margin ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8264 return this[0] ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8265 parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8266 null;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8267 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8268
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8269 jQuery.fn[ type ] = function( size ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8270 // Get window width or height
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8271 var elem = this[0];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8272 if ( !elem ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8273 return size == null ? null : this;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8274 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8275
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8276 if ( jQuery.isFunction( size ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8277 return this.each(function( i ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8278 var self = jQuery( this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8279 self[ type ]( size.call( this, i, self[ type ]() ) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8280 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8281 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8282
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8283 if ( jQuery.isWindow( elem ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8284 // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8285 // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8286 var docElemProp = elem.document.documentElement[ "client" + name ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8287 return elem.document.compatMode === "CSS1Compat" && docElemProp ||
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8288 elem.document.body[ "client" + name ] || docElemProp;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8289
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8290 // Get document width or height
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8291 } else if ( elem.nodeType === 9 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8292 // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8293 return Math.max(
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8294 elem.documentElement["client" + name],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8295 elem.body["scroll" + name], elem.documentElement["scroll" + name],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8296 elem.body["offset" + name], elem.documentElement["offset" + name]
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8297 );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8298
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8299 // Get or set width or height on the element
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8300 } else if ( size === undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8301 var orig = jQuery.css( elem, type ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8302 ret = parseFloat( orig );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8303
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8304 return jQuery.isNaN( ret ) ? orig : ret;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8305
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8306 // Set the width or height on the element (default to pixels if value is unitless)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8307 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8308 return this.css( type, typeof size === "string" ? size : size + "px" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8309 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8310 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8311
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8312 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8313
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8314
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8315 window.jQuery = window.$ = jQuery;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8316 })(window);