Редакция 289 | К новейшей редакции | Только различия | Не учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 289 | Редакция 290 | ||
---|---|---|---|
1 | /*!
|
1 | /*!
|
2 | * jQuery JavaScript Library v1.3.3pre
|
2 | * jQuery JavaScript Library v1.3.3pre
|
3 | * http://jquery.com/
|
3 | * http://jquery.com/
|
4 | *
|
4 | *
|
5 | * Copyright (c) 2009 John Resig
|
5 | * Copyright (c) 2009 John Resig
|
6 | * Dual licensed under the MIT and GPL licenses.
|
6 | * Dual licensed under the MIT and GPL licenses.
|
7 | * http://docs.jquery.com/License
|
7 | * http://docs.jquery.com/License
|
8 | *
|
8 | *
|
9 | * Date: 2009-06-17 09:31:45 +0700 (Срд, 17 Июн 2009)
|
9 | * Date: 2009-07-28 03:48:42 +0700 (Втр, 28 Июл 2009)
|
10 | * Revision: 6399
|
10 | * Revision: 6514
|
11 | */
|
11 | */
|
12 | (function(window, undefined){ |
12 | (function(window, undefined){ |
13 | 13 | ||
14 | // Define a local copy of jQuery
|
14 | // Define a local copy of jQuery
|
15 | var jQuery = function( selector, context ) { |
15 | var jQuery = function( selector, context ) { |
16 | // The jQuery object is actually just the init constructor 'enhanced'
|
16 | // The jQuery object is actually just the init constructor 'enhanced'
|
17 | return arguments.length === 0 ? |
17 | return arguments.length === 0 ? |
18 | rootjQuery :
|
18 | rootjQuery :
|
19 | new jQuery.fn.init( selector, context ); |
19 | new jQuery.fn.init( selector, context ); |
20 | }, |
20 | }, |
21 | 21 | ||
22 | // Map over jQuery in case of overwrite
|
22 | // Map over jQuery in case of overwrite
|
23 | _jQuery = window.jQuery, |
23 | _jQuery = window.jQuery, |
24 | 24 | ||
25 | // Map over the $ in case of overwrite
|
25 | // Map over the $ in case of overwrite
|
26 | _$ = window.$, |
26 | _$ = window.$, |
27 | 27 | ||
- | 28 | // Use the correct document accordingly with window argument (sandbox)
|
|
- | 29 | document = window.document, |
|
- | 30 | ||
28 | // A central reference to the root jQuery(document)
|
31 | // A central reference to the root jQuery(document)
|
29 | rootjQuery,
|
32 | rootjQuery,
|
30 | 33 | ||
31 | // A simple way to check for HTML strings or ID strings
|
34 | // A simple way to check for HTML strings or ID strings
|
32 | // (both of which we optimize for)
|
35 | // (both of which we optimize for)
|
33 | quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/, |
36 | quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/, |
34 | 37 | ||
35 | // Is it a simple selector
|
38 | // Is it a simple selector
|
36 | isSimple = /^.[^:#\[\.,]*$/, |
39 | isSimple = /^.[^:#\[\.,]*$/, |
37 | 40 | ||
- | 41 | // Check if a string has a non-whitespace character in it
|
|
- | 42 | rnotwhite = /\S/, |
|
- | 43 | ||
- | 44 | // Used for trimming whitespace
|
|
- | 45 | rtrim = /^\s+|\s+$/g, |
|
- | 46 | ||
38 | // Keep a UserAgent string for use with jQuery.browser
|
47 | // Keep a UserAgent string for use with jQuery.browser
|
39 | userAgent = navigator.userAgent.toLowerCase(), |
48 | userAgent = navigator.userAgent.toLowerCase(), |
40 | 49 | ||
41 | // Save a reference to the core toString method
|
50 | // Save a reference to some core methods
|
42 | toString = Object.prototype.toString; |
51 | toString = Object.prototype.toString, |
- | 52 | push = Array.prototype.push, |
|
- | 53 | slice = Array.prototype.slice; |
|
43 | 54 | ||
44 | // Expose jQuery to the global object
|
55 | // Expose jQuery to the global object
|
45 | window.jQuery = window.$ = jQuery; |
56 | window.jQuery = window.$ = jQuery; |
46 | 57 | ||
47 | jQuery.fn = jQuery.prototype = { |
58 | jQuery.fn = jQuery.prototype = { |
48 | init: function( selector, context ) { |
59 | init: function( selector, context ) { |
49 | var match, elem, ret; |
60 | var match, elem, ret; |
50 | 61 | ||
51 | // Handle $(""), $(null), or $(undefined)
|
62 | // Handle $(""), $(null), or $(undefined)
|
52 | if ( !selector ) { |
63 | if ( !selector ) { |
53 | this.length = 0; |
- | |
54 | return this; |
64 | return this; |
55 | }
|
65 | }
|
56 | 66 | ||
57 | // Handle $(DOMElement)
|
67 | // Handle $(DOMElement)
|
58 | if ( selector.nodeType ) { |
68 | if ( selector.nodeType ) { |
59 | this[0] = selector; |
69 | this.context = this[0] = selector; |
60 | this.length = 1; |
70 | this.length++; |
61 | this.context = selector; |
- | |
62 | return this; |
71 | return this; |
63 | }
|
72 | }
|
64 | 73 | ||
65 | // Handle HTML strings
|
74 | // Handle HTML strings
|
66 | if ( typeof selector === "string" ) { |
75 | if ( typeof selector === "string" ) { |
67 | // Are we dealing with HTML string or an ID?
|
76 | // Are we dealing with HTML string or an ID?
|
68 | match = quickExpr.exec( selector ); |
77 | match = quickExpr.exec( selector ); |
69 | 78 | ||
70 | // Verify a match, and that no context was specified for #id
|
79 | // Verify a match, and that no context was specified for #id
|
71 | if ( match && (match[1] || !context) ) { |
80 | if ( match && (match[1] || !context) ) { |
72 | 81 | ||
73 | // HANDLE: $(html) -> $(array)
|
82 | // HANDLE: $(html) -> $(array)
|
74 | if ( match[1] ) { |
83 | if ( match[1] ) { |
75 | selector = jQuery.clean( [ match[1] ], context ); |
84 | selector = jQuery.clean( [ match[1] ], context ); |
76 | 85 | ||
77 | // HANDLE: $("#id")
|
86 | // HANDLE: $("#id")
|
78 | } else { |
87 | } else { |
79 | elem = document.getElementById( match[3] ); |
88 | elem = document.getElementById( match[2] ); |
80 | 89 | ||
- | 90 | if ( elem ) { |
|
81 | // Handle the case where IE and Opera return items
|
91 | // Handle the case where IE and Opera return items
|
82 | // by name instead of ID
|
92 | // by name instead of ID
|
83 | if ( elem && elem.id !== match[3] ) { |
93 | if ( elem.id !== match[2] ) { |
84 | return rootjQuery.find( selector ); |
94 | return rootjQuery.find( selector ); |
- | 95 | }
|
|
- | 96 | ||
- | 97 | // Otherwise, we inject the element directly into the jQuery object
|
|
- | 98 | this.length++; |
|
- | 99 | this[0] = elem; |
|
85 | }
|
100 | }
|
86 | 101 | ||
87 | // Otherwise, we inject the element directly into the jQuery object
|
- | |
88 | ret = jQuery( elem || null ); |
- | |
89 | ret.context = document; |
102 | this.context = document; |
90 | ret.selector = selector; |
103 | this.selector = selector; |
91 | return ret; |
104 | return this; |
92 | }
|
105 | }
|
93 | 106 | ||
94 | // HANDLE: $(expr, $(...))
|
107 | // HANDLE: $(expr, $(...))
|
95 | } else if ( !context || context.jquery ) { |
108 | } else if ( !context || context.jquery ) { |
96 | return (context || rootjQuery).find( selector ); |
109 | return (context || rootjQuery).find( selector ); |
97 | 110 | ||
98 | // HANDLE: $(expr, context)
|
111 | // HANDLE: $(expr, context)
|
99 | // (which is just equivalent to: $(context).find(expr)
|
112 | // (which is just equivalent to: $(context).find(expr)
|
100 | } else { |
113 | } else { |
101 | return jQuery( context ).find( selector ); |
114 | return jQuery( context ).find( selector ); |
102 | }
|
115 | }
|
103 | 116 | ||
104 | // HANDLE: $(function)
|
117 | // HANDLE: $(function)
|
105 | // Shortcut for document ready
|
118 | // Shortcut for document ready
|
106 | } else if ( jQuery.isFunction( selector ) ) { |
119 | } else if ( jQuery.isFunction( selector ) ) { |
107 | return rootjQuery.ready( selector ); |
120 | return rootjQuery.ready( selector ); |
108 | }
|
121 | }
|
109 | 122 | ||
110 | // Make sure that old selector state is passed along
|
123 | // Make sure that old selector state is passed along
|
111 | if ( selector.selector && selector.context ) { |
124 | if ( selector.selector && selector.context ) { |
112 | this.selector = selector.selector; |
125 | this.selector = selector.selector; |
113 | this.context = selector.context; |
126 | this.context = selector.context; |
114 | }
|
127 | }
|
115 | 128 | ||
116 | return this.setArray(jQuery.isArray( selector ) ? |
129 | return this.setArray(jQuery.isArray( selector ) ? |
117 | selector :
|
130 | selector :
|
118 | jQuery.makeArray(selector)); |
131 | jQuery.makeArray(selector)); |
119 | }, |
132 | }, |
120 | 133 | ||
121 | // Start with an empty selector
|
134 | // Start with an empty selector
|
122 | selector: "", |
135 | selector: "", |
123 | 136 | ||
124 | // The current version of jQuery being used
|
137 | // The current version of jQuery being used
|
125 | jquery: "1.3.3pre", |
138 | jquery: "1.3.3pre", |
126 | 139 | ||
- | 140 | // The default length of a jQuery object is 0
|
|
- | 141 | length: 0, |
|
- | 142 | ||
127 | // The number of elements contained in the matched element set
|
143 | // The number of elements contained in the matched element set
|
128 | size: function() { |
144 | size: function() { |
129 | return this.length; |
145 | return this.length; |
130 | }, |
146 | }, |
131 | 147 | ||
- | 148 | toArray: function(){ |
|
- | 149 | return slice.call( this, 0 ); |
|
- | 150 | }, |
|
- | 151 | ||
132 | // Get the Nth element in the matched element set OR
|
152 | // Get the Nth element in the matched element set OR
|
133 | // Get the whole matched element set as a clean array
|
153 | // Get the whole matched element set as a clean array
|
134 | get: function( num ) { |
154 | get: function( num ) { |
135 | return num == null ? |
155 | return num == null ? |
136 | 156 | ||
137 | // Return a 'clean' array
|
157 | // Return a 'clean' array
|
138 | Array.prototype.slice.call( this ) : |
158 | this.toArray() : |
139 | 159 | ||
140 | // Return just the object
|
160 | // Return just the object
|
141 | this[ num ]; |
161 | ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] ); |
142 | }, |
162 | }, |
143 | 163 | ||
144 | // Take an array of elements and push it onto the stack
|
164 | // Take an array of elements and push it onto the stack
|
145 | // (returning the new matched element set)
|
165 | // (returning the new matched element set)
|
146 | pushStack: function( elems, name, selector ) { |
166 | pushStack: function( elems, name, selector ) { |
147 | // Build a new jQuery matched element set
|
167 | // Build a new jQuery matched element set
|
148 | var ret = jQuery( elems || null ); |
168 | var ret = jQuery( elems || null ); |
149 | 169 | ||
150 | // Add the old object onto the stack (as a reference)
|
170 | // Add the old object onto the stack (as a reference)
|
151 | ret.prevObject = this; |
171 | ret.prevObject = this; |
152 | 172 | ||
153 | ret.context = this.context; |
173 | ret.context = this.context; |
154 | 174 | ||
155 | if ( name === "find" ) { |
175 | if ( name === "find" ) { |
156 | ret.selector = this.selector + (this.selector ? " " : "") + selector; |
176 | ret.selector = this.selector + (this.selector ? " " : "") + selector; |
157 | } else if ( name ) { |
177 | } else if ( name ) { |
158 | ret.selector = this.selector + "." + name + "(" + selector + ")"; |
178 | ret.selector = this.selector + "." + name + "(" + selector + ")"; |
159 | }
|
179 | }
|
160 | 180 | ||
161 | // Return the newly-formed element set
|
181 | // Return the newly-formed element set
|
162 | return ret; |
182 | return ret; |
163 | }, |
183 | }, |
164 | 184 | ||
165 | // Force the current matched set of elements to become
|
185 | // Force the current matched set of elements to become
|
166 | // the specified array of elements (destroying the stack in the process)
|
186 | // the specified array of elements (destroying the stack in the process)
|
167 | // You should use pushStack() in order to do this, but maintain the stack
|
187 | // You should use pushStack() in order to do this, but maintain the stack
|
168 | setArray: function( elems ) { |
188 | setArray: function( elems ) { |
169 | // Resetting the length to 0, then using the native Array push
|
189 | // Resetting the length to 0, then using the native Array push
|
170 | // is a super-fast way to populate an object with array-like properties
|
190 | // is a super-fast way to populate an object with array-like properties
|
171 | this.length = 0; |
191 | this.length = 0; |
172 | Array.prototype.push.apply( this, elems ); |
192 | push.apply( this, elems ); |
173 | 193 | ||
174 | return this; |
194 | return this; |
175 | }, |
195 | }, |
176 | 196 | ||
177 | // Execute a callback for every element in the matched set.
|
197 | // Execute a callback for every element in the matched set.
|
178 | // (You can seed the arguments with an array of args, but this is
|
198 | // (You can seed the arguments with an array of args, but this is
|
179 | // only used internally.)
|
199 | // only used internally.)
|
180 | each: function( callback, args ) { |
200 | each: function( callback, args ) { |
181 | return jQuery.each( this, callback, args ); |
201 | return jQuery.each( this, callback, args ); |
182 | }, |
202 | }, |
183 | 203 | ||
184 | // Determine the position of an element within
|
204 | // Determine the position of an element within
|
185 | // the matched set of elements
|
205 | // the matched set of elements
|
186 | index: function( elem ) { |
206 | index: function( elem ) { |
187 | if ( !elem || typeof elem === "string" ) { |
207 | if ( !elem || typeof elem === "string" ) { |
188 | return jQuery.inArray( this[0], |
208 | return jQuery.inArray( this[0], |
189 | // If it receives a string, the selector is used
|
209 | // If it receives a string, the selector is used
|
190 | // If it receives nothing, the siblings are used
|
210 | // If it receives nothing, the siblings are used
|
191 | elem ? jQuery( elem ) : this.parent().children() ); |
211 | elem ? jQuery( elem ) : this.parent().children() ); |
192 | }
|
212 | }
|
193 | // Locate the position of the desired element
|
213 | // Locate the position of the desired element
|
194 | return jQuery.inArray( |
214 | return jQuery.inArray( |
195 | // If it receives a jQuery object, the first element is used
|
215 | // If it receives a jQuery object, the first element is used
|
196 | elem.jquery ? elem[0] : elem, this ); |
216 | elem.jquery ? elem[0] : elem, this ); |
197 | }, |
217 | }, |
198 | 218 | ||
199 | is: function( selector ) { |
219 | is: function( selector ) { |
200 | return !!selector && jQuery.multiFilter( selector, this ).length > 0; |
220 | return !!selector && jQuery.multiFilter( selector, this ).length > 0; |
201 | }, |
221 | }, |
202 | 222 | ||
203 | // For internal use only.
|
223 | // For internal use only.
|
204 | // Behaves like an Array's method, not like a jQuery method.
|
224 | // Behaves like an Array's method, not like a jQuery method.
|
205 | push: [].push, |
225 | push: push, |
206 | sort: [].sort, |
226 | sort: [].sort, |
207 | splice: [].splice |
227 | splice: [].splice |
208 | }; |
228 | }; |
209 | 229 | ||
210 | // Give the init function the jQuery prototype for later instantiation
|
230 | // Give the init function the jQuery prototype for later instantiation
|
211 | jQuery.fn.init.prototype = jQuery.fn; |
231 | jQuery.fn.init.prototype = jQuery.fn; |
212 | 232 | ||
213 | jQuery.extend = jQuery.fn.extend = function() { |
233 | jQuery.extend = jQuery.fn.extend = function() { |
214 | // copy reference to target object
|
234 | // copy reference to target object
|
215 | var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy; |
235 | var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy; |
216 | 236 | ||
217 | // Handle a deep copy situation
|
237 | // Handle a deep copy situation
|
218 | if ( typeof target === "boolean" ) { |
238 | if ( typeof target === "boolean" ) { |
219 | deep = target; |
239 | deep = target; |
220 | target = arguments[1] || {}; |
240 | target = arguments[1] || {}; |
221 | // skip the boolean and the target
|
241 | // skip the boolean and the target
|
222 | i = 2; |
242 | i = 2; |
223 | }
|
243 | }
|
224 | 244 | ||
225 | // Handle case when target is a string or something (possible in deep copy)
|
245 | // Handle case when target is a string or something (possible in deep copy)
|
226 | if ( typeof target !== "object" && !jQuery.isFunction(target) ) { |
246 | if ( typeof target !== "object" && !jQuery.isFunction(target) ) { |
227 | target = {}; |
247 | target = {}; |
228 | }
|
248 | }
|
229 | 249 | ||
230 | // extend jQuery itself if only one argument is passed
|
250 | // extend jQuery itself if only one argument is passed
|
231 | if ( length === i ) { |
251 | if ( length === i ) { |
232 | target = this; |
252 | target = this; |
233 | --i; |
253 | --i; |
234 | }
|
254 | }
|
235 | 255 | ||
236 | for ( ; i < length; i++ ) { |
256 | for ( ; i < length; i++ ) { |
237 | // Only deal with non-null/undefined values
|
257 | // Only deal with non-null/undefined values
|
238 | if ( (options = arguments[ i ]) != null ) { |
258 | if ( (options = arguments[ i ]) != null ) { |
239 | // Extend the base object
|
259 | // Extend the base object
|
240 | for ( name in options ) { |
260 | for ( name in options ) { |
241 | src = target[ name ]; |
261 | src = target[ name ]; |
242 | copy = options[ name ]; |
262 | copy = options[ name ]; |
243 | 263 | ||
244 | // Prevent never-ending loop
|
264 | // Prevent never-ending loop
|
245 | if ( target === copy ) { |
265 | if ( target === copy ) { |
246 | continue; |
266 | continue; |
247 | }
|
267 | }
|
248 | 268 | ||
249 | // Recurse if we're merging object values
|
269 | // Recurse if we're merging object values
|
250 | if ( deep && copy && typeof copy === "object" && !copy.nodeType ) { |
270 | if ( deep && copy && typeof copy === "object" && !copy.nodeType ) { |
- | 271 | var clone; |
|
- | 272 | ||
- | 273 | if ( src ) { |
|
- | 274 | clone = src; |
|
- | 275 | } else if ( jQuery.isArray(copy) ) { |
|
- | 276 | clone = []; |
|
251 | target[ name ] = jQuery.extend( deep, |
277 | } else if ( jQuery.isObject(copy) ) { |
- | 278 | clone = {}; |
|
- | 279 | } else { |
|
- | 280 | clone = copy; |
|
- | 281 | }
|
|
- | 282 | ||
252 | // Never move original objects, clone them
|
283 | // Never move original objects, clone them
|
253 | src || ( copy.length != null ? [ ] : { } ), copy ); |
284 | target[ name ] = jQuery.extend( deep, clone, copy ); |
254 | 285 | ||
255 | // Don't bring in undefined values
|
286 | // Don't bring in undefined values
|
256 | } else if ( copy !== undefined ) { |
287 | } else if ( copy !== undefined ) { |
257 | target[ name ] = copy; |
288 | target[ name ] = copy; |
258 | }
|
289 | }
|
259 | }
|
290 | }
|
260 | }
|
291 | }
|
261 | }
|
292 | }
|
262 | 293 | ||
263 | // Return the modified object
|
294 | // Return the modified object
|
264 | return target; |
295 | return target; |
265 | }; |
296 | }; |
266 | 297 | ||
267 | jQuery.extend({ |
298 | jQuery.extend({ |
268 | noConflict: function( deep ) { |
299 | noConflict: function( deep ) { |
269 | window.$ = _$; |
300 | window.$ = _$; |
270 | 301 | ||
271 | if ( deep ) { |
302 | if ( deep ) { |
272 | window.jQuery = _jQuery; |
303 | window.jQuery = _jQuery; |
273 | }
|
304 | }
|
274 | 305 | ||
275 | return jQuery; |
306 | return jQuery; |
276 | }, |
307 | }, |
277 | 308 | ||
278 | // See test/unit/core.js for details concerning isFunction.
|
309 | // See test/unit/core.js for details concerning isFunction.
|
279 | // Since version 1.3, DOM methods and functions like alert
|
310 | // Since version 1.3, DOM methods and functions like alert
|
280 | // aren't supported. They return false on IE (#2968).
|
311 | // aren't supported. They return false on IE (#2968).
|
281 | isFunction: function( obj ) { |
312 | isFunction: function( obj ) { |
282 | return toString.call(obj) === "[object Function]"; |
313 | return toString.call(obj) === "[object Function]"; |
283 | }, |
314 | }, |
284 | 315 | ||
285 | isArray: function( obj ) { |
316 | isArray: function( obj ) { |
286 | return toString.call(obj) === "[object Array]"; |
317 | return toString.call(obj) === "[object Array]"; |
287 | }, |
318 | }, |
288 | 319 | ||
- | 320 | isObject: function( obj ) { |
|
- | 321 | return this.constructor.call(obj) === Object; |
|
- | 322 | }, |
|
- | 323 | ||
- | 324 | isEmptyObject: function( obj ) { |
|
- | 325 | for ( var name in obj ) { |
|
- | 326 | return false; |
|
- | 327 | }
|
|
- | 328 | return true; |
|
- | 329 | }, |
|
- | 330 | ||
289 | // check if an element is in a (or is an) XML document
|
331 | // check if an element is in a (or is an) XML document
|
290 | isXMLDoc: function( elem ) { |
332 | isXMLDoc: function( elem ) { |
291 | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || |
333 | // documentElement is verified for cases where it doesn't yet exist
|
- | 334 | // (such as loading iframes in IE - #4833)
|
|
292 | !!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML"; |
335 | return ((elem.ownerDocument || elem).documentElement || 0).nodeName !== "HTML"; |
293 | }, |
336 | }, |
294 | 337 | ||
295 | // Evalulates a script in a global context
|
338 | // Evalulates a script in a global context
|
296 | globalEval: function( data ) { |
339 | globalEval: function( data ) { |
297 | if ( data && /\S/.test(data) ) { |
340 | if ( data && rnotwhite.test(data) ) { |
298 | // Inspired by code by Andrea Giammarchi
|
341 | // Inspired by code by Andrea Giammarchi
|
299 | // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
|
342 | // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
|
300 | var head = document.getElementsByTagName("head")[0] || document.documentElement, |
343 | var head = document.getElementsByTagName("head")[0] || document.documentElement, |
301 | script = document.createElement("script"); |
344 | script = document.createElement("script"); |
302 | 345 | ||
303 | script.type = "text/javascript"; |
346 | script.type = "text/javascript"; |
- | 347 | ||
304 | if ( jQuery.support.scriptEval ) { |
348 | if ( jQuery.support.scriptEval ) { |
305 | script.appendChild( document.createTextNode( data ) ); |
349 | script.appendChild( document.createTextNode( data ) ); |
306 | } else { |
350 | } else { |
307 | script.text = data; |
351 | script.text = data; |
308 | }
|
352 | }
|
309 | 353 | ||
310 | // Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
354 | // Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
311 | // This arises when a base node is used (#2709).
|
355 | // This arises when a base node is used (#2709).
|
312 | head.insertBefore( script, head.firstChild ); |
356 | head.insertBefore( script, head.firstChild ); |
313 | head.removeChild( script ); |
357 | head.removeChild( script ); |
314 | }
|
358 | }
|
315 | }, |
359 | }, |
316 | 360 | ||
317 | nodeName: function( elem, name ) { |
361 | nodeName: function( elem, name ) { |
318 | return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); |
362 | return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); |
319 | }, |
363 | }, |
320 | 364 | ||
321 | // args is for internal usage only
|
365 | // args is for internal usage only
|
322 | each: function( object, callback, args ) { |
366 | each: function( object, callback, args ) { |
- | 367 | var name, i = 0, |
|
323 | var name, i = 0, length = object.length; |
368 | length = object.length, |
- | 369 | isObj = length === undefined || jQuery.isFunction(object); |
|
324 | 370 | ||
325 | if ( args ) { |
371 | if ( args ) { |
326 | if ( length === undefined ) { |
372 | if ( isObj ) { |
327 | for ( name in object ) { |
373 | for ( name in object ) { |
328 | if ( callback.apply( object[ name ], args ) === false ) { |
374 | if ( callback.apply( object[ name ], args ) === false ) { |
329 | break; |
375 | break; |
330 | }
|
376 | }
|
331 | }
|
377 | }
|
332 | } else { |
378 | } else { |
333 | for ( ; i < length; ) { |
379 | for ( ; i < length; ) { |
334 | if ( callback.apply( object[ i++ ], args ) === false ) { |
380 | if ( callback.apply( object[ i++ ], args ) === false ) { |
335 | break; |
381 | break; |
336 | }
|
382 | }
|
337 | }
|
383 | }
|
338 | }
|
384 | }
|
339 | 385 | ||
340 | // A special, fast, case for the most common use of each
|
386 | // A special, fast, case for the most common use of each
|
341 | } else { |
387 | } else { |
342 | if ( length === undefined ) { |
388 | if ( isObj ) { |
343 | for ( name in object ) { |
389 | for ( name in object ) { |
344 | if ( callback.call( object[ name ], name, object[ name ] ) === false ) { |
390 | if ( callback.call( object[ name ], name, object[ name ] ) === false ) { |
345 | break; |
391 | break; |
346 | }
|
392 | }
|
347 | }
|
393 | }
|
348 | } else { |
394 | } else { |
349 | for ( var value = object[0]; |
395 | for ( var value = object[0]; |
350 | i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {} |
396 | i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {} |
351 | }
|
397 | }
|
352 | }
|
398 | }
|
353 | 399 | ||
354 | return object; |
400 | return object; |
355 | }, |
401 | }, |
356 | 402 | ||
357 | trim: function( text ) { |
403 | trim: function( text ) { |
358 | return (text || "").replace( /^\s+|\s+$/g, "" ); |
404 | return (text || "").replace( rtrim, "" ); |
359 | }, |
405 | }, |
360 | 406 | ||
361 | makeArray: function( array ) { |
407 | makeArray: function( array ) { |
362 | var ret = [], i; |
408 | var ret = [], i; |
363 | 409 | ||
364 | if ( array != null ) { |
410 | if ( array != null ) { |
365 | i = array.length; |
411 | i = array.length; |
366 | 412 | ||
367 | // The window, strings (and functions) also have 'length'
|
413 | // The window, strings (and functions) also have 'length'
|
368 | if ( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval ) { |
414 | if ( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval ) { |
369 | ret[0] = array; |
415 | ret[0] = array; |
370 | } else { |
416 | } else { |
371 | while ( i ) { |
417 | while ( i ) { |
372 | ret[--i] = array[i]; |
418 | ret[--i] = array[i]; |
373 | }
|
419 | }
|
374 | }
|
420 | }
|
375 | }
|
421 | }
|
376 | 422 | ||
377 | return ret; |
423 | return ret; |
378 | }, |
424 | }, |
379 | 425 | ||
380 | inArray: function( elem, array ) { |
426 | inArray: function( elem, array ) { |
381 | for ( var i = 0, length = array.length; i < length; i++ ) { |
427 | for ( var i = 0, length = array.length; i < length; i++ ) { |
382 | if ( array[ i ] === elem ) { |
428 | if ( array[ i ] === elem ) { |
383 | return i; |
429 | return i; |
384 | }
|
430 | }
|
385 | }
|
431 | }
|
386 | 432 | ||
387 | return -1; |
433 | return -1; |
388 | }, |
434 | }, |
389 | 435 | ||
390 | merge: function( first, second ) { |
436 | merge: function( first, second ) { |
391 | // We have to loop this way because IE & Opera overwrite the length
|
437 | // We have to loop this way because IE & Opera overwrite the length
|
392 | // expando of getElementsByTagName
|
438 | // expando of getElementsByTagName
|
393 | var i = 0, elem, pos = first.length; |
439 | var i = 0, elem, pos = first.length; |
394 | 440 | ||
395 | // Also, we need to make sure that the correct elements are being returned
|
441 | // Also, we need to make sure that the correct elements are being returned
|
396 | // (IE returns comment nodes in a '*' query)
|
442 | // (IE returns comment nodes in a '*' query)
|
397 | if ( !jQuery.support.getAll ) { |
443 | if ( !jQuery.support.getAll ) { |
398 | while ( (elem = second[ i++ ]) != null ) { |
444 | while ( (elem = second[ i++ ]) != null ) { |
399 | if ( elem.nodeType !== 8 ) { |
445 | if ( elem.nodeType !== 8 ) { |
400 | first[ pos++ ] = elem; |
446 | first[ pos++ ] = elem; |
401 | }
|
447 | }
|
402 | }
|
448 | }
|
403 | 449 | ||
404 | } else { |
450 | } else { |
405 | while ( (elem = second[ i++ ]) != null ) { |
451 | while ( (elem = second[ i++ ]) != null ) { |
406 | first[ pos++ ] = elem; |
452 | first[ pos++ ] = elem; |
407 | }
|
453 | }
|
408 | }
|
454 | }
|
409 | 455 | ||
410 | return first; |
456 | return first; |
411 | }, |
457 | }, |
412 | 458 | ||
413 | unique: function( array ) { |
459 | unique: function( array ) { |
414 | var ret = [], done = {}, id; |
460 | var ret = [], done = {}, id; |
415 | 461 | ||
416 | try { |
462 | try { |
417 | for ( var i = 0, length = array.length; i < length; i++ ) { |
463 | for ( var i = 0, length = array.length; i < length; i++ ) { |
418 | id = jQuery.data( array[ i ] ); |
464 | id = jQuery.data( array[ i ] ); |
419 | 465 | ||
420 | if ( !done[ id ] ) { |
466 | if ( !done[ id ] ) { |
421 | done[ id ] = true; |
467 | done[ id ] = true; |
422 | ret.push( array[ i ] ); |
468 | ret.push( array[ i ] ); |
423 | }
|
469 | }
|
424 | }
|
470 | }
|
425 | } catch( e ) { |
471 | } catch( e ) { |
426 | ret = array; |
472 | ret = array; |
427 | }
|
473 | }
|
428 | 474 | ||
429 | return ret; |
475 | return ret; |
430 | }, |
476 | }, |
431 | 477 | ||
432 | grep: function( elems, callback, inv ) { |
478 | grep: function( elems, callback, inv ) { |
433 | var ret = []; |
479 | var ret = []; |
434 | 480 | ||
435 | // Go through the array, only saving the items
|
481 | // Go through the array, only saving the items
|
436 | // that pass the validator function
|
482 | // that pass the validator function
|
437 | for ( var i = 0, length = elems.length; i < length; i++ ) { |
483 | for ( var i = 0, length = elems.length; i < length; i++ ) { |
438 | if ( !inv !== !callback( elems[ i ], i ) ) { |
484 | if ( !inv !== !callback( elems[ i ], i ) ) { |
439 | ret.push( elems[ i ] ); |
485 | ret.push( elems[ i ] ); |
440 | }
|
486 | }
|
441 | }
|
487 | }
|
442 | 488 | ||
443 | return ret; |
489 | return ret; |
444 | }, |
490 | }, |
445 | 491 | ||
446 | map: function( elems, callback ) { |
492 | map: function( elems, callback ) { |
447 | var ret = [], value; |
493 | var ret = [], value; |
448 | 494 | ||
449 | // Go through the array, translating each of the items to their
|
495 | // Go through the array, translating each of the items to their
|
450 | // new value (or values).
|
496 | // new value (or values).
|
451 | for ( var i = 0, length = elems.length; i < length; i++ ) { |
497 | for ( var i = 0, length = elems.length; i < length; i++ ) { |
452 | value = callback( elems[ i ], i ); |
498 | value = callback( elems[ i ], i ); |
453 | 499 | ||
454 | if ( value != null ) { |
500 | if ( value != null ) { |
455 | ret[ ret.length ] = value; |
501 | ret[ ret.length ] = value; |
456 | }
|
502 | }
|
457 | }
|
503 | }
|
458 | 504 | ||
459 | return ret.concat.apply( [], ret ); |
505 | return ret.concat.apply( [], ret ); |
460 | }, |
506 | }, |
461 | 507 | ||
462 | // Use of jQuery.browser is deprecated.
|
508 | // Use of jQuery.browser is deprecated.
|
463 | // It's included for backwards compatibility and plugins,
|
509 | // It's included for backwards compatibility and plugins,
|
464 | // although they should work to migrate away.
|
510 | // although they should work to migrate away.
|
465 | browser: { |
511 | browser: { |
466 | version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1], |
512 | version: (/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/.exec(userAgent) || [0,'0'])[1], |
467 | safari: /webkit/.test( userAgent ), |
513 | safari: /webkit/.test( userAgent ), |
468 | opera: /opera/.test( userAgent ), |
514 | opera: /opera/.test( userAgent ), |
469 | msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), |
515 | msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), |
470 | mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) |
516 | mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) |
471 | }
|
517 | }
|
472 | }); |
518 | }); |
473 | 519 | ||
474 | // All jQuery objects should point back to these
|
520 | // All jQuery objects should point back to these
|
475 | rootjQuery = jQuery(document); |
521 | rootjQuery = jQuery(document); |
476 | 522 | ||
477 | function evalScript( i, elem ) { |
523 | function evalScript( i, elem ) { |
478 | if ( elem.src ) { |
524 | if ( elem.src ) { |
479 | jQuery.ajax({ |
525 | jQuery.ajax({ |
480 | url: elem.src, |
526 | url: elem.src, |
481 | async: false, |
527 | async: false, |
482 | dataType: "script" |
528 | dataType: "script" |
483 | }); |
529 | }); |
484 | } else { |
530 | } else { |
485 | jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
531 | jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
486 | }
|
532 | }
|
487 | 533 | ||
488 | if ( elem.parentNode ) { |
534 | if ( elem.parentNode ) { |
489 | elem.parentNode.removeChild( elem ); |
535 | elem.parentNode.removeChild( elem ); |
490 | }
|
536 | }
|
491 | }
|
537 | }
|
492 | 538 | ||
493 | function now() { |
539 | function now() { |
494 | return (new Date).getTime(); |
540 | return (new Date).getTime(); |
495 | }
|
541 | }
|
496 | var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
542 | var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
497 | 543 | ||
498 | jQuery.extend({ |
544 | jQuery.extend({ |
499 | cache: {}, |
545 | cache: {}, |
500 | 546 | ||
501 | data: function( elem, name, data ) { |
547 | data: function( elem, name, data ) { |
502 | elem = elem == window ? |
548 | elem = elem == window ? |
503 | windowData :
|
549 | windowData :
|
504 | elem;
|
550 | elem;
|
505 | 551 | ||
506 | var id = elem[ expando ]; |
552 | var id = elem[ expando ], cache = jQuery.cache; |
507 | 553 | ||
508 | // Compute a unique ID for the element
|
554 | // Compute a unique ID for the element
|
509 | if ( !id ) |
- | |
510 | id = elem[ expando ] = ++uuid; |
555 | if(!id) id = elem[ expando ] = ++uuid; |
511 | 556 | ||
512 | // Only generate the data cache if we're
|
557 | // Only generate the data cache if we're
|
513 | // trying to access or manipulate it
|
558 | // trying to access or manipulate it
|
514 | if ( name && !jQuery.cache[ id ] ) |
559 | if ( name && !cache[ id ] ) |
515 | jQuery.cache[ id ] = {}; |
560 | cache[ id ] = {}; |
- | 561 | ||
- | 562 | var thisCache = cache[ id ]; |
|
516 | 563 | ||
517 | // Prevent overriding the named cache with undefined values
|
564 | // Prevent overriding the named cache with undefined values
|
518 | if ( data !== undefined ) |
565 | if ( data !== undefined ) thisCache[ name ] = data; |
519 | jQuery.cache[ id ][ name ] = data; |
- | |
520 | 566 | ||
521 | // Return the named cache data, or the ID for the element
|
567 | if(name === true) return thisCache |
522 | return name ? |
- | |
523 | jQuery.cache[ id ][ name ] : |
568 | else if(name) return thisCache[name] |
524 | id;
|
569 | else return id |
525 | }, |
570 | }, |
526 | 571 | ||
527 | removeData: function( elem, name ) { |
572 | removeData: function( elem, name ) { |
528 | elem = elem == window ? |
573 | elem = elem == window ? |
529 | windowData :
|
574 | windowData :
|
530 | elem;
|
575 | elem;
|
531 | 576 | ||
532 | var id = elem[ expando ]; |
577 | var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ]; |
533 | 578 | ||
534 | // If we want to remove a specific section of the element's data
|
579 | // If we want to remove a specific section of the element's data
|
535 | if ( name ) { |
580 | if ( name ) { |
536 | if ( jQuery.cache[ id ] ) { |
581 | if ( thisCache ) { |
537 | // Remove the section of cache data
|
582 | // Remove the section of cache data
|
538 | delete jQuery.cache[ id ][ name ]; |
583 | delete thisCache[ name ]; |
539 | 584 | ||
540 | // If we've removed all the data, remove the element's cache
|
585 | // If we've removed all the data, remove the element's cache
|
541 | name = ""; |
- | |
542 | - | ||
543 | for ( name in jQuery.cache[ id ] ) |
586 | if( jQuery.isEmptyObject(thisCache) ) |
544 | break; |
- | |
545 | - | ||
546 | if ( !name ) |
- | |
547 | jQuery.removeData( elem ); |
587 | jQuery.removeData( elem ); |
548 | }
|
588 | }
|
549 | 589 | ||
550 | // Otherwise, we want to remove all of the element's data
|
590 | // Otherwise, we want to remove all of the element's data
|
551 | } else { |
591 | } else { |
552 | // Clean up the element expando
|
592 | // Clean up the element expando
|
553 | try { |
593 | try { |
554 | delete elem[ expando ]; |
594 | delete elem[ expando ]; |
555 | } catch(e){ |
595 | } catch(e){ |
556 | // IE has trouble directly removing the expando
|
596 | // IE has trouble directly removing the expando
|
557 | // but it's ok with using removeAttribute
|
597 | // but it's ok with using removeAttribute
|
558 | if ( elem.removeAttribute ) |
598 | if ( elem.removeAttribute ) |
559 | elem.removeAttribute( expando ); |
599 | elem.removeAttribute( expando ); |
560 | }
|
600 | }
|
561 | 601 | ||
562 | // Completely remove the data cache
|
602 | // Completely remove the data cache
|
563 | delete jQuery.cache[ id ]; |
603 | delete cache[ id ]; |
564 | }
|
604 | }
|
565 | }, |
605 | }, |
566 | queue: function( elem, type, data ) { |
606 | queue: function( elem, type, data ) { |
567 | if ( elem ){ |
607 | if( !elem ) return; |
568 | 608 | ||
569 | type = (type || "fx") + "queue"; |
609 | type = (type || "fx") + "queue"; |
- | 610 | var q = jQuery.data( elem, type ); |
|
570 | 611 | ||
- | 612 | // Speed up dequeue by getting out quickly if this is just a lookup
|
|
571 | var q = jQuery.data( elem, type ); |
613 | if( !data ) return q || []; |
572 | 614 | ||
573 | if ( !q || jQuery.isArray(data) ) |
615 | if ( !q || jQuery.isArray(data) ) |
574 | q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
616 | q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
575 | else if( data ) |
617 | else
|
576 | q.push( data ); |
618 | q.push( data ); |
577 | 619 | ||
578 | }
|
- | |
579 | return q; |
620 | return q; |
580 | }, |
621 | }, |
581 | 622 | ||
582 | dequeue: function( elem, type ){ |
623 | dequeue: function( elem, type ){ |
- | 624 | type = type || "fx"; |
|
- | 625 | ||
583 | var queue = jQuery.queue( elem, type ), |
626 | var queue = jQuery.queue( elem, type ), fn = queue.shift(); |
- | 627 | ||
- | 628 | // If the fx queue is dequeued, always remove the progress sentinel
|
|
584 | fn = queue.shift(); |
629 | if( fn === "inprogress" ) fn = queue.shift(); |
585 | 630 | ||
586 | if( !type || type === "fx" ) |
631 | if( fn ) { |
- | 632 | // Add a progress sentinel to prevent the fx queue from being
|
|
587 | fn = queue[0]; |
633 | // automatically dequeued
|
- | 634 | if( type == "fx" ) queue.unshift("inprogress"); |
|
588 | 635 | ||
589 | if( fn !== undefined ) |
636 | fn.call(elem, function() { jQuery.dequeue(elem, type); }); |
590 | fn.call(elem); |
637 | }
|
591 | }
|
638 | }
|
592 | }); |
639 | }); |
593 | 640 | ||
594 | jQuery.fn.extend({ |
641 | jQuery.fn.extend({ |
595 | data: function( key, value ){ |
642 | data: function( key, value ){ |
- | 643 | if(typeof key === "undefined" && this.length) return jQuery.data(this[0], true); |
|
- | 644 | ||
596 | var parts = key.split("."); |
645 | var parts = key.split("."); |
597 | parts[1] = parts[1] ? "." + parts[1] : ""; |
646 | parts[1] = parts[1] ? "." + parts[1] : ""; |
598 | 647 | ||
599 | if ( value === undefined ) { |
648 | if ( value === undefined ) { |
600 | var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
649 | var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
601 | 650 | ||
602 | if ( data === undefined && this.length ) |
651 | if ( data === undefined && this.length ) |
603 | data = jQuery.data( this[0], key ); |
652 | data = jQuery.data( this[0], key ); |
604 | 653 | ||
605 | return data === undefined && parts[1] ? |
654 | return data === undefined && parts[1] ? |
606 | this.data( parts[0] ) : |
655 | this.data( parts[0] ) : |
607 | data;
|
656 | data;
|
608 | } else |
657 | } else |
609 | return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){ |
658 | return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){ |
610 | jQuery.data( this, key, value ); |
659 | jQuery.data( this, key, value ); |
611 | }); |
660 | }); |
612 | }, |
661 | }, |
613 | 662 | ||
614 | removeData: function( key ){ |
663 | removeData: function( key ){ |
615 | return this.each(function(){ |
664 | return this.each(function(){ |
616 | jQuery.removeData( this, key ); |
665 | jQuery.removeData( this, key ); |
617 | }); |
666 | }); |
618 | }, |
667 | }, |
619 | queue: function(type, data){ |
668 | queue: function(type, data){ |
620 | if ( typeof type !== "string" ) { |
669 | if ( typeof type !== "string" ) { |
621 | data = type; |
670 | data = type; |
622 | type = "fx"; |
671 | type = "fx"; |
623 | }
|
672 | }
|
624 | 673 | ||
625 | if ( data === undefined ) |
674 | if ( data === undefined ) |
626 | return jQuery.queue( this[0], type ); |
675 | return jQuery.queue( this[0], type ); |
627 | 676 | ||
628 | return this.each(function(){ |
677 | return this.each(function(i, elem){ |
629 | var queue = jQuery.queue( this, type, data ); |
678 | var queue = jQuery.queue( this, type, data ); |
630 | 679 | ||
631 | if( type == "fx" && queue.length == 1 ) |
680 | if( type == "fx" && queue[0] !== "inprogress" ) |
632 | queue[0].call(this); |
681 | jQuery.dequeue( this, type ) |
633 | }); |
682 | }); |
634 | }, |
683 | }, |
635 | dequeue: function(type){ |
684 | dequeue: function(type){ |
636 | return this.each(function(){ |
685 | return this.each(function(){ |
637 | jQuery.dequeue( this, type ); |
686 | jQuery.dequeue( this, type ); |
638 | }); |
687 | }); |
- | 688 | }, |
|
- | 689 | clearQueue: function(type){ |
|
- | 690 | return this.queue( type || "fx", [] ); |
|
639 | }
|
691 | }
|
640 | });/*! |
692 | });/*! |
641 | * Sizzle CSS Selector Engine - v1.0
|
693 | * Sizzle CSS Selector Engine - v1.0
|
642 | * Copyright 2009, The Dojo Foundation
|
694 | * Copyright 2009, The Dojo Foundation
|
643 | * Released under the MIT, BSD, and GPL Licenses.
|
695 | * Released under the MIT, BSD, and GPL Licenses.
|
644 | * More information: http://sizzlejs.com/
|
696 | * More information: http://sizzlejs.com/
|
645 | */
|
697 | */
|
646 | (function(){ |
698 | (function(){ |
647 | 699 | ||
648 | var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, |
700 | var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, |
649 | done = 0, |
701 | done = 0, |
650 | toString = Object.prototype.toString, |
702 | toString = Object.prototype.toString, |
651 | hasDuplicate = false; |
703 | hasDuplicate = false; |
652 | 704 | ||
653 | var Sizzle = function(selector, context, results, seed) { |
705 | var Sizzle = function(selector, context, results, seed) { |
654 | results = results || []; |
706 | results = results || []; |
655 | var origContext = context = context || document; |
707 | var origContext = context = context || document; |
656 | 708 | ||
657 | if ( context.nodeType !== 1 && context.nodeType !== 9 ) { |
709 | if ( context.nodeType !== 1 && context.nodeType !== 9 ) { |
658 | return []; |
710 | return []; |
659 | }
|
711 | }
|
660 | 712 | ||
661 | if ( !selector || typeof selector !== "string" ) { |
713 | if ( !selector || typeof selector !== "string" ) { |
662 | return results; |
714 | return results; |
663 | }
|
715 | }
|
664 | 716 | ||
665 | var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context); |
717 | var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context); |
666 | 718 | ||
667 | // Reset the position of the chunker regexp (start from head)
|
719 | // Reset the position of the chunker regexp (start from head)
|
668 | chunker.lastIndex = 0; |
720 | chunker.lastIndex = 0; |
669 | 721 | ||
670 | while ( (m = chunker.exec(selector)) !== null ) { |
722 | while ( (m = chunker.exec(selector)) !== null ) { |
671 | parts.push( m[1] ); |
723 | parts.push( m[1] ); |
672 | 724 | ||
673 | if ( m[2] ) { |
725 | if ( m[2] ) { |
674 | extra = RegExp.rightContext; |
726 | extra = RegExp.rightContext; |
675 | break; |
727 | break; |
676 | }
|
728 | }
|
677 | }
|
729 | }
|
678 | 730 | ||
679 | if ( parts.length > 1 && origPOS.exec( selector ) ) { |
731 | if ( parts.length > 1 && origPOS.exec( selector ) ) { |
680 | if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { |
732 | if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { |
681 | set = posProcess( parts[0] + parts[1], context ); |
733 | set = posProcess( parts[0] + parts[1], context ); |
682 | } else { |
734 | } else { |
683 | set = Expr.relative[ parts[0] ] ? |
735 | set = Expr.relative[ parts[0] ] ? |
684 | [ context ] : |
736 | [ context ] : |
685 | Sizzle( parts.shift(), context ); |
737 | Sizzle( parts.shift(), context ); |
686 | 738 | ||
687 | while ( parts.length ) { |
739 | while ( parts.length ) { |
688 | selector = parts.shift(); |
740 | selector = parts.shift(); |
689 | 741 | ||
690 | if ( Expr.relative[ selector ] ) |
742 | if ( Expr.relative[ selector ] ) |
691 | selector += parts.shift(); |
743 | selector += parts.shift(); |
692 | 744 | ||
693 | set = posProcess( selector, set ); |
745 | set = posProcess( selector, set ); |
694 | }
|
746 | }
|
695 | }
|
747 | }
|
696 | } else { |
748 | } else { |
697 | // Take a shortcut and set the context if the root selector is an ID
|
749 | // Take a shortcut and set the context if the root selector is an ID
|
698 | // (but not if it'll be faster if the inner selector is an ID)
|
750 | // (but not if it'll be faster if the inner selector is an ID)
|
699 | if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && |
751 | if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && |
700 | Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { |
752 | Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { |
701 | var ret = Sizzle.find( parts.shift(), context, contextXML ); |
753 | var ret = Sizzle.find( parts.shift(), context, contextXML ); |
702 | context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0]; |
754 | context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0]; |
703 | }
|
755 | }
|
704 | 756 | ||
705 | if ( context ) { |
757 | if ( context ) { |
706 | var ret = seed ? |
758 | var ret = seed ? |
707 | { expr: parts.pop(), set: makeArray(seed) } : |
759 | { expr: parts.pop(), set: makeArray(seed) } : |
708 | Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); |
760 | Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); |
709 | set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set; |
761 | set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set; |
710 | 762 | ||
711 | if ( parts.length > 0 ) { |
763 | if ( parts.length > 0 ) { |
712 | checkSet = makeArray(set); |
764 | checkSet = makeArray(set); |
713 | } else { |
765 | } else { |
714 | prune = false; |
766 | prune = false; |
715 | }
|
767 | }
|
716 | 768 | ||
717 | while ( parts.length ) { |
769 | while ( parts.length ) { |
718 | var cur = parts.pop(), pop = cur; |
770 | var cur = parts.pop(), pop = cur; |
719 | 771 | ||
720 | if ( !Expr.relative[ cur ] ) { |
772 | if ( !Expr.relative[ cur ] ) { |
721 | cur = ""; |
773 | cur = ""; |
722 | } else { |
774 | } else { |
723 | pop = parts.pop(); |
775 | pop = parts.pop(); |
724 | }
|
776 | }
|
725 | 777 | ||
726 | if ( pop == null ) { |
778 | if ( pop == null ) { |
727 | pop = context; |
779 | pop = context; |
728 | }
|
780 | }
|
729 | 781 | ||
730 | Expr.relative[ cur ]( checkSet, pop, contextXML ); |
782 | Expr.relative[ cur ]( checkSet, pop, contextXML ); |
731 | }
|
783 | }
|
732 | } else { |
784 | } else { |
733 | checkSet = parts = []; |
785 | checkSet = parts = []; |
734 | }
|
786 | }
|
735 | }
|
787 | }
|
736 | 788 | ||
737 | if ( !checkSet ) { |
789 | if ( !checkSet ) { |
738 | checkSet = set; |
790 | checkSet = set; |
739 | }
|
791 | }
|
740 | 792 | ||
741 | if ( !checkSet ) { |
793 | if ( !checkSet ) { |
742 | throw "Syntax error, unrecognized expression: " + (cur || selector); |
794 | throw "Syntax error, unrecognized expression: " + (cur || selector); |
743 | }
|
795 | }
|
744 | 796 | ||
745 | if ( toString.call(checkSet) === "[object Array]" ) { |
797 | if ( toString.call(checkSet) === "[object Array]" ) { |
746 | if ( !prune ) { |
798 | if ( !prune ) { |
747 | results.push.apply( results, checkSet ); |
799 | results.push.apply( results, checkSet ); |
748 | } else if ( context && context.nodeType === 1 ) { |
800 | } else if ( context && context.nodeType === 1 ) { |
749 | for ( var i = 0; checkSet[i] != null; i++ ) { |
801 | for ( var i = 0; checkSet[i] != null; i++ ) { |
750 | if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { |
802 | if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { |
751 | results.push( set[i] ); |
803 | results.push( set[i] ); |
752 | }
|
804 | }
|
753 | }
|
805 | }
|
754 | } else { |
806 | } else { |
755 | for ( var i = 0; checkSet[i] != null; i++ ) { |
807 | for ( var i = 0; checkSet[i] != null; i++ ) { |
756 | if ( checkSet[i] && checkSet[i].nodeType === 1 ) { |
808 | if ( checkSet[i] && checkSet[i].nodeType === 1 ) { |
757 | results.push( set[i] ); |
809 | results.push( set[i] ); |
758 | }
|
810 | }
|
759 | }
|
811 | }
|
760 | }
|
812 | }
|
761 | } else { |
813 | } else { |
762 | makeArray( checkSet, results ); |
814 | makeArray( checkSet, results ); |
763 | }
|
815 | }
|
764 | 816 | ||
765 | if ( extra ) { |
817 | if ( extra ) { |
766 | Sizzle( extra, origContext, results, seed ); |
818 | Sizzle( extra, origContext, results, seed ); |
767 | Sizzle.uniqueSort( results ); |
819 | Sizzle.uniqueSort( results ); |
768 | }
|
820 | }
|
769 | 821 | ||
770 | return results; |
822 | return results; |
771 | }; |
823 | }; |
772 | 824 | ||
773 | Sizzle.uniqueSort = function(results){ |
825 | Sizzle.uniqueSort = function(results){ |
774 | if ( sortOrder ) { |
826 | if ( sortOrder ) { |
775 | hasDuplicate = false; |
827 | hasDuplicate = false; |
776 | results.sort(sortOrder); |
828 | results.sort(sortOrder); |
777 | 829 | ||
778 | if ( hasDuplicate ) { |
830 | if ( hasDuplicate ) { |
779 | for ( var i = 1; i < results.length; i++ ) { |
831 | for ( var i = 1; i < results.length; i++ ) { |
780 | if ( results[i] === results[i-1] ) { |
832 | if ( results[i] === results[i-1] ) { |
781 | results.splice(i--, 1); |
833 | results.splice(i--, 1); |
782 | }
|
834 | }
|
783 | }
|
835 | }
|
784 | }
|
836 | }
|
785 | }
|
837 | }
|
786 | }; |
838 | }; |
787 | 839 | ||
788 | Sizzle.matches = function(expr, set){ |
840 | Sizzle.matches = function(expr, set){ |
789 | return Sizzle(expr, null, null, set); |
841 | return Sizzle(expr, null, null, set); |
790 | }; |
842 | }; |
791 | 843 | ||
792 | Sizzle.find = function(expr, context, isXML){ |
844 | Sizzle.find = function(expr, context, isXML){ |
793 | var set, match; |
845 | var set, match; |
794 | 846 | ||
795 | if ( !expr ) { |
847 | if ( !expr ) { |
796 | return []; |
848 | return []; |
797 | }
|
849 | }
|
798 | 850 | ||
799 | for ( var i = 0, l = Expr.order.length; i < l; i++ ) { |
851 | for ( var i = 0, l = Expr.order.length; i < l; i++ ) { |
800 | var type = Expr.order[i], match; |
852 | var type = Expr.order[i], match; |
801 | 853 | ||
802 | if ( (match = Expr.match[ type ].exec( expr )) ) { |
854 | if ( (match = Expr.match[ type ].exec( expr )) ) { |
803 | var left = RegExp.leftContext; |
855 | var left = RegExp.leftContext; |
804 | 856 | ||
805 | if ( left.substr( left.length - 1 ) !== "\\" ) { |
857 | if ( left.substr( left.length - 1 ) !== "\\" ) { |
806 | match[1] = (match[1] || "").replace(/\\/g, ""); |
858 | match[1] = (match[1] || "").replace(/\\/g, ""); |
807 | set = Expr.find[ type ]( match, context, isXML ); |
859 | set = Expr.find[ type ]( match, context, isXML ); |
808 | if ( set != null ) { |
860 | if ( set != null ) { |
809 | expr = expr.replace( Expr.match[ type ], "" ); |
861 | expr = expr.replace( Expr.match[ type ], "" ); |
810 | break; |
862 | break; |
811 | }
|
863 | }
|
812 | }
|
864 | }
|
813 | }
|
865 | }
|
814 | }
|
866 | }
|
815 | 867 | ||
816 | if ( !set ) { |
868 | if ( !set ) { |
817 | set = context.getElementsByTagName("*"); |
869 | set = context.getElementsByTagName("*"); |
818 | }
|
870 | }
|
819 | 871 | ||
820 | return {set: set, expr: expr}; |
872 | return {set: set, expr: expr}; |
821 | }; |
873 | }; |
822 | 874 | ||
823 | Sizzle.filter = function(expr, set, inplace, not){ |
875 | Sizzle.filter = function(expr, set, inplace, not){ |
824 | var old = expr, result = [], curLoop = set, match, anyFound, |
876 | var old = expr, result = [], curLoop = set, match, anyFound, |
825 | isXMLFilter = set && set[0] && isXML(set[0]); |
877 | isXMLFilter = set && set[0] && isXML(set[0]); |
826 | 878 | ||
827 | while ( expr && set.length ) { |
879 | while ( expr && set.length ) { |
828 | for ( var type in Expr.filter ) { |
880 | for ( var type in Expr.filter ) { |
829 | if ( (match = Expr.match[ type ].exec( expr )) != null ) { |
881 | if ( (match = Expr.match[ type ].exec( expr )) != null ) { |
830 | var filter = Expr.filter[ type ], found, item; |
882 | var filter = Expr.filter[ type ], found, item; |
831 | anyFound = false; |
883 | anyFound = false; |
832 | 884 | ||
833 | if ( curLoop == result ) { |
885 | if ( curLoop == result ) { |
834 | result = []; |
886 | result = []; |
835 | }
|
887 | }
|
836 | 888 | ||
837 | if ( Expr.preFilter[ type ] ) { |
889 | if ( Expr.preFilter[ type ] ) { |
838 | match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); |
890 | match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); |
839 | 891 | ||
840 | if ( !match ) { |
892 | if ( !match ) { |
841 | anyFound = found = true; |
893 | anyFound = found = true; |
842 | } else if ( match === true ) { |
894 | } else if ( match === true ) { |
843 | continue; |
895 | continue; |
844 | }
|
896 | }
|
845 | }
|
897 | }
|
846 | 898 | ||
847 | if ( match ) { |
899 | if ( match ) { |
848 | for ( var i = 0; (item = curLoop[i]) != null; i++ ) { |
900 | for ( var i = 0; (item = curLoop[i]) != null; i++ ) { |
849 | if ( item ) { |
901 | if ( item ) { |
850 | found = filter( item, match, i, curLoop ); |
902 | found = filter( item, match, i, curLoop ); |
851 | var pass = not ^ !!found; |
903 | var pass = not ^ !!found; |
852 | 904 | ||
853 | if ( inplace && found != null ) { |
905 | if ( inplace && found != null ) { |
854 | if ( pass ) { |
906 | if ( pass ) { |
855 | anyFound = true; |
907 | anyFound = true; |
856 | } else { |
908 | } else { |
857 | curLoop[i] = false; |
909 | curLoop[i] = false; |
858 | }
|
910 | }
|
859 | } else if ( pass ) { |
911 | } else if ( pass ) { |
860 | result.push( item ); |
912 | result.push( item ); |
861 | anyFound = true; |
913 | anyFound = true; |
862 | }
|
914 | }
|
863 | }
|
915 | }
|
864 | }
|
916 | }
|
865 | }
|
917 | }
|
866 | 918 | ||
867 | if ( found !== undefined ) { |
919 | if ( found !== undefined ) { |
868 | if ( !inplace ) { |
920 | if ( !inplace ) { |
869 | curLoop = result; |
921 | curLoop = result; |
870 | }
|
922 | }
|
871 | 923 | ||
872 | expr = expr.replace( Expr.match[ type ], "" ); |
924 | expr = expr.replace( Expr.match[ type ], "" ); |
873 | 925 | ||
874 | if ( !anyFound ) { |
926 | if ( !anyFound ) { |
875 | return []; |
927 | return []; |
876 | }
|
928 | }
|
877 | 929 | ||
878 | break; |
930 | break; |
879 | }
|
931 | }
|
880 | }
|
932 | }
|
881 | }
|
933 | }
|
882 | 934 | ||
883 | // Improper expression
|
935 | // Improper expression
|
884 | if ( expr == old ) { |
936 | if ( expr == old ) { |
885 | if ( anyFound == null ) { |
937 | if ( anyFound == null ) { |
886 | throw "Syntax error, unrecognized expression: " + expr; |
938 | throw "Syntax error, unrecognized expression: " + expr; |
887 | } else { |
939 | } else { |
888 | break; |
940 | break; |
889 | }
|
941 | }
|
890 | }
|
942 | }
|
891 | 943 | ||
892 | old = expr; |
944 | old = expr; |
893 | }
|
945 | }
|
894 | 946 | ||
895 | return curLoop; |
947 | return curLoop; |
896 | }; |
948 | }; |
897 | 949 | ||
898 | var Expr = Sizzle.selectors = { |
950 | var Expr = Sizzle.selectors = { |
899 | order: [ "ID", "NAME", "TAG" ], |
951 | order: [ "ID", "NAME", "TAG" ], |
900 | match: { |
952 | match: { |
901 | ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, |
953 | ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, |
902 | CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, |
954 | CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/, |
903 | NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/, |
955 | NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/, |
904 | ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, |
956 | ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, |
905 | TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/, |
957 | TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/, |
906 | CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/, |
958 | CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/, |
907 | POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/, |
959 | POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/, |
908 | PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/ |
960 | PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/ |
909 | }, |
961 | }, |
910 | attrMap: { |
962 | attrMap: { |
911 | "class": "className", |
963 | "class": "className", |
912 | "for": "htmlFor" |
964 | "for": "htmlFor" |
913 | }, |
965 | }, |
914 | attrHandle: { |
966 | attrHandle: { |
915 | href: function(elem){ |
967 | href: function(elem){ |
916 | return elem.getAttribute("href"); |
968 | return elem.getAttribute("href"); |
917 | }
|
969 | }
|
918 | }, |
970 | }, |
919 | relative: { |
971 | relative: { |
920 | "+": function(checkSet, part, isXML){ |
972 | "+": function(checkSet, part, isXML){ |
921 | var isPartStr = typeof part === "string", |
973 | var isPartStr = typeof part === "string", |
922 | isTag = isPartStr && !/\W/.test(part), |
974 | isTag = isPartStr && !/\W/.test(part), |
923 | isPartStrNotTag = isPartStr && !isTag; |
975 | isPartStrNotTag = isPartStr && !isTag; |
924 | 976 | ||
925 | if ( isTag && !isXML ) { |
977 | if ( isTag && !isXML ) { |
926 | part = part.toUpperCase(); |
978 | part = part.toUpperCase(); |
927 | }
|
979 | }
|
928 | 980 | ||
929 | for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { |
981 | for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { |
930 | if ( (elem = checkSet[i]) ) { |
982 | if ( (elem = checkSet[i]) ) { |
931 | while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} |
983 | while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} |
932 | 984 | ||
933 | checkSet[i] = isPartStrNotTag || elem && elem.nodeName === part ? |
985 | checkSet[i] = isPartStrNotTag || elem && elem.nodeName === part ? |
934 | elem || false : |
986 | elem || false : |
935 | elem === part; |
987 | elem === part; |
936 | }
|
988 | }
|
937 | }
|
989 | }
|
938 | 990 | ||
939 | if ( isPartStrNotTag ) { |
991 | if ( isPartStrNotTag ) { |
940 | Sizzle.filter( part, checkSet, true ); |
992 | Sizzle.filter( part, checkSet, true ); |
941 | }
|
993 | }
|
942 | }, |
994 | }, |
943 | ">": function(checkSet, part, isXML){ |
995 | ">": function(checkSet, part, isXML){ |
944 | var isPartStr = typeof part === "string"; |
996 | var isPartStr = typeof part === "string"; |
945 | 997 | ||
946 | if ( isPartStr && !/\W/.test(part) ) { |
998 | if ( isPartStr && !/\W/.test(part) ) { |
947 | part = isXML ? part : part.toUpperCase(); |
999 | part = isXML ? part : part.toUpperCase(); |
948 | 1000 | ||
949 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
1001 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
950 | var elem = checkSet[i]; |
1002 | var elem = checkSet[i]; |
951 | if ( elem ) { |
1003 | if ( elem ) { |
952 | var parent = elem.parentNode; |
1004 | var parent = elem.parentNode; |
953 | checkSet[i] = parent.nodeName === part ? parent : false; |
1005 | checkSet[i] = parent.nodeName === part ? parent : false; |
954 | }
|
1006 | }
|
955 | }
|
1007 | }
|
956 | } else { |
1008 | } else { |
957 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
1009 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
958 | var elem = checkSet[i]; |
1010 | var elem = checkSet[i]; |
959 | if ( elem ) { |
1011 | if ( elem ) { |
960 | checkSet[i] = isPartStr ? |
1012 | checkSet[i] = isPartStr ? |
961 | elem.parentNode : |
1013 | elem.parentNode : |
962 | elem.parentNode === part; |
1014 | elem.parentNode === part; |
963 | }
|
1015 | }
|
964 | }
|
1016 | }
|
965 | 1017 | ||
966 | if ( isPartStr ) { |
1018 | if ( isPartStr ) { |
967 | Sizzle.filter( part, checkSet, true ); |
1019 | Sizzle.filter( part, checkSet, true ); |
968 | }
|
1020 | }
|
969 | }
|
1021 | }
|
970 | }, |
1022 | }, |
971 | "": function(checkSet, part, isXML){ |
1023 | "": function(checkSet, part, isXML){ |
972 | var doneName = done++, checkFn = dirCheck; |
1024 | var doneName = done++, checkFn = dirCheck; |
973 | 1025 | ||
974 | if ( !part.match(/\W/) ) { |
1026 | if ( !/\W/.test(part) ) { |
975 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
1027 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
976 | checkFn = dirNodeCheck; |
1028 | checkFn = dirNodeCheck; |
977 | }
|
1029 | }
|
978 | 1030 | ||
979 | checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
1031 | checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
980 | }, |
1032 | }, |
981 | "~": function(checkSet, part, isXML){ |
1033 | "~": function(checkSet, part, isXML){ |
982 | var doneName = done++, checkFn = dirCheck; |
1034 | var doneName = done++, checkFn = dirCheck; |
983 | 1035 | ||
984 | if ( typeof part === "string" && !part.match(/\W/) ) { |
1036 | if ( typeof part === "string" && !/\W/.test(part) ) { |
985 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
1037 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
986 | checkFn = dirNodeCheck; |
1038 | checkFn = dirNodeCheck; |
987 | }
|
1039 | }
|
988 | 1040 | ||
989 | checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
1041 | checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
990 | }
|
1042 | }
|
991 | }, |
1043 | }, |
992 | find: { |
1044 | find: { |
993 | ID: function(match, context, isXML){ |
1045 | ID: function(match, context, isXML){ |
994 | if ( typeof context.getElementById !== "undefined" && !isXML ) { |
1046 | if ( typeof context.getElementById !== "undefined" && !isXML ) { |
995 | var m = context.getElementById(match[1]); |
1047 | var m = context.getElementById(match[1]); |
996 | return m ? [m] : []; |
1048 | return m ? [m] : []; |
997 | }
|
1049 | }
|
998 | }, |
1050 | }, |
999 | NAME: function(match, context, isXML){ |
1051 | NAME: function(match, context, isXML){ |
1000 | if ( typeof context.getElementsByName !== "undefined" ) { |
1052 | if ( typeof context.getElementsByName !== "undefined" ) { |
1001 | var ret = [], results = context.getElementsByName(match[1]); |
1053 | var ret = [], results = context.getElementsByName(match[1]); |
1002 | 1054 | ||
1003 | for ( var i = 0, l = results.length; i < l; i++ ) { |
1055 | for ( var i = 0, l = results.length; i < l; i++ ) { |
1004 | if ( results[i].getAttribute("name") === match[1] ) { |
1056 | if ( results[i].getAttribute("name") === match[1] ) { |
1005 | ret.push( results[i] ); |
1057 | ret.push( results[i] ); |
1006 | }
|
1058 | }
|
1007 | }
|
1059 | }
|
1008 | 1060 | ||
1009 | return ret.length === 0 ? null : ret; |
1061 | return ret.length === 0 ? null : ret; |
1010 | }
|
1062 | }
|
1011 | }, |
1063 | }, |
1012 | TAG: function(match, context){ |
1064 | TAG: function(match, context){ |
1013 | return context.getElementsByTagName(match[1]); |
1065 | return context.getElementsByTagName(match[1]); |
1014 | }
|
1066 | }
|
1015 | }, |
1067 | }, |
1016 | preFilter: { |
1068 | preFilter: { |
1017 | CLASS: function(match, curLoop, inplace, result, not, isXML){ |
1069 | CLASS: function(match, curLoop, inplace, result, not, isXML){ |
1018 | match = " " + match[1].replace(/\\/g, "") + " "; |
1070 | match = " " + match[1].replace(/\\/g, "") + " "; |
1019 | 1071 | ||
1020 | if ( isXML ) { |
1072 | if ( isXML ) { |
1021 | return match; |
1073 | return match; |
1022 | }
|
1074 | }
|
1023 | 1075 | ||
1024 | for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { |
1076 | for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { |
1025 | if ( elem ) { |
1077 | if ( elem ) { |
1026 | if ( not ^ (elem.className && (" " + elem.className + " ").indexOf(match) >= 0) ) { |
1078 | if ( not ^ (elem.className && (" " + elem.className + " ").indexOf(match) >= 0) ) { |
1027 | if ( !inplace ) |
1079 | if ( !inplace ) |
1028 | result.push( elem ); |
1080 | result.push( elem ); |
1029 | } else if ( inplace ) { |
1081 | } else if ( inplace ) { |
1030 | curLoop[i] = false; |
1082 | curLoop[i] = false; |
1031 | }
|
1083 | }
|
1032 | }
|
1084 | }
|
1033 | }
|
1085 | }
|
1034 | 1086 | ||
1035 | return false; |
1087 | return false; |
1036 | }, |
1088 | }, |
1037 | ID: function(match){ |
1089 | ID: function(match){ |
1038 | return match[1].replace(/\\/g, ""); |
1090 | return match[1].replace(/\\/g, ""); |
1039 | }, |
1091 | }, |
1040 | TAG: function(match, curLoop){ |
1092 | TAG: function(match, curLoop){ |
1041 | for ( var i = 0; curLoop[i] === false; i++ ){} |
1093 | for ( var i = 0; curLoop[i] === false; i++ ){} |
1042 | return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase(); |
1094 | return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase(); |
1043 | }, |
1095 | }, |
1044 | CHILD: function(match){ |
1096 | CHILD: function(match){ |
1045 | if ( match[1] == "nth" ) { |
1097 | if ( match[1] == "nth" ) { |
1046 | // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
|
1098 | // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
|
1047 | var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( |
1099 | var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( |
1048 | match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" || |
1100 | match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" || |
1049 | !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); |
1101 | !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); |
1050 | 1102 | ||
1051 | // calculate the numbers (first)n+(last) including if they are negative
|
1103 | // calculate the numbers (first)n+(last) including if they are negative
|
1052 | match[2] = (test[1] + (test[2] || 1)) - 0; |
1104 | match[2] = (test[1] + (test[2] || 1)) - 0; |
1053 | match[3] = test[3] - 0; |
1105 | match[3] = test[3] - 0; |
1054 | }
|
1106 | }
|
1055 | 1107 | ||
1056 | // TODO: Move to normal caching system
|
1108 | // TODO: Move to normal caching system
|
1057 | match[0] = done++; |
1109 | match[0] = done++; |
1058 | 1110 | ||
1059 | return match; |
1111 | return match; |
1060 | }, |
1112 | }, |
1061 | ATTR: function(match, curLoop, inplace, result, not, isXML){ |
1113 | ATTR: function(match, curLoop, inplace, result, not, isXML){ |
1062 | var name = match[1].replace(/\\/g, ""); |
1114 | var name = match[1].replace(/\\/g, ""); |
1063 | 1115 | ||
1064 | if ( !isXML && Expr.attrMap[name] ) { |
1116 | if ( !isXML && Expr.attrMap[name] ) { |
1065 | match[1] = Expr.attrMap[name]; |
1117 | match[1] = Expr.attrMap[name]; |
1066 | }
|
1118 | }
|
1067 | 1119 | ||
1068 | if ( match[2] === "~=" ) { |
1120 | if ( match[2] === "~=" ) { |
1069 | match[4] = " " + match[4] + " "; |
1121 | match[4] = " " + match[4] + " "; |
1070 | }
|
1122 | }
|
1071 | 1123 | ||
1072 | return match; |
1124 | return match; |
1073 | }, |
1125 | }, |
1074 | PSEUDO: function(match, curLoop, inplace, result, not){ |
1126 | PSEUDO: function(match, curLoop, inplace, result, not){ |
1075 | if ( match[1] === "not" ) { |
1127 | if ( match[1] === "not" ) { |
1076 | // If we're dealing with a complex expression, or a simple one
|
1128 | // If we're dealing with a complex expression, or a simple one
|
1077 | if ( match[3].match(chunker).length > 1 || /^\w/.test(match[3]) ) { |
1129 | if ( chunker.exec(match[3]).length > 1 || /^\w/.test(match[3]) ) { |
1078 | match[3] = Sizzle(match[3], null, null, curLoop); |
1130 | match[3] = Sizzle(match[3], null, null, curLoop); |
1079 | } else { |
1131 | } else { |
1080 | var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
1132 | var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
1081 | if ( !inplace ) { |
1133 | if ( !inplace ) { |
1082 | result.push.apply( result, ret ); |
1134 | result.push.apply( result, ret ); |
1083 | }
|
1135 | }
|
1084 | return false; |
1136 | return false; |
1085 | }
|
1137 | }
|
1086 | } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { |
1138 | } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { |
1087 | return true; |
1139 | return true; |
1088 | }
|
1140 | }
|
1089 | 1141 | ||
1090 | return match; |
1142 | return match; |
1091 | }, |
1143 | }, |
1092 | POS: function(match){ |
1144 | POS: function(match){ |
1093 | match.unshift( true ); |
1145 | match.unshift( true ); |
1094 | return match; |
1146 | return match; |
1095 | }
|
1147 | }
|
1096 | }, |
1148 | }, |
1097 | filters: { |
1149 | filters: { |
1098 | enabled: function(elem){ |
1150 | enabled: function(elem){ |
1099 | return elem.disabled === false && elem.type !== "hidden"; |
1151 | return elem.disabled === false && elem.type !== "hidden"; |
1100 | }, |
1152 | }, |
1101 | disabled: function(elem){ |
1153 | disabled: function(elem){ |
1102 | return elem.disabled === true; |
1154 | return elem.disabled === true; |
1103 | }, |
1155 | }, |
1104 | checked: function(elem){ |
1156 | checked: function(elem){ |
1105 | return elem.checked === true; |
1157 | return elem.checked === true; |
1106 | }, |
1158 | }, |
1107 | selected: function(elem){ |
1159 | selected: function(elem){ |
1108 | // Accessing this property makes selected-by-default
|
1160 | // Accessing this property makes selected-by-default
|
1109 | // options in Safari work properly
|
1161 | // options in Safari work properly
|
1110 | elem.parentNode.selectedIndex; |
1162 | elem.parentNode.selectedIndex; |
1111 | return elem.selected === true; |
1163 | return elem.selected === true; |
1112 | }, |
1164 | }, |
1113 | parent: function(elem){ |
1165 | parent: function(elem){ |
1114 | return !!elem.firstChild; |
1166 | return !!elem.firstChild; |
1115 | }, |
1167 | }, |
1116 | empty: function(elem){ |
1168 | empty: function(elem){ |
1117 | return !elem.firstChild; |
1169 | return !elem.firstChild; |
1118 | }, |
1170 | }, |
1119 | has: function(elem, i, match){ |
1171 | has: function(elem, i, match){ |
1120 | return !!Sizzle( match[3], elem ).length; |
1172 | return !!Sizzle( match[3], elem ).length; |
1121 | }, |
1173 | }, |
1122 | header: function(elem){ |
1174 | header: function(elem){ |
1123 | return /h\d/i.test( elem.nodeName ); |
1175 | return /h\d/i.test( elem.nodeName ); |
1124 | }, |
1176 | }, |
1125 | text: function(elem){ |
1177 | text: function(elem){ |
1126 | return "text" === elem.type; |
1178 | return "text" === elem.type; |
1127 | }, |
1179 | }, |
1128 | radio: function(elem){ |
1180 | radio: function(elem){ |
1129 | return "radio" === elem.type; |
1181 | return "radio" === elem.type; |
1130 | }, |
1182 | }, |
1131 | checkbox: function(elem){ |
1183 | checkbox: function(elem){ |
1132 | return "checkbox" === elem.type; |
1184 | return "checkbox" === elem.type; |
1133 | }, |
1185 | }, |
1134 | file: function(elem){ |
1186 | file: function(elem){ |
1135 | return "file" === elem.type; |
1187 | return "file" === elem.type; |
1136 | }, |
1188 | }, |
1137 | password: function(elem){ |
1189 | password: function(elem){ |
1138 | return "password" === elem.type; |
1190 | return "password" === elem.type; |
1139 | }, |
1191 | }, |
1140 | submit: function(elem){ |
1192 | submit: function(elem){ |
1141 | return "submit" === elem.type; |
1193 | return "submit" === elem.type; |
1142 | }, |
1194 | }, |
1143 | image: function(elem){ |
1195 | image: function(elem){ |
1144 | return "image" === elem.type; |
1196 | return "image" === elem.type; |
1145 | }, |
1197 | }, |
1146 | reset: function(elem){ |
1198 | reset: function(elem){ |
1147 | return "reset" === elem.type; |
1199 | return "reset" === elem.type; |
1148 | }, |
1200 | }, |
1149 | button: function(elem){ |
1201 | button: function(elem){ |
1150 | return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON"; |
1202 | return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON"; |
1151 | }, |
1203 | }, |
1152 | input: function(elem){ |
1204 | input: function(elem){ |
1153 | return /input|select|textarea|button/i.test(elem.nodeName); |
1205 | return /input|select|textarea|button/i.test(elem.nodeName); |
1154 | }
|
1206 | }
|
1155 | }, |
1207 | }, |
1156 | setFilters: { |
1208 | setFilters: { |
1157 | first: function(elem, i){ |
1209 | first: function(elem, i){ |
1158 | return i === 0; |
1210 | return i === 0; |
1159 | }, |
1211 | }, |
1160 | last: function(elem, i, match, array){ |
1212 | last: function(elem, i, match, array){ |
1161 | return i === array.length - 1; |
1213 | return i === array.length - 1; |
1162 | }, |
1214 | }, |
1163 | even: function(elem, i){ |
1215 | even: function(elem, i){ |
1164 | return i % 2 === 0; |
1216 | return i % 2 === 0; |
1165 | }, |
1217 | }, |
1166 | odd: function(elem, i){ |
1218 | odd: function(elem, i){ |
1167 | return i % 2 === 1; |
1219 | return i % 2 === 1; |
1168 | }, |
1220 | }, |
1169 | lt: function(elem, i, match){ |
1221 | lt: function(elem, i, match){ |
1170 | return i < match[3] - 0; |
1222 | return i < match[3] - 0; |
1171 | }, |
1223 | }, |
1172 | gt: function(elem, i, match){ |
1224 | gt: function(elem, i, match){ |
1173 | return i > match[3] - 0; |
1225 | return i > match[3] - 0; |
1174 | }, |
1226 | }, |
1175 | nth: function(elem, i, match){ |
1227 | nth: function(elem, i, match){ |
1176 | return match[3] - 0 == i; |
1228 | return match[3] - 0 == i; |
1177 | }, |
1229 | }, |
1178 | eq: function(elem, i, match){ |
1230 | eq: function(elem, i, match){ |
1179 | return match[3] - 0 == i; |
1231 | return match[3] - 0 == i; |
1180 | }
|
1232 | }
|
1181 | }, |
1233 | }, |
1182 | filter: { |
1234 | filter: { |
1183 | PSEUDO: function(elem, match, i, array){ |
1235 | PSEUDO: function(elem, match, i, array){ |
1184 | var name = match[1], filter = Expr.filters[ name ]; |
1236 | var name = match[1], filter = Expr.filters[ name ]; |
1185 | 1237 | ||
1186 | if ( filter ) { |
1238 | if ( filter ) { |
1187 | return filter( elem, i, match, array ); |
1239 | return filter( elem, i, match, array ); |
1188 | } else if ( name === "contains" ) { |
1240 | } else if ( name === "contains" ) { |
1189 | return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0; |
1241 | return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0; |
1190 | } else if ( name === "not" ) { |
1242 | } else if ( name === "not" ) { |
1191 | var not = match[3]; |
1243 | var not = match[3]; |
1192 | 1244 | ||
1193 | for ( i = 0, l = not.length; i < l; i++ ) { |
1245 | for ( i = 0, l = not.length; i < l; i++ ) { |
1194 | if ( not[i] === elem ) { |
1246 | if ( not[i] === elem ) { |
1195 | return false; |
1247 | return false; |
1196 | }
|
1248 | }
|
1197 | }
|
1249 | }
|
1198 | 1250 | ||
1199 | return true; |
1251 | return true; |
1200 | }
|
1252 | }
|
1201 | }, |
1253 | }, |
1202 | CHILD: function(elem, match){ |
1254 | CHILD: function(elem, match){ |
1203 | var type = match[1], node = elem; |
1255 | var type = match[1], node = elem; |
1204 | switch (type) { |
1256 | switch (type) { |
1205 | case 'only': |
1257 | case 'only': |
1206 | case 'first': |
1258 | case 'first': |
1207 | while ( (node = node.previousSibling) ) { |
1259 | while ( (node = node.previousSibling) ) { |
1208 | if ( node.nodeType === 1 ) return false; |
1260 | if ( node.nodeType === 1 ) return false; |
1209 | }
|
1261 | }
|
1210 | if ( type == 'first') return true; |
1262 | if ( type == 'first') return true; |
1211 | node = elem; |
1263 | node = elem; |
1212 | case 'last': |
1264 | case 'last': |
1213 | while ( (node = node.nextSibling) ) { |
1265 | while ( (node = node.nextSibling) ) { |
1214 | if ( node.nodeType === 1 ) return false; |
1266 | if ( node.nodeType === 1 ) return false; |
1215 | }
|
1267 | }
|
1216 | return true; |
1268 | return true; |
1217 | case 'nth': |
1269 | case 'nth': |
1218 | var first = match[2], last = match[3]; |
1270 | var first = match[2], last = match[3]; |
1219 | 1271 | ||
1220 | if ( first == 1 && last == 0 ) { |
1272 | if ( first == 1 && last == 0 ) { |
1221 | return true; |
1273 | return true; |
1222 | }
|
1274 | }
|
1223 | 1275 | ||
1224 | var doneName = match[0], |
1276 | var doneName = match[0], |
1225 | parent = elem.parentNode; |
1277 | parent = elem.parentNode; |
1226 | 1278 | ||
1227 | if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { |
1279 | if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { |
1228 | var count = 0; |
1280 | var count = 0; |
1229 | for ( node = parent.firstChild; node; node = node.nextSibling ) { |
1281 | for ( node = parent.firstChild; node; node = node.nextSibling ) { |
1230 | if ( node.nodeType === 1 ) { |
1282 | if ( node.nodeType === 1 ) { |
1231 | node.nodeIndex = ++count; |
1283 | node.nodeIndex = ++count; |
1232 | }
|
1284 | }
|
1233 | }
|
1285 | }
|
1234 | parent.sizcache = doneName; |
1286 | parent.sizcache = doneName; |
1235 | }
|
1287 | }
|
1236 | 1288 | ||
1237 | var diff = elem.nodeIndex - last; |
1289 | var diff = elem.nodeIndex - last; |
1238 | if ( first == 0 ) { |
1290 | if ( first == 0 ) { |
1239 | return diff == 0; |
1291 | return diff == 0; |
1240 | } else { |
1292 | } else { |
1241 | return ( diff % first == 0 && diff / first >= 0 ); |
1293 | return ( diff % first == 0 && diff / first >= 0 ); |
1242 | }
|
1294 | }
|
1243 | }
|
1295 | }
|
1244 | }, |
1296 | }, |
1245 | ID: function(elem, match){ |
1297 | ID: function(elem, match){ |
1246 | return elem.nodeType === 1 && elem.getAttribute("id") === match; |
1298 | return elem.nodeType === 1 && elem.getAttribute("id") === match; |
1247 | }, |
1299 | }, |
1248 | TAG: function(elem, match){ |
1300 | TAG: function(elem, match){ |
1249 | return (match === "*" && elem.nodeType === 1) || elem.nodeName === match; |
1301 | return (match === "*" && elem.nodeType === 1) || elem.nodeName === match; |
1250 | }, |
1302 | }, |
1251 | CLASS: function(elem, match){ |
1303 | CLASS: function(elem, match){ |
1252 | return (" " + (elem.className || elem.getAttribute("class")) + " ") |
1304 | return (" " + (elem.className || elem.getAttribute("class")) + " ") |
1253 | .indexOf( match ) > -1; |
1305 | .indexOf( match ) > -1; |
1254 | }, |
1306 | }, |
1255 | ATTR: function(elem, match){ |
1307 | ATTR: function(elem, match){ |
1256 | var name = match[1], |
1308 | var name = match[1], |
1257 | result = Expr.attrHandle[ name ] ? |
1309 | result = Expr.attrHandle[ name ] ? |
1258 | Expr.attrHandle[ name ]( elem ) : |
1310 | Expr.attrHandle[ name ]( elem ) : |
1259 | elem[ name ] != null ? |
1311 | elem[ name ] != null ? |
1260 | elem[ name ] : |
1312 | elem[ name ] : |
1261 | elem.getAttribute( name ), |
1313 | elem.getAttribute( name ), |
1262 | value = result + "", |
1314 | value = result + "", |
1263 | type = match[2], |
1315 | type = match[2], |
1264 | check = match[4]; |
1316 | check = match[4]; |
1265 | 1317 | ||
1266 | return result == null ? |
1318 | return result == null ? |
1267 | type === "!=" : |
1319 | type === "!=" : |
1268 | type === "=" ? |
1320 | type === "=" ? |
1269 | value === check : |
1321 | value === check : |
1270 | type === "*=" ? |
1322 | type === "*=" ? |
1271 | value.indexOf(check) >= 0 : |
1323 | value.indexOf(check) >= 0 : |
1272 | type === "~=" ? |
1324 | type === "~=" ? |
1273 | (" " + value + " ").indexOf(check) >= 0 : |
1325 | (" " + value + " ").indexOf(check) >= 0 : |
1274 | !check ? |
1326 | !check ? |
1275 | value && result !== false : |
1327 | value && result !== false : |
1276 | type === "!=" ? |
1328 | type === "!=" ? |
1277 | value != check : |
1329 | value != check : |
1278 | type === "^=" ? |
1330 | type === "^=" ? |
1279 | value.indexOf(check) === 0 : |
1331 | value.indexOf(check) === 0 : |
1280 | type === "$=" ? |
1332 | type === "$=" ? |
1281 | value.substr(value.length - check.length) === check : |
1333 | value.substr(value.length - check.length) === check : |
1282 | type === "|=" ? |
1334 | type === "|=" ? |
1283 | value === check || value.substr(0, check.length + 1) === check + "-" : |
1335 | value === check || value.substr(0, check.length + 1) === check + "-" : |
1284 | false; |
1336 | false; |
1285 | }, |
1337 | }, |
1286 | POS: function(elem, match, i, array){ |
1338 | POS: function(elem, match, i, array){ |
1287 | var name = match[2], filter = Expr.setFilters[ name ]; |
1339 | var name = match[2], filter = Expr.setFilters[ name ]; |
1288 | 1340 | ||
1289 | if ( filter ) { |
1341 | if ( filter ) { |
1290 | return filter( elem, i, match, array ); |
1342 | return filter( elem, i, match, array ); |
1291 | }
|
1343 | }
|
1292 | }
|
1344 | }
|
1293 | }
|
1345 | }
|
1294 | }; |
1346 | }; |
1295 | 1347 | ||
1296 | var origPOS = Expr.match.POS; |
1348 | var origPOS = Expr.match.POS; |
1297 | 1349 | ||
1298 | for ( var type in Expr.match ) { |
1350 | for ( var type in Expr.match ) { |
1299 | Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
1351 | Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
1300 | }
|
1352 | }
|
1301 | 1353 | ||
1302 | var makeArray = function(array, results) { |
1354 | var makeArray = function(array, results) { |
1303 | array = Array.prototype.slice.call( array ); |
1355 | array = Array.prototype.slice.call( array, 0 ); |
1304 | 1356 | ||
1305 | if ( results ) { |
1357 | if ( results ) { |
1306 | results.push.apply( results, array ); |
1358 | results.push.apply( results, array ); |
1307 | return results; |
1359 | return results; |
1308 | }
|
1360 | }
|
1309 | 1361 | ||
1310 | return array; |
1362 | return array; |
1311 | }; |
1363 | }; |
1312 | 1364 | ||
1313 | // Perform a simple check to determine if the browser is capable of
|
1365 | // Perform a simple check to determine if the browser is capable of
|
1314 | // converting a NodeList to an array using builtin methods.
|
1366 | // converting a NodeList to an array using builtin methods.
|
1315 | try { |
1367 | try { |
1316 | Array.prototype.slice.call( document.documentElement.childNodes ); |
1368 | Array.prototype.slice.call( document.documentElement.childNodes, 0 ); |
1317 | 1369 | ||
1318 | // Provide a fallback method if it does not work
|
1370 | // Provide a fallback method if it does not work
|
1319 | } catch(e){ |
1371 | } catch(e){ |
1320 | makeArray = function(array, results) { |
1372 | makeArray = function(array, results) { |
1321 | var ret = results || []; |
1373 | var ret = results || []; |
1322 | 1374 | ||
1323 | if ( toString.call(array) === "[object Array]" ) { |
1375 | if ( toString.call(array) === "[object Array]" ) { |
1324 | Array.prototype.push.apply( ret, array ); |
1376 | Array.prototype.push.apply( ret, array ); |
1325 | } else { |
1377 | } else { |
1326 | if ( typeof array.length === "number" ) { |
1378 | if ( typeof array.length === "number" ) { |
1327 | for ( var i = 0, l = array.length; i < l; i++ ) { |
1379 | for ( var i = 0, l = array.length; i < l; i++ ) { |
1328 | ret.push( array[i] ); |
1380 | ret.push( array[i] ); |
1329 | }
|
1381 | }
|
1330 | } else { |
1382 | } else { |
1331 | for ( var i = 0; array[i]; i++ ) { |
1383 | for ( var i = 0; array[i]; i++ ) { |
1332 | ret.push( array[i] ); |
1384 | ret.push( array[i] ); |
1333 | }
|
1385 | }
|
1334 | }
|
1386 | }
|
1335 | }
|
1387 | }
|
1336 | 1388 | ||
1337 | return ret; |
1389 | return ret; |
1338 | }; |
1390 | }; |
1339 | }
|
1391 | }
|
1340 | 1392 | ||
1341 | var sortOrder; |
1393 | var sortOrder; |
1342 | 1394 | ||
1343 | if ( document.documentElement.compareDocumentPosition ) { |
1395 | if ( document.documentElement.compareDocumentPosition ) { |
1344 | sortOrder = function( a, b ) { |
1396 | sortOrder = function( a, b ) { |
1345 | var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; |
1397 | var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; |
1346 | if ( ret === 0 ) { |
1398 | if ( ret === 0 ) { |
1347 | hasDuplicate = true; |
1399 | hasDuplicate = true; |
1348 | }
|
1400 | }
|
1349 | return ret; |
1401 | return ret; |
1350 | }; |
1402 | }; |
1351 | } else if ( "sourceIndex" in document.documentElement ) { |
1403 | } else if ( "sourceIndex" in document.documentElement ) { |
1352 | sortOrder = function( a, b ) { |
1404 | sortOrder = function( a, b ) { |
1353 | var ret = a.sourceIndex - b.sourceIndex; |
1405 | var ret = a.sourceIndex - b.sourceIndex; |
1354 | if ( ret === 0 ) { |
1406 | if ( ret === 0 ) { |
1355 | hasDuplicate = true; |
1407 | hasDuplicate = true; |
1356 | }
|
1408 | }
|
1357 | return ret; |
1409 | return ret; |
1358 | }; |
1410 | }; |
1359 | } else if ( document.createRange ) { |
1411 | } else if ( document.createRange ) { |
1360 | sortOrder = function( a, b ) { |
1412 | sortOrder = function( a, b ) { |
1361 | var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); |
1413 | var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); |
1362 | aRange.selectNode(a); |
1414 | aRange.selectNode(a); |
1363 | aRange.collapse(true); |
1415 | aRange.collapse(true); |
1364 | bRange.selectNode(b); |
1416 | bRange.selectNode(b); |
1365 | bRange.collapse(true); |
1417 | bRange.collapse(true); |
1366 | var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange); |
1418 | var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange); |
1367 | if ( ret === 0 ) { |
1419 | if ( ret === 0 ) { |
1368 | hasDuplicate = true; |
1420 | hasDuplicate = true; |
1369 | }
|
1421 | }
|
1370 | return ret; |
1422 | return ret; |
1371 | }; |
1423 | }; |
1372 | }
|
1424 | }
|
1373 | 1425 | ||
1374 | // Check to see if the browser returns elements by name when
|
1426 | // Check to see if the browser returns elements by name when
|
1375 | // querying by getElementById (and provide a workaround)
|
1427 | // querying by getElementById (and provide a workaround)
|
1376 | (function(){ |
1428 | (function(){ |
1377 | // We're going to inject a fake input element with a specified name
|
1429 | // We're going to inject a fake input element with a specified name
|
1378 | var form = document.createElement("div"), |
1430 | var form = document.createElement("div"), |
1379 | id = "script" + (new Date).getTime(); |
1431 | id = "script" + (new Date).getTime(); |
1380 | form.innerHTML = "<a name='" + id + "'/>"; |
1432 | form.innerHTML = "<a name='" + id + "'/>"; |
1381 | 1433 | ||
1382 | // Inject it into the root element, check its status, and remove it quickly
|
1434 | // Inject it into the root element, check its status, and remove it quickly
|
1383 | var root = document.documentElement; |
1435 | var root = document.documentElement; |
1384 | root.insertBefore( form, root.firstChild ); |
1436 | root.insertBefore( form, root.firstChild ); |
1385 | 1437 | ||
1386 | // The workaround has to do additional checks after a getElementById
|
1438 | // The workaround has to do additional checks after a getElementById
|
1387 | // Which slows things down for other browsers (hence the branching)
|
1439 | // Which slows things down for other browsers (hence the branching)
|
1388 | if ( !!document.getElementById( id ) ) { |
1440 | if ( !!document.getElementById( id ) ) { |
1389 | Expr.find.ID = function(match, context, isXML){ |
1441 | Expr.find.ID = function(match, context, isXML){ |
1390 | if ( typeof context.getElementById !== "undefined" && !isXML ) { |
1442 | if ( typeof context.getElementById !== "undefined" && !isXML ) { |
1391 | var m = context.getElementById(match[1]); |
1443 | var m = context.getElementById(match[1]); |
1392 | return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []; |
1444 | return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []; |
1393 | }
|
1445 | }
|
1394 | }; |
1446 | }; |
1395 | 1447 | ||
1396 | Expr.filter.ID = function(elem, match){ |
1448 | Expr.filter.ID = function(elem, match){ |
1397 | var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); |
1449 | var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); |
1398 | return elem.nodeType === 1 && node && node.nodeValue === match; |
1450 | return elem.nodeType === 1 && node && node.nodeValue === match; |
1399 | }; |
1451 | }; |
1400 | }
|
1452 | }
|
1401 | 1453 | ||
1402 | root.removeChild( form ); |
1454 | root.removeChild( form ); |
1403 | root = form = null; // release memory in IE |
1455 | root = form = null; // release memory in IE |
1404 | })(); |
1456 | })(); |
1405 | 1457 | ||
1406 | (function(){ |
1458 | (function(){ |
1407 | // Check to see if the browser returns only elements
|
1459 | // Check to see if the browser returns only elements
|
1408 | // when doing getElementsByTagName("*")
|
1460 | // when doing getElementsByTagName("*")
|
1409 | 1461 | ||
1410 | // Create a fake element
|
1462 | // Create a fake element
|
1411 | var div = document.createElement("div"); |
1463 | var div = document.createElement("div"); |
1412 | div.appendChild( document.createComment("") ); |
1464 | div.appendChild( document.createComment("") ); |
1413 | 1465 | ||
1414 | // Make sure no comments are found
|
1466 | // Make sure no comments are found
|
1415 | if ( div.getElementsByTagName("*").length > 0 ) { |
1467 | if ( div.getElementsByTagName("*").length > 0 ) { |
1416 | Expr.find.TAG = function(match, context){ |
1468 | Expr.find.TAG = function(match, context){ |
1417 | var results = context.getElementsByTagName(match[1]); |
1469 | var results = context.getElementsByTagName(match[1]); |
1418 | 1470 | ||
1419 | // Filter out possible comments
|
1471 | // Filter out possible comments
|
1420 | if ( match[1] === "*" ) { |
1472 | if ( match[1] === "*" ) { |
1421 | var tmp = []; |
1473 | var tmp = []; |
1422 | 1474 | ||
1423 | for ( var i = 0; results[i]; i++ ) { |
1475 | for ( var i = 0; results[i]; i++ ) { |
1424 | if ( results[i].nodeType === 1 ) { |
1476 | if ( results[i].nodeType === 1 ) { |
1425 | tmp.push( results[i] ); |
1477 | tmp.push( results[i] ); |
1426 | }
|
1478 | }
|
1427 | }
|
1479 | }
|
1428 | 1480 | ||
1429 | results = tmp; |
1481 | results = tmp; |
1430 | }
|
1482 | }
|
1431 | 1483 | ||
1432 | return results; |
1484 | return results; |
1433 | }; |
1485 | }; |
1434 | }
|
1486 | }
|
1435 | 1487 | ||
1436 | // Check to see if an attribute returns normalized href attributes
|
1488 | // Check to see if an attribute returns normalized href attributes
|
1437 | div.innerHTML = "<a href='#'></a>"; |
1489 | div.innerHTML = "<a href='#'></a>"; |
1438 | if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && |
1490 | if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && |
1439 | div.firstChild.getAttribute("href") !== "#" ) { |
1491 | div.firstChild.getAttribute("href") !== "#" ) { |
1440 | Expr.attrHandle.href = function(elem){ |
1492 | Expr.attrHandle.href = function(elem){ |
1441 | return elem.getAttribute("href", 2); |
1493 | return elem.getAttribute("href", 2); |
1442 | }; |
1494 | }; |
1443 | }
|
1495 | }
|
1444 | 1496 | ||
1445 | div = null; // release memory in IE |
1497 | div = null; // release memory in IE |
1446 | })(); |
1498 | })(); |
1447 | 1499 | ||
1448 | if ( document.querySelectorAll ) (function(){ |
1500 | if ( document.querySelectorAll ) (function(){ |
1449 | var oldSizzle = Sizzle, div = document.createElement("div"); |
1501 | var oldSizzle = Sizzle, div = document.createElement("div"); |
1450 | div.innerHTML = "<p class='TEST'></p>"; |
1502 | div.innerHTML = "<p class='TEST'></p>"; |
1451 | 1503 | ||
1452 | // Safari can't handle uppercase or unicode characters when
|
1504 | // Safari can't handle uppercase or unicode characters when
|
1453 | // in quirks mode.
|
1505 | // in quirks mode.
|
1454 | if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { |
1506 | if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { |
1455 | return; |
1507 | return; |
1456 | }
|
1508 | }
|
1457 | 1509 | ||
1458 | Sizzle = function(query, context, extra, seed){ |
1510 | Sizzle = function(query, context, extra, seed){ |
1459 | context = context || document; |
1511 | context = context || document; |
1460 | 1512 | ||
1461 | // Only use querySelectorAll on non-XML documents
|
1513 | // Only use querySelectorAll on non-XML documents
|
1462 | // (ID selectors don't work in non-HTML documents)
|
1514 | // (ID selectors don't work in non-HTML documents)
|
1463 | if ( !seed && context.nodeType === 9 && !isXML(context) ) { |
1515 | if ( !seed && context.nodeType === 9 && !isXML(context) ) { |
1464 | try { |
1516 | try { |
1465 | return makeArray( context.querySelectorAll(query), extra ); |
1517 | return makeArray( context.querySelectorAll(query), extra ); |
1466 | } catch(e){} |
1518 | } catch(e){} |
1467 | }
|
1519 | }
|
1468 | 1520 | ||
1469 | return oldSizzle(query, context, extra, seed); |
1521 | return oldSizzle(query, context, extra, seed); |
1470 | }; |
1522 | }; |
1471 | 1523 | ||
1472 | for ( var prop in oldSizzle ) { |
1524 | for ( var prop in oldSizzle ) { |
1473 | Sizzle[ prop ] = oldSizzle[ prop ]; |
1525 | Sizzle[ prop ] = oldSizzle[ prop ]; |
1474 | }
|
1526 | }
|
1475 | 1527 | ||
1476 | div = null; // release memory in IE |
1528 | div = null; // release memory in IE |
1477 | })(); |
1529 | })(); |
1478 | 1530 | ||
1479 | if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ |
1531 | if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ |
1480 | var div = document.createElement("div"); |
1532 | var div = document.createElement("div"); |
1481 | div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
1533 | div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
1482 | 1534 | ||
1483 | // Opera can't find a second classname (in 9.6)
|
1535 | // Opera can't find a second classname (in 9.6)
|
1484 | if ( div.getElementsByClassName("e").length === 0 ) |
1536 | if ( div.getElementsByClassName("e").length === 0 ) |
1485 | return; |
1537 | return; |
1486 | 1538 | ||
1487 | // Safari caches class attributes, doesn't catch changes (in 3.2)
|
1539 | // Safari caches class attributes, doesn't catch changes (in 3.2)
|
1488 | div.lastChild.className = "e"; |
1540 | div.lastChild.className = "e"; |
1489 | 1541 | ||
1490 | if ( div.getElementsByClassName("e").length === 1 ) |
1542 | if ( div.getElementsByClassName("e").length === 1 ) |
1491 | return; |
1543 | return; |
1492 | 1544 | ||
1493 | Expr.order.splice(1, 0, "CLASS"); |
1545 | Expr.order.splice(1, 0, "CLASS"); |
1494 | Expr.find.CLASS = function(match, context, isXML) { |
1546 | Expr.find.CLASS = function(match, context, isXML) { |
1495 | if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
1547 | if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
1496 | return context.getElementsByClassName(match[1]); |
1548 | return context.getElementsByClassName(match[1]); |
1497 | }
|
1549 | }
|
1498 | }; |
1550 | }; |
1499 | 1551 | ||
1500 | div = null; // release memory in IE |
1552 | div = null; // release memory in IE |
1501 | })(); |
1553 | })(); |
1502 | 1554 | ||
1503 | function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
1555 | function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
1504 | var sibDir = dir == "previousSibling" && !isXML; |
1556 | var sibDir = dir == "previousSibling" && !isXML; |
1505 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
1557 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
1506 | var elem = checkSet[i]; |
1558 | var elem = checkSet[i]; |
1507 | if ( elem ) { |
1559 | if ( elem ) { |
1508 | if ( sibDir && elem.nodeType === 1 ){ |
1560 | if ( sibDir && elem.nodeType === 1 ){ |
1509 | elem.sizcache = doneName; |
1561 | elem.sizcache = doneName; |
1510 | elem.sizset = i; |
1562 | elem.sizset = i; |
1511 | }
|
1563 | }
|
1512 | elem = elem[dir]; |
1564 | elem = elem[dir]; |
1513 | var match = false; |
1565 | var match = false; |
1514 | 1566 | ||
1515 | while ( elem ) { |
1567 | while ( elem ) { |
1516 | if ( elem.sizcache === doneName ) { |
1568 | if ( elem.sizcache === doneName ) { |
1517 | match = checkSet[elem.sizset]; |
1569 | match = checkSet[elem.sizset]; |
1518 | break; |
1570 | break; |
1519 | }
|
1571 | }
|
1520 | 1572 | ||
1521 | if ( elem.nodeType === 1 && !isXML ){ |
1573 | if ( elem.nodeType === 1 && !isXML ){ |
1522 | elem.sizcache = doneName; |
1574 | elem.sizcache = doneName; |
1523 | elem.sizset = i; |
1575 | elem.sizset = i; |
1524 | }
|
1576 | }
|
1525 | 1577 | ||
1526 | if ( elem.nodeName === cur ) { |
1578 | if ( elem.nodeName === cur ) { |
1527 | match = elem; |
1579 | match = elem; |
1528 | break; |
1580 | break; |
1529 | }
|
1581 | }
|
1530 | 1582 | ||
1531 | elem = elem[dir]; |
1583 | elem = elem[dir]; |
1532 | }
|
1584 | }
|
1533 | 1585 | ||
1534 | checkSet[i] = match; |
1586 | checkSet[i] = match; |
1535 | }
|
1587 | }
|
1536 | }
|
1588 | }
|
1537 | }
|
1589 | }
|
1538 | 1590 | ||
1539 | function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
1591 | function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
1540 | var sibDir = dir == "previousSibling" && !isXML; |
1592 | var sibDir = dir == "previousSibling" && !isXML; |
1541 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
1593 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
1542 | var elem = checkSet[i]; |
1594 | var elem = checkSet[i]; |
1543 | if ( elem ) { |
1595 | if ( elem ) { |
1544 | if ( sibDir && elem.nodeType === 1 ) { |
1596 | if ( sibDir && elem.nodeType === 1 ) { |
1545 | elem.sizcache = doneName; |
1597 | elem.sizcache = doneName; |
1546 | elem.sizset = i; |
1598 | elem.sizset = i; |
1547 | }
|
1599 | }
|
1548 | elem = elem[dir]; |
1600 | elem = elem[dir]; |
1549 | var match = false; |
1601 | var match = false; |
1550 | 1602 | ||
1551 | while ( elem ) { |
1603 | while ( elem ) { |
1552 | if ( elem.sizcache === doneName ) { |
1604 | if ( elem.sizcache === doneName ) { |
1553 | match = checkSet[elem.sizset]; |
1605 | match = checkSet[elem.sizset]; |
1554 | break; |
1606 | break; |
1555 | }
|
1607 | }
|
1556 | 1608 | ||
1557 | if ( elem.nodeType === 1 ) { |
1609 | if ( elem.nodeType === 1 ) { |
1558 | if ( !isXML ) { |
1610 | if ( !isXML ) { |
1559 | elem.sizcache = doneName; |
1611 | elem.sizcache = doneName; |
1560 | elem.sizset = i; |
1612 | elem.sizset = i; |
1561 | }
|
1613 | }
|
1562 | if ( typeof cur !== "string" ) { |
1614 | if ( typeof cur !== "string" ) { |
1563 | if ( elem === cur ) { |
1615 | if ( elem === cur ) { |
1564 | match = true; |
1616 | match = true; |
1565 | break; |
1617 | break; |
1566 | }
|
1618 | }
|
1567 | 1619 | ||
1568 | } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { |
1620 | } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { |
1569 | match = elem; |
1621 | match = elem; |
1570 | break; |
1622 | break; |
1571 | }
|
1623 | }
|
1572 | }
|
1624 | }
|
1573 | 1625 | ||
1574 | elem = elem[dir]; |
1626 | elem = elem[dir]; |
1575 | }
|
1627 | }
|
1576 | 1628 | ||
1577 | checkSet[i] = match; |
1629 | checkSet[i] = match; |
1578 | }
|
1630 | }
|
1579 | }
|
1631 | }
|
1580 | }
|
1632 | }
|
1581 | 1633 | ||
1582 | var contains = document.compareDocumentPosition ? function(a, b){ |
1634 | var contains = document.compareDocumentPosition ? function(a, b){ |
1583 | return a.compareDocumentPosition(b) & 16; |
1635 | return a.compareDocumentPosition(b) & 16; |
1584 | } : function(a, b){ |
1636 | } : function(a, b){ |
1585 | return a !== b && (a.contains ? a.contains(b) : true); |
1637 | return a !== b && (a.contains ? a.contains(b) : true); |
1586 | }; |
1638 | }; |
1587 | 1639 | ||
1588 | var isXML = function(elem){ |
1640 | var isXML = function(elem){ |
1589 | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || |
1641 | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || |
1590 | !!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML"; |
1642 | !!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML"; |
1591 | }; |
1643 | }; |
1592 | 1644 | ||
1593 | var posProcess = function(selector, context){ |
1645 | var posProcess = function(selector, context){ |
1594 | var tmpSet = [], later = "", match, |
1646 | var tmpSet = [], later = "", match, |
1595 | root = context.nodeType ? [context] : context; |
1647 | root = context.nodeType ? [context] : context; |
1596 | 1648 | ||
1597 | // Position selectors must be done after the filter
|
1649 | // Position selectors must be done after the filter
|
1598 | // And so must :not(positional) so we move all PSEUDOs to the end
|
1650 | // And so must :not(positional) so we move all PSEUDOs to the end
|
1599 | while ( (match = Expr.match.PSEUDO.exec( selector )) ) { |
1651 | while ( (match = Expr.match.PSEUDO.exec( selector )) ) { |
1600 | later += match[0]; |
1652 | later += match[0]; |
1601 | selector = selector.replace( Expr.match.PSEUDO, "" ); |
1653 | selector = selector.replace( Expr.match.PSEUDO, "" ); |
1602 | }
|
1654 | }
|
1603 | 1655 | ||
1604 | selector = Expr.relative[selector] ? selector + "*" : selector; |
1656 | selector = Expr.relative[selector] ? selector + "*" : selector; |
1605 | 1657 | ||
1606 | for ( var i = 0, l = root.length; i < l; i++ ) { |
1658 | for ( var i = 0, l = root.length; i < l; i++ ) { |
1607 | Sizzle( selector, root[i], tmpSet ); |
1659 | Sizzle( selector, root[i], tmpSet ); |
1608 | }
|
1660 | }
|
1609 | 1661 | ||
1610 | return Sizzle.filter( later, tmpSet ); |
1662 | return Sizzle.filter( later, tmpSet ); |
1611 | }; |
1663 | }; |
1612 | 1664 | ||
1613 | // EXPOSE
|
1665 | // EXPOSE
|
1614 | jQuery.find = Sizzle; |
1666 | jQuery.find = Sizzle; |
1615 | jQuery.expr = Sizzle.selectors; |
1667 | jQuery.expr = Sizzle.selectors; |
1616 | jQuery.expr[":"] = jQuery.expr.filters; |
1668 | jQuery.expr[":"] = jQuery.expr.filters; |
1617 | 1669 | ||
1618 | Sizzle.selectors.filters.hidden = function(elem){ |
1670 | Sizzle.selectors.filters.hidden = function(elem){ |
1619 | var width = elem.offsetWidth, height = elem.offsetHeight; |
1671 | var width = elem.offsetWidth, height = elem.offsetHeight, |
- | 1672 | force = /^tr$/i.test( elem.nodeName ); // ticket #4512 |
|
1620 | return ( width === 0 && height === 0 ) ? |
1673 | return ( width === 0 && height === 0 && !force ) ? |
1621 | true : |
1674 | true : |
1622 | ( width !== 0 && height !== 0 ) ? |
1675 | ( width !== 0 && height !== 0 && !force ) ? |
1623 | false : |
1676 | false : |
1624 | !!( jQuery.curCSS(elem, "display") === "none" ); |
1677 | !!( jQuery.curCSS(elem, "display") === "none" ); |
1625 | }; |
1678 | }; |
1626 | 1679 | ||
1627 | Sizzle.selectors.filters.visible = function(elem){ |
1680 | Sizzle.selectors.filters.visible = function(elem){ |
1628 | var width = elem.offsetWidth, height = elem.offsetHeight; |
- | |
1629 | return ( width === 0 && height === 0 ) ? |
1681 | return !Sizzle.selectors.filters.hidden(elem); |
1630 | false : |
- | |
1631 | ( width > 0 && height > 0 ) ? |
- | |
1632 | true : |
- | |
1633 | !!( jQuery.curCSS(elem, "display") !== "none" ); |
- | |
1634 | }; |
1682 | }; |
1635 | 1683 | ||
1636 | Sizzle.selectors.filters.animated = function(elem){ |
1684 | Sizzle.selectors.filters.animated = function(elem){ |
1637 | return jQuery.grep(jQuery.timers, function(fn){ |
1685 | return jQuery.grep(jQuery.timers, function(fn){ |
1638 | return elem === fn.elem; |
1686 | return elem === fn.elem; |
1639 | }).length; |
1687 | }).length; |
1640 | }; |
1688 | }; |
1641 | 1689 | ||
1642 | jQuery.filter = jQuery.multiFilter = function( expr, elems, not ) { |
1690 | jQuery.filter = jQuery.multiFilter = function( expr, elems, not ) { |
1643 | if ( not ) { |
1691 | if ( not ) { |
1644 | expr = ":not(" + expr + ")"; |
1692 | expr = ":not(" + expr + ")"; |
1645 | }
|
1693 | }
|
1646 | 1694 | ||
1647 | return Sizzle.matches(expr, elems); |
1695 | return Sizzle.matches(expr, elems); |
1648 | }; |
1696 | }; |
1649 | 1697 | ||
1650 | jQuery.dir = function( elem, dir ){ |
1698 | jQuery.dir = function( elem, dir ){ |
1651 | var matched = [], cur = elem[dir]; |
1699 | var matched = [], cur = elem[dir]; |
1652 | while ( cur && cur != document ) { |
1700 | while ( cur && cur != document ) { |
1653 | if ( cur.nodeType == 1 ) |
1701 | if ( cur.nodeType == 1 ) |
1654 | matched.push( cur ); |
1702 | matched.push( cur ); |
1655 | cur = cur[dir]; |
1703 | cur = cur[dir]; |
1656 | }
|
1704 | }
|
1657 | return matched; |
1705 | return matched; |
1658 | }; |
1706 | }; |
1659 | 1707 | ||
1660 | jQuery.nth = function(cur, result, dir, elem){ |
1708 | jQuery.nth = function(cur, result, dir, elem){ |
1661 | result = result || 1; |
1709 | result = result || 1; |
1662 | var num = 0; |
1710 | var num = 0; |
1663 | 1711 | ||
1664 | for ( ; cur; cur = cur[dir] ) |
1712 | for ( ; cur; cur = cur[dir] ) |
1665 | if ( cur.nodeType == 1 && ++num == result ) |
1713 | if ( cur.nodeType == 1 && ++num == result ) |
1666 | break; |
1714 | break; |
1667 | 1715 | ||
1668 | return cur; |
1716 | return cur; |
1669 | }; |
1717 | }; |
1670 | 1718 | ||
1671 | jQuery.sibling = function(n, elem){ |
1719 | jQuery.sibling = function(n, elem){ |
1672 | var r = []; |
1720 | var r = []; |
1673 | 1721 | ||
1674 | for ( ; n; n = n.nextSibling ) { |
1722 | for ( ; n; n = n.nextSibling ) { |
1675 | if ( n.nodeType == 1 && n != elem ) |
1723 | if ( n.nodeType == 1 && n != elem ) |
1676 | r.push( n ); |
1724 | r.push( n ); |
1677 | }
|
1725 | }
|
1678 | 1726 | ||
1679 | return r; |
1727 | return r; |
1680 | }; |
1728 | }; |
1681 | 1729 | ||
1682 | return; |
1730 | return; |
1683 | 1731 | ||
1684 | window.Sizzle = Sizzle; |
1732 | window.Sizzle = Sizzle; |
1685 | 1733 | ||
1686 | })(); |
1734 | })(); |
- | 1735 | jQuery.winnow = function( elements, qualifier, keep ) { |
|
- | 1736 | if(jQuery.isFunction( qualifier )) { |
|
- | 1737 | return jQuery.grep(elements, function(elem, i) { |
|
- | 1738 | return !!qualifier.call( elem, i ) === keep; |
|
- | 1739 | }); |
|
- | 1740 | } else if( qualifier.nodeType ) { |
|
- | 1741 | return jQuery.grep(elements, function(elem, i) { |
|
- | 1742 | return (elem === qualifier) === keep; |
|
- | 1743 | }) |
|
- | 1744 | } else if( typeof qualifier === "string" ) { |
|
- | 1745 | var filtered = jQuery.grep(elements, function(elem) { return elem.nodeType === 1 }); |
|
- | 1746 | ||
- | 1747 | if(isSimple.test( qualifier )) return jQuery.multiFilter(qualifier, filtered, !keep); |
|
- | 1748 | else qualifier = jQuery.multiFilter( qualifier, elements ); |
|
- | 1749 | }
|
|
- | 1750 | ||
- | 1751 | return jQuery.grep(elements, function(elem, i) { |
|
- | 1752 | return (jQuery.inArray( elem, qualifier ) >= 0) === keep; |
|
- | 1753 | }); |
|
- | 1754 | }
|
|
- | 1755 | ||
1687 | jQuery.fn.extend({ |
1756 | jQuery.fn.extend({ |
1688 | find: function( selector ) { |
1757 | find: function( selector ) { |
1689 | var ret = this.pushStack( "", "find", selector ), length = 0; |
1758 | var ret = this.pushStack( "", "find", selector ), length = 0; |
1690 | 1759 | ||
1691 | for ( var i = 0, l = this.length; i < l; i++ ) { |
1760 | for ( var i = 0, l = this.length; i < l; i++ ) { |
1692 | length = ret.length; |
1761 | length = ret.length; |
1693 | jQuery.find( selector, this[i], ret ); |
1762 | jQuery.find( selector, this[i], ret ); |
1694 | 1763 | ||
1695 | if ( i > 0 ) { |
1764 | if ( i > 0 ) { |
1696 | // Make sure that the results are unique
|
1765 | // Make sure that the results are unique
|
1697 | for ( var n = length; n < ret.length; n++ ) { |
1766 | for ( var n = length; n < ret.length; n++ ) { |
1698 | for ( var r = 0; r < length; r++ ) { |
1767 | for ( var r = 0; r < length; r++ ) { |
1699 | if ( ret[r] === ret[n] ) { |
1768 | if ( ret[r] === ret[n] ) { |
1700 | ret.splice(n--, 1); |
1769 | ret.splice(n--, 1); |
1701 | break; |
1770 | break; |
1702 | }
|
1771 | }
|
1703 | }
|
1772 | }
|
1704 | }
|
1773 | }
|
1705 | }
|
1774 | }
|
1706 | }
|
1775 | }
|
1707 | 1776 | ||
1708 | return ret; |
1777 | return ret; |
1709 | }, |
1778 | }, |
1710 | 1779 | ||
- | 1780 | not: function( selector ) { |
|
- | 1781 | return this.pushStack( jQuery.winnow(this, selector, false), "not", selector); |
|
- | 1782 | }, |
|
- | 1783 | ||
1711 | filter: function( selector ) { |
1784 | filter: function( selector ) { |
1712 | return this.pushStack( |
- | |
1713 | jQuery.isFunction( selector ) && |
- | |
1714 | jQuery.grep(this, function(elem, i){ |
- | |
1715 | return selector.call( elem, i ); |
- | |
1716 | }) || |
- | |
1717 | - | ||
1718 | jQuery.multiFilter( selector, jQuery.grep(this, function(elem){ |
1785 | return this.pushStack( jQuery.winnow(this, selector, true), "filter", selector ); |
1719 | return elem.nodeType === 1; |
- | |
1720 | }) ), "filter", selector ); |
- | |
1721 | }, |
1786 | }, |
1722 | 1787 | ||
1723 | closest: function( selector ) { |
1788 | closest: function( selector ) { |
1724 | var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, |
1789 | var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, |
1725 | closer = 0; |
1790 | closer = 0, |
- | 1791 | context = this.context; |
|
1726 | 1792 | ||
1727 | return this.map(function(){ |
1793 | return this.map(function(){ |
1728 | var cur = this; |
1794 | var cur = this; |
1729 | while ( cur && cur.ownerDocument ) { |
1795 | while ( cur && cur.ownerDocument && cur !== context ) { |
1730 | if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { |
1796 | if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { |
1731 | jQuery.data(cur, "closest", closer); |
1797 | jQuery.data(cur, "closest", closer); |
1732 | return cur; |
1798 | return cur; |
1733 | }
|
1799 | }
|
1734 | cur = cur.parentNode; |
1800 | cur = cur.parentNode; |
1735 | closer++;
|
1801 | closer++;
|
1736 | }
|
1802 | }
|
1737 | }); |
1803 | }); |
1738 | }, |
1804 | }, |
1739 | 1805 | ||
1740 | not: function( selector ) { |
- | |
1741 | if ( typeof selector === "string" ) |
- | |
1742 | // test special case where just one selector is passed in
|
- | |
1743 | if ( isSimple.test( selector ) ) |
- | |
1744 | return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector ); |
- | |
1745 | else
|
- | |
1746 | selector = jQuery.multiFilter( selector, this ); |
- | |
1747 | - | ||
1748 | var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; |
- | |
1749 | return this.filter(function() { |
- | |
1750 | return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; |
- | |
1751 | }); |
- | |
1752 | }, |
- | |
1753 | - | ||
1754 | add: function( selector ) { |
1806 | add: function( selector ) { |
1755 | return this.pushStack( jQuery.unique( jQuery.merge( |
1807 | return this.pushStack( jQuery.unique( jQuery.merge( |
1756 | this.get(), |
1808 | this.get(), |
1757 | typeof selector === "string" ? |
1809 | typeof selector === "string" ? |
1758 | jQuery( selector ) : |
1810 | jQuery( selector ) : |
1759 | jQuery.makeArray( selector ) |
1811 | jQuery.makeArray( selector ) |
1760 | ))); |
1812 | ))); |
1761 | }, |
1813 | }, |
1762 | 1814 | ||
1763 | eq: function( i ) { |
1815 | eq: function( i ) { |
1764 | return this.slice( i, +i + 1 ); |
1816 | return this.slice( i, +i + 1 ); |
1765 | }, |
1817 | }, |
1766 | 1818 | ||
1767 | slice: function() { |
1819 | slice: function() { |
1768 | return this.pushStack( Array.prototype.slice.apply( this, arguments ), |
1820 | return this.pushStack( Array.prototype.slice.apply( this, arguments ), |
1769 | "slice", Array.prototype.slice.call(arguments).join(",") ); |
1821 | "slice", Array.prototype.slice.call(arguments).join(",") ); |
1770 | }, |
1822 | }, |
1771 | 1823 | ||
1772 | map: function( callback ) { |
1824 | map: function( callback ) { |
1773 | return this.pushStack( jQuery.map(this, function(elem, i){ |
1825 | return this.pushStack( jQuery.map(this, function(elem, i){ |
1774 | return callback.call( elem, i, elem ); |
1826 | return callback.call( elem, i, elem ); |
1775 | })); |
1827 | })); |
1776 | }, |
1828 | }, |
1777 | 1829 | ||
1778 | andSelf: function() { |
1830 | andSelf: function() { |
1779 | return this.add( this.prevObject ); |
1831 | return this.add( this.prevObject ); |
1780 | }, |
1832 | }, |
1781 | 1833 | ||
1782 | end: function() { |
1834 | end: function() { |
1783 | return this.prevObject || jQuery(null); |
1835 | return this.prevObject || jQuery(null); |
1784 | }
|
1836 | }
|
1785 | }); |
1837 | }); |
1786 | 1838 | ||
1787 | jQuery.each({ |
1839 | jQuery.each({ |
1788 | parent: function(elem){return elem.parentNode;}, |
1840 | parent: function(elem){return elem.parentNode;}, |
1789 | parents: function(elem){return jQuery.dir(elem,"parentNode");}, |
1841 | parents: function(elem){return jQuery.dir(elem,"parentNode");}, |
1790 | next: function(elem){return jQuery.nth(elem,2,"nextSibling");}, |
1842 | next: function(elem){return jQuery.nth(elem,2,"nextSibling");}, |
1791 | prev: function(elem){return jQuery.nth(elem,2,"previousSibling");}, |
1843 | prev: function(elem){return jQuery.nth(elem,2,"previousSibling");}, |
1792 | nextAll: function(elem){return jQuery.dir(elem,"nextSibling");}, |
1844 | nextAll: function(elem){return jQuery.dir(elem,"nextSibling");}, |
1793 | prevAll: function(elem){return jQuery.dir(elem,"previousSibling");}, |
1845 | prevAll: function(elem){return jQuery.dir(elem,"previousSibling");}, |
1794 | siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);}, |
1846 | siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);}, |
1795 | children: function(elem){return jQuery.sibling(elem.firstChild);}, |
1847 | children: function(elem){return jQuery.sibling(elem.firstChild);}, |
1796 | contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);} |
1848 | contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);} |
1797 | }, function(name, fn){ |
1849 | }, function(name, fn){ |
1798 | jQuery.fn[ name ] = function( selector ) { |
1850 | jQuery.fn[ name ] = function( selector ) { |
1799 | var ret = jQuery.map( this, fn ); |
1851 | var ret = jQuery.map( this, fn ); |
1800 | 1852 | ||
1801 | if ( selector && typeof selector == "string" ) |
1853 | if ( selector && typeof selector == "string" ) |
1802 | ret = jQuery.multiFilter( selector, ret ); |
1854 | ret = jQuery.multiFilter( selector, ret ); |
1803 | 1855 | ||
1804 | return this.pushStack( jQuery.unique( ret ), name, selector ); |
1856 | return this.pushStack( jQuery.unique( ret ), name, selector ); |
1805 | }; |
1857 | }; |
- | 1858 | }); |
|
1806 | });jQuery.fn.extend({ |
1859 | jQuery.fn.extend({ |
1807 | attr: function( name, value ) { |
1860 | attr: function( name, value ) { |
1808 | var options = name, isFunction = jQuery.isFunction( value ); |
1861 | var elem, options, isFunction = jQuery.isFunction(value); |
1809 | 1862 | ||
1810 | if ( typeof name === "string" ) { |
1863 | if ( typeof name === "string" ) { // A single attribute |
1811 | // Are we setting the attribute?
|
- | |
1812 | if ( value === undefined ) { |
1864 | if ( value === undefined ) { // Query it on first element |
1813 | return this.length ? |
1865 | return this.length ? |
1814 | jQuery.attr( this[0], name ) : |
1866 | jQuery.attr( this[0], name ) : |
1815 | null; |
1867 | null; |
1816 | - | ||
1817 | // Convert name, value params to options hash format
|
1868 | } else { // Set it on all elements |
- | 1869 | for ( var i = 0, l = this.length; i < l; i++ ) { |
|
1818 | } else { |
1870 | elem = this[i]; |
1819 | options = {}; |
1871 | if ( isFunction ) |
- | 1872 | value = value.call(elem,i); |
|
1820 | options[ name ] = value; |
1873 | jQuery.attr( elem, name, value ); |
1821 | }
|
1874 | }
|
1822 | }
|
1875 | }
|
1823 | - | ||
- | 1876 | } else { // Multiple attributes to set on all |
|
1824 | // For each element...
|
1877 | options = name; |
1825 | for ( var i = 0, l = this.length; i < l; i++ ) { |
1878 | for ( var i = 0, l = this.length; i < l; i++ ) { |
1826 | var elem = this[i]; |
1879 | elem = this[i]; |
1827 | - | ||
1828 | // Set all the attributes
|
- | |
1829 | for ( var prop in options ) { |
1880 | for ( name in options ) { |
1830 | value = options[prop]; |
1881 | value = options[name]; |
1831 | - | ||
1832 | if ( isFunction ) { |
1882 | if ( jQuery.isFunction(value) ) |
1833 | value = value.call( elem, i ); |
1883 | value = value.call(elem,i); |
- | 1884 | jQuery.attr( elem, name, value ); |
|
1834 | }
|
1885 | }
|
1835 | - | ||
1836 | jQuery.attr( elem, prop, value ); |
- | |
1837 | }
|
1886 | }
|
1838 | }
|
1887 | }
|
1839 | 1888 | ||
1840 | return this; |
1889 | return this; |
1841 | }, |
1890 | }, |
1842 | 1891 | ||
1843 | hasClass: function( selector ) { |
1892 | hasClass: function( selector ) { |
1844 | return !!selector && this.is( "." + selector ); |
1893 | return !!selector && this.is( "." + selector ); |
1845 | }, |
1894 | }, |
1846 | 1895 | ||
1847 | val: function( value ) { |
1896 | val: function( value ) { |
1848 | if ( value === undefined ) { |
1897 | if ( value === undefined ) { |
1849 | var elem = this[0]; |
1898 | var elem = this[0]; |
1850 | 1899 | ||
1851 | if ( elem ) { |
1900 | if ( elem ) { |
1852 | if( jQuery.nodeName( elem, 'option' ) ) |
1901 | if( jQuery.nodeName( elem, 'option' ) ) |
1853 | return (elem.attributes.value || {}).specified ? elem.value : elem.text; |
1902 | return (elem.attributes.value || {}).specified ? elem.value : elem.text; |
1854 | 1903 | ||
1855 | // We need to handle select boxes special
|
1904 | // We need to handle select boxes special
|
1856 | if ( jQuery.nodeName( elem, "select" ) ) { |
1905 | if ( jQuery.nodeName( elem, "select" ) ) { |
1857 | var index = elem.selectedIndex, |
1906 | var index = elem.selectedIndex, |
1858 | values = [], |
1907 | values = [], |
1859 | options = elem.options, |
1908 | options = elem.options, |
1860 | one = elem.type == "select-one"; |
1909 | one = elem.type == "select-one"; |
1861 | 1910 | ||
1862 | // Nothing was selected
|
1911 | // Nothing was selected
|
1863 | if ( index < 0 ) |
1912 | if ( index < 0 ) |
1864 | return null; |
1913 | return null; |
1865 | 1914 | ||
1866 | // Loop through all the selected options
|
1915 | // Loop through all the selected options
|
1867 | for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
1916 | for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
1868 | var option = options[ i ]; |
1917 | var option = options[ i ]; |
1869 | 1918 | ||
1870 | if ( option.selected ) { |
1919 | if ( option.selected ) { |
1871 | // Get the specifc value for the option
|
1920 | // Get the specifc value for the option
|
1872 | value = jQuery(option).val(); |
1921 | value = jQuery(option).val(); |
1873 | 1922 | ||
1874 | // We don't need an array for one selects
|
1923 | // We don't need an array for one selects
|
1875 | if ( one ) |
1924 | if ( one ) |
1876 | return value; |
1925 | return value; |
1877 | 1926 | ||
1878 | // Multi-Selects return an array
|
1927 | // Multi-Selects return an array
|
1879 | values.push( value ); |
1928 | values.push( value ); |
1880 | }
|
1929 | }
|
1881 | }
|
1930 | }
|
1882 | 1931 | ||
1883 | return values; |
1932 | return values; |
1884 | }
|
1933 | }
|
1885 | 1934 | ||
1886 | // Everything else, we just grab the value
|
1935 | // Everything else, we just grab the value
|
1887 | return (elem.value || "").replace(/\r/g, ""); |
1936 | return (elem.value || "").replace(/\r/g, ""); |
1888 | 1937 | ||
1889 | }
|
1938 | }
|
1890 | 1939 | ||
1891 | return undefined; |
1940 | return undefined; |
1892 | }
|
1941 | }
|
1893 | 1942 | ||
- | 1943 | // Typecast once if the value is a number
|
|
1894 | if ( typeof value === "number" ) |
1944 | if ( typeof value === "number" ) |
1895 | value += ''; |
1945 | value += ''; |
- | 1946 | ||
- | 1947 | var val = value; |
|
1896 | 1948 | ||
1897 | return this.each(function(){ |
1949 | return this.each(function(){ |
- | 1950 | if(jQuery.isFunction(value)) { |
|
- | 1951 | val = value.call(this); |
|
- | 1952 | // Typecast each time if the value is a Function and the appended
|
|
- | 1953 | // value is therefore different each time.
|
|
- | 1954 | if( typeof val === "number" ) val += ''; |
|
- | 1955 | }
|
|
- | 1956 | ||
1898 | if ( this.nodeType != 1 ) |
1957 | if ( this.nodeType != 1 ) |
1899 | return; |
1958 | return; |
1900 | 1959 | ||
1901 | if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) ) |
1960 | if ( jQuery.isArray(val) && /radio|checkbox/.test( this.type ) ) |
1902 | this.checked = (jQuery.inArray(this.value, value) >= 0 || |
1961 | this.checked = jQuery.inArray(this.value || this.name, val) >= 0; |
1903 | jQuery.inArray(this.name, value) >= 0); |
- | |
1904 | 1962 | ||
1905 | else if ( jQuery.nodeName( this, "select" ) ) { |
1963 | else if ( jQuery.nodeName( this, "select" ) ) { |
1906 | var values = jQuery.makeArray(value); |
1964 | var values = jQuery.makeArray(val); |
1907 | 1965 | ||
1908 | jQuery( "option", this ).each(function(){ |
1966 | jQuery( "option", this ).each(function(){ |
1909 | this.selected = (jQuery.inArray( this.value, values ) >= 0 || |
1967 | this.selected = jQuery.inArray( this.value || this.text, values ) >= 0; |
1910 | jQuery.inArray( this.text, values ) >= 0); |
- | |
1911 | }); |
1968 | }); |
1912 | 1969 | ||
1913 | if ( !values.length ) |
1970 | if ( !values.length ) |
1914 | this.selectedIndex = -1; |
1971 | this.selectedIndex = -1; |
1915 | 1972 | ||
1916 | } else |
1973 | } else |
1917 | this.value = value; |
1974 | this.value = val; |
1918 | }); |
1975 | }); |
1919 | }
|
1976 | }
|
1920 | }); |
1977 | }); |
1921 | 1978 | ||
1922 | jQuery.each({ |
1979 | jQuery.each({ |
1923 | removeAttr: function( name ) { |
1980 | removeAttr: function( name ) { |
1924 | jQuery.attr( this, name, "" ); |
1981 | jQuery.attr( this, name, "" ); |
1925 | if (this.nodeType == 1) |
1982 | if (this.nodeType == 1) |
1926 | this.removeAttribute( name ); |
1983 | this.removeAttribute( name ); |
1927 | }, |
1984 | }, |
1928 | 1985 | ||
1929 | addClass: function( classNames ) { |
1986 | addClass: function( classNames ) { |
1930 | jQuery.className.add( this, classNames ); |
1987 | jQuery.className.add( this, classNames ); |
1931 | }, |
1988 | }, |
1932 | 1989 | ||
1933 | removeClass: function( classNames ) { |
1990 | removeClass: function( classNames ) { |
1934 | jQuery.className.remove( this, classNames ); |
1991 | jQuery.className.remove( this, classNames ); |
1935 | }, |
1992 | }, |
1936 | 1993 | ||
1937 | toggleClass: function( classNames, state ) { |
1994 | toggleClass: function( classNames, state ) { |
1938 | var type = typeof classNames; |
1995 | var type = typeof classNames; |
1939 | if ( type === "string" ) { |
1996 | if ( type === "string" ) { |
1940 | // toggle individual class names
|
1997 | // toggle individual class names
|
1941 | var isBool = typeof state === "boolean", className, i = 0, |
1998 | var isBool = typeof state === "boolean", className, i = 0, |
1942 | classNames = classNames.split( /\s+/ ); |
1999 | classNames = classNames.split( /\s+/ ); |
1943 | while ( (className = classNames[ i++ ]) ) { |
2000 | while ( (className = classNames[ i++ ]) ) { |
1944 | // check each className given, space seperated list
|
2001 | // check each className given, space seperated list
|
1945 | state = isBool ? state : !jQuery.className.has( this, className ); |
2002 | state = isBool ? state : !jQuery.className.has( this, className ); |
1946 | jQuery.className[ state ? "add" : "remove" ]( this, className ); |
2003 | jQuery.className[ state ? "add" : "remove" ]( this, className ); |
1947 | }
|
2004 | }
|
1948 | } else if ( type === "undefined" || type === "boolean" ) { |
2005 | } else if ( type === "undefined" || type === "boolean" ) { |
1949 | if ( this.className ) { |
2006 | if ( this.className ) { |
1950 | // store className if set
|
2007 | // store className if set
|
1951 | jQuery.data( this, "__className__", this.className ); |
2008 | jQuery.data( this, "__className__", this.className ); |
1952 | }
|
2009 | }
|
1953 | // toggle whole className
|
2010 | // toggle whole className
|
1954 | this.className = this.className || classNames === false ? "" : jQuery.data( this, "__className__" ) || ""; |
2011 | this.className = this.className || classNames === false ? "" : jQuery.data( this, "__className__" ) || ""; |
1955 | }
|
2012 | }
|
1956 | }
|
2013 | }
|
1957 | }, function(name, fn){ |
2014 | }, function(name, fn){ |
1958 | jQuery.fn[ name ] = function(){ |
2015 | jQuery.fn[ name ] = function(){ |
1959 | return this.each( fn, arguments ); |
2016 | return this.each( fn, arguments ); |
1960 | }; |
2017 | }; |
1961 | }); |
2018 | }); |
1962 | 2019 | ||
1963 | jQuery.extend({ |
2020 | jQuery.extend({ |
1964 | className: { |
2021 | className: { |
1965 | // internal only, use addClass("class")
|
2022 | // internal only, use addClass("class")
|
1966 | add: function( elem, classNames ) { |
2023 | add: function( elem, classNames ) { |
1967 | jQuery.each((classNames || "").split(/\s+/), function(i, className){ |
2024 | jQuery.each((classNames || "").split(/\s+/), function(i, className){ |
1968 | if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) |
2025 | if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) |
1969 | elem.className += (elem.className ? " " : "") + className; |
2026 | elem.className += (elem.className ? " " : "") + className; |
1970 | }); |
2027 | }); |
1971 | }, |
2028 | }, |
1972 | 2029 | ||
1973 | // internal only, use removeClass("class")
|
2030 | // internal only, use removeClass("class")
|
1974 | remove: function( elem, classNames ) { |
2031 | remove: function( elem, classNames ) { |
1975 | if (elem.nodeType == 1) |
2032 | if (elem.nodeType == 1) |
1976 | elem.className = classNames !== undefined ? |
2033 | elem.className = classNames !== undefined ? |
1977 | jQuery.grep(elem.className.split(/\s+/), function(className){ |
2034 | jQuery.grep(elem.className.split(/\s+/), function(className){ |
1978 | return !jQuery.className.has( classNames, className ); |
2035 | return !jQuery.className.has( classNames, className ); |
1979 | }).join(" ") : |
2036 | }).join(" ") : |
1980 | ""; |
2037 | ""; |
1981 | }, |
2038 | }, |
1982 | 2039 | ||
1983 | // internal only, use hasClass("class")
|
2040 | // internal only, use hasClass("class")
|
1984 | has: function( elem, className ) { |
2041 | has: function( elem, className ) { |
1985 | return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; |
2042 | return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; |
1986 | }
|
2043 | }
|
1987 | }, |
2044 | }, |
1988 | 2045 | ||
1989 | attr: function( elem, name, value ) { |
2046 | attr: function( elem, name, value ) { |
1990 | // don't set attributes on text and comment nodes
|
2047 | // don't set attributes on text and comment nodes
|
1991 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
2048 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
1992 | return undefined; |
2049 | return undefined; |
1993 | 2050 | ||
1994 | var notxml = !elem.tagName || !jQuery.isXMLDoc( elem ), |
2051 | var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), |
1995 | // Whether we are setting (or getting)
|
2052 | // Whether we are setting (or getting)
|
1996 | set = value !== undefined; |
2053 | set = value !== undefined; |
1997 | 2054 | ||
1998 | // Try to normalize/fix the name
|
2055 | // Try to normalize/fix the name
|
1999 | name = notxml && jQuery.props[ name ] || name; |
2056 | name = notxml && jQuery.props[ name ] || name; |
2000 | 2057 | ||
2001 | // Only do all the following if this is a node (faster for style)
|
2058 | // Only do all the following if this is a node (faster for style)
|
2002 | if ( elem.tagName ) { |
2059 | if ( elem.nodeType === 1 ) { |
2003 | 2060 | ||
2004 | // These attributes require special treatment
|
2061 | // These attributes require special treatment
|
2005 | var special = /href|src|style/.test( name ); |
2062 | var special = /href|src|style/.test( name ); |
2006 | 2063 | ||
2007 | // Safari mis-reports the default selected property of a hidden option
|
2064 | // Safari mis-reports the default selected property of a hidden option
|
2008 | // Accessing the parent's selectedIndex property fixes it
|
2065 | // Accessing the parent's selectedIndex property fixes it
|
2009 | if ( name == "selected" && elem.parentNode ) |
2066 | if ( name == "selected" && elem.parentNode ) |
2010 | elem.parentNode.selectedIndex; |
2067 | elem.parentNode.selectedIndex; |
2011 | 2068 | ||
2012 | // If applicable, access the attribute via the DOM 0 way
|
2069 | // If applicable, access the attribute via the DOM 0 way
|
2013 | if ( name in elem && notxml && !special ) { |
2070 | if ( name in elem && notxml && !special ) { |
2014 | if ( set ){ |
2071 | if ( set ){ |
2015 | // We can't allow the type property to be changed (since it causes problems in IE)
|
2072 | // We can't allow the type property to be changed (since it causes problems in IE)
|
2016 | if ( name == "type" && elem.nodeName.match(/(button|input)/i) && elem.parentNode ) |
2073 | if ( name == "type" && /(button|input)/i.test(elem.nodeName) && elem.parentNode ) |
2017 | throw "type property can't be changed"; |
2074 | throw "type property can't be changed"; |
2018 | 2075 | ||
2019 | elem[ name ] = value; |
2076 | elem[ name ] = value; |
2020 | }
|
2077 | }
|
2021 | 2078 | ||
2022 | // browsers index elements by id/name on forms, give priority to attributes.
|
2079 | // browsers index elements by id/name on forms, give priority to attributes.
|
2023 | if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) |
2080 | if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) |
2024 | return elem.getAttributeNode( name ).nodeValue; |
2081 | return elem.getAttributeNode( name ).nodeValue; |
2025 | 2082 | ||
2026 | // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
2083 | // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
2027 | // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
2084 | // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
2028 | if ( name == "tabIndex" ) { |
2085 | if ( name == "tabIndex" ) { |
2029 | var attributeNode = elem.getAttributeNode( "tabIndex" ); |
2086 | var attributeNode = elem.getAttributeNode( "tabIndex" ); |
2030 | return attributeNode && attributeNode.specified |
2087 | return attributeNode && attributeNode.specified |
2031 | ? attributeNode.value |
2088 | ? attributeNode.value |
2032 | : elem.nodeName.match(/(button|input|object|select|textarea)/i) |
2089 | : /(button|input|object|select|textarea)/i.test(elem.nodeName) |
2033 | ? 0 |
2090 | ? 0 |
2034 | : elem.nodeName.match(/^(a|area)$/i) && elem.href |
2091 | : /^(a|area)$/i.test(elem.nodeName) && elem.href |
2035 | ? 0 |
2092 | ? 0 |
2036 | : undefined; |
2093 | : undefined; |
2037 | }
|
2094 | }
|
2038 | 2095 | ||
2039 | return elem[ name ]; |
2096 | return elem[ name ]; |
2040 | }
|
2097 | }
|
2041 | 2098 | ||
2042 | if ( !jQuery.support.style && notxml && name == "style" ) { |
2099 | if ( !jQuery.support.style && notxml && name == "style" ) { |
2043 | if ( set ) |
2100 | if ( set ) |
2044 | elem.style.cssText = "" + value; |
2101 | elem.style.cssText = "" + value; |
2045 | 2102 | ||
2046 | return elem.style.cssText; |
2103 | return elem.style.cssText; |
2047 | }
|
2104 | }
|
2048 | 2105 | ||
2049 | if ( set ) |
2106 | if ( set ) |
2050 | // convert the value to a string (all browsers do this but IE) see #1070
|
2107 | // convert the value to a string (all browsers do this but IE) see #1070
|
2051 | elem.setAttribute( name, "" + value ); |
2108 | elem.setAttribute( name, "" + value ); |
2052 | 2109 | ||
2053 | var attr = !jQuery.support.hrefNormalized && notxml && special |
2110 | var attr = !jQuery.support.hrefNormalized && notxml && special |
2054 | // Some attributes require a special call on IE
|
2111 | // Some attributes require a special call on IE
|
2055 | ? elem.getAttribute( name, 2 ) |
2112 | ? elem.getAttribute( name, 2 ) |
2056 | : elem.getAttribute( name ); |
2113 | : elem.getAttribute( name ); |
2057 | 2114 | ||
2058 | // Non-existent attributes return null, we normalize to undefined
|
2115 | // Non-existent attributes return null, we normalize to undefined
|
2059 | return attr === null ? undefined : attr; |
2116 | return attr === null ? undefined : attr; |
2060 | }
|
2117 | }
|
2061 | 2118 | ||
2062 | // elem is actually elem.style ... set the style
|
2119 | // elem is actually elem.style ... set the style
|
2063 | // Using attr for specific style information is now deprecated. Use style insead.
|
2120 | // Using attr for specific style information is now deprecated. Use style insead.
|
2064 | return jQuery.style(elem, name, value); |
2121 | return jQuery.style(elem, name, value); |
2065 | }
|
2122 | }
|
- | 2123 | }); |
|
- | 2124 | var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, |
|
- | 2125 | rleadingWhitespace = /^\s+/, |
|
- | 2126 | rsingleTag = /^<(\w+)\s*\/?>$/, |
|
- | 2127 | rxhtmlTag = /(<(\w+)[^>]*?)\/>/g, |
|
- | 2128 | rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i, |
|
- | 2129 | rinsideTable = /^<(thead|tbody|tfoot|colg|cap)/, |
|
- | 2130 | rtbody = /<tbody/i, |
|
- | 2131 | fcloseTag = function(all, front, tag){ |
|
- | 2132 | return rselfClosing.test(tag) ? |
|
- | 2133 | all :
|
|
- | 2134 | front + "></" + tag + ">"; |
|
- | 2135 | }; |
|
- | 2136 | ||
2066 | });jQuery.fn.extend({ |
2137 | jQuery.fn.extend({ |
2067 | text: function( text ) { |
2138 | text: function( text ) { |
2068 | if ( typeof text !== "object" && text != null ) |
2139 | if ( typeof text !== "object" && text !== undefined ) |
2069 | return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
2140 | return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
2070 | 2141 | ||
2071 | var ret = ""; |
2142 | var ret = ""; |
2072 | 2143 | ||
2073 | jQuery.each( text || this, function(){ |
2144 | jQuery.each( text || this, function(){ |
2074 | jQuery.each( this.childNodes, function(){ |
2145 | jQuery.each( this.childNodes, function(){ |
2075 | if ( this.nodeType != 8 ) |
2146 | if ( this.nodeType !== 8 ) { |
2076 | ret += this.nodeType != 1 ? |
2147 | ret += this.nodeType !== 1 ? |
2077 | this.nodeValue : |
2148 | this.nodeValue : |
2078 | jQuery.fn.text( [ this ] ); |
2149 | jQuery.fn.text( [ this ] ); |
- | 2150 | }
|
|
2079 | }); |
2151 | }); |
2080 | }); |
2152 | }); |
2081 | 2153 | ||
2082 | return ret; |
2154 | return ret; |
2083 | }, |
2155 | }, |
2084 | 2156 | ||
2085 | wrapAll: function( html ) { |
2157 | wrapAll: function( html ) { |
- | 2158 | if ( jQuery.isFunction( html ) ) { |
|
- | 2159 | return this.each(function() { |
|
- | 2160 | jQuery(this).wrapAll( html.apply(this, arguments) ); |
|
- | 2161 | }); |
|
- | 2162 | }
|
|
- | 2163 | ||
2086 | if ( this[0] ) { |
2164 | if ( this[0] ) { |
2087 | // The elements to wrap the target around
|
2165 | // The elements to wrap the target around
|
2088 | var wrap = jQuery( html, this[0].ownerDocument ).clone(); |
2166 | var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(); |
2089 | 2167 | ||
2090 | if ( this[0].parentNode ) |
2168 | if ( this[0].parentNode ) { |
2091 | wrap.insertBefore( this[0] ); |
2169 | wrap.insertBefore( this[0] ); |
- | 2170 | }
|
|
2092 | 2171 | ||
2093 | wrap.map(function(){ |
2172 | wrap.map(function(){ |
2094 | var elem = this; |
2173 | var elem = this; |
2095 | 2174 | ||
2096 | while ( elem.firstChild ) |
2175 | while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { |
2097 | elem = elem.firstChild; |
2176 | elem = elem.firstChild; |
- | 2177 | }
|
|
2098 | 2178 | ||
2099 | return elem; |
2179 | return elem; |
2100 | }).append(this); |
2180 | }).append(this); |
2101 | }
|
2181 | }
|
2102 | 2182 | ||
2103 | return this; |
2183 | return this; |
2104 | }, |
2184 | }, |
2105 | 2185 | ||
2106 | wrapInner: function( html ) { |
2186 | wrapInner: function( html ) { |
2107 | return this.each(function(){ |
2187 | return this.each(function(){ |
2108 | jQuery( this ).contents().wrapAll( html ); |
2188 | jQuery( this ).contents().wrapAll( html ); |
2109 | }); |
2189 | }); |
2110 | }, |
2190 | }, |
2111 | 2191 | ||
2112 | wrap: function( html ) { |
2192 | wrap: function( html ) { |
2113 | return this.each(function(){ |
2193 | return this.each(function(){ |
2114 | jQuery( this ).wrapAll( html ); |
2194 | jQuery( this ).wrapAll( html ); |
2115 | }); |
2195 | }); |
2116 | }, |
2196 | }, |
2117 | 2197 | ||
2118 | append: function() { |
2198 | append: function() { |
2119 | return this.domManip(arguments, true, function(elem){ |
2199 | return this.domManip(arguments, true, function(elem){ |
2120 | if (this.nodeType == 1) |
2200 | if ( this.nodeType === 1 ) { |
2121 | this.appendChild( elem ); |
2201 | this.appendChild( elem ); |
- | 2202 | }
|
|
2122 | }); |
2203 | }); |
2123 | }, |
2204 | }, |
2124 | 2205 | ||
2125 | prepend: function() { |
2206 | prepend: function() { |
2126 | return this.domManip(arguments, true, function(elem){ |
2207 | return this.domManip(arguments, true, function(elem){ |
2127 | if (this.nodeType == 1) |
2208 | if ( this.nodeType === 1 ) { |
2128 | this.insertBefore( elem, this.firstChild ); |
2209 | this.insertBefore( elem, this.firstChild ); |
- | 2210 | }
|
|
2129 | }); |
2211 | }); |
2130 | }, |
2212 | }, |
2131 | 2213 | ||
2132 | before: function() { |
2214 | before: function() { |
2133 | return this.domManip(arguments, false, function(elem){ |
2215 | return this.domManip(arguments, false, function(elem){ |
2134 | this.parentNode.insertBefore( elem, this ); |
2216 | this.parentNode.insertBefore( elem, this ); |
2135 | }); |
2217 | }); |
2136 | }, |
2218 | }, |
2137 | 2219 | ||
2138 | after: function() { |
2220 | after: function() { |
2139 | return this.domManip(arguments, false, function(elem){ |
2221 | return this.domManip(arguments, false, function(elem){ |
2140 | this.parentNode.insertBefore( elem, this.nextSibling ); |
2222 | this.parentNode.insertBefore( elem, this.nextSibling ); |
2141 | }); |
2223 | }); |
2142 | }, |
2224 | }, |
2143 | 2225 | ||
2144 | clone: function( events ) { |
2226 | clone: function( events ) { |
2145 | // Do the clone
|
2227 | // Do the clone
|
2146 | var ret = this.map(function(){ |
2228 | var ret = this.map(function(){ |
2147 | if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { |
2229 | if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { |
2148 | // IE copies events bound via attachEvent when
|
2230 | // IE copies events bound via attachEvent when
|
2149 | // using cloneNode. Calling detachEvent on the
|
2231 | // using cloneNode. Calling detachEvent on the
|
2150 | // clone will also remove the events from the orignal
|
2232 | // clone will also remove the events from the orignal
|
2151 | // In order to get around this, we use innerHTML.
|
2233 | // In order to get around this, we use innerHTML.
|
2152 | // Unfortunately, this means some modifications to
|
2234 | // Unfortunately, this means some modifications to
|
2153 | // attributes in IE that are actually only stored
|
2235 | // attributes in IE that are actually only stored
|
2154 | // as properties will not be copied (such as the
|
2236 | // as properties will not be copied (such as the
|
2155 | // the name attribute on an input).
|
2237 | // the name attribute on an input).
|
2156 | var html = this.outerHTML, ownerDocument = this.ownerDocument; |
2238 | var html = this.outerHTML, ownerDocument = this.ownerDocument; |
2157 | if ( !html ) { |
2239 | if ( !html ) { |
2158 | var div = ownerDocument.createElement("div"); |
2240 | var div = ownerDocument.createElement("div"); |
2159 | div.appendChild( this.cloneNode(true) ); |
2241 | div.appendChild( this.cloneNode(true) ); |
2160 | html = div.innerHTML; |
2242 | html = div.innerHTML; |
2161 | }
|
2243 | }
|
2162 | 2244 | ||
2163 | return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g, "").replace(/^\s*/, "")], ownerDocument)[0]; |
2245 | return jQuery.clean([html.replace(rinlinejQuery, "") |
- | 2246 | .replace(rleadingWhitespace, "")], ownerDocument)[0]; |
|
2164 | } else |
2247 | } else { |
2165 | return this.cloneNode(true); |
2248 | return this.cloneNode(true); |
- | 2249 | }
|
|
2166 | }); |
2250 | }); |
2167 | 2251 | ||
2168 | // Copy the events from the original to the clone
|
2252 | // Copy the events from the original to the clone
|
2169 | if ( events === true ) { |
2253 | if ( events === true ) { |
2170 | var orig = this.find("*").andSelf(), i = 0; |
2254 | var orig = this.find("*").andSelf(), i = 0; |
2171 | 2255 | ||
2172 | ret.find("*").andSelf().each(function(){ |
2256 | ret.find("*").andSelf().each(function(){ |
2173 | if ( this.nodeName !== orig[i].nodeName ) |
2257 | if ( this.nodeName !== orig[i].nodeName ) { return; } |
2174 | return; |
- | |
2175 | 2258 | ||
2176 | var events = jQuery.data( orig[i], "events" ); |
2259 | var events = jQuery.data( orig[i], "events" ); |
2177 | 2260 | ||
2178 | for ( var type in events ) { |
2261 | for ( var type in events ) { |
2179 | for ( var handler in events[ type ] ) { |
2262 | for ( var handler in events[ type ] ) { |
2180 | jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); |
2263 | jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); |
2181 | }
|
2264 | }
|
2182 | }
|
2265 | }
|
2183 | 2266 | ||
2184 | i++;
|
2267 | i++;
|
2185 | }); |
2268 | }); |
2186 | }
|
2269 | }
|
2187 | 2270 | ||
2188 | // Return the cloned set
|
2271 | // Return the cloned set
|
2189 | return ret; |
2272 | return ret; |
2190 | }, |
2273 | }, |
2191 | 2274 | ||
2192 | html: function( value ) { |
2275 | html: function( value ) { |
2193 | return value === undefined ? |
2276 | return value === undefined ? |
2194 | (this[0] ? |
2277 | (this[0] ? |
2195 | this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") : |
2278 | this[0].innerHTML.replace(rinlinejQuery, "") : |
2196 | null) : |
2279 | null) : |
2197 | this.empty().append( value ); |
2280 | this.empty().append( value ); |
2198 | }, |
2281 | }, |
2199 | 2282 | ||
2200 | replaceWith: function( value ) { |
2283 | replaceWith: function( value ) { |
2201 | return this.after( value ).remove(); |
2284 | return this.after( value ).remove(); |
2202 | }, |
2285 | }, |
2203 | 2286 | ||
- | 2287 | detach: function( selector ) { |
|
- | 2288 | return this.remove( selector, true ); |
|
- | 2289 | }, |
|
- | 2290 | ||
2204 | domManip: function( args, table, callback ) { |
2291 | domManip: function( args, table, callback ) { |
- | 2292 | var fragment, scripts, cacheable, cached, cacheresults, first, |
|
- | 2293 | value = args[0]; |
|
- | 2294 | ||
- | 2295 | if ( jQuery.isFunction(value) ) { |
|
- | 2296 | return this.each(function() { |
|
- | 2297 | args[0] = value.call(this); |
|
- | 2298 | return jQuery(this).domManip( args, table, callback ); |
|
- | 2299 | }); |
|
- | 2300 | }
|
|
- | 2301 | ||
2205 | if ( this[0] ) { |
2302 | if ( this[0] ) { |
2206 | var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(), |
2303 | if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) { |
- | 2304 | cacheable = true; |
|
2207 | scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ), |
2305 | cacheresults = jQuery.fragments[ args[0] ]; |
- | 2306 | if ( cacheresults ) { |
|
- | 2307 | if ( cacheresults !== 1 ) { |
|
2208 | first = fragment.firstChild; |
2308 | fragment = cacheresults; |
- | 2309 | }
|
|
- | 2310 | cached = true; |
|
- | 2311 | }
|
|
- | 2312 | }
|
|
2209 | 2313 | ||
2210 | if ( first ) |
2314 | if ( !fragment ) { |
2211 | for ( var i = 0, l = this.length; i < l; i++ ) |
2315 | fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(); |
2212 | callback.call( root(this[i], first), this.length > 1 || i > 0 ? |
2316 | scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ); |
- | 2317 | }
|
|
- | 2318 | ||
2213 | fragment.cloneNode(true) : fragment ); |
2319 | first = fragment.firstChild; |
2214 | 2320 | ||
- | 2321 | if ( first ) { |
|
- | 2322 | table = table && jQuery.nodeName( first, "tr" ); |
|
- | 2323 | ||
- | 2324 | for ( var i = 0, l = this.length; i < l; i++ ) { |
|
- | 2325 | callback.call( |
|
- | 2326 | table ?
|
|
- | 2327 | root(this[i], first) : |
|
- | 2328 | this[i], |
|
- | 2329 | cacheable || this.length > 1 || i > 0 ? |
|
- | 2330 | fragment.cloneNode(true) : |
|
- | 2331 | fragment |
|
- | 2332 | ); |
|
- | 2333 | }
|
|
- | 2334 | }
|
|
- | 2335 | ||
2215 | if ( scripts ) |
2336 | if ( scripts ) { |
2216 | jQuery.each( scripts, evalScript ); |
2337 | jQuery.each( scripts, evalScript ); |
- | 2338 | }
|
|
- | 2339 | ||
- | 2340 | if ( cacheable ) { |
|
- | 2341 | jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1; |
|
- | 2342 | }
|
|
2217 | }
|
2343 | }
|
2218 | 2344 | ||
2219 | return this; |
2345 | return this; |
2220 | 2346 | ||
2221 | function root( elem, cur ) { |
2347 | function root( elem, cur ) { |
2222 | return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ? |
2348 | return jQuery.nodeName(elem, "table") ? |
2223 | (elem.getElementsByTagName("tbody")[0] || |
2349 | (elem.getElementsByTagName("tbody")[0] || |
2224 | elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
2350 | elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
2225 | elem;
|
2351 | elem;
|
2226 | }
|
2352 | }
|
2227 | }
|
2353 | }
|
2228 | }); |
2354 | }); |
2229 | 2355 | ||
- | 2356 | jQuery.fragments = {}; |
|
- | 2357 | ||
2230 | jQuery.each({ |
2358 | jQuery.each({ |
2231 | appendTo: "append", |
2359 | appendTo: "append", |
2232 | prependTo: "prepend", |
2360 | prependTo: "prepend", |
2233 | insertBefore: "before", |
2361 | insertBefore: "before", |
2234 | insertAfter: "after", |
2362 | insertAfter: "after", |
2235 | replaceAll: "replaceWith" |
2363 | replaceAll: "replaceWith" |
2236 | }, function(name, original){ |
2364 | }, function(name, original){ |
2237 | jQuery.fn[ name ] = function( selector ) { |
2365 | jQuery.fn[ name ] = function( selector ) { |
2238 | var ret = [], insert = jQuery( selector ); |
2366 | var ret = [], insert = jQuery( selector ); |
2239 | 2367 | ||
2240 | for ( var i = 0, l = insert.length; i < l; i++ ) { |
2368 | for ( var i = 0, l = insert.length; i < l; i++ ) { |
2241 | var elems = (i > 0 ? this.clone(true) : this).get(); |
2369 | var elems = (i > 0 ? this.clone(true) : this).get(); |
2242 | jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); |
2370 | jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); |
2243 | ret = ret.concat( elems ); |
2371 | ret = ret.concat( elems ); |
2244 | }
|
2372 | }
|
2245 | 2373 | ||
2246 | return this.pushStack( ret, name, selector ); |
2374 | return this.pushStack( ret, name, selector ); |
2247 | }; |
2375 | }; |
2248 | }); |
2376 | }); |
2249 | 2377 | ||
2250 | jQuery.each({ |
2378 | jQuery.each({ |
- | 2379 | // keepData is for internal use only--do not document
|
|
2251 | remove: function( selector ) { |
2380 | remove: function( selector, keepData ) { |
2252 | if ( !selector || jQuery.multiFilter( selector, [ this ] ).length ) { |
2381 | if ( !selector || jQuery.multiFilter( selector, [ this ] ).length ) { |
2253 | if ( this.nodeType === 1 ) { |
2382 | if ( !keepData && this.nodeType === 1 ) { |
2254 | cleanData( jQuery("*", this).add(this) ); |
2383 | cleanData( jQuery("*", this).add(this) ); |
2255 | }
|
2384 | }
|
2256 | 2385 | ||
2257 | if ( this.parentNode ) { |
2386 | if ( this.parentNode ) { |
2258 | this.parentNode.removeChild( this ); |
2387 | this.parentNode.removeChild( this ); |
2259 | }
|
2388 | }
|
2260 | }
|
2389 | }
|
2261 | }, |
2390 | }, |
2262 | 2391 | ||
2263 | empty: function() { |
2392 | empty: function() { |
2264 | // Remove element nodes and prevent memory leaks
|
2393 | // Remove element nodes and prevent memory leaks
|
2265 | if ( this.nodeType === 1 ) { |
2394 | if ( this.nodeType === 1 ) { |
2266 | cleanData( jQuery("*", this) ); |
2395 | cleanData( jQuery("*", this) ); |
2267 | }
|
2396 | }
|
2268 | 2397 | ||
2269 | // Remove any remaining nodes
|
2398 | // Remove any remaining nodes
|
2270 | while ( this.firstChild ) { |
2399 | while ( this.firstChild ) { |
2271 | this.removeChild( this.firstChild ); |
2400 | this.removeChild( this.firstChild ); |
2272 | }
|
2401 | }
|
2273 | }
|
2402 | }
|
2274 | }, function(name, fn){ |
2403 | }, function(name, fn){ |
2275 | jQuery.fn[ name ] = function(){ |
2404 | jQuery.fn[ name ] = function(){ |
2276 | return this.each( fn, arguments ); |
2405 | return this.each( fn, arguments ); |
2277 | }; |
2406 | }; |
2278 | }); |
2407 | }); |
2279 | 2408 | ||
2280 | jQuery.extend({ |
2409 | jQuery.extend({ |
2281 | clean: function( elems, context, fragment ) { |
2410 | clean: function( elems, context, fragment ) { |
2282 | context = context || document; |
2411 | context = context || document; |
2283 | 2412 | ||
2284 | // !context.createElement fails in IE with an error but returns typeof 'object'
|
2413 | // !context.createElement fails in IE with an error but returns typeof 'object'
|
2285 | if ( typeof context.createElement === "undefined" ) |
2414 | if ( typeof context.createElement === "undefined" ) { |
2286 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
2415 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
- | 2416 | }
|
|
2287 | 2417 | ||
2288 | // If a single string is passed in and it's a single tag
|
2418 | // If a single string is passed in and it's a single tag
|
2289 | // just do a createElement and skip the rest
|
2419 | // just do a createElement and skip the rest
|
2290 | if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) { |
2420 | if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) { |
2291 | var match = /^<(\w+)\s*\/?>$/.exec(elems[0]); |
2421 | var match = rsingleTag.exec(elems[0]); |
2292 | if ( match ) |
2422 | if ( match ) { |
2293 | return [ context.createElement( match[1] ) ]; |
2423 | return [ context.createElement( match[1] ) ]; |
- | 2424 | }
|
|
2294 | }
|
2425 | }
|
2295 | 2426 | ||
2296 | var ret = [], scripts = [], div = context.createElement("div"); |
2427 | var ret = [], scripts = [], div = context.createElement("div"); |
2297 | 2428 | ||
2298 | jQuery.each(elems, function(i, elem){ |
2429 | jQuery.each(elems, function(i, elem){ |
2299 | if ( typeof elem === "number" ) |
2430 | if ( typeof elem === "number" ) { |
2300 | elem += ''; |
2431 | elem += ''; |
- | 2432 | }
|
|
2301 | 2433 | ||
2302 | if ( !elem ) |
2434 | if ( !elem ) { return; } |
2303 | return; |
- | |
2304 | 2435 | ||
2305 | // Convert html string into DOM nodes
|
2436 | // Convert html string into DOM nodes
|
2306 | if ( typeof elem === "string" ) { |
2437 | if ( typeof elem === "string" ) { |
2307 | // Fix "XHTML"-style tags in all browsers
|
2438 | // Fix "XHTML"-style tags in all browsers
|
2308 | elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ |
2439 | elem = elem.replace(rxhtmlTag, fcloseTag); |
2309 | return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? |
- | |
2310 | all :
|
- | |
2311 | front + "></" + tag + ">"; |
- | |
2312 | }); |
- | |
2313 | 2440 | ||
2314 | // Trim whitespace, otherwise indexOf won't work as expected
|
2441 | // Trim whitespace, otherwise indexOf won't work as expected
|
2315 | var tags = elem.replace(/^\s+/, "").substring(0, 10).toLowerCase(); |
2442 | var tags = elem.replace(rleadingWhitespace, "") |
- | 2443 | .substring(0, 10).toLowerCase(); |
|
2316 | 2444 | ||
2317 | var wrap = |
2445 | var wrap = |
2318 | // option or optgroup
|
2446 | // option or optgroup
|
2319 | !tags.indexOf("<opt") && |
2447 | !tags.indexOf("<opt") && |
2320 | [ 1, "<select multiple='multiple'>", "</select>" ] || |
2448 | [ 1, "<select multiple='multiple'>", "</select>" ] || |
2321 | 2449 | ||
2322 | !tags.indexOf("<leg") && |
2450 | !tags.indexOf("<leg") && |
2323 | [ 1, "<fieldset>", "</fieldset>" ] || |
2451 | [ 1, "<fieldset>", "</fieldset>" ] || |
2324 | 2452 | ||
2325 | tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && |
2453 | rinsideTable.test(tags) && |
2326 | [ 1, "<table>", "</table>" ] || |
2454 | [ 1, "<table>", "</table>" ] || |
2327 | 2455 | ||
2328 | !tags.indexOf("<tr") && |
2456 | !tags.indexOf("<tr") && |
2329 | [ 2, "<table><tbody>", "</tbody></table>" ] || |
2457 | [ 2, "<table><tbody>", "</tbody></table>" ] || |
2330 | 2458 | ||
2331 | // <thead> matched above
|
2459 | // <thead> matched above
|
2332 | (!tags.indexOf("<td") || !tags.indexOf("<th")) && |
2460 | (!tags.indexOf("<td") || !tags.indexOf("<th")) && |
2333 | [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] || |
2461 | [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] || |
2334 | 2462 | ||
2335 | !tags.indexOf("<col") && |
2463 | !tags.indexOf("<col") && |
2336 | [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] || |
2464 | [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] || |
2337 | 2465 | ||
2338 | // IE can't serialize <link> and <script> tags normally
|
2466 | // IE can't serialize <link> and <script> tags normally
|
2339 | !jQuery.support.htmlSerialize && |
2467 | !jQuery.support.htmlSerialize && |
2340 | [ 1, "div<div>", "</div>" ] || |
2468 | [ 1, "div<div>", "</div>" ] || |
2341 | 2469 | ||
2342 | [ 0, "", "" ]; |
2470 | [ 0, "", "" ]; |
2343 | 2471 | ||
2344 | // Go to html and back, then peel off extra wrappers
|
2472 | // Go to html and back, then peel off extra wrappers
|
2345 | div.innerHTML = wrap[1] + elem + wrap[2]; |
2473 | div.innerHTML = wrap[1] + elem + wrap[2]; |
2346 | 2474 | ||
2347 | // Move to the right depth
|
2475 | // Move to the right depth
|
2348 | while ( wrap[0]-- ) |
2476 | while ( wrap[0]-- ) { |
2349 | div = div.lastChild; |
2477 | div = div.lastChild; |
- | 2478 | }
|
|
2350 | 2479 | ||
2351 | // Remove IE's autoinserted <tbody> from table fragments
|
2480 | // Remove IE's autoinserted <tbody> from table fragments
|
2352 | if ( !jQuery.support.tbody ) { |
2481 | if ( !jQuery.support.tbody ) { |
2353 | 2482 | ||
2354 | // String was a <table>, *may* have spurious <tbody>
|
2483 | // String was a <table>, *may* have spurious <tbody>
|
2355 | var hasBody = /<tbody/i.test(elem), |
2484 | var hasBody = rtbody.test(elem), |
2356 | tbody = !tags.indexOf("<table") && !hasBody ? |
2485 | tbody = !tags.indexOf("<table") && !hasBody ? |
2357 | div.firstChild && div.firstChild.childNodes : |
2486 | div.firstChild && div.firstChild.childNodes : |
2358 | 2487 | ||
2359 | // String was a bare <thead> or <tfoot>
|
2488 | // String was a bare <thead> or <tfoot>
|
2360 | wrap[1] == "<table>" && !hasBody ? |
2489 | wrap[1] == "<table>" && !hasBody ? |
2361 | div.childNodes : |
2490 | div.childNodes : |
2362 | []; |
2491 | []; |
2363 | 2492 | ||
2364 | for ( var j = tbody.length - 1; j >= 0 ; --j ) |
2493 | for ( var j = tbody.length - 1; j >= 0 ; --j ) { |
2365 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) |
2494 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
2366 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
2495 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
2367 | 2496 | }
|
|
2368 | }
|
2497 | }
|
2369 | 2498 | ||
- | 2499 | }
|
|
- | 2500 | ||
2370 | // IE completely kills leading whitespace when innerHTML is used
|
2501 | // IE completely kills leading whitespace when innerHTML is used
|
2371 | if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) ) |
2502 | if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
2372 | div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild ); |
2503 | div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
- | 2504 | }
|
|
2373 | 2505 | ||
2374 | elem = jQuery.makeArray( div.childNodes ); |
2506 | elem = jQuery.makeArray( div.childNodes ); |
2375 | }
|
2507 | }
|
2376 | 2508 | ||
2377 | if ( elem.nodeType ) |
2509 | if ( elem.nodeType ) { |
2378 | ret.push( elem ); |
2510 | ret.push( elem ); |
2379 | else
|
2511 | } else { |
2380 | ret = jQuery.merge( ret, elem ); |
2512 | ret = jQuery.merge( ret, elem ); |
- | 2513 | }
|
|
2381 | 2514 | ||
2382 | }); |
2515 | }); |
2383 | 2516 | ||
2384 | if ( fragment ) { |
2517 | if ( fragment ) { |
2385 | for ( var i = 0; ret[i]; i++ ) { |
2518 | for ( var i = 0; ret[i]; i++ ) { |
2386 | if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
2519 | if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
2387 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
2520 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
2388 | } else { |
2521 | } else { |
2389 | if ( ret[i].nodeType === 1 ) |
2522 | if ( ret[i].nodeType === 1 ) { |
2390 | ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
2523 | ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
- | 2524 | }
|
|
2391 | fragment.appendChild( ret[i] ); |
2525 | fragment.appendChild( ret[i] ); |
2392 | }
|
2526 | }
|
2393 | }
|
2527 | }
|
2394 | 2528 | ||
2395 | return scripts; |
2529 | return scripts; |
2396 | }
|
2530 | }
|
2397 | 2531 | ||
2398 | return ret; |
2532 | return ret; |
2399 | }
|
2533 | }
|
2400 | }); |
2534 | }); |
2401 | 2535 | ||
2402 | function cleanData( elems ) { |
2536 | function cleanData( elems ) { |
2403 | for ( var i = 0, l = elems.length; i < l; i++ ) { |
2537 | for ( var i = 0, l = elems.length; i < l; i++ ) { |
2404 | var id = elems[i][expando]; |
2538 | var id = elems[i][expando]; |
2405 | if ( id ) { |
2539 | if ( id ) { |
2406 | delete jQuery.cache[ id ]; |
2540 | delete jQuery.cache[ id ]; |
2407 | }
|
2541 | }
|
2408 | }
|
2542 | }
|
2409 | }
|
2543 | }
|
2410 | /*
|
2544 | /*
|
2411 | * A number of helper functions used for managing events.
|
2545 | * A number of helper functions used for managing events.
|
2412 | * Many of the ideas behind this code originated from
|
2546 | * Many of the ideas behind this code originated from
|
2413 | * Dean Edwards' addEvent library.
|
2547 | * Dean Edwards' addEvent library.
|
2414 | */
|
2548 | */
|
2415 | jQuery.event = { |
2549 | jQuery.event = { |
2416 | 2550 | ||
2417 | // Bind an event to an element
|
2551 | // Bind an event to an element
|
2418 | // Original by Dean Edwards
|
2552 | // Original by Dean Edwards
|
2419 | add: function( elem, types, handler, data ) { |
2553 | add: function( elem, types, handler, data ) { |
2420 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
2554 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
2421 | return; |
2555 | return; |
2422 | }
|
2556 | }
|
2423 | 2557 | ||
2424 | // For whatever reason, IE has trouble passing the window object
|
2558 | // For whatever reason, IE has trouble passing the window object
|
2425 | // around, causing it to be cloned in the process
|
2559 | // around, causing it to be cloned in the process
|
2426 | if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) { |
2560 | if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) { |
2427 | elem = window; |
2561 | elem = window; |
2428 | }
|
2562 | }
|
2429 | 2563 | ||
2430 | // Make sure that the function being executed has a unique ID
|
2564 | // Make sure that the function being executed has a unique ID
|
2431 | if ( !handler.guid ) { |
2565 | if ( !handler.guid ) { |
2432 | handler.guid = this.guid++; |
2566 | handler.guid = this.guid++; |
2433 | }
|
2567 | }
|
2434 | 2568 | ||
2435 | // if data is passed, bind to handler
|
2569 | // if data is passed, bind to handler
|
2436 | if ( data !== undefined ) { |
2570 | if ( data !== undefined ) { |
2437 | // Create temporary function pointer to original handler
|
2571 | // Create temporary function pointer to original handler
|
2438 | var fn = handler; |
2572 | var fn = handler; |
2439 | 2573 | ||
2440 | // Create unique handler function, wrapped around original handler
|
2574 | // Create unique handler function, wrapped around original handler
|
2441 | handler = this.proxy( fn ); |
2575 | handler = this.proxy( fn ); |
2442 | 2576 | ||
2443 | // Store data in unique handler
|
2577 | // Store data in unique handler
|
2444 | handler.data = data; |
2578 | handler.data = data; |
2445 | }
|
2579 | }
|
2446 | 2580 | ||
2447 | // Init the element's event structure
|
2581 | // Init the element's event structure
|
2448 | var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ), |
2582 | var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ), |
2449 | handle = jQuery.data( elem, "handle" ) || jQuery.data( elem, "handle", function() { |
2583 | handle = jQuery.data( elem, "handle" ) || jQuery.data( elem, "handle", function() { |
2450 | // Handle the second event of a trigger and when
|
2584 | // Handle the second event of a trigger and when
|
2451 | // an event is called after a page has unloaded
|
2585 | // an event is called after a page has unloaded
|
2452 | return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
2586 | return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
2453 | jQuery.event.handle.apply( arguments.callee.elem, arguments ) : |
2587 | jQuery.event.handle.apply( arguments.callee.elem, arguments ) : |
2454 | undefined; |
2588 | undefined; |
2455 | }); |
2589 | }); |
2456 | // Add elem as a property of the handle function
|
2590 | // Add elem as a property of the handle function
|
2457 | // This is to prevent a memory leak with non-native
|
2591 | // This is to prevent a memory leak with non-native
|
2458 | // event in IE.
|
2592 | // event in IE.
|
2459 | handle.elem = elem; |
2593 | handle.elem = elem; |
2460 | 2594 | ||
2461 | // Handle multiple events separated by a space
|
2595 | // Handle multiple events separated by a space
|
2462 | // jQuery(...).bind("mouseover mouseout", fn);
|
2596 | // jQuery(...).bind("mouseover mouseout", fn);
|
2463 | types = types.split( /\s+/ ); |
2597 | types = types.split( /\s+/ ); |
2464 | var type, i=0; |
2598 | var type, i=0; |
2465 | while ( (type = types[ i++ ]) ) { |
2599 | while ( (type = types[ i++ ]) ) { |
2466 | // Namespaced event handlers
|
2600 | // Namespaced event handlers
|
2467 | var namespaces = type.split("."); |
2601 | var namespaces = type.split("."); |
2468 | type = namespaces.shift(); |
2602 | type = namespaces.shift(); |
2469 | handler.type = namespaces.slice().sort().join("."); |
2603 | handler.type = namespaces.slice(0).sort().join("."); |
2470 | 2604 | ||
2471 | // Get the current list of functions bound to this event
|
2605 | // Get the current list of functions bound to this event
|
2472 | var handlers = events[ type ], |
2606 | var handlers = events[ type ], |
2473 | special = this.special[ type ] || {}; |
2607 | special = this.special[ type ] || {}; |
2474 | 2608 | ||
2475 | if ( special.add ) { |
2609 | if ( special.add ) { |
2476 | var modifiedHandler = special.add.call( elem, handler, data, namespaces ); |
2610 | var modifiedHandler = special.add.call( elem, handler, data, namespaces ); |
2477 | if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) { |
2611 | if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) { |
2478 | modifiedHandler.guid = modifiedHandler.guid || handler.guid; |
2612 | modifiedHandler.guid = modifiedHandler.guid || handler.guid; |
2479 | handler = modifiedHandler; |
2613 | handler = modifiedHandler; |
2480 | }
|
2614 | }
|
2481 | }
|
2615 | }
|
2482 | 2616 | ||
2483 | // Init the event handler queue
|
2617 | // Init the event handler queue
|
2484 | if ( !handlers ) { |
2618 | if ( !handlers ) { |
2485 | handlers = events[ type ] = {}; |
2619 | handlers = events[ type ] = {}; |
2486 | 2620 | ||
2487 | // Check for a special event handler
|
2621 | // Check for a special event handler
|
2488 | // Only use addEventListener/attachEvent if the special
|
2622 | // Only use addEventListener/attachEvent if the special
|
2489 | // events handler returns false
|
2623 | // events handler returns false
|
2490 | if ( !special.setup || special.setup.call( elem, data, namespaces ) === false ) { |
2624 | if ( !special.setup || special.setup.call( elem, data, namespaces ) === false ) { |
2491 | // Bind the global event handler to the element
|
2625 | // Bind the global event handler to the element
|
2492 | if ( elem.addEventListener ) { |
2626 | if ( elem.addEventListener ) { |
2493 | elem.addEventListener( type, handle, false ); |
2627 | elem.addEventListener( type, handle, false ); |
2494 | } else if ( elem.attachEvent ) { |
2628 | } else if ( elem.attachEvent ) { |
2495 | elem.attachEvent( "on" + type, handle ); |
2629 | elem.attachEvent( "on" + type, handle ); |
2496 | }
|
2630 | }
|
2497 | }
|
2631 | }
|
2498 | }
|
2632 | }
|
2499 | 2633 | ||
2500 | // Add the function to the element's handler list
|
2634 | // Add the function to the element's handler list
|
2501 | handlers[ handler.guid ] = handler; |
2635 | handlers[ handler.guid ] = handler; |
2502 | 2636 | ||
2503 | // Keep track of which events have been used, for global triggering
|
2637 | // Keep track of which events have been used, for global triggering
|
2504 | this.global[ type ] = true; |
2638 | this.global[ type ] = true; |
2505 | }
|
2639 | }
|
2506 | 2640 | ||
2507 | // Nullify elem to prevent memory leaks in IE
|
2641 | // Nullify elem to prevent memory leaks in IE
|
2508 | elem = null; |
2642 | elem = null; |
2509 | }, |
2643 | }, |
2510 | 2644 | ||
2511 | guid: 1, |
2645 | guid: 1, |
2512 | global: {}, |
2646 | global: {}, |
2513 | 2647 | ||
2514 | // Detach an event or set of events from an element
|
2648 | // Detach an event or set of events from an element
|
2515 | remove: function( elem, types, handler ) { |
2649 | remove: function( elem, types, handler ) { |
2516 | // don't do events on text and comment nodes
|
2650 | // don't do events on text and comment nodes
|
2517 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
2651 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
2518 | return; |
2652 | return; |
2519 | }
|
2653 | }
|
2520 | 2654 | ||
2521 | var events = jQuery.data( elem, "events" ), ret, type; |
2655 | var events = jQuery.data( elem, "events" ), ret, type; |
2522 | 2656 | ||
2523 | if ( events ) { |
2657 | if ( events ) { |
2524 | // Unbind all events for the element
|
2658 | // Unbind all events for the element
|
2525 | if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) { |
2659 | if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) { |
2526 | for ( type in events ) { |
2660 | for ( type in events ) { |
2527 | this.remove( elem, type + (types || "") ); |
2661 | this.remove( elem, type + (types || "") ); |
2528 | }
|
2662 | }
|
2529 | } else { |
2663 | } else { |
2530 | // types is actually an event object here
|
2664 | // types is actually an event object here
|
2531 | if ( types.type ) { |
2665 | if ( types.type ) { |
2532 | handler = types.handler; |
2666 | handler = types.handler; |
2533 | types = types.type; |
2667 | types = types.type; |
2534 | }
|
2668 | }
|
2535 | 2669 | ||
2536 | // Handle multiple events seperated by a space
|
2670 | // Handle multiple events seperated by a space
|
2537 | // jQuery(...).unbind("mouseover mouseout", fn);
|
2671 | // jQuery(...).unbind("mouseover mouseout", fn);
|
2538 | types = types.split(/\s+/); |
2672 | types = types.split(/\s+/); |
2539 | var i = 0; |
2673 | var i = 0; |
2540 | while ( (type = types[ i++ ]) ) { |
2674 | while ( (type = types[ i++ ]) ) { |
2541 | // Namespaced event handlers
|
2675 | // Namespaced event handlers
|
2542 | var namespaces = type.split("."); |
2676 | var namespaces = type.split("."); |
2543 | type = namespaces.shift(); |
2677 | type = namespaces.shift(); |
2544 | var all = !namespaces.length, |
2678 | var all = !namespaces.length, |
2545 | namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"), |
2679 | namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"), |
2546 | special = this.special[ type ] || {}; |
2680 | special = this.special[ type ] || {}; |
2547 | 2681 | ||
2548 | if ( events[ type ] ) { |
2682 | if ( events[ type ] ) { |
2549 | // remove the given handler for the given type
|
2683 | // remove the given handler for the given type
|
2550 | if ( handler ) { |
2684 | if ( handler ) { |
2551 | delete events[ type ][ handler.guid ]; |
2685 | delete events[ type ][ handler.guid ]; |
2552 | 2686 | ||
2553 | // remove all handlers for the given type
|
2687 | // remove all handlers for the given type
|
2554 | } else { |
2688 | } else { |
2555 | for ( var handle in events[ type ] ) { |
2689 | for ( var handle in events[ type ] ) { |
2556 | // Handle the removal of namespaced events
|
2690 | // Handle the removal of namespaced events
|
2557 | if ( all || namespace.test( events[ type ][ handle ].type ) ) { |
2691 | if ( all || namespace.test( events[ type ][ handle ].type ) ) { |
2558 | delete events[ type ][ handle ]; |
2692 | delete events[ type ][ handle ]; |
2559 | }
|
2693 | }
|
2560 | }
|
2694 | }
|
2561 | }
|
2695 | }
|
2562 | 2696 | ||
2563 | if ( special.remove ) { |
2697 | if ( special.remove ) { |
2564 | special.remove.call( elem, namespaces ); |
2698 | special.remove.call( elem, namespaces ); |
2565 | }
|
2699 | }
|
2566 | 2700 | ||
2567 | // remove generic event handler if no more handlers exist
|
2701 | // remove generic event handler if no more handlers exist
|
2568 | for ( ret in events[ type ] ) { |
2702 | for ( ret in events[ type ] ) { |
2569 | break; |
2703 | break; |
2570 | }
|
2704 | }
|
2571 | if ( !ret ) { |
2705 | if ( !ret ) { |
2572 | if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { |
2706 | if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { |
2573 | if ( elem.removeEventListener ) { |
2707 | if ( elem.removeEventListener ) { |
2574 | elem.removeEventListener( type, jQuery.data( elem, "handle" ), false ); |
2708 | elem.removeEventListener( type, jQuery.data( elem, "handle" ), false ); |
2575 | } else if ( elem.detachEvent ) { |
2709 | } else if ( elem.detachEvent ) { |
2576 | elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) ); |
2710 | elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) ); |
2577 | }
|
2711 | }
|
2578 | }
|
2712 | }
|
2579 | ret = null; |
2713 | ret = null; |
2580 | delete events[ type ]; |
2714 | delete events[ type ]; |
2581 | }
|
2715 | }
|
2582 | }
|
2716 | }
|
2583 | }
|
2717 | }
|
2584 | }
|
2718 | }
|
2585 | 2719 | ||
2586 | // Remove the expando if it's no longer used
|
2720 | // Remove the expando if it's no longer used
|
2587 | for ( ret in events ) { |
2721 | for ( ret in events ) { |
2588 | break; |
2722 | break; |
2589 | }
|
2723 | }
|
2590 | if ( !ret ) { |
2724 | if ( !ret ) { |
2591 | var handle = jQuery.data( elem, "handle" ); |
2725 | var handle = jQuery.data( elem, "handle" ); |
2592 | if ( handle ) { |
2726 | if ( handle ) { |
2593 | handle.elem = null; |
2727 | handle.elem = null; |
2594 | }
|
2728 | }
|
2595 | jQuery.removeData( elem, "events" ); |
2729 | jQuery.removeData( elem, "events" ); |
2596 | jQuery.removeData( elem, "handle" ); |
2730 | jQuery.removeData( elem, "handle" ); |
2597 | }
|
2731 | }
|
2598 | }
|
2732 | }
|
2599 | }, |
2733 | }, |
2600 | 2734 | ||
2601 | // bubbling is internal
|
2735 | // bubbling is internal
|
2602 | trigger: function( event, data, elem /*, bubbling */ ) { |
2736 | trigger: function( event, data, elem /*, bubbling */ ) { |
2603 | // Event object or event type
|
2737 | // Event object or event type
|
2604 | var type = event.type || event, |
2738 | var type = event.type || event, |
2605 | bubbling = arguments[3]; |
2739 | bubbling = arguments[3]; |
2606 | 2740 | ||
2607 | if ( !bubbling ) { |
2741 | if ( !bubbling ) { |
2608 | event = typeof event === "object" ? |
2742 | event = typeof event === "object" ? |
2609 | // jQuery.Event object
|
2743 | // jQuery.Event object
|
2610 | event[expando] ? event : |
2744 | event[expando] ? event : |
2611 | // Object literal
|
2745 | // Object literal
|
2612 | jQuery.extend( jQuery.Event(type), event ) : |
2746 | jQuery.extend( jQuery.Event(type), event ) : |
2613 | // Just the event type (string)
|
2747 | // Just the event type (string)
|
2614 | jQuery.Event(type); |
2748 | jQuery.Event(type); |
2615 | 2749 | ||
2616 | if ( type.indexOf("!") >= 0 ) { |
2750 | if ( type.indexOf("!") >= 0 ) { |
2617 | event.type = type = type.slice(0, -1); |
2751 | event.type = type = type.slice(0, -1); |
2618 | event.exclusive = true; |
2752 | event.exclusive = true; |
2619 | }
|
2753 | }
|
2620 | 2754 | ||
2621 | // Handle a global trigger
|
2755 | // Handle a global trigger
|
2622 | if ( !elem ) { |
2756 | if ( !elem ) { |
2623 | // Don't bubble custom events when global (to avoid too much overhead)
|
2757 | // Don't bubble custom events when global (to avoid too much overhead)
|
2624 | event.stopPropagation(); |
2758 | event.stopPropagation(); |
2625 | // Only trigger if we've ever bound an event for it
|
2759 | // Only trigger if we've ever bound an event for it
|
2626 | if ( this.global[ type ] ) { |
2760 | if ( this.global[ type ] ) { |
2627 | jQuery.each( jQuery.cache, function() { |
2761 | jQuery.each( jQuery.cache, function() { |
2628 | if ( this.events && this.events[type] ) { |
2762 | if ( this.events && this.events[type] ) { |
2629 | jQuery.event.trigger( event, data, this.handle.elem ); |
2763 | jQuery.event.trigger( event, data, this.handle.elem ); |
2630 | }
|
2764 | }
|
2631 | }); |
2765 | }); |
2632 | }
|
2766 | }
|
2633 | }
|
2767 | }
|
2634 | 2768 | ||
2635 | // Handle triggering a single element
|
2769 | // Handle triggering a single element
|
2636 | 2770 | ||
2637 | // don't do events on text and comment nodes
|
2771 | // don't do events on text and comment nodes
|
2638 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
2772 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
2639 | return undefined; |
2773 | return undefined; |
2640 | }
|
2774 | }
|
2641 | 2775 | ||
2642 | // Clean up in case it is reused
|
2776 | // Clean up in case it is reused
|
2643 | event.result = undefined; |
2777 | event.result = undefined; |
2644 | event.target = elem; |
2778 | event.target = elem; |
2645 | 2779 | ||
2646 | // Clone the incoming data, if any
|
2780 | // Clone the incoming data, if any
|
2647 | data = jQuery.makeArray( data ); |
2781 | data = jQuery.makeArray( data ); |
2648 | data.unshift( event ); |
2782 | data.unshift( event ); |
2649 | }
|
2783 | }
|
2650 | 2784 | ||
2651 | event.currentTarget = elem; |
2785 | event.currentTarget = elem; |
2652 | 2786 | ||
2653 | // Trigger the event, it is assumed that "handle" is a function
|
2787 | // Trigger the event, it is assumed that "handle" is a function
|
2654 | var handle = jQuery.data( elem, "handle" ); |
2788 | var handle = jQuery.data( elem, "handle" ); |
2655 | if ( handle ) { |
2789 | if ( handle ) { |
2656 | handle.apply( elem, data ); |
2790 | handle.apply( elem, data ); |
2657 | }
|
2791 | }
|
2658 | 2792 | ||
2659 | var nativeFn, nativeHandler; |
2793 | var nativeFn, nativeHandler; |
2660 | try { |
2794 | try { |
2661 | nativeFn = elem[ type ]; |
2795 | nativeFn = elem[ type ]; |
2662 | nativeHandler = elem[ "on" + type ]; |
2796 | nativeHandler = elem[ "on" + type ]; |
2663 | // prevent IE from throwing an error for some elements with some event types, see #3533
|
2797 | // prevent IE from throwing an error for some elements with some event types, see #3533
|
2664 | } catch (e) {} |
2798 | } catch (e) {} |
2665 | // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
|
2799 | // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
|
2666 | if ( (!nativeFn || (jQuery.nodeName(elem, 'a') && type === "click")) && nativeHandler && nativeHandler.apply( elem, data ) === false ) { |
2800 | if ( (!nativeFn || (jQuery.nodeName(elem, 'a') && type === "click")) && nativeHandler && nativeHandler.apply( elem, data ) === false ) { |
2667 | event.result = false; |
2801 | event.result = false; |
2668 | }
|
2802 | }
|
2669 | 2803 | ||
2670 | // Trigger the native events (except for clicks on links)
|
2804 | // Trigger the native events (except for clicks on links)
|
2671 | if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type === "click") ) { |
2805 | if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type === "click") ) { |
2672 | this.triggered = true; |
2806 | this.triggered = true; |
2673 | try { |
2807 | try { |
2674 | nativeFn(); |
2808 | nativeFn(); |
2675 | // prevent IE from throwing an error for some hidden elements
|
2809 | // prevent IE from throwing an error for some hidden elements
|
2676 | } catch (e) {} |
2810 | } catch (e) {} |
2677 | }
|
2811 | }
|
2678 | 2812 | ||
2679 | this.triggered = false; |
2813 | this.triggered = false; |
2680 | 2814 | ||
2681 | if ( !event.isPropagationStopped() ) { |
2815 | if ( !event.isPropagationStopped() ) { |
2682 | var parent = elem.parentNode || elem.ownerDocument; |
2816 | var parent = elem.parentNode || elem.ownerDocument; |
2683 | if ( parent ) { |
2817 | if ( parent ) { |
2684 | jQuery.event.trigger( event, data, parent, true ); |
2818 | jQuery.event.trigger( event, data, parent, true ); |
2685 | }
|
2819 | }
|
2686 | }
|
2820 | }
|
2687 | }, |
2821 | }, |
2688 | 2822 | ||
2689 | handle: function( event ) { |
2823 | handle: function( event ) { |
2690 | // returned undefined or false
|
2824 | // returned undefined or false
|
2691 | var all, handlers; |
2825 | var all, handlers; |
2692 | 2826 | ||
2693 | event = arguments[0] = jQuery.event.fix( event || window.event ); |
2827 | event = arguments[0] = jQuery.event.fix( event || window.event ); |
2694 | event.currentTarget = this; |
2828 | event.currentTarget = this; |
2695 | 2829 | ||
2696 | // Namespaced event handlers
|
2830 | // Namespaced event handlers
|
2697 | var namespaces = event.type.split("."); |
2831 | var namespaces = event.type.split("."); |
2698 | event.type = namespaces.shift(); |
2832 | event.type = namespaces.shift(); |
2699 | 2833 | ||
2700 | // Cache this now, all = true means, any handler
|
2834 | // Cache this now, all = true means, any handler
|
2701 | all = !namespaces.length && !event.exclusive; |
2835 | all = !namespaces.length && !event.exclusive; |
2702 | 2836 | ||
2703 | var namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); |
2837 | var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"); |
2704 | 2838 | ||
2705 | handlers = ( jQuery.data(this, "events") || {} )[ event.type ]; |
2839 | handlers = ( jQuery.data(this, "events") || {} )[ event.type ]; |
2706 | 2840 | ||
2707 | for ( var j in handlers ) { |
2841 | for ( var j in handlers ) { |
2708 | var handler = handlers[ j ]; |
2842 | var handler = handlers[ j ]; |
2709 | 2843 | ||
2710 | // Filter the functions by class
|
2844 | // Filter the functions by class
|
2711 | if ( all || namespace.test(handler.type) ) { |
2845 | if ( all || namespace.test(handler.type) ) { |
2712 | // Pass in a reference to the handler function itself
|
2846 | // Pass in a reference to the handler function itself
|
2713 | // So that we can later remove it
|
2847 | // So that we can later remove it
|
2714 | event.handler = handler; |
2848 | event.handler = handler; |
2715 | event.data = handler.data; |
2849 | event.data = handler.data; |
2716 | 2850 | ||
2717 | var ret = handler.apply( this, arguments ); |
2851 | var ret = handler.apply( this, arguments ); |
2718 | 2852 | ||
2719 | if ( ret !== undefined ) { |
2853 | if ( ret !== undefined ) { |
2720 | event.result = ret; |
2854 | event.result = ret; |
2721 | if ( ret === false ) { |
2855 | if ( ret === false ) { |
2722 | event.preventDefault(); |
2856 | event.preventDefault(); |
2723 | event.stopPropagation(); |
2857 | event.stopPropagation(); |
2724 | }
|
2858 | }
|
2725 | }
|
2859 | }
|
2726 | 2860 | ||
2727 | if ( event.isImmediatePropagationStopped() ) { |
2861 | if ( event.isImmediatePropagationStopped() ) { |
2728 | break; |
2862 | break; |
2729 | }
|
2863 | }
|
2730 | 2864 | ||
2731 | }
|
2865 | }
|
2732 | }
|
2866 | }
|
2733 | }, |
2867 | }, |
2734 | 2868 | ||
2735 | props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), |
2869 | props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), |
2736 | 2870 | ||
2737 | fix: function( event ) { |
2871 | fix: function( event ) { |
2738 | if ( event[ expando ] ) { |
2872 | if ( event[ expando ] ) { |
2739 | return event; |
2873 | return event; |
2740 | }
|
2874 | }
|
2741 | 2875 | ||
2742 | // store a copy of the original event object
|
2876 | // store a copy of the original event object
|
2743 | // and "clone" to set read-only properties
|
2877 | // and "clone" to set read-only properties
|
2744 | var originalEvent = event; |
2878 | var originalEvent = event; |
2745 | event = jQuery.Event( originalEvent ); |
2879 | event = jQuery.Event( originalEvent ); |
2746 | 2880 | ||
2747 | for ( var i = this.props.length, prop; i; ) { |
2881 | for ( var i = this.props.length, prop; i; ) { |
2748 | prop = this.props[ --i ]; |
2882 | prop = this.props[ --i ]; |
2749 | event[ prop ] = originalEvent[ prop ]; |
2883 | event[ prop ] = originalEvent[ prop ]; |
2750 | }
|
2884 | }
|
2751 | 2885 | ||
2752 | // Fix target property, if necessary
|
2886 | // Fix target property, if necessary
|
2753 | if ( !event.target ) { |
2887 | if ( !event.target ) { |
2754 | event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
2888 | event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
2755 | }
|
2889 | }
|
2756 | 2890 | ||
2757 | // check if target is a textnode (safari)
|
2891 | // check if target is a textnode (safari)
|
2758 | if ( event.target.nodeType === 3 ) { |
2892 | if ( event.target.nodeType === 3 ) { |
2759 | event.target = event.target.parentNode; |
2893 | event.target = event.target.parentNode; |
2760 | }
|
2894 | }
|
2761 | 2895 | ||
2762 | // Add relatedTarget, if necessary
|
2896 | // Add relatedTarget, if necessary
|
2763 | if ( !event.relatedTarget && event.fromElement ) { |
2897 | if ( !event.relatedTarget && event.fromElement ) { |
2764 | event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; |
2898 | event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; |
2765 | }
|
2899 | }
|
2766 | 2900 | ||
2767 | // Calculate pageX/Y if missing and clientX/Y available
|
2901 | // Calculate pageX/Y if missing and clientX/Y available
|
2768 | if ( event.pageX == null && event.clientX != null ) { |
2902 | if ( event.pageX == null && event.clientX != null ) { |
2769 | var doc = document.documentElement, body = document.body; |
2903 | var doc = document.documentElement, body = document.body; |
2770 | event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); |
2904 | event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); |
2771 | event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); |
2905 | event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); |
2772 | }
|
2906 | }
|
2773 | 2907 | ||
2774 | // Add which for key events
|
2908 | // Add which for key events
|
2775 | if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) { |
2909 | if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) { |
2776 | event.which = event.charCode || event.keyCode; |
2910 | event.which = event.charCode || event.keyCode; |
2777 | }
|
2911 | }
|
2778 | 2912 | ||
2779 | // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
2913 | // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
2780 | if ( !event.metaKey && event.ctrlKey ) { |
2914 | if ( !event.metaKey && event.ctrlKey ) { |
2781 | event.metaKey = event.ctrlKey; |
2915 | event.metaKey = event.ctrlKey; |
2782 | }
|
2916 | }
|
2783 | 2917 | ||
2784 | // Add which for click: 1 == left; 2 == middle; 3 == right
|
2918 | // Add which for click: 1 == left; 2 == middle; 3 == right
|
2785 | // Note: button is not normalized, so don't use it
|
2919 | // Note: button is not normalized, so don't use it
|
2786 | if ( !event.which && event.button !== undefined ) { |
2920 | if ( !event.which && event.button !== undefined ) { |
2787 | event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
2921 | event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
2788 | }
|
2922 | }
|
2789 | 2923 | ||
2790 | return event; |
2924 | return event; |
2791 | }, |
2925 | }, |
2792 | 2926 | ||
2793 | proxy: function( fn, proxy, thisObject ) { |
2927 | proxy: function( fn, proxy, thisObject ) { |
2794 | if ( proxy !== undefined && !jQuery.isFunction( proxy ) ) { |
2928 | if ( proxy !== undefined && !jQuery.isFunction( proxy ) ) { |
2795 | thisObject = proxy; |
2929 | thisObject = proxy; |
2796 | proxy = undefined; |
2930 | proxy = undefined; |
2797 | }
|
2931 | }
|
2798 | // FIXME: Should proxy be redefined to be applied with thisObject if defined?
|
2932 | // FIXME: Should proxy be redefined to be applied with thisObject if defined?
|
2799 | proxy = proxy || function() { return fn.apply( thisObject !== undefined ? thisObject : this, arguments ); }; |
2933 | proxy = proxy || function() { return fn.apply( thisObject !== undefined ? thisObject : this, arguments ); }; |
2800 | // Set the guid of unique handler to the same of original handler, so it can be removed
|
2934 | // Set the guid of unique handler to the same of original handler, so it can be removed
|
2801 | proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++; |
2935 | proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++; |
2802 | // So proxy can be declared as an argument
|
2936 | // So proxy can be declared as an argument
|
2803 | return proxy; |
2937 | return proxy; |
2804 | }, |
2938 | }, |
2805 | 2939 | ||
2806 | special: { |
2940 | special: { |
2807 | ready: { |
2941 | ready: { |
2808 | // Make sure the ready event is setup
|
2942 | // Make sure the ready event is setup
|
2809 | setup: bindReady, |
2943 | setup: bindReady, |
2810 | teardown: function() {} |
2944 | teardown: function() {} |
2811 | }, |
2945 | }, |
2812 | 2946 | ||
2813 | live: { |
2947 | live: { |
2814 | add: function( proxy, data, namespaces ) { |
2948 | add: function( proxy, data, namespaces ) { |
2815 | jQuery.extend( proxy, data || {} ); |
2949 | jQuery.extend( proxy, data || {} ); |
2816 | proxy.guid += data.selector + data.live; |
2950 | proxy.guid += data.selector + data.live; |
2817 | jQuery.event.add( this, data.live, liveHandler ); |
2951 | jQuery.event.add( this, data.live, liveHandler ); |
2818 | }, |
2952 | }, |
2819 | 2953 | ||
2820 | remove: function( namespaces ) { |
2954 | remove: function( namespaces ) { |
2821 | if ( namespaces.length ) { |
2955 | if ( namespaces.length ) { |
2822 | var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); |
2956 | var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); |
2823 | 2957 | ||
2824 | jQuery.each( (jQuery.data(this, "events").live || {}), function() { |
2958 | jQuery.each( (jQuery.data(this, "events").live || {}), function() { |
2825 | if ( name.test(this.type) ) { |
2959 | if ( name.test(this.type) ) { |
2826 | remove++;
|
2960 | remove++;
|
2827 | }
|
2961 | }
|
2828 | }); |
2962 | }); |
2829 | 2963 | ||
2830 | if ( remove < 1 ) { |
2964 | if ( remove < 1 ) { |
2831 | jQuery.event.remove( this, namespaces[0], liveHandler ); |
2965 | jQuery.event.remove( this, namespaces[0], liveHandler ); |
2832 | }
|
2966 | }
|
2833 | }
|
2967 | }
|
2834 | }
|
2968 | }
|
2835 | }
|
2969 | }
|
2836 | }
|
2970 | }
|
2837 | }; |
2971 | }; |
2838 | 2972 | ||
2839 | jQuery.Event = function( src ){ |
2973 | jQuery.Event = function( src ){ |
2840 | // Allow instantiation without the 'new' keyword
|
2974 | // Allow instantiation without the 'new' keyword
|
2841 | if ( !this.preventDefault ) { |
2975 | if ( !this.preventDefault ) { |
2842 | return new jQuery.Event( src ); |
2976 | return new jQuery.Event( src ); |
2843 | }
|
2977 | }
|
2844 | 2978 | ||
2845 | // Event object
|
2979 | // Event object
|
2846 | if ( src && src.type ) { |
2980 | if ( src && src.type ) { |
2847 | this.originalEvent = src; |
2981 | this.originalEvent = src; |
2848 | this.type = src.type; |
2982 | this.type = src.type; |
2849 | // Event type
|
2983 | // Event type
|
2850 | } else { |
2984 | } else { |
2851 | this.type = src; |
2985 | this.type = src; |
2852 | }
|
2986 | }
|
2853 | 2987 | ||
2854 | // timeStamp is buggy for some events on Firefox(#3843)
|
2988 | // timeStamp is buggy for some events on Firefox(#3843)
|
2855 | // So we won't rely on the native value
|
2989 | // So we won't rely on the native value
|
2856 | this.timeStamp = now(); |
2990 | this.timeStamp = now(); |
2857 | 2991 | ||
2858 | // Mark it as fixed
|
2992 | // Mark it as fixed
|
2859 | this[ expando ] = true; |
2993 | this[ expando ] = true; |
2860 | }; |
2994 | }; |
2861 | 2995 | ||
2862 | function returnFalse() { |
2996 | function returnFalse() { |
2863 | return false; |
2997 | return false; |
2864 | }
|
2998 | }
|
2865 | function returnTrue() { |
2999 | function returnTrue() { |
2866 | return true; |
3000 | return true; |
2867 | }
|
3001 | }
|
2868 | 3002 | ||
2869 | // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
3003 | // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
2870 | // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
3004 | // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
2871 | jQuery.Event.prototype = { |
3005 | jQuery.Event.prototype = { |
2872 | preventDefault: function() { |
3006 | preventDefault: function() { |
2873 | this.isDefaultPrevented = returnTrue; |
3007 | this.isDefaultPrevented = returnTrue; |
2874 | 3008 | ||
2875 | var e = this.originalEvent; |
3009 | var e = this.originalEvent; |
2876 | if ( !e ) { |
3010 | if ( !e ) { |
2877 | return; |
3011 | return; |
2878 | }
|
3012 | }
|
2879 | // if preventDefault exists run it on the original event
|
3013 | // if preventDefault exists run it on the original event
|
2880 | if ( e.preventDefault ) { |
3014 | if ( e.preventDefault ) { |
2881 | e.preventDefault(); |
3015 | e.preventDefault(); |
2882 | }
|
3016 | }
|
2883 | // otherwise set the returnValue property of the original event to false (IE)
|
3017 | // otherwise set the returnValue property of the original event to false (IE)
|
2884 | e.returnValue = false; |
3018 | e.returnValue = false; |
2885 | }, |
3019 | }, |
2886 | stopPropagation: function() { |
3020 | stopPropagation: function() { |
2887 | this.isPropagationStopped = returnTrue; |
3021 | this.isPropagationStopped = returnTrue; |
2888 | 3022 | ||
2889 | var e = this.originalEvent; |
3023 | var e = this.originalEvent; |
2890 | if ( !e ) { |
3024 | if ( !e ) { |
2891 | return; |
3025 | return; |
2892 | }
|
3026 | }
|
2893 | // if stopPropagation exists run it on the original event
|
3027 | // if stopPropagation exists run it on the original event
|
2894 | if ( e.stopPropagation ) { |
3028 | if ( e.stopPropagation ) { |
2895 | e.stopPropagation(); |
3029 | e.stopPropagation(); |
2896 | }
|
3030 | }
|
2897 | // otherwise set the cancelBubble property of the original event to true (IE)
|
3031 | // otherwise set the cancelBubble property of the original event to true (IE)
|
2898 | e.cancelBubble = true; |
3032 | e.cancelBubble = true; |
2899 | }, |
3033 | }, |
2900 | stopImmediatePropagation: function(){ |
3034 | stopImmediatePropagation: function(){ |
2901 | this.isImmediatePropagationStopped = returnTrue; |
3035 | this.isImmediatePropagationStopped = returnTrue; |
2902 | this.stopPropagation(); |
3036 | this.stopPropagation(); |
2903 | }, |
3037 | }, |
2904 | isDefaultPrevented: returnFalse, |
3038 | isDefaultPrevented: returnFalse, |
2905 | isPropagationStopped: returnFalse, |
3039 | isPropagationStopped: returnFalse, |
2906 | isImmediatePropagationStopped: returnFalse
|
3040 | isImmediatePropagationStopped: returnFalse
|
2907 | }; |
3041 | }; |
2908 | // Checks if an event happened on an element within another element
|
3042 | // Checks if an event happened on an element within another element
|
2909 | // Used in jQuery.event.special.mouseenter and mouseleave handlers
|
3043 | // Used in jQuery.event.special.mouseenter and mouseleave handlers
|
2910 | var withinElement = function( event ) { |
3044 | var withinElement = function( event ) { |
2911 | // Check if mouse(over|out) are still within the same parent element
|
3045 | // Check if mouse(over|out) are still within the same parent element
|
2912 | var parent = event.relatedTarget; |
3046 | var parent = event.relatedTarget; |
2913 | // Traverse up the tree
|
3047 | // Traverse up the tree
|
2914 | while ( parent && parent != this ) { |
3048 | while ( parent && parent != this ) { |
2915 | // Firefox sometimes assigns relatedTarget a XUL element
|
3049 | // Firefox sometimes assigns relatedTarget a XUL element
|
2916 | // which we cannot access the parentNode property of
|
3050 | // which we cannot access the parentNode property of
|
2917 | try { parent = parent.parentNode; } |
3051 | try { parent = parent.parentNode; } |
2918 | // assuming we've left the element since we most likely mousedover a xul element
|
3052 | // assuming we've left the element since we most likely mousedover a xul element
|
2919 | catch(e) { break; } |
3053 | catch(e) { break; } |
2920 | }
|
3054 | }
|
2921 | 3055 | ||
2922 | if ( parent != this ) { |
3056 | if ( parent != this ) { |
2923 | // set the correct event type
|
3057 | // set the correct event type
|
2924 | event.type = event.data; |
3058 | event.type = event.data; |
2925 | // handle event if we actually just moused on to a non sub-element
|
3059 | // handle event if we actually just moused on to a non sub-element
|
2926 | jQuery.event.handle.apply( this, arguments ); |
3060 | jQuery.event.handle.apply( this, arguments ); |
2927 | }
|
3061 | }
|
2928 | }; |
3062 | }; |
2929 | 3063 | ||
2930 | jQuery.each({ |
3064 | jQuery.each({ |
2931 | mouseover: 'mouseenter', |
3065 | mouseover: 'mouseenter', |
2932 | mouseout: 'mouseleave' |
3066 | mouseout: 'mouseleave' |
2933 | }, function( orig, fix ) { |
3067 | }, function( orig, fix ) { |
2934 | jQuery.event.special[ fix ] = { |
3068 | jQuery.event.special[ fix ] = { |
2935 | setup: function(){ |
3069 | setup: function(){ |
2936 | jQuery.event.add( this, orig, withinElement, fix ); |
3070 | jQuery.event.add( this, orig, withinElement, fix ); |
2937 | }, |
3071 | }, |
2938 | teardown: function(){ |
3072 | teardown: function(){ |
2939 | jQuery.event.remove( this, orig, withinElement ); |
3073 | jQuery.event.remove( this, orig, withinElement ); |
2940 | }
|
3074 | }
|
2941 | }; |
3075 | }; |
2942 | }); |
3076 | }); |
2943 | 3077 | ||
2944 | jQuery.fn.extend({ |
3078 | jQuery.fn.extend({ |
2945 | bind: function( type, data, fn, thisObject ) { |
3079 | bind: function( type, data, fn, thisObject ) { |
2946 | if ( jQuery.isFunction( data ) ) { |
3080 | if ( jQuery.isFunction( data ) ) { |
2947 | if ( fn !== undefined ) { |
3081 | if ( fn !== undefined ) { |
2948 | thisObject = fn; |
3082 | thisObject = fn; |
2949 | }
|
3083 | }
|
2950 | fn = data; |
3084 | fn = data; |
2951 | data = undefined; |
3085 | data = undefined; |
2952 | }
|
3086 | }
|
2953 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
3087 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
2954 | return type === "unload" ? this.one(type, data, fn, thisObject) : this.each(function() { |
3088 | return type === "unload" ? this.one(type, data, fn, thisObject) : this.each(function() { |
2955 | jQuery.event.add( this, type, fn, data ); |
3089 | jQuery.event.add( this, type, fn, data ); |
2956 | }); |
3090 | }); |
2957 | }, |
3091 | }, |
2958 | 3092 | ||
2959 | one: function( type, data, fn, thisObject ) { |
3093 | one: function( type, data, fn, thisObject ) { |
2960 | if ( jQuery.isFunction( data ) ) { |
3094 | if ( jQuery.isFunction( data ) ) { |
2961 | if ( fn !== undefined ) { |
3095 | if ( fn !== undefined ) { |
2962 | thisObject = fn; |
3096 | thisObject = fn; |
2963 | }
|
3097 | }
|
2964 | fn = data; |
3098 | fn = data; |
2965 | data = undefined; |
3099 | data = undefined; |
2966 | }
|
3100 | }
|
2967 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
3101 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
2968 | var one = jQuery.event.proxy( fn, function( event ) { |
3102 | var one = jQuery.event.proxy( fn, function( event ) { |
2969 | jQuery( this ).unbind( event, one ); |
3103 | jQuery( this ).unbind( event, one ); |
2970 | return fn.apply( this, arguments ); |
3104 | return fn.apply( this, arguments ); |
2971 | }); |
3105 | }); |
2972 | return this.each(function() { |
3106 | return this.each(function() { |
2973 | jQuery.event.add( this, type, one, data ); |
3107 | jQuery.event.add( this, type, one, data ); |
2974 | }); |
3108 | }); |
2975 | }, |
3109 | }, |
2976 | 3110 | ||
2977 | unbind: function( type, fn ) { |
3111 | unbind: function( type, fn ) { |
2978 | return this.each(function() { |
3112 | return this.each(function() { |
2979 | jQuery.event.remove( this, type, fn ); |
3113 | jQuery.event.remove( this, type, fn ); |
2980 | }); |
3114 | }); |
2981 | }, |
3115 | }, |
2982 | 3116 | ||
2983 | trigger: function( type, data ) { |
3117 | trigger: function( type, data ) { |
2984 | return this.each(function() { |
3118 | return this.each(function() { |
2985 | jQuery.event.trigger( type, data, this ); |
3119 | jQuery.event.trigger( type, data, this ); |
2986 | }); |
3120 | }); |
2987 | }, |
3121 | }, |
2988 | 3122 | ||
2989 | triggerHandler: function( type, data ) { |
3123 | triggerHandler: function( type, data ) { |
2990 | if ( this[0] ) { |
3124 | if ( this[0] ) { |
2991 | var event = jQuery.Event( type ); |
3125 | var event = jQuery.Event( type ); |
2992 | event.preventDefault(); |
3126 | event.preventDefault(); |
2993 | event.stopPropagation(); |
3127 | event.stopPropagation(); |
2994 | jQuery.event.trigger( event, data, this[0] ); |
3128 | jQuery.event.trigger( event, data, this[0] ); |
2995 | return event.result; |
3129 | return event.result; |
2996 | }
|
3130 | }
|
2997 | }, |
3131 | }, |
2998 | 3132 | ||
2999 | toggle: function( fn ) { |
3133 | toggle: function( fn ) { |
3000 | // Save reference to arguments for access in closure
|
3134 | // Save reference to arguments for access in closure
|
3001 | var args = arguments, i = 1; |
3135 | var args = arguments, i = 1; |
3002 | 3136 | ||
3003 | // link all the functions, so any of them can unbind this click handler
|
3137 | // link all the functions, so any of them can unbind this click handler
|
3004 | while( i < args.length ) { |
3138 | while( i < args.length ) { |
3005 | jQuery.event.proxy( fn, args[ i++ ] ); |
3139 | jQuery.event.proxy( fn, args[ i++ ] ); |
3006 | }
|
3140 | }
|
3007 | 3141 | ||
3008 | return this.click( jQuery.event.proxy( fn, function( event ) { |
3142 | return this.click( jQuery.event.proxy( fn, function( event ) { |
3009 | // Figure out which function to execute
|
3143 | // Figure out which function to execute
|
3010 | this.lastToggle = ( this.lastToggle || 0 ) % i; |
3144 | this.lastToggle = ( this.lastToggle || 0 ) % i; |
3011 | 3145 | ||
3012 | // Make sure that clicks stop
|
3146 | // Make sure that clicks stop
|
3013 | event.preventDefault(); |
3147 | event.preventDefault(); |
3014 | 3148 | ||
3015 | // and execute the function
|
3149 | // and execute the function
|
3016 | return args[ this.lastToggle++ ].apply( this, arguments ) || false; |
3150 | return args[ this.lastToggle++ ].apply( this, arguments ) || false; |
3017 | })); |
3151 | })); |
3018 | }, |
3152 | }, |
3019 | 3153 | ||
3020 | hover: function( fnOver, fnOut ) { |
3154 | hover: function( fnOver, fnOut ) { |
3021 | return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
3155 | return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
3022 | }, |
3156 | }, |
3023 | 3157 | ||
3024 | ready: function( fn ) { |
3158 | ready: function( fn ) { |
3025 | // Attach the listeners
|
3159 | // Attach the listeners
|
3026 | bindReady(); |
3160 | bindReady(); |
3027 | 3161 | ||
3028 | // If the DOM is already ready
|
3162 | // If the DOM is already ready
|
3029 | if ( jQuery.isReady ) { |
3163 | if ( jQuery.isReady ) { |
3030 | // Execute the function immediately
|
3164 | // Execute the function immediately
|
3031 | fn.call( document, jQuery ); |
3165 | fn.call( document, jQuery ); |
3032 | 3166 | ||
3033 | // Otherwise, remember the function for later
|
3167 | // Otherwise, remember the function for later
|
3034 | } else { |
3168 | } else { |
3035 | // Add the function to the wait list
|
3169 | // Add the function to the wait list
|
3036 | jQuery.readyList.push( fn ); |
3170 | jQuery.readyList.push( fn ); |
3037 | }
|
3171 | }
|
3038 | 3172 | ||
3039 | return this; |
3173 | return this; |
3040 | }, |
3174 | }, |
3041 | 3175 | ||
3042 | live: function( type, data, fn, thisObject ) { |
3176 | live: function( type, data, fn, thisObject ) { |
3043 | if ( jQuery.isFunction( data ) ) { |
3177 | if ( jQuery.isFunction( data ) ) { |
3044 | if ( fn !== undefined ) { |
3178 | if ( fn !== undefined ) { |
3045 | thisObject = fn; |
3179 | thisObject = fn; |
3046 | }
|
3180 | }
|
3047 | fn = data; |
3181 | fn = data; |
3048 | data = undefined; |
3182 | data = undefined; |
3049 | }
|
3183 | }
|
3050 | jQuery( this.context ).bind( liveConvert( type, this.selector ), { |
3184 | jQuery( this.context ).bind( liveConvert( type, this.selector ), { |
3051 | data: data, selector: this.selector, live: type |
3185 | data: data, selector: this.selector, live: type |
3052 | }, fn, thisObject ); |
3186 | }, fn, thisObject ); |
3053 | return this; |
3187 | return this; |
3054 | }, |
3188 | }, |
3055 | 3189 | ||
3056 | die: function( type, fn ) { |
3190 | die: function( type, fn ) { |
3057 | jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null ); |
3191 | jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null ); |
3058 | return this; |
3192 | return this; |
3059 | }
|
3193 | }
|
3060 | }); |
3194 | }); |
3061 | 3195 | ||
3062 | function liveHandler( event ) { |
3196 | function liveHandler( event ) { |
3063 | var stop = true, elems = [], args = arguments; |
3197 | var stop = true, elems = [], args = arguments; |
3064 | 3198 | ||
3065 | jQuery.each( jQuery.data( this, "events" ).live || [], function( i, fn ) { |
3199 | jQuery.each( jQuery.data( this, "events" ).live || [], function( i, fn ) { |
3066 | if ( fn.live === event.type ) { |
3200 | if ( fn.live === event.type ) { |
3067 | var elem = jQuery( event.target ).closest( fn.selector )[0]; |
3201 | var elem = jQuery( event.target ).closest( fn.selector )[0]; |
3068 | if ( elem ) { |
3202 | if ( elem ) { |
3069 | elems.push({ elem: elem, fn: fn }); |
3203 | elems.push({ elem: elem, fn: fn }); |
3070 | }
|
3204 | }
|
3071 | }
|
3205 | }
|
3072 | }); |
3206 | }); |
3073 | 3207 | ||
3074 | elems.sort(function( a, b ) { |
3208 | elems.sort(function( a, b ) { |
3075 | return jQuery.data( a.elem, "closest" ) - jQuery.data( b.elem, "closest" ); |
3209 | return jQuery.data( a.elem, "closest" ) - jQuery.data( b.elem, "closest" ); |
3076 | }); |
3210 | }); |
3077 | 3211 | ||
3078 | jQuery.each(elems, function() { |
3212 | jQuery.each(elems, function() { |
3079 | event.currentTarget = this.elem; |
3213 | event.currentTarget = this.elem; |
3080 | event.data = this.fn.data; |
3214 | event.data = this.fn.data; |
3081 | if ( this.fn.apply( this.elem, args ) === false ) { |
3215 | if ( this.fn.apply( this.elem, args ) === false ) { |
3082 | return (stop = false); |
3216 | return (stop = false); |
3083 | }
|
3217 | }
|
3084 | }); |
3218 | }); |
3085 | 3219 | ||
3086 | return stop; |
3220 | return stop; |
3087 | }
|
3221 | }
|
3088 | 3222 | ||
3089 | function liveConvert( type, selector ) { |
3223 | function liveConvert( type, selector ) { |
3090 | return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); |
3224 | return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); |
3091 | }
|
3225 | }
|
3092 | 3226 | ||
3093 | jQuery.extend({ |
3227 | jQuery.extend({ |
3094 | isReady: false, |
3228 | isReady: false, |
3095 | readyList: [], |
3229 | readyList: [], |
3096 | // Handle when the DOM is ready
|
3230 | // Handle when the DOM is ready
|
3097 | ready: function() { |
3231 | ready: function() { |
3098 | // Make sure that the DOM is not already loaded
|
3232 | // Make sure that the DOM is not already loaded
|
3099 | if ( !jQuery.isReady ) { |
3233 | if ( !jQuery.isReady ) { |
3100 | // Remember that the DOM is ready
|
3234 | // Remember that the DOM is ready
|
3101 | jQuery.isReady = true; |
3235 | jQuery.isReady = true; |
3102 | 3236 | ||
3103 | // If there are functions bound, to execute
|
3237 | // If there are functions bound, to execute
|
3104 | if ( jQuery.readyList ) { |
3238 | if ( jQuery.readyList ) { |
3105 | // Execute all of them
|
3239 | // Execute all of them
|
3106 | var fn, i = 0; |
3240 | var fn, i = 0; |
3107 | while ( (fn = jQuery.readyList[ i++ ]) ) { |
3241 | while ( (fn = jQuery.readyList[ i++ ]) ) { |
3108 | fn.call( document, jQuery ); |
3242 | fn.call( document, jQuery ); |
3109 | }
|
3243 | }
|
3110 | 3244 | ||
3111 | // Reset the list of functions
|
3245 | // Reset the list of functions
|
3112 | jQuery.readyList = null; |
3246 | jQuery.readyList = null; |
3113 | }
|
3247 | }
|
3114 | 3248 | ||
3115 | // Trigger any bound ready events
|
3249 | // Trigger any bound ready events
|
3116 | jQuery( document ).triggerHandler( "ready" ); |
3250 | jQuery( document ).triggerHandler( "ready" ); |
3117 | }
|
3251 | }
|
3118 | }
|
3252 | }
|
3119 | }); |
3253 | }); |
3120 | 3254 | ||
3121 | var readyBound = false; |
3255 | var readyBound = false; |
3122 | 3256 | ||
3123 | function bindReady() { |
3257 | function bindReady() { |
3124 | if ( readyBound ) return; |
3258 | if ( readyBound ) return; |
3125 | readyBound = true; |
3259 | readyBound = true; |
3126 | 3260 | ||
- | 3261 | // Catch cases where $(document).ready() is called after the
|
|
- | 3262 | // browser event has already occurred.
|
|
- | 3263 | if ( document.readyState === "complete" ) { |
|
- | 3264 | return jQuery.ready(); |
|
- | 3265 | }
|
|
- | 3266 | ||
3127 | // Mozilla, Opera and webkit nightlies currently support this event
|
3267 | // Mozilla, Opera and webkit nightlies currently support this event
|
3128 | if ( document.addEventListener ) { |
3268 | if ( document.addEventListener ) { |
3129 | // Use the handy event callback
|
3269 | // Use the handy event callback
|
3130 | document.addEventListener( "DOMContentLoaded", function() { |
3270 | document.addEventListener( "DOMContentLoaded", function() { |
3131 | document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
3271 | document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
3132 | jQuery.ready(); |
3272 | jQuery.ready(); |
3133 | }, false ); |
3273 | }, false ); |
3134 | 3274 | ||
3135 | // If IE event model is used
|
3275 | // If IE event model is used
|
3136 | } else if ( document.attachEvent ) { |
3276 | } else if ( document.attachEvent ) { |
3137 | // ensure firing before onload,
|
3277 | // ensure firing before onload,
|
3138 | // maybe late but safe also for iframes
|
3278 | // maybe late but safe also for iframes
|
3139 | document.attachEvent("onreadystatechange", function() { |
3279 | document.attachEvent("onreadystatechange", function() { |
3140 | if ( document.readyState === "complete" ) { |
3280 | if ( document.readyState === "complete" ) { |
3141 | document.detachEvent( "onreadystatechange", arguments.callee ); |
3281 | document.detachEvent( "onreadystatechange", arguments.callee ); |
3142 | jQuery.ready(); |
3282 | jQuery.ready(); |
3143 | }
|
3283 | }
|
3144 | }); |
3284 | }); |
3145 | 3285 | ||
3146 | // If IE and not an iframe
|
3286 | // If IE and not an iframe
|
3147 | // continually check to see if the document is ready
|
3287 | // continually check to see if the document is ready
|
3148 | if ( document.documentElement.doScroll && window === window.top ) (function() { |
3288 | if ( document.documentElement.doScroll && window === window.top ) (function() { |
3149 | if ( jQuery.isReady ) { |
3289 | if ( jQuery.isReady ) { |
3150 | return; |
3290 | return; |
3151 | }
|
3291 | }
|
3152 | 3292 | ||
3153 | try { |
3293 | try { |
3154 | // If IE is used, use the trick by Diego Perini
|
3294 | // If IE is used, use the trick by Diego Perini
|
3155 | // http://javascript.nwbox.com/IEContentLoaded/
|
3295 | // http://javascript.nwbox.com/IEContentLoaded/
|
3156 | document.documentElement.doScroll("left"); |
3296 | document.documentElement.doScroll("left"); |
3157 | } catch( error ) { |
3297 | } catch( error ) { |
3158 | setTimeout( arguments.callee, 0 ); |
3298 | setTimeout( arguments.callee, 0 ); |
3159 | return; |
3299 | return; |
3160 | }
|
3300 | }
|
3161 | 3301 | ||
3162 | // and execute any waiting functions
|
3302 | // and execute any waiting functions
|
3163 | jQuery.ready(); |
3303 | jQuery.ready(); |
3164 | })(); |
3304 | })(); |
3165 | }
|
3305 | }
|
3166 | 3306 | ||
3167 | // A fallback to window.onload, that will always work
|
3307 | // A fallback to window.onload, that will always work
|
3168 | jQuery.event.add( window, "load", jQuery.ready ); |
3308 | jQuery.event.add( window, "load", jQuery.ready ); |
3169 | }
|
3309 | }
|
3170 | 3310 | ||
3171 | jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + |
3311 | jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + |
3172 | "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," + |
3312 | "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," + |
3173 | "change,select,submit,keydown,keypress,keyup,error").split(","), function( i, name ) { |
3313 | "change,select,submit,keydown,keypress,keyup,error").split(","), function( i, name ) { |
3174 | 3314 | ||
3175 | // Handle event binding
|
3315 | // Handle event binding
|
3176 | jQuery.fn[ name ] = function( fn ) { |
3316 | jQuery.fn[ name ] = function( fn ) { |
3177 | return fn ? this.bind( name, fn ) : this.trigger( name ); |
3317 | return fn ? this.bind( name, fn ) : this.trigger( name ); |
3178 | }; |
3318 | }; |
3179 | }); |
3319 | }); |
3180 | 3320 | ||
3181 | // Prevent memory leaks in IE
|
3321 | // Prevent memory leaks in IE
|
3182 | // And prevent errors on refresh with events like mouseover in other browsers
|
3322 | // And prevent errors on refresh with events like mouseover in other browsers
|
3183 | // Window isn't included so as not to unbind existing unload events
|
3323 | // Window isn't included so as not to unbind existing unload events
|
3184 | // More info:
|
3324 | // More info:
|
3185 | // - http://isaacschlueter.com/2006/10/msie-memory-leaks/
|
3325 | // - http://isaacschlueter.com/2006/10/msie-memory-leaks/
|
3186 | // - https://bugzilla.mozilla.org/show_bug.cgi?id=252542
|
3326 | // - https://bugzilla.mozilla.org/show_bug.cgi?id=252542
|
3187 | jQuery( window ).bind( 'unload', function() { |
3327 | jQuery( window ).bind( 'unload', function() { |
3188 | for ( var id in jQuery.cache ) { |
3328 | for ( var id in jQuery.cache ) { |
3189 | // Skip the window
|
3329 | // Skip the window
|
3190 | if ( id != 1 && jQuery.cache[ id ].handle ) { |
3330 | if ( id != 1 && jQuery.cache[ id ].handle ) { |
3191 | jQuery.event.remove( jQuery.cache[ id ].handle.elem ); |
3331 | jQuery.event.remove( jQuery.cache[ id ].handle.elem ); |
3192 | }
|
3332 | }
|
3193 | }
|
3333 | }
|
3194 | }); |
3334 | }); |
3195 | (function(){ |
3335 | (function(){ |
3196 | 3336 | ||
3197 | jQuery.support = {}; |
3337 | jQuery.support = {}; |
3198 | 3338 | ||
3199 | var root = document.documentElement, |
3339 | var root = document.documentElement, |
3200 | script = document.createElement("script"), |
3340 | script = document.createElement("script"), |
3201 | div = document.createElement("div"), |
3341 | div = document.createElement("div"), |
3202 | id = "script" + (new Date).getTime(); |
3342 | id = "script" + (new Date).getTime(); |
3203 | 3343 | ||
3204 | div.style.display = "none"; |
3344 | div.style.display = "none"; |
3205 | div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select>'; |
3345 | div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select>'; |
3206 | 3346 | ||
3207 | var all = div.getElementsByTagName("*"), |
3347 | var all = div.getElementsByTagName("*"), |
3208 | a = div.getElementsByTagName("a")[0]; |
3348 | a = div.getElementsByTagName("a")[0]; |
3209 | 3349 | ||
3210 | // Can't get basic test support
|
3350 | // Can't get basic test support
|
3211 | if ( !all || !all.length || !a ) { |
3351 | if ( !all || !all.length || !a ) { |
3212 | return; |
3352 | return; |
3213 | }
|
3353 | }
|
3214 | 3354 | ||
3215 | jQuery.support = { |
3355 | jQuery.support = { |
3216 | // IE strips leading whitespace when .innerHTML is used
|
3356 | // IE strips leading whitespace when .innerHTML is used
|
3217 | leadingWhitespace: div.firstChild.nodeType == 3, |
3357 | leadingWhitespace: div.firstChild.nodeType == 3, |
3218 | 3358 | ||
3219 | // Make sure that tbody elements aren't automatically inserted
|
3359 | // Make sure that tbody elements aren't automatically inserted
|
3220 | // IE will insert them into empty tables
|
3360 | // IE will insert them into empty tables
|
3221 | tbody: !div.getElementsByTagName("tbody").length, |
3361 | tbody: !div.getElementsByTagName("tbody").length, |
3222 | 3362 | ||
3223 | // Make sure that link elements get serialized correctly by innerHTML
|
3363 | // Make sure that link elements get serialized correctly by innerHTML
|
3224 | // This requires a wrapper element in IE
|
3364 | // This requires a wrapper element in IE
|
3225 | htmlSerialize: !!div.getElementsByTagName("link").length, |
3365 | htmlSerialize: !!div.getElementsByTagName("link").length, |
3226 | 3366 | ||
3227 | // Get the style information from getAttribute
|
3367 | // Get the style information from getAttribute
|
3228 | // (IE uses .cssText insted)
|
3368 | // (IE uses .cssText insted)
|
3229 | style: /red/.test( a.getAttribute("style") ), |
3369 | style: /red/.test( a.getAttribute("style") ), |
3230 | 3370 | ||
3231 | // Make sure that URLs aren't manipulated
|
3371 | // Make sure that URLs aren't manipulated
|
3232 | // (IE normalizes it by default)
|
3372 | // (IE normalizes it by default)
|
3233 | hrefNormalized: a.getAttribute("href") === "/a", |
3373 | hrefNormalized: a.getAttribute("href") === "/a", |
3234 | 3374 | ||
3235 | // Make sure that element opacity exists
|
3375 | // Make sure that element opacity exists
|
3236 | // (IE uses filter instead)
|
3376 | // (IE uses filter instead)
|
3237 | opacity: a.style.opacity === "0.5", |
3377 | opacity: a.style.opacity === "0.5", |
3238 | 3378 | ||
3239 | // Verify style float existence
|
3379 | // Verify style float existence
|
3240 | // (IE uses styleFloat instead of cssFloat)
|
3380 | // (IE uses styleFloat instead of cssFloat)
|
3241 | cssFloat: !!a.style.cssFloat, |
3381 | cssFloat: !!a.style.cssFloat, |
3242 | 3382 | ||
3243 | // Will be defined later
|
3383 | // Will be defined later
|
3244 | scriptEval: false, |
3384 | scriptEval: false, |
3245 | noCloneEvent: true, |
3385 | noCloneEvent: true, |
3246 | boxModel: null |
3386 | boxModel: null |
3247 | }; |
3387 | }; |
3248 | 3388 | ||
3249 | script.type = "text/javascript"; |
3389 | script.type = "text/javascript"; |
3250 | try { |
3390 | try { |
3251 | script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
3391 | script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
3252 | } catch(e){} |
3392 | } catch(e){} |
3253 | 3393 | ||
3254 | root.insertBefore( script, root.firstChild ); |
3394 | root.insertBefore( script, root.firstChild ); |
3255 | 3395 | ||
3256 | // Make sure that the execution of code works by injecting a script
|
3396 | // Make sure that the execution of code works by injecting a script
|
3257 | // tag with appendChild/createTextNode
|
3397 | // tag with appendChild/createTextNode
|
3258 | // (IE doesn't support this, fails, and uses .text instead)
|
3398 | // (IE doesn't support this, fails, and uses .text instead)
|
3259 | if ( window[ id ] ) { |
3399 | if ( window[ id ] ) { |
3260 | jQuery.support.scriptEval = true; |
3400 | jQuery.support.scriptEval = true; |
3261 | delete window[ id ]; |
3401 | delete window[ id ]; |
3262 | }
|
3402 | }
|
3263 | 3403 | ||
3264 | root.removeChild( script ); |
3404 | root.removeChild( script ); |
3265 | 3405 | ||
3266 | if ( div.attachEvent && div.fireEvent ) { |
3406 | if ( div.attachEvent && div.fireEvent ) { |
3267 | div.attachEvent("onclick", function click(){ |
3407 | div.attachEvent("onclick", function click(){ |
3268 | // Cloning a node shouldn't copy over any
|
3408 | // Cloning a node shouldn't copy over any
|
3269 | // bound event handlers (IE does this)
|
3409 | // bound event handlers (IE does this)
|
3270 | jQuery.support.noCloneEvent = false; |
3410 | jQuery.support.noCloneEvent = false; |
3271 | div.detachEvent("onclick", click); |
3411 | div.detachEvent("onclick", click); |
3272 | }); |
3412 | }); |
3273 | div.cloneNode(true).fireEvent("onclick"); |
3413 | div.cloneNode(true).fireEvent("onclick"); |
3274 | }
|
3414 | }
|
3275 | 3415 | ||
3276 | // Figure out if the W3C box model works as expected
|
3416 | // Figure out if the W3C box model works as expected
|
3277 | // document.body must exist before we can do this
|
3417 | // document.body must exist before we can do this
|
3278 | jQuery(function(){ |
3418 | jQuery(function(){ |
3279 | var div = document.createElement("div"); |
3419 | var div = document.createElement("div"); |
3280 | div.style.width = div.style.paddingLeft = "1px"; |
3420 | div.style.width = div.style.paddingLeft = "1px"; |
3281 | 3421 | ||
3282 | document.body.appendChild( div ); |
3422 | document.body.appendChild( div ); |
3283 | jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
3423 | jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
3284 | document.body.removeChild( div ).style.display = 'none'; |
3424 | document.body.removeChild( div ).style.display = 'none'; |
3285 | div = null; |
3425 | div = null; |
3286 | }); |
3426 | }); |
3287 | 3427 | ||
3288 | // release memory in IE
|
3428 | // release memory in IE
|
3289 | root = script = div = all = a = null; |
3429 | root = script = div = all = a = null; |
3290 | })(); |
3430 | })(); |
3291 | 3431 | ||
3292 | jQuery.props = { |
3432 | jQuery.props = { |
3293 | "for": "htmlFor", |
3433 | "for": "htmlFor", |
3294 | "class": "className", |
3434 | "class": "className", |
3295 | readonly: "readOnly", |
3435 | readonly: "readOnly", |
3296 | maxlength: "maxLength", |
3436 | maxlength: "maxLength", |
3297 | cellspacing: "cellSpacing", |
3437 | cellspacing: "cellSpacing", |
3298 | rowspan: "rowSpan", |
3438 | rowspan: "rowSpan", |
3299 | colspan: "colSpan", |
3439 | colspan: "colSpan", |
3300 | tabindex: "tabIndex" |
3440 | tabindex: "tabIndex" |
3301 | }; |
3441 | }; |
3302 | // exclude the following css properties to add px
|
3442 | // exclude the following css properties to add px
|
3303 | var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
3443 | var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
- | 3444 | ralpha = /alpha\([^)]*\)/, |
|
- | 3445 | ropacity = /opacity=([^)]*)/, |
|
- | 3446 | rfloat = /float/i, |
|
- | 3447 | rdashAlpha = /-([a-z])/ig, |
|
- | 3448 | rupper = /([A-Z])/g, |
|
- | 3449 | rnumpx = /^\d+(?:px)?$/i, |
|
- | 3450 | rnum = /^\d/, |
|
- | 3451 | ||
3304 | // cache check for defaultView.getComputedStyle
|
3452 | // cache check for defaultView.getComputedStyle
|
3305 | getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, |
3453 | getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, |
3306 | // normalize float css property
|
3454 | // normalize float css property
|
3307 | styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat"; |
3455 | styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat", |
- | 3456 | fcamelCase = function(all, letter){ |
|
- | 3457 | return letter.toUpperCase(); |
|
- | 3458 | }; |
|
3308 | 3459 | ||
3309 | jQuery.fn.css = function( name, value ) { |
3460 | jQuery.fn.css = function( name, value ) { |
3310 | var options = name, isFunction = jQuery.isFunction( value ); |
3461 | var options = name, isFunction = jQuery.isFunction( value ); |
3311 | 3462 | ||
3312 | if ( typeof name === "string" ) { |
3463 | if ( typeof name === "string" ) { |
3313 | // Are we setting the style?
|
3464 | // Are we setting the style?
|
3314 | if ( value === undefined ) { |
3465 | if ( value === undefined ) { |
3315 | return this.length ? |
3466 | return this.length ? |
3316 | jQuery.css( this[0], name ) : |
3467 | jQuery.css( this[0], name ) : |
3317 | null; |
3468 | null; |
3318 | 3469 | ||
3319 | // Convert name, value params to options hash format
|
3470 | // Convert name, value params to options hash format
|
3320 | } else { |
3471 | } else { |
3321 | options = {}; |
3472 | options = {}; |
3322 | options[ name ] = value; |
3473 | options[ name ] = value; |
3323 | }
|
3474 | }
|
3324 | }
|
3475 | }
|
- | 3476 | ||
- | 3477 | var isFunction = {}; |
|
- | 3478 | ||
- | 3479 | // For each value, determine whether it's a Function so we don't
|
|
- | 3480 | // need to determine it again for each element
|
|
- | 3481 | for ( var prop in options ) { |
|
- | 3482 | isFunction[prop] = jQuery.isFunction( options[prop] ); |
|
- | 3483 | }
|
|
3325 | 3484 | ||
3326 | // For each element...
|
3485 | // For each element...
|
3327 | for ( var i = 0, l = this.length; i < l; i++ ) { |
3486 | for ( var i = 0, l = this.length; i < l; i++ ) { |
3328 | var elem = this[i]; |
3487 | var elem = this[i]; |
3329 | 3488 | ||
3330 | // Set all the styles
|
3489 | // Set all the styles
|
3331 | for ( var prop in options ) { |
3490 | for ( var prop in options ) { |
3332 | value = options[prop]; |
3491 | value = options[prop]; |
3333 | 3492 | ||
3334 | if ( isFunction ) { |
3493 | if ( isFunction[prop] ) { |
3335 | value = value.call( elem, i ); |
3494 | value = value.call( elem, i ); |
3336 | }
|
3495 | }
|
3337 | 3496 | ||
3338 | if ( typeof value === "number" && !exclude.test(prop) ) { |
3497 | if ( typeof value === "number" && !rexclude.test(prop) ) { |
3339 | value = value + "px"; |
3498 | value = value + "px"; |
3340 | }
|
3499 | }
|
3341 | 3500 | ||
3342 | jQuery.style( elem, prop, value ); |
3501 | jQuery.style( elem, prop, value ); |
3343 | }
|
3502 | }
|
3344 | }
|
3503 | }
|
3345 | 3504 | ||
3346 | return this; |
3505 | return this; |
3347 | }; |
3506 | }; |
3348 | 3507 | ||
3349 | jQuery.extend({ |
3508 | jQuery.extend({ |
3350 | style: function( elem, name, value ) { |
3509 | style: function( elem, name, value ) { |
3351 | // don't set styles on text and comment nodes
|
3510 | // don't set styles on text and comment nodes
|
3352 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
3511 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
3353 | return undefined; |
3512 | return undefined; |
- | 3513 | }
|
|
3354 | 3514 | ||
3355 | // ignore negative width and height values #1599
|
3515 | // ignore negative width and height values #1599
|
3356 | if ( (name == 'width' || name == 'height') && parseFloat(value) < 0 ) |
3516 | if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) { |
3357 | value = undefined; |
3517 | value = undefined; |
- | 3518 | }
|
|
3358 | 3519 | ||
3359 | var style = elem.style || elem, set = value !== undefined; |
3520 | var style = elem.style || elem, set = value !== undefined; |
3360 | 3521 | ||
3361 | // IE uses filters for opacity
|
3522 | // IE uses filters for opacity
|
3362 | if ( !jQuery.support.opacity && name == "opacity" ) { |
3523 | if ( !jQuery.support.opacity && name === "opacity" ) { |
3363 | if ( set ) { |
3524 | if ( set ) { |
3364 | // IE has trouble with opacity if it does not have layout
|
3525 | // IE has trouble with opacity if it does not have layout
|
3365 | // Force it by setting the zoom level
|
3526 | // Force it by setting the zoom level
|
3366 | style.zoom = 1; |
3527 | style.zoom = 1; |
3367 | 3528 | ||
3368 | // Set the alpha filter to set the opacity
|
3529 | // Set the alpha filter to set the opacity
|
3369 | style.filter = (style.filter || "").replace( /alpha\([^)]*\)/, "" ) + |
3530 | style.filter = (style.filter || "").replace( ralpha, "" ) + |
3370 | (parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"); |
3531 | (parseInt( value ) + '' === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"); |
3371 | }
|
3532 | }
|
3372 | 3533 | ||
3373 | return style.filter && style.filter.indexOf("opacity=") >= 0 ? |
3534 | return style.filter && style.filter.indexOf("opacity=") >= 0 ? |
3374 | (parseFloat( style.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '': |
3535 | (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + '': |
3375 | ""; |
3536 | ""; |
3376 | }
|
3537 | }
|
3377 | 3538 | ||
3378 | // Make sure we're using the right name for getting the float value
|
3539 | // Make sure we're using the right name for getting the float value
|
3379 | if ( /float/i.test( name ) ) |
3540 | if ( rfloat.test( name ) ) { |
3380 | name = styleFloat; |
3541 | name = styleFloat; |
- | 3542 | }
|
|
3381 | 3543 | ||
3382 | name = name.replace(/-([a-z])/ig, function(all, letter){ |
3544 | name = name.replace(rdashAlpha, fcamelCase); |
3383 | return letter.toUpperCase(); |
- | |
3384 | }); |
- | |
3385 | 3545 | ||
3386 | if ( set ) |
3546 | if ( set ) { |
3387 | style[ name ] = value; |
3547 | style[ name ] = value; |
- | 3548 | }
|
|
3388 | 3549 | ||
3389 | return style[ name ]; |
3550 | return style[ name ]; |
3390 | }, |
3551 | }, |
3391 | 3552 | ||
3392 | css: function( elem, name, force, extra ) { |
3553 | css: function( elem, name, force, extra ) { |
3393 | if ( name == "width" || name == "height" ) { |
3554 | if ( name === "width" || name === "height" ) { |
3394 | var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; |
3555 | var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name === "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; |
3395 | 3556 | ||
3396 | function getWH() { |
3557 | function getWH() { |
3397 | val = name == "width" ? elem.offsetWidth : elem.offsetHeight; |
3558 | val = name === "width" ? elem.offsetWidth : elem.offsetHeight; |
3398 | 3559 | ||
3399 | if ( extra === "border" ) |
3560 | if ( extra === "border" ) { return; } |
3400 | return; |
- | |
3401 | 3561 | ||
3402 | jQuery.each( which, function() { |
3562 | jQuery.each( which, function() { |
3403 | if ( !extra ) |
3563 | if ( !extra ) { |
3404 | val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
3564 | val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
- | 3565 | }
|
|
- | 3566 | ||
3405 | if ( extra === "margin" ) |
3567 | if ( extra === "margin" ) { |
3406 | val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; |
3568 | val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; |
3407 | else
|
3569 | } else { |
3408 | val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
3570 | val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
- | 3571 | }
|
|
3409 | }); |
3572 | }); |
3410 | }
|
3573 | }
|
3411 | 3574 | ||
3412 | if ( elem.offsetWidth !== 0 ) |
3575 | if ( elem.offsetWidth !== 0 ) { |
3413 | getWH(); |
3576 | getWH(); |
3414 | else
|
3577 | } else { |
3415 | jQuery.swap( elem, props, getWH ); |
3578 | jQuery.swap( elem, props, getWH ); |
- | 3579 | }
|
|
3416 | 3580 | ||
3417 | return Math.max(0, Math.round(val)); |
3581 | return Math.max(0, Math.round(val)); |
3418 | }
|
3582 | }
|
3419 | 3583 | ||
3420 | return jQuery.curCSS( elem, name, force ); |
3584 | return jQuery.curCSS( elem, name, force ); |
3421 | }, |
3585 | }, |
3422 | 3586 | ||
3423 | curCSS: function( elem, name, force ) { |
3587 | curCSS: function( elem, name, force ) { |
3424 | var ret, style = elem.style, filter; |
3588 | var ret, style = elem.style, filter; |
3425 | 3589 | ||
3426 | // IE uses filters for opacity
|
3590 | // IE uses filters for opacity
|
3427 | if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) { |
3591 | if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) { |
3428 | ret = (elem.currentStyle.filter || "").match(/opacity=([^)]*)/) ? |
3592 | ret = ropacity.test(elem.currentStyle.filter || "") ? |
3429 | (parseFloat(RegExp.$1) / 100) + "" : |
3593 | (parseFloat(RegExp.$1) / 100) + "" : |
3430 | ""; |
3594 | ""; |
3431 | 3595 | ||
3432 | return ret === "" ? |
3596 | return ret === "" ? |
3433 | "1" : |
3597 | "1" : |
3434 | ret;
|
3598 | ret;
|
3435 | }
|
3599 | }
|
3436 | 3600 | ||
3437 | // Make sure we're using the right name for getting the float value
|
3601 | // Make sure we're using the right name for getting the float value
|
3438 | if ( /float/i.test( name ) ) |
3602 | if ( rfloat.test( name ) ) { |
3439 | name = styleFloat; |
3603 | name = styleFloat; |
- | 3604 | }
|
|
3440 | 3605 | ||
3441 | if ( !force && style && style[ name ] ) { |
3606 | if ( !force && style && style[ name ] ) { |
3442 | ret = style[ name ]; |
3607 | ret = style[ name ]; |
3443 | 3608 | ||
3444 | } else if ( getComputedStyle ) { |
3609 | } else if ( getComputedStyle ) { |
3445 | 3610 | ||
3446 | // Only "float" is needed here
|
3611 | // Only "float" is needed here
|
3447 | if ( /float/i.test( name ) ) |
3612 | if ( rfloat.test( name ) ) { |
3448 | name = "float"; |
3613 | name = "float"; |
- | 3614 | }
|
|
3449 | 3615 | ||
3450 | name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); |
3616 | name = name.replace( rupper, "-$1" ).toLowerCase(); |
3451 | 3617 | ||
3452 | var computedStyle = elem.ownerDocument.defaultView.getComputedStyle( elem, null ); |
3618 | var computedStyle = elem.ownerDocument.defaultView.getComputedStyle( elem, null ); |
3453 | 3619 | ||
3454 | if ( computedStyle ) |
3620 | if ( computedStyle ) { |
3455 | ret = computedStyle.getPropertyValue( name ); |
3621 | ret = computedStyle.getPropertyValue( name ); |
- | 3622 | }
|
|
3456 | 3623 | ||
3457 | // We should always get a number back from opacity
|
3624 | // We should always get a number back from opacity
|
3458 | if ( name == "opacity" && ret == "" ) |
3625 | if ( name === "opacity" && ret === "" ) { |
3459 | ret = "1"; |
3626 | ret = "1"; |
- | 3627 | }
|
|
3460 | 3628 | ||
3461 | } else if ( elem.currentStyle ) { |
3629 | } else if ( elem.currentStyle ) { |
3462 | var camelCase = name.replace(/\-(\w)/g, function(all, letter){ |
3630 | var camelCase = name.replace(rdashAlpha, fcamelCase); |
3463 | return letter.toUpperCase(); |
- | |
3464 | }); |
- | |
3465 | 3631 | ||
3466 | ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; |
3632 | ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; |
3467 | 3633 | ||
3468 | // From the awesome hack by Dean Edwards
|
3634 | // From the awesome hack by Dean Edwards
|
3469 | // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
3635 | // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
3470 | 3636 | ||
3471 | // If we're not dealing with a regular pixel number
|
3637 | // If we're not dealing with a regular pixel number
|
3472 | // but a number that has a weird ending, we need to convert it to pixels
|
3638 | // but a number that has a weird ending, we need to convert it to pixels
|
3473 | if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { |
3639 | if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { |
3474 | // Remember the original values
|
3640 | // Remember the original values
|
3475 | var left = style.left, rsLeft = elem.runtimeStyle.left; |
3641 | var left = style.left, rsLeft = elem.runtimeStyle.left; |
3476 | 3642 | ||
3477 | // Put in the new values to get a computed value out
|
3643 | // Put in the new values to get a computed value out
|
3478 | elem.runtimeStyle.left = elem.currentStyle.left; |
3644 | elem.runtimeStyle.left = elem.currentStyle.left; |
3479 | style.left = ret || 0; |
3645 | style.left = ret || 0; |
3480 | ret = style.pixelLeft + "px"; |
3646 | ret = style.pixelLeft + "px"; |
3481 | 3647 | ||
3482 | // Revert the changed values
|
3648 | // Revert the changed values
|
3483 | style.left = left; |
3649 | style.left = left; |
3484 | elem.runtimeStyle.left = rsLeft; |
3650 | elem.runtimeStyle.left = rsLeft; |
3485 | }
|
3651 | }
|
3486 | }
|
3652 | }
|
3487 | 3653 | ||
3488 | return ret; |
3654 | return ret; |
3489 | }, |
3655 | }, |
3490 | 3656 | ||
3491 | // A method for quickly swapping in/out CSS properties to get correct calculations
|
3657 | // A method for quickly swapping in/out CSS properties to get correct calculations
|
3492 | swap: function( elem, options, callback ) { |
3658 | swap: function( elem, options, callback ) { |
3493 | var old = {}; |
3659 | var old = {}; |
- | 3660 | ||
3494 | // Remember the old values, and insert the new ones
|
3661 | // Remember the old values, and insert the new ones
|
3495 | for ( var name in options ) { |
3662 | for ( var name in options ) { |
3496 | old[ name ] = elem.style[ name ]; |
3663 | old[ name ] = elem.style[ name ]; |
3497 | elem.style[ name ] = options[ name ]; |
3664 | elem.style[ name ] = options[ name ]; |
3498 | }
|
3665 | }
|
3499 | 3666 | ||
3500 | callback.call( elem ); |
3667 | callback.call( elem ); |
3501 | 3668 | ||
3502 | // Revert the old values
|
3669 | // Revert the old values
|
3503 | for ( var name in options ) |
3670 | for ( var name in options ) { |
3504 | elem.style[ name ] = old[ name ]; |
3671 | elem.style[ name ] = old[ name ]; |
- | 3672 | }
|
|
3505 | }
|
3673 | }
|
- | 3674 | }); |
|
- | 3675 | var jsc = now(), |
|
- | 3676 | rscript = /<script(.|\s)*?\/script>/g, |
|
- | 3677 | rselectTextarea = /select|textarea/i, |
|
- | 3678 | rinput = /text|hidden|password|search/i, |
|
- | 3679 | jsre = /=\?(&|$)/, |
|
- | 3680 | rquery = /\?/, |
|
- | 3681 | rts = /(\?|&)_=.*?(&|$)/, |
|
- | 3682 | rurl = /^(\w+:)?\/\/([^\/?#]+)/, |
|
- | 3683 | r20 = /%20/g; |
|
- | 3684 | ||
3506 | });jQuery.fn.extend({ |
3685 | jQuery.fn.extend({ |
3507 | // Keep a copy of the old load
|
3686 | // Keep a copy of the old load
|
3508 | _load: jQuery.fn.load, |
3687 | _load: jQuery.fn.load, |
3509 | 3688 | ||
3510 | load: function( url, params, callback ) { |
3689 | load: function( url, params, callback ) { |
3511 | if ( typeof url !== "string" ) |
3690 | if ( typeof url !== "string" ) { |
3512 | return this._load( url ); |
3691 | return this._load( url ); |
- | 3692 | }
|
|
3513 | 3693 | ||
3514 | var off = url.indexOf(" "); |
3694 | var off = url.indexOf(" "); |
3515 | if ( off >= 0 ) { |
3695 | if ( off >= 0 ) { |
3516 | var selector = url.slice(off, url.length); |
3696 | var selector = url.slice(off, url.length); |
3517 | url = url.slice(0, off); |
3697 | url = url.slice(0, off); |
3518 | }
|
3698 | }
|
3519 | 3699 | ||
3520 | // Default to a GET request
|
3700 | // Default to a GET request
|
3521 | var type = "GET"; |
3701 | var type = "GET"; |
3522 | 3702 | ||
3523 | // If the second parameter was provided
|
3703 | // If the second parameter was provided
|
3524 | if ( params ) |
3704 | if ( params ) { |
3525 | // If it's a function
|
3705 | // If it's a function
|
3526 | if ( jQuery.isFunction( params ) ) { |
3706 | if ( jQuery.isFunction( params ) ) { |
3527 | // We assume that it's the callback
|
3707 | // We assume that it's the callback
|
3528 | callback = params; |
3708 | callback = params; |
3529 | params = null; |
3709 | params = null; |
3530 | 3710 | ||
3531 | // Otherwise, build a param string
|
3711 | // Otherwise, build a param string
|
3532 | } else if( typeof params === "object" ) { |
3712 | } else if ( typeof params === "object" ) { |
3533 | params = jQuery.param( params ); |
3713 | params = jQuery.param( params ); |
3534 | type = "POST"; |
3714 | type = "POST"; |
3535 | }
|
3715 | }
|
- | 3716 | }
|
|
3536 | 3717 | ||
3537 | var self = this; |
3718 | var self = this; |
3538 | 3719 | ||
3539 | // Request the remote document
|
3720 | // Request the remote document
|
3540 | jQuery.ajax({ |
3721 | jQuery.ajax({ |
3541 | url: url, |
3722 | url: url, |
3542 | type: type, |
3723 | type: type, |
3543 | dataType: "html", |
3724 | dataType: "html", |
3544 | data: params, |
3725 | data: params, |
3545 | complete: function(res, status){ |
3726 | complete: function(res, status){ |
3546 | // If successful, inject the HTML into all the matched elements
|
3727 | // If successful, inject the HTML into all the matched elements
|
3547 | if ( status == "success" || status == "notmodified" ) |
3728 | if ( status === "success" || status === "notmodified" ) { |
3548 | // See if a selector was specified
|
3729 | // See if a selector was specified
|
3549 | self.html( selector ? |
3730 | self.html( selector ? |
3550 | // Create a dummy div to hold the results
|
3731 | // Create a dummy div to hold the results
|
3551 | jQuery("<div/>") |
3732 | jQuery("<div/>") |
3552 | // inject the contents of the document in, removing the scripts
|
3733 | // inject the contents of the document in, removing the scripts
|
3553 | // to avoid any 'Permission Denied' errors in IE
|
3734 | // to avoid any 'Permission Denied' errors in IE
|
3554 | .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, "")) |
3735 | .append(res.responseText.replace(rscript, "")) |
3555 | 3736 | ||
3556 | // Locate the specified elements
|
3737 | // Locate the specified elements
|
3557 | .find(selector) : |
3738 | .find(selector) : |
3558 | 3739 | ||
3559 | // If not, just inject the full result
|
3740 | // If not, just inject the full result
|
3560 | res.responseText ); |
3741 | res.responseText ); |
- | 3742 | }
|
|
3561 | 3743 | ||
3562 | if( callback ) |
3744 | if ( callback ) { |
3563 | self.each( callback, [res.responseText, status, res] ); |
3745 | self.each( callback, [res.responseText, status, res] ); |
- | 3746 | }
|
|
3564 | }
|
3747 | }
|
3565 | }); |
3748 | }); |
- | 3749 | ||
3566 | return this; |
3750 | return this; |
3567 | }, |
3751 | }, |
3568 | 3752 | ||
3569 | serialize: function() { |
3753 | serialize: function() { |
3570 | return jQuery.param(this.serializeArray()); |
3754 | return jQuery.param(this.serializeArray()); |
3571 | }, |
3755 | }, |
3572 | serializeArray: function() { |
3756 | serializeArray: function() { |
3573 | return this.map(function(){ |
3757 | return this.map(function(){ |
3574 | return this.elements ? jQuery.makeArray(this.elements) : this; |
3758 | return this.elements ? jQuery.makeArray(this.elements) : this; |
3575 | }) |
3759 | }) |
3576 | .filter(function(){ |
3760 | .filter(function(){ |
3577 | return this.name && !this.disabled && |
3761 | return this.name && !this.disabled && |
3578 | (this.checked || /select|textarea/i.test(this.nodeName) || |
3762 | (this.checked || rselectTextarea.test(this.nodeName) || |
3579 | /text|hidden|password|search/i.test(this.type)); |
3763 | rinput.test(this.type)); |
3580 | }) |
3764 | }) |
3581 | .map(function(i, elem){ |
3765 | .map(function(i, elem){ |
3582 | var val = jQuery(this).val(); |
3766 | var val = jQuery(this).val(); |
- | 3767 | ||
3583 | return val == null ? null : |
3768 | return val == null ? |
- | 3769 | null : |
|
3584 | jQuery.isArray(val) ? |
3770 | jQuery.isArray(val) ? |
3585 | jQuery.map( val, function(val, i){ |
3771 | jQuery.map( val, function(val, i){ |
3586 | return {name: elem.name, value: val}; |
3772 | return {name: elem.name, value: val}; |
3587 | }) : |
3773 | }) : |
3588 | {name: elem.name, value: val}; |
3774 | {name: elem.name, value: val}; |
3589 | }).get(); |
3775 | }).get(); |
3590 | }
|
3776 | }
|
3591 | }); |
3777 | }); |
3592 | 3778 | ||
3593 | // Attach a bunch of functions for handling common AJAX events
|
3779 | // Attach a bunch of functions for handling common AJAX events
|
3594 | jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){ |
3780 | jQuery.each( "ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","), function(i,o){ |
3595 | jQuery.fn[o] = function(f){ |
3781 | jQuery.fn[o] = function(f){ |
3596 | return this.bind(o, f); |
3782 | return this.bind(o, f); |
3597 | }; |
3783 | }; |
3598 | }); |
3784 | }); |
3599 | 3785 | ||
3600 | var jsc = now(); |
- | |
3601 | - | ||
3602 | jQuery.extend({ |
3786 | jQuery.extend({ |
3603 | 3787 | ||
3604 | get: function( url, data, callback, type ) { |
3788 | get: function( url, data, callback, type ) { |
3605 | // shift arguments if data argument was ommited
|
3789 | // shift arguments if data argument was ommited
|
3606 | if ( jQuery.isFunction( data ) ) { |
3790 | if ( jQuery.isFunction( data ) ) { |
3607 | callback = data; |
3791 | callback = data; |
3608 | data = null; |
3792 | data = null; |
3609 | }
|
3793 | }
|
3610 | 3794 | ||
3611 | return jQuery.ajax({ |
3795 | return jQuery.ajax({ |
3612 | type: "GET", |
3796 | type: "GET", |
3613 | url: url, |
3797 | url: url, |
3614 | data: data, |
3798 | data: data, |
3615 | success: callback, |
3799 | success: callback, |
3616 | dataType: type
|
3800 | dataType: type
|
3617 | }); |
3801 | }); |
3618 | }, |
3802 | }, |
3619 | 3803 | ||
3620 | getScript: function( url, callback ) { |
3804 | getScript: function( url, callback ) { |
3621 | return jQuery.get(url, null, callback, "script"); |
3805 | return jQuery.get(url, null, callback, "script"); |
3622 | }, |
3806 | }, |
3623 | 3807 | ||
3624 | getJSON: function( url, data, callback ) { |
3808 | getJSON: function( url, data, callback ) { |
3625 | return jQuery.get(url, data, callback, "json"); |
3809 | return jQuery.get(url, data, callback, "json"); |
3626 | }, |
3810 | }, |
3627 | 3811 | ||
3628 | post: function( url, data, callback, type ) { |
3812 | post: function( url, data, callback, type ) { |
3629 | if ( jQuery.isFunction( data ) ) { |
3813 | if ( jQuery.isFunction( data ) ) { |
3630 | callback = data; |
3814 | callback = data; |
3631 | data = {}; |
3815 | data = {}; |
3632 | }
|
3816 | }
|
3633 | 3817 | ||
3634 | return jQuery.ajax({ |
3818 | return jQuery.ajax({ |
3635 | type: "POST", |
3819 | type: "POST", |
3636 | url: url, |
3820 | url: url, |
3637 | data: data, |
3821 | data: data, |
3638 | success: callback, |
3822 | success: callback, |
3639 | dataType: type
|
3823 | dataType: type
|
3640 | }); |
3824 | }); |
3641 | }, |
3825 | }, |
3642 | 3826 | ||
3643 | ajaxSetup: function( settings ) { |
3827 | ajaxSetup: function( settings ) { |
3644 | jQuery.extend( jQuery.ajaxSettings, settings ); |
3828 | jQuery.extend( jQuery.ajaxSettings, settings ); |
3645 | }, |
3829 | }, |
3646 | 3830 | ||
3647 | ajaxSettings: { |
3831 | ajaxSettings: { |
3648 | url: location.href, |
3832 | url: location.href, |
3649 | global: true, |
3833 | global: true, |
3650 | type: "GET", |
3834 | type: "GET", |
3651 | contentType: "application/x-www-form-urlencoded", |
3835 | contentType: "application/x-www-form-urlencoded", |
3652 | processData: true, |
3836 | processData: true, |
3653 | async: true, |
3837 | async: true, |
3654 | /*
|
3838 | /*
|
3655 | timeout: 0,
|
3839 | timeout: 0,
|
3656 | data: null,
|
3840 | data: null,
|
3657 | username: null,
|
3841 | username: null,
|
3658 | password: null,
|
3842 | password: null,
|
3659 | */
|
3843 | */
|
3660 | // Create the request object; Microsoft failed to properly
|
3844 | // Create the request object; Microsoft failed to properly
|
3661 | // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
|
3845 | // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
|
3662 | // This function can be overriden by calling jQuery.ajaxSetup
|
3846 | // This function can be overriden by calling jQuery.ajaxSetup
|
3663 | xhr:function(){ |
3847 | xhr: function(){ |
- | 3848 | return window.ActiveXObject ? |
|
3664 | return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); |
3849 | new ActiveXObject("Microsoft.XMLHTTP") : |
- | 3850 | new XMLHttpRequest(); |
|
3665 | }, |
3851 | }, |
3666 | accepts: { |
3852 | accepts: { |
3667 | xml: "application/xml, text/xml", |
3853 | xml: "application/xml, text/xml", |
3668 | html: "text/html", |
3854 | html: "text/html", |
3669 | script: "text/javascript, application/javascript", |
3855 | script: "text/javascript, application/javascript", |
3670 | json: "application/json, text/javascript", |
3856 | json: "application/json, text/javascript", |
3671 | text: "text/plain", |
3857 | text: "text/plain", |
3672 | _default: "*/*" |
3858 | _default: "*/*" |
3673 | }
|
3859 | }
|
3674 | }, |
3860 | }, |
3675 | 3861 | ||
3676 | // Last-Modified header cache for next request
|
3862 | // Last-Modified header cache for next request
|
3677 | lastModified: {}, |
3863 | lastModified: {}, |
3678 | etag: {}, |
3864 | etag: {}, |
3679 | 3865 | ||
3680 | ajax: function( s ) { |
3866 | ajax: function( s ) { |
3681 | // Extend the settings, but re-extend 's' so that it can be
|
3867 | // Extend the settings, but re-extend 's' so that it can be
|
3682 | // checked again later (in the test suite, specifically)
|
3868 | // checked again later (in the test suite, specifically)
|
3683 | s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); |
3869 | s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); |
3684 | 3870 | ||
3685 | var jsonp, jsre = /=\?(&|$)/g, status, data, |
3871 | var jsonp, status, data, |
3686 | type = s.type.toUpperCase(); |
3872 | type = s.type.toUpperCase(); |
3687 | 3873 | ||
3688 | // convert data if not already a string
|
3874 | // convert data if not already a string
|
3689 | if ( s.data && s.processData && typeof s.data !== "string" ) |
3875 | if ( s.data && s.processData && typeof s.data !== "string" ) { |
3690 | s.data = jQuery.param(s.data); |
3876 | s.data = jQuery.param(s.data); |
- | 3877 | }
|
|
3691 | 3878 | ||
3692 | // Handle JSONP Parameter Callbacks
|
3879 | // Handle JSONP Parameter Callbacks
|
3693 | if ( s.dataType == "jsonp" ) { |
3880 | if ( s.dataType === "jsonp" ) { |
3694 | if ( type == "GET" ) { |
3881 | if ( type === "GET" ) { |
3695 | if ( !s.url.match(jsre) ) |
3882 | if ( !jsre.test( s.url ) ) { |
3696 | s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
3883 | s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
- | 3884 | }
|
|
3697 | } else if ( !s.data || !s.data.match(jsre) ) |
3885 | } else if ( !s.data || !jsre.test(s.data) ) { |
3698 | s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
3886 | s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
- | 3887 | }
|
|
3699 | s.dataType = "json"; |
3888 | s.dataType = "json"; |
3700 | }
|
3889 | }
|
3701 | 3890 | ||
3702 | // Build temporary JSONP function
|
3891 | // Build temporary JSONP function
|
3703 | if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) { |
3892 | if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) { |
3704 | jsonp = "jsonp" + jsc++; |
3893 | jsonp = "jsonp" + jsc++; |
3705 | 3894 | ||
3706 | // Replace the =? sequence both in the query string and the data
|
3895 | // Replace the =? sequence both in the query string and the data
|
3707 | if ( s.data ) |
3896 | if ( s.data ) { |
3708 | s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
3897 | s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
- | 3898 | }
|
|
- | 3899 | ||
3709 | s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
3900 | s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
3710 | 3901 | ||
3711 | // We need to make sure
|
3902 | // We need to make sure
|
3712 | // that a JSONP style response is executed properly
|
3903 | // that a JSONP style response is executed properly
|
3713 | s.dataType = "script"; |
3904 | s.dataType = "script"; |
3714 | 3905 | ||
3715 | // Handle JSONP-style loading
|
3906 | // Handle JSONP-style loading
|
3716 | window[ jsonp ] = function(tmp){ |
3907 | window[ jsonp ] = function(tmp){ |
3717 | data = tmp; |
3908 | data = tmp; |
3718 | success(); |
3909 | success(); |
3719 | complete(); |
3910 | complete(); |
3720 | // Garbage collect
|
3911 | // Garbage collect
|
3721 | window[ jsonp ] = undefined; |
3912 | window[ jsonp ] = undefined; |
3722 | try{ delete window[ jsonp ]; } catch(e){} |
3913 | try{ delete window[ jsonp ]; } catch(e){} |
3723 | if ( head ) |
3914 | if ( head ) { |
3724 | head.removeChild( script ); |
3915 | head.removeChild( script ); |
- | 3916 | }
|
|
3725 | }; |
3917 | }; |
3726 | }
|
3918 | }
|
3727 | 3919 | ||
3728 | if ( s.dataType == "script" && s.cache == null ) |
3920 | if ( s.dataType === "script" && s.cache === null ) { |
3729 | s.cache = false; |
3921 | s.cache = false; |
- | 3922 | }
|
|
3730 | 3923 | ||
3731 | if ( s.cache === false && type == "GET" ) { |
3924 | if ( s.cache === false && type === "GET" ) { |
3732 | var ts = now(); |
3925 | var ts = now(); |
- | 3926 | ||
3733 | // try replacing _= if it is there
|
3927 | // try replacing _= if it is there
|
3734 | var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2"); |
3928 | var ret = s.url.replace(rts, "$1_=" + ts + "$2"); |
- | 3929 | ||
3735 | // if nothing was replaced, add timestamp to the end
|
3930 | // if nothing was replaced, add timestamp to the end
|
3736 | s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : ""); |
3931 | s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : ""); |
3737 | }
|
3932 | }
|
3738 | 3933 | ||
3739 | // If data is available, append data to url for get requests
|
3934 | // If data is available, append data to url for get requests
|
3740 | if ( s.data && type == "GET" ) { |
3935 | if ( s.data && type === "GET" ) { |
3741 | s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; |
3936 | s.url += (rquery.test(s.url) ? "&" : "?") + s.data; |
3742 | }
|
3937 | }
|
3743 | 3938 | ||
3744 | // Watch for a new set of requests
|
3939 | // Watch for a new set of requests
|
3745 | if ( s.global && ! jQuery.active++ ) |
3940 | if ( s.global && ! jQuery.active++ ) { |
3746 | jQuery.event.trigger( "ajaxStart" ); |
3941 | jQuery.event.trigger( "ajaxStart" ); |
- | 3942 | }
|
|
3747 | 3943 | ||
3748 | // Matches an absolute URL, and saves the domain
|
3944 | // Matches an absolute URL, and saves the domain
|
3749 | var parts = /^(\w+:)?\/\/([^\/?#]+)/.exec( s.url ); |
3945 | var parts = rurl.exec( s.url ); |
3750 | 3946 | ||
3751 | // If we're requesting a remote document
|
3947 | // If we're requesting a remote document
|
3752 | // and trying to load JSON or Script with a GET
|
3948 | // and trying to load JSON or Script with a GET
|
3753 | if ( s.dataType == "script" && type == "GET" && parts |
3949 | if ( s.dataType === "script" && type === "GET" && parts |
3754 | && ( parts[1] && parts[1] != location.protocol || parts[2] != location.host )){ |
3950 | && ( parts[1] && parts[1] !== location.protocol || parts[2] !== location.host )) { |
3755 | 3951 | ||
3756 | var head = document.getElementsByTagName("head")[0]; |
3952 | var head = document.getElementsByTagName("head")[0]; |
3757 | var script = document.createElement("script"); |
3953 | var script = document.createElement("script"); |
3758 | script.src = s.url; |
3954 | script.src = s.url; |
3759 | if (s.scriptCharset) |
3955 | if ( s.scriptCharset ) { |
3760 | script.charset = s.scriptCharset; |
3956 | script.charset = s.scriptCharset; |
- | 3957 | }
|
|
3761 | 3958 | ||
3762 | // Handle Script loading
|
3959 | // Handle Script loading
|
3763 | if ( !jsonp ) { |
3960 | if ( !jsonp ) { |
3764 | var done = false; |
3961 | var done = false; |
3765 | 3962 | ||
3766 | // Attach handlers for all browsers
|
3963 | // Attach handlers for all browsers
|
3767 | script.onload = script.onreadystatechange = function(){ |
3964 | script.onload = script.onreadystatechange = function(){ |
3768 | if ( !done && (!this.readyState || |
3965 | if ( !done && (!this.readyState || |
3769 | this.readyState == "loaded" || this.readyState == "complete") ) { |
3966 | this.readyState === "loaded" || this.readyState === "complete") ) { |
3770 | done = true; |
3967 | done = true; |
3771 | success(); |
3968 | success(); |
3772 | complete(); |
3969 | complete(); |
3773 | 3970 | ||
3774 | // Handle memory leak in IE
|
3971 | // Handle memory leak in IE
|
3775 | script.onload = script.onreadystatechange = null; |
3972 | script.onload = script.onreadystatechange = null; |
- | 3973 | if ( head && script.parentNode ) { |
|
3776 | head.removeChild( script ); |
3974 | head.removeChild( script ); |
- | 3975 | }
|
|
3777 | }
|
3976 | }
|
3778 | }; |
3977 | }; |
3779 | }
|
3978 | }
|
3780 | 3979 | ||
3781 | // Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
3980 | // Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
3782 | // This arises when a base node is used (#2709 and #4378).
|
3981 | // This arises when a base node is used (#2709 and #4378).
|
3783 | head.insertBefore( script, head.firstChild ); |
3982 | head.insertBefore( script, head.firstChild ); |
3784 | 3983 | ||
3785 | // We handle everything using the script element injection
|
3984 | // We handle everything using the script element injection
|
3786 | return undefined; |
3985 | return undefined; |
3787 | }
|
3986 | }
|
3788 | 3987 | ||
3789 | var requestDone = false; |
3988 | var requestDone = false; |
3790 | 3989 | ||
3791 | // Create the request object
|
3990 | // Create the request object
|
3792 | var xhr = s.xhr(); |
3991 | var xhr = s.xhr(); |
3793 | 3992 | ||
3794 | // Open the socket
|
3993 | // Open the socket
|
3795 | // Passing null username, generates a login popup on Opera (#2865)
|
3994 | // Passing null username, generates a login popup on Opera (#2865)
|
3796 | if( s.username ) |
3995 | if ( s.username ) { |
3797 | xhr.open(type, s.url, s.async, s.username, s.password); |
3996 | xhr.open(type, s.url, s.async, s.username, s.password); |
3798 | else
|
3997 | } else { |
3799 | xhr.open(type, s.url, s.async); |
3998 | xhr.open(type, s.url, s.async); |
- | 3999 | }
|
|
3800 | 4000 | ||
3801 | // Need an extra try/catch for cross domain requests in Firefox 3
|
4001 | // Need an extra try/catch for cross domain requests in Firefox 3
|
3802 | try { |
4002 | try { |
3803 | // Set the correct header, if data is being sent
|
4003 | // Set the correct header, if data is being sent
|
3804 | if ( s.data ) |
4004 | if ( s.data ) { |
3805 | xhr.setRequestHeader("Content-Type", s.contentType); |
4005 | xhr.setRequestHeader("Content-Type", s.contentType); |
- | 4006 | }
|
|
3806 | 4007 | ||
3807 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
4008 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
3808 | if ( s.ifModified ) { |
4009 | if ( s.ifModified ) { |
3809 | if (jQuery.lastModified[s.url]) |
4010 | if ( jQuery.lastModified[s.url] ) { |
3810 | xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]); |
4011 | xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]); |
- | 4012 | }
|
|
- | 4013 | ||
3811 | if (jQuery.etag[s.url]) |
4014 | if ( jQuery.etag[s.url] ) { |
3812 | xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]); |
4015 | xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]); |
- | 4016 | }
|
|
3813 | }
|
4017 | }
|
3814 | 4018 | ||
3815 | // Set header so the called script knows that it's an XMLHttpRequest
|
4019 | // Set header so the called script knows that it's an XMLHttpRequest
|
3816 | xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
4020 | xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
3817 | 4021 | ||
3818 | // Set the Accepts header for the server, depending on the dataType
|
4022 | // Set the Accepts header for the server, depending on the dataType
|
3819 | xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ? |
4023 | xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ? |
3820 | s.accepts[ s.dataType ] + ", */*" : |
4024 | s.accepts[ s.dataType ] + ", */*" : |
3821 | s.accepts._default ); |
4025 | s.accepts._default ); |
3822 | } catch(e){} |
4026 | } catch(e){} |
3823 | 4027 | ||
3824 | // Allow custom headers/mimetypes and early abort
|
4028 | // Allow custom headers/mimetypes and early abort
|
3825 | if ( s.beforeSend && s.beforeSend(xhr, s) === false ) { |
4029 | if ( s.beforeSend && s.beforeSend(xhr, s) === false ) { |
3826 | // Handle the global AJAX counter
|
4030 | // Handle the global AJAX counter
|
3827 | if ( s.global && ! --jQuery.active ) |
4031 | if ( s.global && ! --jQuery.active ) { |
3828 | jQuery.event.trigger( "ajaxStop" ); |
4032 | jQuery.event.trigger( "ajaxStop" ); |
- | 4033 | }
|
|
- | 4034 | ||
3829 | // close opended socket
|
4035 | // close opended socket
|
3830 | xhr.abort(); |
4036 | xhr.abort(); |
3831 | return false; |
4037 | return false; |
3832 | }
|
4038 | }
|
3833 | 4039 | ||
3834 | if ( s.global ) |
4040 | if ( s.global ) { |
3835 | jQuery.event.trigger("ajaxSend", [xhr, s]); |
4041 | jQuery.event.trigger("ajaxSend", [xhr, s]); |
- | 4042 | }
|
|
3836 | 4043 | ||
3837 | // Wait for a response to come back
|
4044 | // Wait for a response to come back
|
3838 | var onreadystatechange = function(isTimeout){ |
4045 | var onreadystatechange = function(isTimeout){ |
3839 | // The request was aborted, clear the interval and decrement jQuery.active
|
4046 | // The request was aborted, clear the interval and decrement jQuery.active
|
3840 | if (xhr.readyState == 0) { |
4047 | if ( xhr.readyState === 0 ) { |
3841 | if (ival) { |
4048 | if ( ival ) { |
3842 | // clear poll interval
|
4049 | // clear poll interval
|
3843 | clearInterval(ival); |
4050 | clearInterval( ival ); |
3844 | ival = null; |
4051 | ival = null; |
- | 4052 | ||
3845 | // Handle the global AJAX counter
|
4053 | // Handle the global AJAX counter
|
3846 | if ( s.global && ! --jQuery.active ) |
4054 | if ( s.global && ! --jQuery.active ) { |
3847 | jQuery.event.trigger( "ajaxStop" ); |
4055 | jQuery.event.trigger( "ajaxStop" ); |
- | 4056 | }
|
|
3848 | }
|
4057 | }
|
- | 4058 | ||
3849 | // The transfer is complete and the data is available, or the request timed out
|
4059 | // The transfer is complete and the data is available, or the request timed out
|
3850 | } else if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) { |
4060 | } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) { |
3851 | requestDone = true; |
4061 | requestDone = true; |
3852 | 4062 | ||
3853 | // clear poll interval
|
4063 | // clear poll interval
|
3854 | if (ival) { |
4064 | if (ival) { |
3855 | clearInterval(ival); |
4065 | clearInterval(ival); |
3856 | ival = null; |
4066 | ival = null; |
3857 | }
|
4067 | }
|
3858 | 4068 | ||
3859 | status = isTimeout == "timeout" ? "timeout" : |
4069 | status = isTimeout === "timeout" ? |
- | 4070 | "timeout" : |
|
3860 | !jQuery.httpSuccess( xhr ) ? "error" : |
4071 | !jQuery.httpSuccess( xhr ) ? |
- | 4072 | "error" : |
|
3861 | s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? "notmodified" : |
4073 | s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? |
- | 4074 | "notmodified" : |
|
3862 | "success"; |
4075 | "success"; |
3863 | 4076 | ||
3864 | if ( status == "success" ) { |
4077 | if ( status === "success" ) { |
3865 | // Watch for, and catch, XML document parse errors
|
4078 | // Watch for, and catch, XML document parse errors
|
3866 | try { |
4079 | try { |
3867 | // process the data (runs the xml through httpData regardless of callback)
|
4080 | // process the data (runs the xml through httpData regardless of callback)
|
3868 | data = jQuery.httpData( xhr, s.dataType, s ); |
4081 | data = jQuery.httpData( xhr, s.dataType, s ); |
3869 | } catch(e) { |
4082 | } catch(e) { |
3870 | status = "parsererror"; |
4083 | status = "parsererror"; |
3871 | }
|
4084 | }
|
3872 | }
|
4085 | }
|
3873 | 4086 | ||
3874 | // Make sure that the request was successful or notmodified
|
4087 | // Make sure that the request was successful or notmodified
|
3875 | if ( status == "success" || status == "notmodified" ) { |
4088 | if ( status === "success" || status === "notmodified" ) { |
3876 | // JSONP handles its own success callback
|
4089 | // JSONP handles its own success callback
|
3877 | if ( !jsonp ) |
4090 | if ( !jsonp ) { |
3878 | success(); |
4091 | success(); |
- | 4092 | }
|
|
3879 | } else |
4093 | } else { |
3880 | jQuery.handleError(s, xhr, status); |
4094 | jQuery.handleError(s, xhr, status); |
- | 4095 | }
|
|
3881 | 4096 | ||
3882 | // Fire the complete handlers
|
4097 | // Fire the complete handlers
|
3883 | complete(); |
4098 | complete(); |
3884 | 4099 | ||
3885 | if ( isTimeout ) |
4100 | if ( isTimeout ) { |
3886 | xhr.abort(); |
4101 | xhr.abort(); |
- | 4102 | }
|
|
3887 | 4103 | ||
3888 | // Stop memory leaks
|
4104 | // Stop memory leaks
|
3889 | if ( s.async ) |
4105 | if ( s.async ) { |
3890 | xhr = null; |
4106 | xhr = null; |
- | 4107 | }
|
|
3891 | }
|
4108 | }
|
3892 | }; |
4109 | }; |
3893 | 4110 | ||
3894 | if ( s.async ) { |
4111 | if ( s.async ) { |
3895 | // don't attach the handler to the request, just poll it instead
|
4112 | // don't attach the handler to the request, just poll it instead
|
3896 | var ival = setInterval(onreadystatechange, 13); |
4113 | var ival = setInterval(onreadystatechange, 13); |
3897 | 4114 | ||
3898 | // Timeout checker
|
4115 | // Timeout checker
|
3899 | if ( s.timeout > 0 ) |
4116 | if ( s.timeout > 0 ) { |
3900 | setTimeout(function(){ |
4117 | setTimeout(function(){ |
3901 | // Check to see if the request is still happening
|
4118 | // Check to see if the request is still happening
|
3902 | if ( xhr && !requestDone ) |
4119 | if ( xhr && !requestDone ) { |
3903 | onreadystatechange( "timeout" ); |
4120 | onreadystatechange( "timeout" ); |
- | 4121 | }
|
|
3904 | }, s.timeout); |
4122 | }, s.timeout); |
- | 4123 | }
|
|
3905 | }
|
4124 | }
|
3906 | 4125 | ||
3907 | // Send the data
|
4126 | // Send the data
|
3908 | try { |
4127 | try { |
3909 | xhr.send( type === "POST" ? s.data : null ); |
4128 | xhr.send( type === "POST" || type === "PUT" ? s.data : null ); |
3910 | } catch(e) { |
4129 | } catch(e) { |
3911 | jQuery.handleError(s, xhr, null, e); |
4130 | jQuery.handleError(s, xhr, null, e); |
3912 | }
|
4131 | }
|
3913 | 4132 | ||
3914 | // firefox 1.5 doesn't fire statechange for sync requests
|
4133 | // firefox 1.5 doesn't fire statechange for sync requests
|
3915 | if ( !s.async ) |
4134 | if ( !s.async ) { |
3916 | onreadystatechange(); |
4135 | onreadystatechange(); |
- | 4136 | }
|
|
3917 | 4137 | ||
3918 | function success(){ |
4138 | function success(){ |
3919 | // If a local callback was specified, fire it and pass it the data
|
4139 | // If a local callback was specified, fire it and pass it the data
|
3920 | if ( s.success ) |
4140 | if ( s.success ) { |
3921 | s.success( data, status ); |
4141 | s.success( data, status ); |
- | 4142 | }
|
|
3922 | 4143 | ||
3923 | // Fire the global callback
|
4144 | // Fire the global callback
|
3924 | if ( s.global ) |
4145 | if ( s.global ) { |
3925 | jQuery.event.trigger( "ajaxSuccess", [xhr, s] ); |
4146 | jQuery.event.trigger( "ajaxSuccess", [xhr, s] ); |
- | 4147 | }
|
|
3926 | }
|
4148 | }
|
3927 | 4149 | ||
3928 | function complete(){ |
4150 | function complete(){ |
3929 | // Process result
|
4151 | // Process result
|
3930 | if ( s.complete ) |
4152 | if ( s.complete ) { |
3931 | s.complete(xhr, status); |
4153 | s.complete(xhr, status); |
- | 4154 | }
|
|
3932 | 4155 | ||
3933 | // The request was completed
|
4156 | // The request was completed
|
3934 | if ( s.global ) |
4157 | if ( s.global ) { |
3935 | jQuery.event.trigger( "ajaxComplete", [xhr, s] ); |
4158 | jQuery.event.trigger( "ajaxComplete", [xhr, s] ); |
- | 4159 | }
|
|
3936 | 4160 | ||
3937 | // Handle the global AJAX counter
|
4161 | // Handle the global AJAX counter
|
3938 | if ( s.global && ! --jQuery.active ) |
4162 | if ( s.global && ! --jQuery.active ) { |
3939 | jQuery.event.trigger( "ajaxStop" ); |
4163 | jQuery.event.trigger( "ajaxStop" ); |
- | 4164 | }
|
|
3940 | }
|
4165 | }
|
3941 | 4166 | ||
3942 | // return XMLHttpRequest to allow aborting the request etc.
|
4167 | // return XMLHttpRequest to allow aborting the request etc.
|
3943 | return xhr; |
4168 | return xhr; |
3944 | }, |
4169 | }, |
3945 | 4170 | ||
3946 | handleError: function( s, xhr, status, e ) { |
4171 | handleError: function( s, xhr, status, e ) { |
3947 | // If a local callback was specified, fire it
|
4172 | // If a local callback was specified, fire it
|
- | 4173 | if ( s.error ) { |
|
3948 | if ( s.error ) s.error( xhr, status, e ); |
4174 | s.error( xhr, status, e ); |
- | 4175 | }
|
|
3949 | 4176 | ||
3950 | // Fire the global callback
|
4177 | // Fire the global callback
|
3951 | if ( s.global ) |
4178 | if ( s.global ) { |
3952 | jQuery.event.trigger( "ajaxError", [xhr, s, e] ); |
4179 | jQuery.event.trigger( "ajaxError", [xhr, s, e] ); |
- | 4180 | }
|
|
3953 | }, |
4181 | }, |
3954 | 4182 | ||
3955 | // Counter for holding the number of active queries
|
4183 | // Counter for holding the number of active queries
|
3956 | active: 0, |
4184 | active: 0, |
3957 | 4185 | ||
3958 | // Determines if an XMLHttpRequest was successful or not
|
4186 | // Determines if an XMLHttpRequest was successful or not
|
3959 | httpSuccess: function( xhr ) { |
4187 | httpSuccess: function( xhr ) { |
3960 | try { |
4188 | try { |
3961 | // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
|
4189 | // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
|
3962 | return !xhr.status && location.protocol == "file:" || |
4190 | return !xhr.status && location.protocol === "file:" || |
- | 4191 | // Opera returns 0 when status is 304
|
|
- | 4192 | ( xhr.status >= 200 && xhr.status < 300 ) || |
|
3963 | ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223; |
4193 | xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; |
3964 | } catch(e){} |
4194 | } catch(e){} |
- | 4195 | ||
3965 | return false; |
4196 | return false; |
3966 | }, |
4197 | }, |
3967 | 4198 | ||
3968 | // Determines if an XMLHttpRequest returns NotModified
|
4199 | // Determines if an XMLHttpRequest returns NotModified
|
3969 | httpNotModified: function( xhr, url ) { |
4200 | httpNotModified: function( xhr, url ) { |
3970 | var last_modified = xhr.getResponseHeader("Last-Modified"); |
4201 | var last_modified = xhr.getResponseHeader("Last-Modified"), |
3971 | var etag = xhr.getResponseHeader("Etag"); |
4202 | etag = xhr.getResponseHeader("Etag"); |
3972 | 4203 | ||
3973 | if (last_modified) |
4204 | if ( last_modified ) { |
3974 | jQuery.lastModified[url] = last_modified; |
4205 | jQuery.lastModified[url] = last_modified; |
- | 4206 | }
|
|
3975 | 4207 | ||
3976 | if (etag) |
4208 | if ( etag ) { |
3977 | jQuery.etag[url] = etag; |
4209 | jQuery.etag[url] = etag; |
- | 4210 | }
|
|
3978 | 4211 | ||
- | 4212 | // Opera returns 0 when status is 304
|
|
3979 | return xhr.status == 304; |
4213 | return xhr.status === 304 || xhr.status === 0; |
3980 | }, |
4214 | }, |
3981 | 4215 | ||
3982 | httpData: function( xhr, type, s ) { |
4216 | httpData: function( xhr, type, s ) { |
3983 | var ct = xhr.getResponseHeader("content-type"), |
4217 | var ct = xhr.getResponseHeader("content-type"), |
3984 | xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0, |
4218 | xml = type === "xml" || !type && ct && ct.indexOf("xml") >= 0, |
3985 | data = xml ? xhr.responseXML : xhr.responseText; |
4219 | data = xml ? xhr.responseXML : xhr.responseText; |
3986 | 4220 | ||
3987 | if ( xml && data.documentElement.tagName == "parsererror" ) { |
4221 | if ( xml && data.documentElement.nodeName === "parsererror" ) { |
3988 | throw "parsererror"; |
4222 | throw "parsererror"; |
3989 | }
|
4223 | }
|
3990 | 4224 | ||
3991 | // Allow a pre-filtering function to sanitize the response
|
4225 | // Allow a pre-filtering function to sanitize the response
|
3992 | // s != null is checked to keep backwards compatibility
|
4226 | // s is checked to keep backwards compatibility
|
3993 | if ( s && s.dataFilter ) { |
4227 | if ( s && s.dataFilter ) { |
3994 | data = s.dataFilter( data, type ); |
4228 | data = s.dataFilter( data, type ); |
3995 | }
|
4229 | }
|
3996 | 4230 | ||
3997 | // The filter can actually parse the response
|
4231 | // The filter can actually parse the response
|
3998 | if ( typeof data === "string" ) { |
4232 | if ( typeof data === "string" ) { |
3999 | 4233 | ||
4000 | // If the type is "script", eval it in global context
|
4234 | // If the type is "script", eval it in global context
|
4001 | if ( type === "script" ) { |
4235 | if ( type === "script" ) { |
4002 | jQuery.globalEval( data ); |
4236 | jQuery.globalEval( data ); |
4003 | }
|
4237 | }
|
4004 | 4238 | ||
4005 | // Get the JavaScript object, if JSON is used.
|
4239 | // Get the JavaScript object, if JSON is used.
|
4006 | if ( type == "json" ) { |
4240 | if ( type === "json" ) { |
4007 | if ( typeof JSON === "object" && JSON.parse ) { |
4241 | if ( typeof JSON === "object" && JSON.parse ) { |
4008 | data = JSON.parse( data ); |
4242 | data = JSON.parse( data ); |
4009 | } else { |
4243 | } else { |
4010 | data = (new Function("return " + data))(); |
4244 | data = (new Function("return " + data))(); |
4011 | }
|
4245 | }
|
4012 | }
|
4246 | }
|
4013 | }
|
4247 | }
|
4014 | 4248 | ||
4015 | return data; |
4249 | return data; |
4016 | }, |
4250 | }, |
4017 | 4251 | ||
4018 | // Serialize an array of form elements or a set of
|
4252 | // Serialize an array of form elements or a set of
|
4019 | // key/values into a query string
|
4253 | // key/values into a query string
|
4020 | param: function( a ) { |
4254 | param: function( a ) { |
4021 | var s = [ ]; |
4255 | var s = []; |
4022 | 4256 | ||
4023 | function add( key, value ){ |
4257 | function add( key, value ){ |
4024 | s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
4258 | s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
4025 | }; |
4259 | }
|
4026 | 4260 | ||
4027 | // If an array was passed in, assume that it is an array
|
4261 | // If an array was passed in, assume that it is an array
|
4028 | // of form elements
|
4262 | // of form elements
|
4029 | if ( jQuery.isArray(a) || a.jquery ) |
4263 | if ( jQuery.isArray(a) || a.jquery ) { |
4030 | // Serialize the form elements
|
4264 | // Serialize the form elements
|
4031 | jQuery.each( a, function(){ |
4265 | jQuery.each( a, function(){ |
4032 | add( this.name, this.value ); |
4266 | add( this.name, this.value ); |
4033 | }); |
4267 | }); |
4034 | 4268 | ||
4035 | // Otherwise, assume that it's an object of key/value pairs
|
4269 | // Otherwise, assume that it's an object of key/value pairs
|
4036 | else
|
4270 | } else { |
4037 | // Serialize the key/values
|
4271 | // Serialize the key/values
|
4038 | for ( var j in a ) |
4272 | for ( var j in a ) { |
4039 | // If the value is an array then the key names need to be repeated
|
4273 | // If the value is an array then the key names need to be repeated
|
4040 | if ( jQuery.isArray(a[j]) ) |
4274 | if ( jQuery.isArray(a[j]) ) { |
4041 | jQuery.each( a[j], function(){ |
4275 | jQuery.each( a[j], function(){ |
4042 | add( j, this ); |
4276 | add( j, this ); |
4043 | }); |
4277 | }); |
4044 | else
|
4278 | } else { |
4045 | add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] ); |
4279 | add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] ); |
- | 4280 | }
|
|
- | 4281 | }
|
|
- | 4282 | }
|
|
4046 | 4283 | ||
4047 | // Return the resulting serialization
|
4284 | // Return the resulting serialization
|
4048 | return s.join("&").replace(/%20/g, "+"); |
4285 | return s.join("&").replace(r20, "+"); |
4049 | }
|
4286 | }
|
4050 | 4287 | ||
4051 | }); |
4288 | }); |
4052 | var elemdisplay = {}, |
4289 | var elemdisplay = {}, |
4053 | timerId,
|
4290 | timerId,
|
4054 | fxAttrs = [ |
4291 | fxAttrs = [ |
4055 | // height animations
|
4292 | // height animations
|
4056 | [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ], |
4293 | [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ], |
4057 | // width animations
|
4294 | // width animations
|
4058 | [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ], |
4295 | [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ], |
4059 | // opacity animations
|
4296 | // opacity animations
|
4060 | [ "opacity" ] |
4297 | [ "opacity" ] |
4061 | ]; |
4298 | ]; |
4062 | 4299 | ||
4063 | function genFx( type, num ){ |
4300 | function genFx( type, num ){ |
4064 | var obj = {}; |
4301 | var obj = {}; |
4065 | jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function(){ |
4302 | jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function(){ |
4066 | obj[ this ] = type; |
4303 | obj[ this ] = type; |
4067 | }); |
4304 | }); |
4068 | return obj; |
4305 | return obj; |
4069 | }
|
4306 | }
|
4070 | 4307 | ||
4071 | jQuery.fn.extend({ |
4308 | jQuery.fn.extend({ |
4072 | show: function(speed,callback){ |
4309 | show: function(speed,callback){ |
4073 | if ( speed ) { |
4310 | if ( speed ) { |
4074 | return this.animate( genFx("show", 3), speed, callback); |
4311 | return this.animate( genFx("show", 3), speed, callback); |
4075 | } else { |
4312 | } else { |
4076 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4313 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4077 | var old = jQuery.data(this[i], "olddisplay"); |
4314 | var old = jQuery.data(this[i], "olddisplay"); |
4078 | 4315 | ||
4079 | this[i].style.display = old || ""; |
4316 | this[i].style.display = old || ""; |
4080 | 4317 | ||
4081 | if ( jQuery.css(this[i], "display") === "none" ) { |
4318 | if ( jQuery.css(this[i], "display") === "none" ) { |
4082 | var tagName = this[i].tagName, display; |
4319 | var nodeName = this[i].nodeName, display; |
4083 | 4320 | ||
4084 | if ( elemdisplay[ tagName ] ) { |
4321 | if ( elemdisplay[ nodeName ] ) { |
4085 | display = elemdisplay[ tagName ]; |
4322 | display = elemdisplay[ nodeName ]; |
4086 | } else { |
4323 | } else { |
4087 | var elem = jQuery("<" + tagName + " />").appendTo("body"); |
4324 | var elem = jQuery("<" + nodeName + " />").appendTo("body"); |
4088 | 4325 | ||
4089 | display = elem.css("display"); |
4326 | display = elem.css("display"); |
4090 | if ( display === "none" ) |
4327 | if ( display === "none" ) |
4091 | display = "block"; |
4328 | display = "block"; |
4092 | 4329 | ||
4093 | elem.remove(); |
4330 | elem.remove(); |
4094 | 4331 | ||
4095 | elemdisplay[ tagName ] = display; |
4332 | elemdisplay[ nodeName ] = display; |
4096 | }
|
4333 | }
|
4097 | 4334 | ||
4098 | jQuery.data(this[i], "olddisplay", display); |
4335 | jQuery.data(this[i], "olddisplay", display); |
4099 | }
|
4336 | }
|
4100 | }
|
4337 | }
|
4101 | 4338 | ||
4102 | // Set the display of the elements in a second loop
|
4339 | // Set the display of the elements in a second loop
|
4103 | // to avoid the constant reflow
|
4340 | // to avoid the constant reflow
|
4104 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4341 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4105 | this[i].style.display = jQuery.data(this[i], "olddisplay") || ""; |
4342 | this[i].style.display = jQuery.data(this[i], "olddisplay") || ""; |
4106 | }
|
4343 | }
|
4107 | 4344 | ||
4108 | return this; |
4345 | return this; |
4109 | }
|
4346 | }
|
4110 | }, |
4347 | }, |
4111 | 4348 | ||
4112 | hide: function(speed,callback){ |
4349 | hide: function(speed,callback){ |
4113 | if ( speed ) { |
4350 | if ( speed ) { |
4114 | return this.animate( genFx("hide", 3), speed, callback); |
4351 | return this.animate( genFx("hide", 3), speed, callback); |
4115 | } else { |
4352 | } else { |
4116 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4353 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4117 | var old = jQuery.data(this[i], "olddisplay"); |
4354 | var old = jQuery.data(this[i], "olddisplay"); |
4118 | if ( !old && old !== "none" ) |
4355 | if ( !old && old !== "none" ) |
4119 | jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display")); |
4356 | jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display")); |
4120 | }
|
4357 | }
|
4121 | 4358 | ||
4122 | // Set the display of the elements in a second loop
|
4359 | // Set the display of the elements in a second loop
|
4123 | // to avoid the constant reflow
|
4360 | // to avoid the constant reflow
|
4124 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4361 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4125 | this[i].style.display = "none"; |
4362 | this[i].style.display = "none"; |
4126 | }
|
4363 | }
|
4127 | 4364 | ||
4128 | return this; |
4365 | return this; |
4129 | }
|
4366 | }
|
4130 | }, |
4367 | }, |
4131 | 4368 | ||
4132 | // Save the old toggle function
|
4369 | // Save the old toggle function
|
4133 | _toggle: jQuery.fn.toggle, |
4370 | _toggle: jQuery.fn.toggle, |
4134 | 4371 | ||
4135 | toggle: function( fn, fn2 ){ |
4372 | toggle: function( fn, fn2 ){ |
4136 | var bool = typeof fn === "boolean"; |
4373 | var bool = typeof fn === "boolean"; |
4137 | 4374 | ||
4138 | return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? |
4375 | return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ? |
4139 | this._toggle.apply( this, arguments ) : |
4376 | this._toggle.apply( this, arguments ) : |
4140 | fn == null || bool ? |
4377 | fn == null || bool ? |
4141 | this.each(function(){ |
4378 | this.each(function(){ |
4142 | var state = bool ? fn : jQuery(this).is(":hidden"); |
4379 | var state = bool ? fn : jQuery(this).is(":hidden"); |
4143 | jQuery(this)[ state ? "show" : "hide" ](); |
4380 | jQuery(this)[ state ? "show" : "hide" ](); |
4144 | }) : |
4381 | }) : |
4145 | this.animate(genFx("toggle", 3), fn, fn2); |
4382 | this.animate(genFx("toggle", 3), fn, fn2); |
4146 | }, |
4383 | }, |
4147 | 4384 | ||
4148 | fadeTo: function(speed,to,callback){ |
4385 | fadeTo: function(speed,to,callback){ |
4149 | return this.filter(":hidden").css('opacity', 0).show().end() |
4386 | return this.filter(":hidden").css('opacity', 0).show().end() |
4150 | .animate({opacity: to}, speed, callback); |
4387 | .animate({opacity: to}, speed, callback); |
4151 | }, |
4388 | }, |
4152 | 4389 | ||
4153 | animate: function( prop, speed, easing, callback ) { |
4390 | animate: function( prop, speed, easing, callback ) { |
4154 | var optall = jQuery.speed(speed, easing, callback); |
4391 | var optall = jQuery.speed(speed, easing, callback); |
4155 | 4392 | ||
4156 | return this[ optall.queue === false ? "each" : "queue" ](function(){ |
4393 | return this[ optall.queue === false ? "each" : "queue" ](function(){ |
4157 | 4394 | ||
4158 | var opt = jQuery.extend({}, optall), p, |
4395 | var opt = jQuery.extend({}, optall), p, |
4159 | hidden = this.nodeType == 1 && jQuery(this).is(":hidden"), |
4396 | hidden = this.nodeType == 1 && jQuery(this).is(":hidden"), |
4160 | self = this; |
4397 | self = this; |
4161 | 4398 | ||
4162 | for ( p in prop ) { |
4399 | for ( p in prop ) { |
- | 4400 | var name = p.replace(rdashAlpha, fcamelCase); |
|
- | 4401 | ||
- | 4402 | if ( p !== name ) { |
|
- | 4403 | prop[ name ] = prop[ p ]; |
|
- | 4404 | delete prop[ p ]; |
|
- | 4405 | p = name; |
|
- | 4406 | }
|
|
- | 4407 | ||
4163 | if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) |
4408 | if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) |
4164 | return opt.complete.call(this); |
4409 | return opt.complete.call(this); |
4165 | 4410 | ||
4166 | if ( ( p == "height" || p == "width" ) && this.style ) { |
4411 | if ( ( p == "height" || p == "width" ) && this.style ) { |
4167 | // Store display property
|
4412 | // Store display property
|
4168 | opt.display = jQuery.css(this, "display"); |
4413 | opt.display = jQuery.css(this, "display"); |
4169 | 4414 | ||
4170 | // Make sure that nothing sneaks out
|
4415 | // Make sure that nothing sneaks out
|
4171 | opt.overflow = this.style.overflow; |
4416 | opt.overflow = this.style.overflow; |
4172 | }
|
4417 | }
|
4173 | }
|
4418 | }
|
4174 | 4419 | ||
4175 | if ( opt.overflow != null ) |
4420 | if ( opt.overflow != null ) |
4176 | this.style.overflow = "hidden"; |
4421 | this.style.overflow = "hidden"; |
4177 | 4422 | ||
4178 | opt.curAnim = jQuery.extend({}, prop); |
4423 | opt.curAnim = jQuery.extend({}, prop); |
4179 | 4424 | ||
4180 | jQuery.each( prop, function(name, val){ |
4425 | jQuery.each( prop, function(name, val){ |
4181 | var e = new jQuery.fx( self, opt, name ); |
4426 | var e = new jQuery.fx( self, opt, name ); |
4182 | 4427 | ||
4183 | if ( /toggle|show|hide/.test(val) ) |
4428 | if ( /toggle|show|hide/.test(val) ) |
4184 | e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
4429 | e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
4185 | else { |
4430 | else { |
4186 | var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/), |
4431 | var parts = /^([+-]=)?([\d+-.]+)(.*)$/.exec(val), |
4187 | start = e.cur(true) || 0; |
4432 | start = e.cur(true) || 0; |
4188 | 4433 | ||
4189 | if ( parts ) { |
4434 | if ( parts ) { |
4190 | var end = parseFloat(parts[2]), |
4435 | var end = parseFloat(parts[2]), |
4191 | unit = parts[3] || "px"; |
4436 | unit = parts[3] || "px"; |
4192 | 4437 | ||
4193 | // We need to compute starting value
|
4438 | // We need to compute starting value
|
4194 | if ( unit != "px" ) { |
4439 | if ( unit != "px" ) { |
4195 | self.style[ name ] = (end || 1) + unit; |
4440 | self.style[ name ] = (end || 1) + unit; |
4196 | start = ((end || 1) / e.cur(true)) * start; |
4441 | start = ((end || 1) / e.cur(true)) * start; |
4197 | self.style[ name ] = start + unit; |
4442 | self.style[ name ] = start + unit; |
4198 | }
|
4443 | }
|
4199 | 4444 | ||
4200 | // If a +=/-= token was provided, we're doing a relative animation
|
4445 | // If a +=/-= token was provided, we're doing a relative animation
|
4201 | if ( parts[1] ) |
4446 | if ( parts[1] ) |
4202 | end = ((parts[1] == "-=" ? -1 : 1) * end) + start; |
4447 | end = ((parts[1] == "-=" ? -1 : 1) * end) + start; |
4203 | 4448 | ||
4204 | e.custom( start, end, unit ); |
4449 | e.custom( start, end, unit ); |
4205 | } else |
4450 | } else |
4206 | e.custom( start, val, "" ); |
4451 | e.custom( start, val, "" ); |
4207 | }
|
4452 | }
|
4208 | }); |
4453 | }); |
4209 | 4454 | ||
4210 | // For JS strict compliance
|
4455 | // For JS strict compliance
|
4211 | return true; |
4456 | return true; |
4212 | }); |
4457 | }); |
4213 | }, |
4458 | }, |
4214 | 4459 | ||
4215 | stop: function(clearQueue, gotoEnd){ |
4460 | stop: function(clearQueue, gotoEnd){ |
4216 | var timers = jQuery.timers; |
4461 | var timers = jQuery.timers; |
4217 | 4462 | ||
4218 | if (clearQueue) |
4463 | if (clearQueue) |
4219 | this.queue([]); |
4464 | this.queue([]); |
4220 | 4465 | ||
4221 | this.each(function(){ |
4466 | this.each(function(){ |
4222 | // go in reverse order so anything added to the queue during the loop is ignored
|
4467 | // go in reverse order so anything added to the queue during the loop is ignored
|
4223 | for ( var i = timers.length - 1; i >= 0; i-- ) |
4468 | for ( var i = timers.length - 1; i >= 0; i-- ) |
4224 | if ( timers[i].elem == this ) { |
4469 | if ( timers[i].elem == this ) { |
4225 | if (gotoEnd) |
4470 | if (gotoEnd) |
4226 | // force the next step to be the last
|
4471 | // force the next step to be the last
|
4227 | timers[i](true); |
4472 | timers[i](true); |
4228 | timers.splice(i, 1); |
4473 | timers.splice(i, 1); |
4229 | }
|
4474 | }
|
4230 | }); |
4475 | }); |
4231 | 4476 | ||
4232 | // start the next in the queue if the last step wasn't forced
|
4477 | // start the next in the queue if the last step wasn't forced
|
4233 | if (!gotoEnd) |
4478 | if (!gotoEnd) |
4234 | this.dequeue(); |
4479 | this.dequeue(); |
4235 | 4480 | ||
4236 | return this; |
4481 | return this; |
4237 | }
|
4482 | }
|
4238 | 4483 | ||
4239 | }); |
4484 | }); |
4240 | 4485 | ||
4241 | // Generate shortcuts for custom animations
|
4486 | // Generate shortcuts for custom animations
|
4242 | jQuery.each({ |
4487 | jQuery.each({ |
4243 | slideDown: genFx("show", 1), |
4488 | slideDown: genFx("show", 1), |
4244 | slideUp: genFx("hide", 1), |
4489 | slideUp: genFx("hide", 1), |
4245 | slideToggle: genFx("toggle", 1), |
4490 | slideToggle: genFx("toggle", 1), |
4246 | fadeIn: { opacity: "show" }, |
4491 | fadeIn: { opacity: "show" }, |
4247 | fadeOut: { opacity: "hide" } |
4492 | fadeOut: { opacity: "hide" } |
4248 | }, function( name, props ){ |
4493 | }, function( name, props ){ |
4249 | jQuery.fn[ name ] = function( speed, callback ){ |
4494 | jQuery.fn[ name ] = function( speed, callback ){ |
4250 | return this.animate( props, speed, callback ); |
4495 | return this.animate( props, speed, callback ); |
4251 | }; |
4496 | }; |
4252 | }); |
4497 | }); |
4253 | 4498 | ||
4254 | jQuery.extend({ |
4499 | jQuery.extend({ |
4255 | 4500 | ||
4256 | speed: function(speed, easing, fn) { |
4501 | speed: function(speed, easing, fn) { |
4257 | var opt = typeof speed === "object" ? speed : { |
4502 | var opt = typeof speed === "object" ? speed : { |
4258 | complete: fn || !fn && easing || |
4503 | complete: fn || !fn && easing || |
4259 | jQuery.isFunction( speed ) && speed, |
4504 | jQuery.isFunction( speed ) && speed, |
4260 | duration: speed, |
4505 | duration: speed, |
4261 | easing: fn && easing || easing && !jQuery.isFunction(easing) && easing |
4506 | easing: fn && easing || easing && !jQuery.isFunction(easing) && easing |
4262 | }; |
4507 | }; |
4263 | 4508 | ||
4264 | opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : |
4509 | opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : |
4265 | jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default; |
4510 | jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default; |
4266 | 4511 | ||
4267 | // Queueing
|
4512 | // Queueing
|
4268 | opt.old = opt.complete; |
4513 | opt.old = opt.complete; |
4269 | opt.complete = function(){ |
4514 | opt.complete = function(){ |
4270 | if ( opt.queue !== false ) |
4515 | if ( opt.queue !== false ) |
4271 | jQuery(this).dequeue(); |
4516 | jQuery(this).dequeue(); |
4272 | if ( jQuery.isFunction( opt.old ) ) |
4517 | if ( jQuery.isFunction( opt.old ) ) |
4273 | opt.old.call( this ); |
4518 | opt.old.call( this ); |
4274 | }; |
4519 | }; |
4275 | 4520 | ||
4276 | return opt; |
4521 | return opt; |
4277 | }, |
4522 | }, |
4278 | 4523 | ||
4279 | easing: { |
4524 | easing: { |
4280 | linear: function( p, n, firstNum, diff ) { |
4525 | linear: function( p, n, firstNum, diff ) { |
4281 | return firstNum + diff * p; |
4526 | return firstNum + diff * p; |
4282 | }, |
4527 | }, |
4283 | swing: function( p, n, firstNum, diff ) { |
4528 | swing: function( p, n, firstNum, diff ) { |
4284 | return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum; |
4529 | return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum; |
4285 | }
|
4530 | }
|
4286 | }, |
4531 | }, |
4287 | 4532 | ||
4288 | timers: [], |
4533 | timers: [], |
4289 | 4534 | ||
4290 | fx: function( elem, options, prop ){ |
4535 | fx: function( elem, options, prop ){ |
4291 | this.options = options; |
4536 | this.options = options; |
4292 | this.elem = elem; |
4537 | this.elem = elem; |
4293 | this.prop = prop; |
4538 | this.prop = prop; |
4294 | 4539 | ||
4295 | if ( !options.orig ) |
4540 | if ( !options.orig ) |
4296 | options.orig = {}; |
4541 | options.orig = {}; |
4297 | }
|
4542 | }
|
4298 | 4543 | ||
4299 | }); |
4544 | }); |
4300 | 4545 | ||
4301 | jQuery.fx.prototype = { |
4546 | jQuery.fx.prototype = { |
4302 | 4547 | ||
4303 | // Simple function for setting a style value
|
4548 | // Simple function for setting a style value
|
4304 | update: function(){ |
4549 | update: function(){ |
4305 | if ( this.options.step ) |
4550 | if ( this.options.step ) |
4306 | this.options.step.call( this.elem, this.now, this ); |
4551 | this.options.step.call( this.elem, this.now, this ); |
4307 | 4552 | ||
4308 | (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); |
4553 | (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); |
4309 | 4554 | ||
4310 | // Set display property to block for height/width animations
|
4555 | // Set display property to block for height/width animations
|
4311 | if ( ( this.prop == "height" || this.prop == "width" ) && this.elem.style ) |
4556 | if ( ( this.prop == "height" || this.prop == "width" ) && this.elem.style ) |
4312 | this.elem.style.display = "block"; |
4557 | this.elem.style.display = "block"; |
4313 | }, |
4558 | }, |
4314 | 4559 | ||
4315 | // Get the current size
|
4560 | // Get the current size
|
4316 | cur: function(force){ |
4561 | cur: function(force){ |
4317 | if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) |
4562 | if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) |
4318 | return this.elem[ this.prop ]; |
4563 | return this.elem[ this.prop ]; |
4319 | 4564 | ||
4320 | var r = parseFloat(jQuery.css(this.elem, this.prop, force)); |
4565 | var r = parseFloat(jQuery.css(this.elem, this.prop, force)); |
4321 | return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0; |
4566 | return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0; |
4322 | }, |
4567 | }, |
4323 | 4568 | ||
4324 | // Start an animation from one number to another
|
4569 | // Start an animation from one number to another
|
4325 | custom: function(from, to, unit){ |
4570 | custom: function(from, to, unit){ |
4326 | this.startTime = now(); |
4571 | this.startTime = now(); |
4327 | this.start = from; |
4572 | this.start = from; |
4328 | this.end = to; |
4573 | this.end = to; |
4329 | this.unit = unit || this.unit || "px"; |
4574 | this.unit = unit || this.unit || "px"; |
4330 | this.now = this.start; |
4575 | this.now = this.start; |
4331 | this.pos = this.state = 0; |
4576 | this.pos = this.state = 0; |
4332 | 4577 | ||
4333 | var self = this; |
4578 | var self = this; |
4334 | function t(gotoEnd){ |
4579 | function t(gotoEnd){ |
4335 | return self.step(gotoEnd); |
4580 | return self.step(gotoEnd); |
4336 | }
|
4581 | }
|
4337 | 4582 | ||
4338 | t.elem = this.elem; |
4583 | t.elem = this.elem; |
4339 | 4584 | ||
4340 | if ( t() && jQuery.timers.push(t) && !timerId ) |
4585 | if ( t() && jQuery.timers.push(t) && !timerId ) |
4341 | timerId = setInterval(jQuery.fx.tick, 13); |
4586 | timerId = setInterval(jQuery.fx.tick, 13); |
4342 | }, |
4587 | }, |
4343 | 4588 | ||
4344 | // Simple 'show' function
|
4589 | // Simple 'show' function
|
4345 | show: function(){ |
4590 | show: function(){ |
4346 | // Remember where we started, so that we can go back to it later
|
4591 | // Remember where we started, so that we can go back to it later
|
4347 | this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); |
4592 | this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); |
4348 | this.options.show = true; |
4593 | this.options.show = true; |
4349 | 4594 | ||
4350 | // Begin the animation
|
4595 | // Begin the animation
|
4351 | // Make sure that we start at a small width/height to avoid any
|
4596 | // Make sure that we start at a small width/height to avoid any
|
4352 | // flash of content
|
4597 | // flash of content
|
4353 | this.custom(this.prop == "width" || this.prop == "height" ? 1 : 0, this.cur()); |
4598 | this.custom(this.prop == "width" || this.prop == "height" ? 1 : 0, this.cur()); |
4354 | 4599 | ||
4355 | // Start by showing the element
|
4600 | // Start by showing the element
|
4356 | jQuery(this.elem).show(); |
4601 | jQuery(this.elem).show(); |
4357 | }, |
4602 | }, |
4358 | 4603 | ||
4359 | // Simple 'hide' function
|
4604 | // Simple 'hide' function
|
4360 | hide: function(){ |
4605 | hide: function(){ |
4361 | // Remember where we started, so that we can go back to it later
|
4606 | // Remember where we started, so that we can go back to it later
|
4362 | this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); |
4607 | this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); |
4363 | this.options.hide = true; |
4608 | this.options.hide = true; |
4364 | 4609 | ||
4365 | // Begin the animation
|
4610 | // Begin the animation
|
4366 | this.custom(this.cur(), 0); |
4611 | this.custom(this.cur(), 0); |
4367 | }, |
4612 | }, |
4368 | 4613 | ||
4369 | // Each step of an animation
|
4614 | // Each step of an animation
|
4370 | step: function(gotoEnd){ |
4615 | step: function(gotoEnd){ |
4371 | var t = now(); |
4616 | var t = now(); |
4372 | 4617 | ||
4373 | if ( gotoEnd || t >= this.options.duration + this.startTime ) { |
4618 | if ( gotoEnd || t >= this.options.duration + this.startTime ) { |
4374 | this.now = this.end; |
4619 | this.now = this.end; |
4375 | this.pos = this.state = 1; |
4620 | this.pos = this.state = 1; |
4376 | this.update(); |
4621 | this.update(); |
4377 | 4622 | ||
4378 | this.options.curAnim[ this.prop ] = true; |
4623 | this.options.curAnim[ this.prop ] = true; |
4379 | 4624 | ||
4380 | var done = true; |
4625 | var done = true; |
4381 | for ( var i in this.options.curAnim ) |
4626 | for ( var i in this.options.curAnim ) |
4382 | if ( this.options.curAnim[i] !== true ) |
4627 | if ( this.options.curAnim[i] !== true ) |
4383 | done = false; |
4628 | done = false; |
4384 | 4629 | ||
4385 | if ( done ) { |
4630 | if ( done ) { |
4386 | if ( this.options.display != null ) { |
4631 | if ( this.options.display != null ) { |
4387 | // Reset the overflow
|
4632 | // Reset the overflow
|
4388 | this.elem.style.overflow = this.options.overflow; |
4633 | this.elem.style.overflow = this.options.overflow; |
4389 | 4634 | ||
4390 | // Reset the display
|
4635 | // Reset the display
|
4391 | this.elem.style.display = this.options.display; |
4636 | this.elem.style.display = this.options.display; |
4392 | if ( jQuery.css(this.elem, "display") == "none" ) |
4637 | if ( jQuery.css(this.elem, "display") == "none" ) |
4393 | this.elem.style.display = "block"; |
4638 | this.elem.style.display = "block"; |
4394 | }
|
4639 | }
|
4395 | 4640 | ||
4396 | // Hide the element if the "hide" operation was done
|
4641 | // Hide the element if the "hide" operation was done
|
4397 | if ( this.options.hide ) |
4642 | if ( this.options.hide ) |
4398 | jQuery(this.elem).hide(); |
4643 | jQuery(this.elem).hide(); |
4399 | 4644 | ||
4400 | // Reset the properties, if the item has been hidden or shown
|
4645 | // Reset the properties, if the item has been hidden or shown
|
4401 | if ( this.options.hide || this.options.show ) |
4646 | if ( this.options.hide || this.options.show ) |
4402 | for ( var p in this.options.curAnim ) |
4647 | for ( var p in this.options.curAnim ) |
4403 | jQuery.style(this.elem, p, this.options.orig[p]); |
4648 | jQuery.style(this.elem, p, this.options.orig[p]); |
4404 | 4649 | ||
4405 | // Execute the complete function
|
4650 | // Execute the complete function
|
4406 | this.options.complete.call( this.elem ); |
4651 | this.options.complete.call( this.elem ); |
4407 | }
|
4652 | }
|
4408 | 4653 | ||
4409 | return false; |
4654 | return false; |
4410 | } else { |
4655 | } else { |
4411 | var n = t - this.startTime; |
4656 | var n = t - this.startTime; |
4412 | this.state = n / this.options.duration; |
4657 | this.state = n / this.options.duration; |
4413 | 4658 | ||
4414 | // Perform the easing function, defaults to swing
|
4659 | // Perform the easing function, defaults to swing
|
4415 | this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration); |
4660 | this.pos = jQuery.easing[this.options.easing || (jQuery.easing.swing ? "swing" : "linear")](this.state, n, 0, 1, this.options.duration); |
4416 | this.now = this.start + ((this.end - this.start) * this.pos); |
4661 | this.now = this.start + ((this.end - this.start) * this.pos); |
4417 | 4662 | ||
4418 | // Perform the next step of the animation
|
4663 | // Perform the next step of the animation
|
4419 | this.update(); |
4664 | this.update(); |
4420 | }
|
4665 | }
|
4421 | 4666 | ||
4422 | return true; |
4667 | return true; |
4423 | }
|
4668 | }
|
4424 | 4669 | ||
4425 | }; |
4670 | }; |
4426 | 4671 | ||
4427 | jQuery.extend( jQuery.fx, { |
4672 | jQuery.extend( jQuery.fx, { |
4428 | 4673 | ||
4429 | tick:function(){ |
4674 | tick:function(){ |
4430 | var timers = jQuery.timers; |
4675 | var timers = jQuery.timers; |
4431 | 4676 | ||
4432 | for ( var i = 0; i < timers.length; i++ ) |
4677 | for ( var i = 0; i < timers.length; i++ ) |
4433 | if ( !timers[i]() ) |
4678 | if ( !timers[i]() ) |
4434 | timers.splice(i--, 1); |
4679 | timers.splice(i--, 1); |
4435 | 4680 | ||
4436 | if ( !timers.length ) |
4681 | if ( !timers.length ) |
4437 | jQuery.fx.stop(); |
4682 | jQuery.fx.stop(); |
4438 | }, |
4683 | }, |
4439 | 4684 | ||
4440 | stop:function(){ |
4685 | stop:function(){ |
4441 | clearInterval( timerId ); |
4686 | clearInterval( timerId ); |
4442 | timerId = null; |
4687 | timerId = null; |
4443 | }, |
4688 | }, |
4444 | 4689 | ||
4445 | speeds:{ |
4690 | speeds:{ |
4446 | slow: 600, |
4691 | slow: 600, |
4447 | fast: 200, |
4692 | fast: 200, |
4448 | // Default speed
|
4693 | // Default speed
|
4449 | _default: 400 |
4694 | _default: 400 |
4450 | }, |
4695 | }, |
4451 | 4696 | ||
4452 | step: { |
4697 | step: { |
4453 | 4698 | ||
4454 | opacity: function(fx){ |
4699 | opacity: function(fx){ |
4455 | jQuery.style(fx.elem, "opacity", fx.now); |
4700 | jQuery.style(fx.elem, "opacity", fx.now); |
4456 | }, |
4701 | }, |
4457 | 4702 | ||
4458 | _default: function(fx){ |
4703 | _default: function(fx){ |
4459 | if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) |
4704 | if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) |
4460 | fx.elem.style[ fx.prop ] = fx.now + fx.unit; |
4705 | fx.elem.style[ fx.prop ] = fx.now + fx.unit; |
4461 | else
|
4706 | else
|
4462 | fx.elem[ fx.prop ] = fx.now; |
4707 | fx.elem[ fx.prop ] = fx.now; |
4463 | }
|
4708 | }
|
4464 | }
|
4709 | }
|
4465 | }); |
4710 | }); |
4466 | if ( "getBoundingClientRect" in document.documentElement ) |
4711 | if ( "getBoundingClientRect" in document.documentElement ) { |
4467 | jQuery.fn.offset = function() { |
4712 | jQuery.fn.offset = function() { |
4468 | var elem = this[0]; |
4713 | var elem = this[0]; |
4469 | if ( !elem || !elem.ownerDocument ) return null; |
4714 | if ( !elem || !elem.ownerDocument ) { return null; } |
- | 4715 | if ( elem === elem.ownerDocument.body ) { |
|
4470 | if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem ); |
4716 | return jQuery.offset.bodyOffset( elem ); |
- | 4717 | }
|
|
- | 4718 | ||
4471 | var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, |
4719 | var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, |
4472 | clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
4720 | clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
4473 | top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
4721 | top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
4474 | left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
4722 | left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
4475 | return { top: top, left: left }; |
4723 | return { top: top, left: left }; |
4476 | }; |
4724 | }; |
4477 | else
|
4725 | } else { |
4478 | jQuery.fn.offset = function() { |
4726 | jQuery.fn.offset = function() { |
4479 | var elem = this[0]; |
4727 | var elem = this[0]; |
4480 | if ( !elem || !elem.ownerDocument ) return null; |
4728 | if ( !elem || !elem.ownerDocument ) { return null; } |
- | 4729 | if ( elem === elem.ownerDocument.body ) { |
|
4481 | if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem ); |
4730 | return jQuery.offset.bodyOffset( elem ); |
- | 4731 | }
|
|
- | 4732 | ||
4482 | jQuery.offset.initialize(); |
4733 | jQuery.offset.initialize(); |
4483 | 4734 | ||
4484 | var offsetParent = elem.offsetParent, prevOffsetParent = elem, |
4735 | var offsetParent = elem.offsetParent, prevOffsetParent = elem, |
4485 | doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
4736 | doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
4486 | body = doc.body, defaultView = doc.defaultView, |
4737 | body = doc.body, defaultView = doc.defaultView, |
4487 | prevComputedStyle = defaultView.getComputedStyle(elem, null), |
4738 | prevComputedStyle = defaultView.getComputedStyle(elem, null), |
4488 | top = elem.offsetTop, left = elem.offsetLeft; |
4739 | top = elem.offsetTop, left = elem.offsetLeft; |
4489 | 4740 | ||
4490 | while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
4741 | while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
4491 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) break; |
4742 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { break; } |
- | 4743 | ||
4492 | computedStyle = defaultView.getComputedStyle(elem, null); |
4744 | computedStyle = defaultView.getComputedStyle(elem, null); |
- | 4745 | top -= elem.scrollTop; |
|
4493 | top -= elem.scrollTop, left -= elem.scrollLeft; |
4746 | left -= elem.scrollLeft; |
- | 4747 | ||
4494 | if ( elem === offsetParent ) { |
4748 | if ( elem === offsetParent ) { |
- | 4749 | top += elem.offsetTop; |
|
4495 | top += elem.offsetTop, left += elem.offsetLeft; |
4750 | left += elem.offsetLeft; |
- | 4751 | ||
4496 | if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.tagName)) ) |
4752 | if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) { |
4497 | top += parseFloat( computedStyle.borderTopWidth ) || 0, |
4753 | top += parseFloat( computedStyle.borderTopWidth ) || 0; |
4498 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
4754 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
- | 4755 | }
|
|
- | 4756 | ||
4499 | prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
4757 | prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
4500 | }
|
4758 | }
|
- | 4759 | ||
4501 | if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) |
4760 | if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) { |
4502 | top += parseFloat( computedStyle.borderTopWidth ) || 0, |
4761 | top += parseFloat( computedStyle.borderTopWidth ) || 0; |
4503 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
4762 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
- | 4763 | }
|
|
- | 4764 | ||
4504 | prevComputedStyle = computedStyle; |
4765 | prevComputedStyle = computedStyle; |
4505 | }
|
4766 | }
|
4506 | 4767 | ||
4507 | if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) |
4768 | if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) { |
4508 | top += body.offsetTop, |
4769 | top += body.offsetTop; |
4509 | left += body.offsetLeft; |
4770 | left += body.offsetLeft; |
- | 4771 | }
|
|
4510 | 4772 | ||
4511 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) |
4773 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { |
4512 | top += Math.max( docElem.scrollTop, body.scrollTop ), |
4774 | top += Math.max( docElem.scrollTop, body.scrollTop ); |
4513 | left += Math.max( docElem.scrollLeft, body.scrollLeft ); |
4775 | left += Math.max( docElem.scrollLeft, body.scrollLeft ); |
- | 4776 | }
|
|
4514 | 4777 | ||
4515 | return { top: top, left: left }; |
4778 | return { top: top, left: left }; |
4516 | }; |
4779 | }; |
- | 4780 | }
|
|
4517 | 4781 | ||
4518 | jQuery.offset = { |
4782 | jQuery.offset = { |
4519 | initialize: function() { |
4783 | initialize: function() { |
4520 | var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0, |
4784 | var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0, |
4521 | 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>'; |
4785 | 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>'; |
4522 | 4786 | ||
4523 | jQuery.extend( container.style, { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' } ); |
4787 | jQuery.extend( container.style, { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' } ); |
4524 | 4788 | ||
4525 | container.innerHTML = html; |
4789 | container.innerHTML = html; |
4526 | body.insertBefore( container, body.firstChild ); |
4790 | body.insertBefore( container, body.firstChild ); |
- | 4791 | innerDiv = container.firstChild; |
|
- | 4792 | checkDiv = innerDiv.firstChild; |
|
4527 | innerDiv = container.firstChild, checkDiv = innerDiv.firstChild, td = innerDiv.nextSibling.firstChild.firstChild; |
4793 | td = innerDiv.nextSibling.firstChild.firstChild; |
4528 | 4794 | ||
4529 | this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
4795 | this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
4530 | this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
4796 | this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
4531 | 4797 | ||
4532 | checkDiv.style.position = 'fixed', checkDiv.style.top = '20px'; |
4798 | checkDiv.style.position = 'fixed', checkDiv.style.top = '20px'; |
- | 4799 | // safari subtracts parent border width here which is 5px
|
|
4533 | this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); // safari subtracts parent border width here which is 5px |
4800 | this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); |
4534 | checkDiv.style.position = '', checkDiv.style.top = ''; |
4801 | checkDiv.style.position = checkDiv.style.top = ''; |
4535 | 4802 | ||
4536 | innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; |
4803 | innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; |
4537 | this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
4804 | this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
4538 | 4805 | ||
4539 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
4806 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
4540 | 4807 | ||
4541 | body.removeChild( container ); |
4808 | body.removeChild( container ); |
4542 | jQuery.offset.initialize = function(){}; |
- | |
4543 | - | ||
4544 | body = container = innerDiv = checkDiv = table = td = null; |
4809 | body = container = innerDiv = checkDiv = table = td = null; |
- | 4810 | jQuery.offset.initialize = function(){}; |
|
4545 | }, |
4811 | }, |
4546 | 4812 | ||
4547 | bodyOffset: function(body) { |
4813 | bodyOffset: function(body) { |
4548 | jQuery.offset.initialize(); |
- | |
4549 | var top = body.offsetTop, left = body.offsetLeft; |
4814 | var top = body.offsetTop, left = body.offsetLeft; |
- | 4815 | ||
- | 4816 | jQuery.offset.initialize(); |
|
- | 4817 | ||
4550 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) |
4818 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) { |
4551 | top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0, |
4819 | top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0; |
4552 | left += parseFloat( jQuery.curCSS(body, 'marginLeft', true) ) || 0; |
4820 | left += parseFloat( jQuery.curCSS(body, 'marginLeft', true) ) || 0; |
- | 4821 | }
|
|
- | 4822 | ||
4553 | return { top: top, left: left }; |
4823 | return { top: top, left: left }; |
4554 | }
|
4824 | }
|
4555 | }; |
4825 | }; |
4556 | 4826 | ||
4557 | 4827 | ||
4558 | jQuery.fn.extend({ |
4828 | jQuery.fn.extend({ |
4559 | position: function() { |
4829 | position: function() { |
4560 | if ( !this[0] ) return null; |
4830 | if ( !this[0] ) { return null; } |
4561 | 4831 | ||
4562 | var elem = this[0], |
4832 | var elem = this[0], |
4563 | 4833 | ||
4564 | // Get *real* offsetParent
|
4834 | // Get *real* offsetParent
|
4565 | offsetParent = this.offsetParent(), |
4835 | offsetParent = this.offsetParent(), |
4566 | 4836 | ||
4567 | // Get correct offsets
|
4837 | // Get correct offsets
|
4568 | offset = this.offset(), |
4838 | offset = this.offset(), |
4569 | parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset(); |
4839 | parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); |
4570 | 4840 | ||
4571 | // Subtract element margins
|
4841 | // Subtract element margins
|
4572 | // note: when an element has margin: auto the offsetLeft and marginLeft
|
4842 | // note: when an element has margin: auto the offsetLeft and marginLeft
|
4573 | // are the same in Safari causing offset.left to incorrectly be 0
|
4843 | // are the same in Safari causing offset.left to incorrectly be 0
|
4574 | offset.top -= parseFloat( jQuery.curCSS(elem, 'marginTop', true) ) || 0; |
4844 | offset.top -= parseFloat( jQuery.curCSS(elem, 'marginTop', true) ) || 0; |
4575 | offset.left -= parseFloat( jQuery.curCSS(elem, 'marginLeft', true) ) || 0; |
4845 | offset.left -= parseFloat( jQuery.curCSS(elem, 'marginLeft', true) ) || 0; |
4576 | 4846 | ||
4577 | // Add offsetParent borders
|
4847 | // Add offsetParent borders
|
4578 | parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], 'borderTopWidth', true) ) || 0; |
4848 | parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], 'borderTopWidth', true) ) || 0; |
4579 | parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], 'borderLeftWidth', true) ) || 0; |
4849 | parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], 'borderLeftWidth', true) ) || 0; |
4580 | 4850 | ||
4581 | // Subtract the two offsets
|
4851 | // Subtract the two offsets
|
4582 | return { |
4852 | return { |
4583 | top: offset.top - parentOffset.top, |
4853 | top: offset.top - parentOffset.top, |
4584 | left: offset.left - parentOffset.left |
4854 | left: offset.left - parentOffset.left |
4585 | }; |
4855 | }; |
4586 | }, |
4856 | }, |
4587 | 4857 | ||
4588 | offsetParent: function() { |
4858 | offsetParent: function() { |
- | 4859 | return this.map(function(){ |
|
4589 | var offsetParent = this[0].offsetParent || document.body; |
4860 | var offsetParent = this.offsetParent || document.body; |
4590 | while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') === 'static') ) |
4861 | while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, 'position') === 'static') ) { |
4591 | offsetParent = offsetParent.offsetParent; |
4862 | offsetParent = offsetParent.offsetParent; |
- | 4863 | }
|
|
4592 | return jQuery( offsetParent ); |
4864 | return offsetParent; |
- | 4865 | }); |
|
4593 | }
|
4866 | }
|
4594 | }); |
4867 | }); |
4595 | 4868 | ||
4596 | 4869 | ||
4597 | // Create scrollLeft and scrollTop methods
|
4870 | // Create scrollLeft and scrollTop methods
|
4598 | jQuery.each( ['Left', 'Top'], function(i, name) { |
4871 | jQuery.each( ['Left', 'Top'], function(i, name) { |
4599 | var method = 'scroll' + name; |
4872 | var method = 'scroll' + name; |
4600 | 4873 | ||
4601 | jQuery.fn[ method ] = function(val) { |
4874 | jQuery.fn[ method ] = function(val) { |
4602 | if ( !this[0] ) return null; |
4875 | var elem = this[0], win; |
4603 | 4876 | ||
4604 | var elem = this[0], win = ("scrollTo" in elem && elem.document) ? elem : |
- | |
4605 | (elem.nodeName === "#document") ? elem.defaultView || elem.parentWindow : |
- | |
4606 | false; |
- | |
4607 | - | ||
4608 | return val !== undefined ? |
4877 | if ( !elem ) { return null; } |
4609 | 4878 | ||
- | 4879 | if ( val !== undefined ) { |
|
4610 | // Set the scroll offset
|
4880 | // Set the scroll offset
|
4611 | this.each(function() { |
4881 | return this.each(function() { |
4612 | win = ("scrollTo" in this && this.document) ? this : |
4882 | win = getWindow( this ); |
4613 | (this.nodeName === "#document") ? this.defaultView || this.parentWindow : |
- | |
4614 | false; |
- | |
4615 | 4883 | ||
4616 | win ?
|
4884 | win ?
|
4617 | win.scrollTo( |
4885 | win.scrollTo( |
4618 | !i ? val : jQuery(win).scrollLeft(), |
4886 | !i ? val : jQuery(win).scrollLeft(), |
4619 | i ? val : jQuery(win).scrollTop() |
4887 | i ? val : jQuery(win).scrollTop() |
4620 | ) : |
4888 | ) : |
4621 | this[ method ] = val; |
4889 | this[ method ] = val; |
4622 | }) : |
4890 | }); |
- | 4891 | } else { |
|
- | 4892 | win = getWindow( elem ); |
|
4623 | 4893 | ||
4624 | // Return the scroll offset
|
4894 | // Return the scroll offset
|
4625 | win ?
|
- | |
4626 | win[ i ? 'pageYOffset' : 'pageXOffset' ] || |
4895 | return win ? ('pageXOffset' in win) ? win[ i ? 'pageYOffset' : 'pageXOffset' ] : |
4627 | jQuery.support.boxModel && win.document.documentElement[ method ] || |
4896 | jQuery.support.boxModel && win.document.documentElement[ method ] || |
4628 | win.document.body[ method ] : |
4897 | win.document.body[ method ] : |
4629 | elem[ method ]; |
4898 | elem[ method ]; |
- | 4899 | }
|
|
4630 | }; |
4900 | }; |
4631 | }); |
4901 | }); |
- | 4902 | ||
- | 4903 | function getWindow( elem ) { |
|
- | 4904 | return ("scrollTo" in elem && elem.document) ? |
|
- | 4905 | elem :
|
|
- | 4906 | elem.nodeType === 9 ? |
|
- | 4907 | elem.defaultView || elem.parentWindow : |
|
- | 4908 | false; |
|
- | 4909 | }
|
|
4632 | // Create innerHeight, innerWidth, outerHeight and outerWidth methods
|
4910 | // Create innerHeight, innerWidth, outerHeight and outerWidth methods
|
4633 | jQuery.each([ "Height", "Width" ], function(i, name){ |
4911 | jQuery.each([ "Height", "Width" ], function(i, name){ |
4634 | 4912 | ||
4635 | var type = name.toLowerCase(); |
4913 | var type = name.toLowerCase(); |
4636 | 4914 | ||
4637 | // innerHeight and innerWidth
|
4915 | // innerHeight and innerWidth
|
4638 | jQuery.fn["inner" + name] = function(){ |
4916 | jQuery.fn["inner" + name] = function(){ |
4639 | return this[0] ? |
4917 | return this[0] ? |
4640 | jQuery.css( this[0], type, false, "padding" ) : |
4918 | jQuery.css( this[0], type, false, "padding" ) : |
4641 | null; |
4919 | null; |
4642 | }; |
4920 | }; |
4643 | 4921 | ||
4644 | // outerHeight and outerWidth
|
4922 | // outerHeight and outerWidth
|
4645 | jQuery.fn["outer" + name] = function(margin) { |
4923 | jQuery.fn["outer" + name] = function(margin) { |
4646 | return this[0] ? |
4924 | return this[0] ? |
4647 | jQuery.css( this[0], type, false, margin ? "margin" : "border" ) : |
4925 | jQuery.css( this[0], type, false, margin ? "margin" : "border" ) : |
4648 | null; |
4926 | null; |
4649 | }; |
4927 | }; |
4650 | 4928 | ||
4651 | jQuery.fn[ type ] = function( size ) { |
4929 | jQuery.fn[ type ] = function( size ) { |
4652 | // Get window width or height
|
4930 | // Get window width or height
|
4653 | var elem = this[0]; |
4931 | var elem = this[0]; |
4654 | if ( !elem ) return null; |
4932 | if ( !elem ) return null; |
4655 | return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window? |
4933 | return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window? |
4656 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
|
4934 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
|
4657 | elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || |
4935 | elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || |
4658 | elem.document.body[ "client" + name ] : |
4936 | elem.document.body[ "client" + name ] : |
4659 | 4937 | ||
4660 | // Get document width or height
|
4938 | // Get document width or height
|
4661 | (elem.nodeName === "#document") ? // is it a document |
4939 | (elem.nodeType === 9) ? // is it a document |
4662 | // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
|
4940 | // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
|
4663 | Math.max( |
4941 | Math.max( |
4664 | elem.documentElement["client" + name], |
4942 | elem.documentElement["client" + name], |
4665 | elem.body["scroll" + name], elem.documentElement["scroll" + name], |
4943 | elem.body["scroll" + name], elem.documentElement["scroll" + name], |
4666 | elem.body["offset" + name], elem.documentElement["offset" + name] |
4944 | elem.body["offset" + name], elem.documentElement["offset" + name] |
4667 | ) : |
4945 | ) : |
4668 | 4946 | ||
4669 | // Get or set width or height on the element
|
4947 | // Get or set width or height on the element
|
4670 | size === undefined ? |
4948 | size === undefined ? |
4671 | // Get width or height on the element
|
4949 | // Get width or height on the element
|
4672 | jQuery.css( elem, type ) : |
4950 | jQuery.css( elem, type ) : |
4673 | 4951 | ||
4674 | // Set the width or height on the element (default to pixels if value is unitless)
|
4952 | // Set the width or height on the element (default to pixels if value is unitless)
|
4675 | this.css( type, typeof size === "string" ? size : size + "px" ); |
4953 | this.css( type, typeof size === "string" ? size : size + "px" ); |
4676 | }; |
4954 | }; |
4677 | 4955 | ||
4678 | }); |
4956 | }); |
4679 | })(window); |
4957 | })(window); |
4680 | 4958 |