Редакция 475 | Весь файл | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 475 | Редакция 682 | ||
---|---|---|---|
Строка 1... | Строка 1... | ||
1 | /*!
|
1 | /*!
|
2 | * jQuery JavaScript Library v1.4pre
|
2 | * jQuery JavaScript Library v1.3.2
|
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-10-12 23:26:01 +0700 (Пнд, 12 Окт 2009)
|
9 | * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
|
10 | * Revision: 6617
|
10 | * Revision: 6246
|
11 | */
|
11 | */
|
12 | (function(window, undefined){ |
12 | (function(){ |
13 | - | ||
14 | // Define a local copy of jQuery
|
- | |
15 | var jQuery = function( selector, context ) { |
- | |
16 | // The jQuery object is actually just the init constructor 'enhanced'
|
- | |
17 | return arguments.length === 0 ? |
- | |
18 | rootjQuery :
|
- | |
19 | new jQuery.fn.init( selector, context ); |
- | |
20 | }, |
- | |
21 | 13 | ||
- | 14 | var
|
|
- | 15 | // Will speed up references to window, and allows munging its name.
|
|
- | 16 | window = this, |
|
- | 17 | // Will speed up references to undefined, and allows munging its name.
|
|
- | 18 | undefined, |
|
22 | // Map over jQuery in case of overwrite
|
19 | // Map over jQuery in case of overwrite
|
23 | _jQuery = window.jQuery, |
20 | _jQuery = window.jQuery, |
24 | - | ||
25 | // Map over the $ in case of overwrite
|
21 | // Map over the $ in case of overwrite
|
26 | _$ = window.$, |
22 | _$ = window.$, |
27 | 23 | ||
28 | // Use the correct document accordingly with window argument (sandbox)
|
24 | jQuery = window.jQuery = window.$ = function( selector, context ) { |
29 | document = window.document, |
25 | // The jQuery object is actually just the init constructor 'enhanced'
|
30 | - | ||
31 | // A central reference to the root jQuery(document)
|
26 | return new jQuery.fn.init( selector, context ); |
32 | rootjQuery,
|
27 | }, |
33 | 28 | ||
34 | // A simple way to check for HTML strings or ID strings
|
29 | // A simple way to check for HTML strings or ID strings
|
35 | // (both of which we optimize for)
|
30 | // (both of which we optimize for)
|
36 | quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/, |
31 | quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/, |
37 | - | ||
38 | // Is it a simple selector
|
32 | // Is it a simple selector
|
39 | isSimple = /^.[^:#\[\.,]*$/, |
33 | isSimple = /^.[^:#\[\.,]*$/; |
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 | - | ||
47 | // Match a standalone tag
|
- | |
48 | rsingleTag = /^<(\w+)\s*\/?>$/, |
- | |
49 | - | ||
50 | // Keep a UserAgent string for use with jQuery.browser
|
- | |
51 | userAgent = navigator.userAgent.toLowerCase(), |
- | |
52 | - | ||
53 | // Save a reference to some core methods
|
- | |
54 | toString = Object.prototype.toString, |
- | |
55 | push = Array.prototype.push, |
- | |
56 | slice = Array.prototype.slice, |
- | |
57 | indexOf = Array.prototype.indexOf; |
- | |
58 | 34 | ||
59 | jQuery.fn = jQuery.prototype = { |
35 | jQuery.fn = jQuery.prototype = { |
60 | init: function( selector, context ) { |
36 | init: function( selector, context ) { |
61 | var match, elem, ret, doc; |
- | |
62 | - | ||
63 | // Handle $(""), $(null), or $(undefined)
|
37 | // Make sure that a selection was provided
|
64 | if ( !selector ) { |
38 | selector = selector || document; |
65 | return this; |
- | |
66 | }
|
- | |
67 | 39 | ||
68 | // Handle $(DOMElement)
|
40 | // Handle $(DOMElement)
|
69 | if ( selector.nodeType ) { |
41 | if ( selector.nodeType ) { |
70 | this.context = this[0] = selector; |
42 | this[0] = selector; |
71 | this.length++; |
43 | this.length = 1; |
- | 44 | this.context = selector; |
|
72 | return this; |
45 | return this; |
73 | }
|
46 | }
|
74 | - | ||
75 | // Handle HTML strings
|
47 | // Handle HTML strings
|
76 | if ( typeof selector === "string" ) { |
48 | if ( typeof selector === "string" ) { |
77 | // Are we dealing with HTML string or an ID?
|
49 | // Are we dealing with HTML string or an ID?
|
78 | match = quickExpr.exec( selector ); |
50 | var match = quickExpr.exec( selector ); |
79 | 51 | ||
80 | // Verify a match, and that no context was specified for #id
|
52 | // Verify a match, and that no context was specified for #id
|
81 | if ( match && (match[1] || !context) ) { |
53 | if ( match && (match[1] || !context) ) { |
82 | 54 | ||
83 | // HANDLE: $(html) -> $(array)
|
55 | // HANDLE: $(html) -> $(array)
|
84 | if ( match[1] ) { |
56 | if ( match[1] ) |
85 | doc = (context ? context.ownerDocument || context : document); |
- | |
86 | - | ||
87 | // If a single string is passed in and it's a single tag
|
- | |
88 | // just do a createElement and skip the rest
|
- | |
89 | ret = rsingleTag.exec( selector ); |
- | |
90 | - | ||
91 | if ( ret ) { |
- | |
92 | selector = [ doc.createElement( ret[1] ) ]; |
- | |
93 | - | ||
94 | } else { |
- | |
95 | ret = buildFragment( [ match[1] ], [ doc ] ); |
57 | selector = jQuery.clean( [ match[1] ], context ); |
96 | selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; |
- | |
97 | }
|
- | |
98 | 58 | ||
99 | // HANDLE: $("#id")
|
59 | // HANDLE: $("#id")
|
100 | } else { |
60 | else { |
101 | elem = document.getElementById( match[2] ); |
61 | var elem = document.getElementById( match[3] ); |
102 | 62 | ||
103 | if ( elem ) { |
- | |
104 | // Handle the case where IE and Opera return items
|
63 | // Handle the case where IE and Opera return items
|
105 | // by name instead of ID
|
64 | // by name instead of ID
|
106 | if ( elem.id !== match[2] ) { |
65 | if ( elem && elem.id != match[3] ) |
107 | return rootjQuery.find( selector ); |
66 | return jQuery().find( selector ); |
108 | }
|
- | |
109 | 67 | ||
110 | // Otherwise, we inject the element directly into the jQuery object
|
68 | // Otherwise, we inject the element directly into the jQuery object
|
111 | this.length++; |
- | |
112 | this[0] = elem; |
69 | var ret = jQuery( elem || [] ); |
113 | }
|
- | |
114 | - | ||
115 | this.context = document; |
70 | ret.context = document; |
116 | this.selector = selector; |
71 | ret.selector = selector; |
117 | return this; |
72 | return ret; |
118 | }
|
73 | }
|
119 | 74 | ||
120 | // HANDLE: $("TAG")
|
- | |
121 | } else if ( !context && /^\w+$/.test( selector ) ) { |
- | |
122 | this.selector = selector; |
- | |
123 | this.context = document; |
- | |
124 | selector = document.getElementsByTagName( selector ); |
- | |
125 | - | ||
126 | // HANDLE: $(expr, $(...))
|
- | |
127 | } else if ( !context || context.jquery ) { |
- | |
128 | return (context || rootjQuery).find( selector ); |
- | |
129 | - | ||
130 | // HANDLE: $(expr, context)
|
75 | // HANDLE: $(expr, [context])
|
131 | // (which is just equivalent to: $(context).find(expr)
|
76 | // (which is just equivalent to: $(content).find(expr)
|
132 | } else { |
77 | } else |
133 | return jQuery( context ).find( selector ); |
78 | return jQuery( context ).find( selector ); |
134 | }
|
- | |
135 | 79 | ||
136 | // HANDLE: $(function)
|
80 | // HANDLE: $(function)
|
137 | // Shortcut for document ready
|
81 | // Shortcut for document ready
|
138 | } else if ( jQuery.isFunction( selector ) ) { |
82 | } else if ( jQuery.isFunction( selector ) ) |
139 | return rootjQuery.ready( selector ); |
83 | return jQuery( document ).ready( selector ); |
140 | }
|
- | |
141 | 84 | ||
- | 85 | // Make sure that old selector state is passed along
|
|
142 | if (selector.selector !== undefined) { |
86 | if ( selector.selector && selector.context ) { |
143 | this.selector = selector.selector; |
87 | this.selector = selector.selector; |
144 | this.context = selector.context; |
88 | this.context = selector.context; |
145 | }
|
89 | }
|
146 | 90 | ||
147 | return this.setArray(jQuery.isArray( selector ) ? |
91 | return this.setArray(jQuery.isArray( selector ) ? |
Строка 151... | Строка 95... | ||
151 | 95 | ||
152 | // Start with an empty selector
|
96 | // Start with an empty selector
|
153 | selector: "", |
97 | selector: "", |
154 | 98 | ||
155 | // The current version of jQuery being used
|
99 | // The current version of jQuery being used
|
156 | jquery: "1.4pre", |
100 | jquery: "1.3.2", |
157 | - | ||
158 | // The default length of a jQuery object is 0
|
- | |
159 | length: 0, |
- | |
160 | 101 | ||
161 | // The number of elements contained in the matched element set
|
102 | // The number of elements contained in the matched element set
|
162 | size: function() { |
103 | size: function() { |
163 | return this.length; |
104 | return this.length; |
164 | }, |
105 | }, |
165 | 106 | ||
166 | toArray: function(){ |
- | |
167 | return slice.call( this, 0 ); |
- | |
168 | }, |
- | |
169 | - | ||
170 | // Get the Nth element in the matched element set OR
|
107 | // Get the Nth element in the matched element set OR
|
171 | // Get the whole matched element set as a clean array
|
108 | // Get the whole matched element set as a clean array
|
172 | get: function( num ) { |
109 | get: function( num ) { |
173 | return num == null ? |
110 | return num === undefined ? |
174 | 111 | ||
175 | // Return a 'clean' array
|
112 | // Return a 'clean' array
|
176 | this.toArray() : |
113 | Array.prototype.slice.call( this ) : |
177 | 114 | ||
178 | // Return just the object
|
115 | // Return just the object
|
179 | ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] ); |
116 | this[ num ]; |
180 | }, |
117 | }, |
181 | 118 | ||
182 | // Take an array of elements and push it onto the stack
|
119 | // Take an array of elements and push it onto the stack
|
183 | // (returning the new matched element set)
|
120 | // (returning the new matched element set)
|
184 | pushStack: function( elems, name, selector ) { |
121 | pushStack: function( elems, name, selector ) { |
185 | // Build a new jQuery matched element set
|
122 | // Build a new jQuery matched element set
|
186 | var ret = jQuery( elems || null ); |
123 | var ret = jQuery( elems ); |
187 | 124 | ||
188 | // Add the old object onto the stack (as a reference)
|
125 | // Add the old object onto the stack (as a reference)
|
189 | ret.prevObject = this; |
126 | ret.prevObject = this; |
190 | 127 | ||
191 | ret.context = this.context; |
128 | ret.context = this.context; |
192 | 129 | ||
193 | if ( name === "find" ) { |
130 | if ( name === "find" ) |
194 | ret.selector = this.selector + (this.selector ? " " : "") + selector; |
131 | ret.selector = this.selector + (this.selector ? " " : "") + selector; |
195 | } else if ( name ) { |
132 | else if ( name ) |
196 | ret.selector = this.selector + "." + name + "(" + selector + ")"; |
133 | ret.selector = this.selector + "." + name + "(" + selector + ")"; |
197 | }
|
- | |
198 | 134 | ||
199 | // Return the newly-formed element set
|
135 | // Return the newly-formed element set
|
200 | return ret; |
136 | return ret; |
201 | }, |
137 | }, |
202 | 138 | ||
Строка 205... | Строка 141... | ||
205 | // You should use pushStack() in order to do this, but maintain the stack
|
141 | // You should use pushStack() in order to do this, but maintain the stack
|
206 | setArray: function( elems ) { |
142 | setArray: function( elems ) { |
207 | // Resetting the length to 0, then using the native Array push
|
143 | // Resetting the length to 0, then using the native Array push
|
208 | // is a super-fast way to populate an object with array-like properties
|
144 | // is a super-fast way to populate an object with array-like properties
|
209 | this.length = 0; |
145 | this.length = 0; |
210 | push.apply( this, elems ); |
146 | Array.prototype.push.apply( this, elems ); |
211 | 147 | ||
212 | return this; |
148 | return this; |
213 | }, |
149 | }, |
214 | 150 | ||
215 | // Execute a callback for every element in the matched set.
|
151 | // Execute a callback for every element in the matched set.
|
Строка 220... | Строка 156... | ||
220 | }, |
156 | }, |
221 | 157 | ||
222 | // Determine the position of an element within
|
158 | // Determine the position of an element within
|
223 | // the matched set of elements
|
159 | // the matched set of elements
|
224 | index: function( elem ) { |
160 | index: function( elem ) { |
225 | if ( !elem || typeof elem === "string" ) { |
- | |
226 | return jQuery.inArray( this[0], |
- | |
227 | // If it receives a string, the selector is used
|
- | |
228 | // If it receives nothing, the siblings are used
|
- | |
229 | elem ? jQuery( elem ) : this.parent().children() ); |
- | |
230 | }
|
- | |
231 | // Locate the position of the desired element
|
161 | // Locate the position of the desired element
|
232 | return jQuery.inArray( |
162 | return jQuery.inArray( |
233 | // If it receives a jQuery object, the first element is used
|
163 | // If it receives a jQuery object, the first element is used
|
234 | elem.jquery ? elem[0] : elem, this ); |
164 | elem && elem.jquery ? elem[0] : elem |
235 | }, |
165 | , this ); |
236 | - | ||
237 | is: function( selector ) { |
- | |
238 | return !!selector && jQuery.multiFilter( selector, this ).length > 0; |
- | |
239 | }, |
166 | }, |
240 | 167 | ||
241 | // For internal use only.
|
168 | attr: function( name, value, type ) { |
242 | // Behaves like an Array's method, not like a jQuery method.
|
- | |
243 | push: push, |
- | |
244 | sort: [].sort, |
- | |
245 | splice: [].splice |
169 | var options = name; |
246 | }; |
- | |
247 | - | ||
248 | // Give the init function the jQuery prototype for later instantiation
|
- | |
249 | jQuery.fn.init.prototype = jQuery.fn; |
- | |
250 | 170 | ||
251 | jQuery.extend = jQuery.fn.extend = function() { |
171 | // Look for the case where we're accessing a style value
|
252 | // copy reference to target object
|
172 | if ( typeof name === "string" ) |
- | 173 | if ( value === undefined ) |
|
253 | var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy; |
174 | return this[0] && jQuery[ type || "attr" ]( this[0], name ); |
254 | 175 | ||
255 | // Handle a deep copy situation
|
- | |
256 | if ( typeof target === "boolean" ) { |
- | |
257 | deep = target; |
176 | else { |
258 | target = arguments[1] || {}; |
177 | options = {}; |
259 | // skip the boolean and the target
|
178 | options[ name ] = value; |
260 | i = 2; |
- | |
261 | }
|
179 | }
|
262 | 180 | ||
263 | // Handle case when target is a string or something (possible in deep copy)
|
181 | // Check to see if we're setting style values
|
264 | if ( typeof target !== "object" && !jQuery.isFunction(target) ) { |
182 | return this.each(function(i){ |
- | 183 | // Set all the styles
|
|
- | 184 | for ( name in options ) |
|
- | 185 | jQuery.attr( |
|
- | 186 | type ?
|
|
- | 187 | this.style : |
|
265 | target = {}; |
188 | this, |
- | 189 | name, jQuery.prop( this, options[ name ], type, i, name ) |
|
- | 190 | ); |
|
- | 191 | }); |
|
266 | }
|
192 | }, |
267 | 193 | ||
- | 194 | css: function( key, value ) { |
|
268 | // extend jQuery itself if only one argument is passed
|
195 | // ignore negative width and height values
|
269 | if ( length === i ) { |
196 | if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 ) |
270 | target = this; |
197 | value = undefined; |
271 | --i; |
198 | return this.attr( key, value, "curCSS" ); |
272 | }
|
199 | }, |
273 | 200 | ||
274 | for ( ; i < length; i++ ) { |
201 | text: function( text ) { |
275 | // Only deal with non-null/undefined values
|
- | |
276 | if ( (options = arguments[ i ]) != null ) { |
202 | if ( typeof text !== "object" && text != null ) |
277 | // Extend the base object
|
203 | return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
278 | for ( name in options ) { |
- | |
279 | src = target[ name ]; |
- | |
280 | copy = options[ name ]; |
- | |
281 | 204 | ||
282 | // Prevent never-ending loop
|
- | |
283 | if ( target === copy ) { |
- | |
284 | continue; |
205 | var ret = ""; |
285 | }
|
- | |
286 | 206 | ||
287 | // Recurse if we're merging object values
|
207 | jQuery.each( text || this, function(){ |
288 | if ( deep && copy && typeof copy === "object" && !copy.nodeType ) { |
208 | jQuery.each( this.childNodes, function(){ |
- | 209 | if ( this.nodeType != 8 ) |
|
- | 210 | ret += this.nodeType != 1 ? |
|
289 | var clone; |
211 | this.nodeValue : |
- | 212 | jQuery.fn.text( [ this ] ); |
|
- | 213 | }); |
|
- | 214 | }); |
|
290 | 215 | ||
291 | if ( src ) { |
- | |
292 | clone = src; |
- | |
293 | } else if ( jQuery.isArray(copy) ) { |
- | |
294 | clone = []; |
- | |
295 | } else if ( jQuery.isObject(copy) ) { |
- | |
296 | clone = {}; |
- | |
297 | } else { |
216 | return ret; |
298 | clone = copy; |
- | |
299 | }
|
217 | }, |
300 | 218 | ||
- | 219 | wrapAll: function( html ) { |
|
- | 220 | if ( this[0] ) { |
|
301 | // Never move original objects, clone them
|
221 | // The elements to wrap the target around
|
302 | target[ name ] = jQuery.extend( deep, clone, copy ); |
222 | var wrap = jQuery( html, this[0].ownerDocument ).clone(); |
303 | 223 | ||
304 | // Don't bring in undefined values
|
- | |
305 | } else if ( copy !== undefined ) { |
224 | if ( this[0].parentNode ) |
306 | target[ name ] = copy; |
225 | wrap.insertBefore( this[0] ); |
307 | }
|
- | |
308 | }
|
- | |
309 | }
|
- | |
310 | }
|
- | |
311 | 226 | ||
312 | // Return the modified object
|
227 | wrap.map(function(){ |
313 | return target; |
228 | var elem = this; |
314 | }; |
- | |
315 | 229 | ||
316 | jQuery.extend({ |
- | |
317 | noConflict: function( deep ) { |
230 | while ( elem.firstChild ) |
318 | window.$ = _$; |
231 | elem = elem.firstChild; |
319 | 232 | ||
320 | if ( deep ) { |
233 | return elem; |
321 | window.jQuery = _jQuery; |
234 | }).append(this); |
322 | }
|
235 | }
|
323 | 236 | ||
324 | return jQuery; |
237 | return this; |
325 | }, |
238 | }, |
326 | 239 | ||
327 | // See test/unit/core.js for details concerning isFunction.
|
- | |
328 | // Since version 1.3, DOM methods and functions like alert
|
240 | wrapInner: function( html ) { |
329 | // aren't supported. They return false on IE (#2968).
|
- | |
330 | isFunction: function( obj ) { |
241 | return this.each(function(){ |
331 | return toString.call(obj) === "[object Function]"; |
242 | jQuery( this ).contents().wrapAll( html ); |
- | 243 | }); |
|
332 | }, |
244 | }, |
333 | 245 | ||
334 | isArray: function( obj ) { |
246 | wrap: function( html ) { |
335 | return toString.call(obj) === "[object Array]"; |
247 | return this.each(function(){ |
- | 248 | jQuery( this ).wrapAll( html ); |
|
- | 249 | }); |
|
336 | }, |
250 | }, |
337 | 251 | ||
338 | isObject: function( obj ) { |
252 | append: function() { |
339 | return this.constructor.call(obj) === Object; |
253 | return this.domManip(arguments, true, function(elem){ |
- | 254 | if (this.nodeType == 1) |
|
- | 255 | this.appendChild( elem ); |
|
- | 256 | }); |
|
340 | }, |
257 | }, |
341 | 258 | ||
342 | isEmptyObject: function( obj ) { |
259 | prepend: function() { |
- | 260 | return this.domManip(arguments, true, function(elem){ |
|
343 | for ( var name in obj ) { |
261 | if (this.nodeType == 1) |
344 | return false; |
262 | this.insertBefore( elem, this.firstChild ); |
345 | }
|
263 | }); |
346 | return true; |
- | |
347 | }, |
264 | }, |
348 | 265 | ||
349 | // check if an element is in a (or is an) XML document
|
- | |
350 | isXMLDoc: function( elem ) { |
266 | before: function() { |
351 | // documentElement is verified for cases where it doesn't yet exist
|
267 | return this.domManip(arguments, false, function(elem){ |
352 | // (such as loading iframes in IE - #4833)
|
268 | this.parentNode.insertBefore( elem, this ); |
353 | var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; |
- | |
354 | return documentElement ? documentElement.nodeName !== "HTML" : false; |
- | |
- | 269 | }); |
|
355 | }, |
270 | }, |
356 | 271 | ||
357 | // Evalulates a script in a global context
|
- | |
358 | globalEval: function( data ) { |
272 | after: function() { |
359 | if ( data && rnotwhite.test(data) ) { |
- | |
360 | // Inspired by code by Andrea Giammarchi
|
- | |
361 | // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
|
- | |
362 | var head = document.getElementsByTagName("head")[0] || document.documentElement, |
- | |
363 | script = document.createElement("script"); |
- | |
364 | - | ||
365 | script.type = "text/javascript"; |
- | |
366 | - | ||
367 | if ( jQuery.support.scriptEval ) { |
- | |
368 | script.appendChild( document.createTextNode( data ) ); |
273 | return this.domManip(arguments, false, function(elem){ |
369 | } else { |
- | |
370 | script.text = data; |
- | |
371 | }
|
- | |
372 | - | ||
373 | // Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
- | |
374 | // This arises when a base node is used (#2709).
|
- | |
375 | head.insertBefore( script, head.firstChild ); |
274 | this.parentNode.insertBefore( elem, this.nextSibling ); |
376 | head.removeChild( script ); |
- | |
377 | }
|
275 | }); |
378 | }, |
276 | }, |
379 | 277 | ||
380 | nodeName: function( elem, name ) { |
278 | end: function() { |
381 | return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); |
279 | return this.prevObject || jQuery( [] ); |
382 | }, |
280 | }, |
383 | 281 | ||
384 | // args is for internal usage only
|
282 | // For internal use only.
|
385 | each: function( object, callback, args ) { |
283 | // Behaves like an Array's method, not like a jQuery method.
|
386 | var name, i = 0, |
284 | push: [].push, |
387 | length = object.length, |
285 | sort: [].sort, |
388 | isObj = length === undefined || jQuery.isFunction(object); |
286 | splice: [].splice, |
389 | 287 | ||
390 | if ( args ) { |
288 | find: function( selector ) { |
391 | if ( isObj ) { |
289 | if ( this.length === 1 ) { |
- | 290 | var ret = this.pushStack( [], "find", selector ); |
|
392 | for ( name in object ) { |
291 | ret.length = 0; |
393 | if ( callback.apply( object[ name ], args ) === false ) { |
292 | jQuery.find( selector, this[0], ret ); |
394 | break; |
293 | return ret; |
395 | }
|
- | |
396 | }
|
- | |
397 | } else { |
294 | } else { |
398 | for ( ; i < length; ) { |
295 | return this.pushStack( jQuery.unique(jQuery.map(this, function(elem){ |
399 | if ( callback.apply( object[ i++ ], args ) === false ) { |
296 | return jQuery.find( selector, elem ); |
400 | break; |
297 | })), "find", selector ); |
401 | }
|
- | |
402 | }
|
- | |
403 | }
|
298 | }
|
- | 299 | }, |
|
404 | 300 | ||
405 | // A special, fast, case for the most common use of each
|
301 | clone: function( events ) { |
406 | } else { |
302 | // Do the clone
|
407 | if ( isObj ) { |
303 | var ret = this.map(function(){ |
- | 304 | if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { |
|
- | 305 | // IE copies events bound via attachEvent when
|
|
408 | for ( name in object ) { |
306 | // using cloneNode. Calling detachEvent on the
|
409 | if ( callback.call( object[ name ], name, object[ name ] ) === false ) { |
307 | // clone will also remove the events from the orignal
|
- | 308 | // In order to get around this, we use innerHTML.
|
|
- | 309 | // Unfortunately, this means some modifications to
|
|
- | 310 | // attributes in IE that are actually only stored
|
|
- | 311 | // as properties will not be copied (such as the
|
|
410 | break; |
312 | // the name attribute on an input).
|
411 | }
|
313 | var html = this.outerHTML; |
412 | }
|
- | |
413 | } else { |
314 | if ( !html ) { |
414 | for ( var value = object[0]; |
315 | var div = this.ownerDocument.createElement("div"); |
415 | i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {} |
316 | div.appendChild( this.cloneNode(true) ); |
416 | }
|
317 | html = div.innerHTML; |
417 | }
|
318 | }
|
418 | 319 | ||
- | 320 | return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g, "").replace(/^\s*/, "")])[0]; |
|
- | 321 | } else |
|
419 | return object; |
322 | return this.cloneNode(true); |
420 | }, |
323 | }); |
421 | 324 | ||
- | 325 | // Copy the events from the original to the clone
|
|
422 | trim: function( text ) { |
326 | if ( events === true ) { |
423 | return (text || "").replace( rtrim, "" ); |
327 | var orig = this.find("*").andSelf(), i = 0; |
424 | }, |
- | |
425 | 328 | ||
426 | makeArray: function( array ) { |
329 | ret.find("*").andSelf().each(function(){ |
- | 330 | if ( this.nodeName !== orig[i].nodeName ) |
|
427 | var ret = [], i; |
331 | return; |
428 | 332 | ||
429 | if ( array != null ) { |
333 | var events = jQuery.data( orig[i], "events" ); |
430 | i = array.length; |
- | |
431 | 334 | ||
432 | // The window, strings (and functions) also have 'length'
|
- | |
433 | if ( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval ) { |
- | |
434 | ret[0] = array; |
335 | for ( var type in events ) { |
435 | } else { |
- | |
436 | while ( i ) { |
336 | for ( var handler in events[ type ] ) { |
437 | ret[--i] = array[i]; |
337 | jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); |
438 | }
|
338 | }
|
439 | }
|
339 | }
|
- | 340 | ||
- | 341 | i++;
|
|
- | 342 | }); |
|
440 | }
|
343 | }
|
441 | 344 | ||
- | 345 | // Return the cloned set
|
|
442 | return ret; |
346 | return ret; |
443 | }, |
347 | }, |
444 | 348 | ||
445 | inArray: function( elem, array ) { |
349 | filter: function( selector ) { |
- | 350 | return this.pushStack( |
|
446 | for ( var i = 0, length = array.length; i < length; i++ ) { |
351 | jQuery.isFunction( selector ) && |
447 | if ( array[ i ] === elem ) { |
352 | jQuery.grep(this, function(elem, i){ |
448 | return i; |
353 | return selector.call( elem, i ); |
449 | }
|
354 | }) || |
450 | }
|
- | |
451 | 355 | ||
- | 356 | jQuery.multiFilter( selector, jQuery.grep(this, function(elem){ |
|
452 | return -1; |
357 | return elem.nodeType === 1; |
- | 358 | }) ), "filter", selector ); |
|
453 | }, |
359 | }, |
454 | 360 | ||
455 | merge: function( first, second ) { |
361 | closest: function( selector ) { |
456 | // We have to loop this way because IE & Opera overwrite the length
|
- | |
457 | // expando of getElementsByTagName
|
- | |
458 | var i = 0, elem, pos = first.length; |
- | |
459 | - | ||
460 | // Also, we need to make sure that the correct elements are being returned
|
362 | var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, |
461 | // (IE returns comment nodes in a '*' query)
|
- | |
462 | if ( !jQuery.support.getAll ) { |
- | |
463 | while ( (elem = second[ i++ ]) != null ) { |
- | |
464 | if ( elem.nodeType !== 8 ) { |
- | |
465 | first[ pos++ ] = elem; |
363 | closer = 0; |
466 | }
|
- | |
467 | }
|
- | |
468 | 364 | ||
- | 365 | return this.map(function(){ |
|
469 | } else { |
366 | var cur = this; |
470 | while ( (elem = second[ i++ ]) != null ) { |
367 | while ( cur && cur.ownerDocument ) { |
- | 368 | if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { |
|
- | 369 | jQuery.data(cur, "closest", closer); |
|
471 | first[ pos++ ] = elem; |
370 | return cur; |
472 | }
|
371 | }
|
- | 372 | cur = cur.parentNode; |
|
- | 373 | closer++;
|
|
473 | }
|
374 | }
|
474 | - | ||
475 | return first; |
375 | }); |
476 | }, |
376 | }, |
477 | 377 | ||
478 | grep: function( elems, callback, inv ) { |
378 | not: function( selector ) { |
- | 379 | if ( typeof selector === "string" ) |
|
- | 380 | // test special case where just one selector is passed in
|
|
- | 381 | if ( isSimple.test( selector ) ) |
|
- | 382 | return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector ); |
|
479 | var ret = []; |
383 | else
|
- | 384 | selector = jQuery.multiFilter( selector, this ); |
|
480 | 385 | ||
481 | // Go through the array, only saving the items
|
386 | var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; |
482 | // that pass the validator function
|
387 | return this.filter(function() { |
483 | for ( var i = 0, length = elems.length; i < length; i++ ) { |
388 | return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; |
484 | if ( !inv !== !callback( elems[ i ], i ) ) { |
- | |
485 | ret.push( elems[ i ] ); |
- | |
486 | }
|
389 | }); |
487 | }
|
390 | }, |
488 | 391 | ||
- | 392 | add: function( selector ) { |
|
- | 393 | return this.pushStack( jQuery.unique( jQuery.merge( |
|
489 | return ret; |
394 | this.get(), |
- | 395 | typeof selector === "string" ? |
|
- | 396 | jQuery( selector ) : |
|
- | 397 | jQuery.makeArray( selector ) |
|
- | 398 | ))); |
|
490 | }, |
399 | }, |
491 | 400 | ||
492 | map: function( elems, callback ) { |
401 | is: function( selector ) { |
493 | var ret = [], value; |
402 | return !!selector && jQuery.multiFilter( selector, this ).length > 0; |
- | 403 | }, |
|
494 | 404 | ||
495 | // Go through the array, translating each of the items to their
|
- | |
496 | // new value (or values).
|
405 | hasClass: function( selector ) { |
497 | for ( var i = 0, length = elems.length; i < length; i++ ) { |
406 | return !!selector && this.is( "." + selector ); |
498 | value = callback( elems[ i ], i ); |
407 | }, |
499 | 408 | ||
- | 409 | val: function( value ) { |
|
500 | if ( value != null ) { |
410 | if ( value === undefined ) { |
501 | ret[ ret.length ] = value; |
411 | var elem = this[0]; |
502 | }
|
- | |
503 | }
|
- | |
504 | 412 | ||
- | 413 | if ( elem ) { |
|
505 | return ret.concat.apply( [], ret ); |
414 | if( jQuery.nodeName( elem, 'option' ) ) |
506 | }, |
- | |
- | 415 | return (elem.attributes.value || {}).specified ? elem.value : elem.text; |
|
507 | 416 | ||
508 | // Use of jQuery.browser is deprecated.
|
417 | // We need to handle select boxes special
|
509 | // It's included for backwards compatibility and plugins,
|
418 | if ( jQuery.nodeName( elem, "select" ) ) { |
510 | // although they should work to migrate away.
|
419 | var index = elem.selectedIndex, |
511 | browser: { |
420 | values = [], |
512 | version: (/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/.exec(userAgent) || [0,'0'])[1], |
- | |
513 | safari: /webkit/.test( userAgent ), |
421 | options = elem.options, |
514 | opera: /opera/.test( userAgent ), |
422 | one = elem.type == "select-one"; |
515 | msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), |
- | |
516 | mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) |
- | |
517 | }
|
- | |
518 | }); |
- | |
519 | 423 | ||
520 | if ( indexOf ) { |
424 | // Nothing was selected
|
521 | jQuery.inArray = function( elem, array ) { |
425 | if ( index < 0 ) |
522 | return indexOf.call( array, elem ); |
426 | return null; |
523 | }; |
- | |
524 | }
|
- | |
525 | 427 | ||
526 | // All jQuery objects should point back to these
|
428 | // Loop through all the selected options
|
- | 429 | for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
|
527 | rootjQuery = jQuery(document); |
430 | var option = options[ i ]; |
528 | 431 | ||
529 | function evalScript( i, elem ) { |
- | |
530 | if ( elem.src ) { |
432 | if ( option.selected ) { |
531 | jQuery.ajax({ |
- | |
532 | url: elem.src, |
- | |
533 | async: false, |
433 | // Get the specifc value for the option
|
534 | dataType: "script" |
434 | value = jQuery(option).val(); |
535 | }); |
- | |
536 | } else { |
- | |
537 | jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
- | |
538 | }
|
- | |
539 | 435 | ||
- | 436 | // We don't need an array for one selects
|
|
540 | if ( elem.parentNode ) { |
437 | if ( one ) |
- | 438 | return value; |
|
- | 439 | ||
- | 440 | // Multi-Selects return an array
|
|
541 | elem.parentNode.removeChild( elem ); |
441 | values.push( value ); |
542 | }
|
442 | }
|
543 | }
|
443 | }
|
544 | 444 | ||
545 | // Mutifunctional method to get and set values to a collection
|
- | |
546 | // The value/s can be optionally by executed if its a function
|
- | |
547 | function access( elems, key, value, exec, fn ) { |
- | |
548 | var l = elems.length; |
- | |
549 | - | ||
550 | // Setting many attributes
|
- | |
551 | if ( typeof key === "object" ) { |
- | |
552 | for (var k in key) { |
- | |
553 | access(elems, k, key[k], exec, fn); |
- | |
554 | }
|
- | |
555 | return elems; |
445 | return values; |
556 | }
|
446 | }
|
557 | 447 | ||
558 | // Setting one attribute
|
448 | // Everything else, we just grab the value
|
559 | if (value !== undefined) { |
- | |
560 | // Optionally, function values get executed if exec is true
|
- | |
561 | exec = exec && jQuery.isFunction(value); |
449 | return (elem.value || "").replace(/\r/g, ""); |
562 | 450 | ||
563 | for (var i = 0; i < l; i++) { |
- | |
564 | var elem = elems[i], |
- | |
565 | val = exec ? value.call(elem, i) : value; |
- | |
566 | fn(elem, key, val); |
- | |
567 | }
|
- | |
568 | return elems; |
- | |
569 | }
|
451 | }
|
570 | 452 | ||
571 | // Getting an attribute
|
453 | return undefined; |
572 | return l ? fn(elems[0], key) : null; |
- | |
573 | }
|
454 | }
|
574 | 455 | ||
575 | function now() { |
- | |
576 | return (new Date).getTime(); |
456 | if ( typeof value === "number" ) |
577 | }
|
- | |
578 | var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
- | |
579 | var emptyObject = {}; |
457 | value += ''; |
580 | 458 | ||
581 | jQuery.extend({ |
459 | return this.each(function(){ |
- | 460 | if ( this.nodeType != 1 ) |
|
582 | cache: {}, |
461 | return; |
583 | 462 | ||
- | 463 | if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) ) |
|
- | 464 | this.checked = (jQuery.inArray(this.value, value) >= 0 || |
|
584 | expando:expando, |
465 | jQuery.inArray(this.name, value) >= 0); |
585 | 466 | ||
586 | data: function( elem, name, data ) { |
467 | else if ( jQuery.nodeName( this, "select" ) ) { |
587 | elem = elem == window ? |
468 | var values = jQuery.makeArray(value); |
588 | windowData :
|
- | |
589 | elem;
|
- | |
590 | 469 | ||
591 | var id = elem[ expando ], cache = jQuery.cache, thisCache; |
470 | jQuery( "option", this ).each(function(){ |
- | 471 | this.selected = (jQuery.inArray( this.value, values ) >= 0 || |
|
- | 472 | jQuery.inArray( this.text, values ) >= 0); |
|
- | 473 | }); |
|
592 | 474 | ||
593 | // Handle the case where there's no name immediately
|
- | |
594 | if ( !name && !id ) { |
475 | if ( !values.length ) |
595 | return null; |
476 | this.selectedIndex = -1; |
596 | }
|
- | |
597 | 477 | ||
598 | // Compute a unique ID for the element
|
- | |
599 | if ( !id ) { |
478 | } else |
600 | id = ++uuid; |
479 | this.value = value; |
601 | }
|
480 | }); |
- | 481 | }, |
|
602 | 482 | ||
603 | // Avoid generating a new cache unless none exists and we
|
- | |
604 | // want to manipulate it.
|
483 | html: function( value ) { |
605 | if ( cache[ id ] ) { |
484 | return value === undefined ? |
606 | thisCache = cache[ id ]; |
485 | (this[0] ? |
607 | } else if ( typeof data === "undefined" ) { |
486 | this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") : |
608 | thisCache = emptyObject; |
- | |
609 | } else { |
487 | null) : |
610 | thisCache = cache[ id ] = {}; |
488 | this.empty().append( value ); |
611 | }
|
489 | }, |
612 | 490 | ||
613 | // Prevent overriding the named cache with undefined values
|
- | |
614 | if ( data !== undefined ) { |
491 | replaceWith: function( value ) { |
615 | elem[ expando ] = id; |
- | |
616 | thisCache[ name ] = data; |
492 | return this.after( value ).remove(); |
617 | }
|
493 | }, |
618 | 494 | ||
- | 495 | eq: function( i ) { |
|
619 | return name ? thisCache[ name ] : thisCache; |
496 | return this.slice( i, +i + 1 ); |
620 | }, |
497 | }, |
621 | 498 | ||
622 | removeData: function( elem, name ) { |
499 | slice: function() { |
623 | elem = elem == window ? |
500 | return this.pushStack( Array.prototype.slice.apply( this, arguments ), |
624 | windowData :
|
501 | "slice", Array.prototype.slice.call(arguments).join(",") ); |
625 | elem;
|
502 | }, |
626 | 503 | ||
- | 504 | map: function( callback ) { |
|
627 | var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ]; |
505 | return this.pushStack( jQuery.map(this, function(elem, i){ |
- | 506 | return callback.call( elem, i, elem ); |
|
- | 507 | })); |
|
- | 508 | }, |
|
628 | 509 | ||
629 | // If we want to remove a specific section of the element's data
|
- | |
630 | if ( name ) { |
510 | andSelf: function() { |
631 | if ( thisCache ) { |
- | |
632 | // Remove the section of cache data
|
- | |
633 | delete thisCache[ name ]; |
511 | return this.add( this.prevObject ); |
- | 512 | }, |
|
634 | 513 | ||
- | 514 | domManip: function( args, table, callback ) { |
|
- | 515 | if ( this[0] ) { |
|
- | 516 | var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(), |
|
635 | // If we've removed all the data, remove the element's cache
|
517 | scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ), |
- | 518 | first = fragment.firstChild; |
|
- | 519 | ||
- | 520 | if ( first ) |
|
636 | if ( jQuery.isEmptyObject(thisCache) ) { |
521 | for ( var i = 0, l = this.length; i < l; i++ ) |
- | 522 | callback.call( root(this[i], first), this.length > 1 || i > 0 ? |
|
637 | jQuery.removeData( elem ); |
523 | fragment.cloneNode(true) : fragment ); |
- | 524 | ||
638 | }
|
525 | if ( scripts ) |
- | 526 | jQuery.each( scripts, evalScript ); |
|
639 | }
|
527 | }
|
640 | 528 | ||
641 | // Otherwise, we want to remove all of the element's data
|
- | |
642 | } else { |
529 | return this; |
643 | // Clean up the element expando
|
- | |
644 | try { |
530 | |
645 | delete elem[ expando ]; |
531 | function root( elem, cur ) { |
646 | } catch( e ) { |
- | |
647 | // IE has trouble directly removing the expando
|
532 | return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ? |
648 | // but it's ok with using removeAttribute
|
533 | (elem.getElementsByTagName("tbody")[0] || |
649 | if ( elem.removeAttribute ) { |
534 | elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
650 | elem.removeAttribute( expando ); |
535 | elem;
|
651 | }
|
536 | }
|
652 | }
|
537 | }
|
- | 538 | }; |
|
653 | 539 | ||
- | 540 | // Give the init function the jQuery prototype for later instantiation
|
|
- | 541 | jQuery.fn.init.prototype = jQuery.fn; |
|
- | 542 | ||
654 | // Completely remove the data cache
|
543 | function evalScript( i, elem ) { |
- | 544 | if ( elem.src ) |
|
- | 545 | jQuery.ajax({ |
|
- | 546 | url: elem.src, |
|
- | 547 | async: false, |
|
655 | delete cache[ id ]; |
548 | dataType: "script" |
- | 549 | }); |
|
- | 550 | ||
- | 551 | else
|
|
- | 552 | jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
|
- | 553 | ||
- | 554 | if ( elem.parentNode ) |
|
- | 555 | elem.parentNode.removeChild( elem ); |
|
656 | }
|
556 | }
|
657 | }, |
- | |
658 | 557 | ||
659 | queue: function( elem, type, data ) { |
558 | function now(){ |
660 | if( !elem ) return; |
559 | return +new Date; |
- | 560 | }
|
|
661 | 561 | ||
662 | type = (type || "fx") + "queue"; |
562 | jQuery.extend = jQuery.fn.extend = function() { |
663 | var q = jQuery.data( elem, type ); |
563 | // copy reference to target object
|
- | 564 | var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; |
|
664 | 565 | ||
665 | // Speed up dequeue by getting out quickly if this is just a lookup
|
566 | // Handle a deep copy situation
|
- | 567 | if ( typeof target === "boolean" ) { |
|
- | 568 | deep = target; |
|
666 | if( !data ) return q || []; |
569 | target = arguments[1] || {}; |
- | 570 | // skip the boolean and the target
|
|
- | 571 | i = 2; |
|
- | 572 | }
|
|
667 | 573 | ||
668 | if ( !q || jQuery.isArray(data) ) |
574 | // Handle case when target is a string or something (possible in deep copy)
|
669 | q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
575 | if ( typeof target !== "object" && !jQuery.isFunction(target) ) |
670 | else
|
- | |
671 | q.push( data ); |
576 | target = {}; |
672 | 577 | ||
- | 578 | // extend jQuery itself if only one argument is passed
|
|
- | 579 | if ( length == i ) { |
|
673 | return q; |
580 | target = this; |
- | 581 | --i; |
|
674 | }, |
582 | }
|
675 | 583 | ||
676 | dequeue: function( elem, type ){ |
584 | for ( ; i < length; i++ ) |
- | 585 | // Only deal with non-null/undefined values
|
|
- | 586 | if ( (options = arguments[ i ]) != null ) |
|
677 | type = type || "fx"; |
587 | // Extend the base object
|
- | 588 | for ( var name in options ) { |
|
- | 589 | var src = target[ name ], copy = options[ name ]; |
|
678 | 590 | ||
679 | var queue = jQuery.queue( elem, type ), fn = queue.shift(); |
591 | // Prevent never-ending loop
|
- | 592 | if ( target === copy ) |
|
- | 593 | continue; |
|
680 | 594 | ||
- | 595 | // Recurse if we're merging object values
|
|
681 | // If the fx queue is dequeued, always remove the progress sentinel
|
596 | if ( deep && copy && typeof copy === "object" && !copy.nodeType ) |
- | 597 | target[ name ] = jQuery.extend( deep, |
|
682 | if( fn === "inprogress" ) fn = queue.shift(); |
598 | // Never move original objects, clone them
|
- | 599 | src || ( copy.length != null ? [ ] : { } ) |
|
- | 600 | , copy ); |
|
683 | 601 | ||
684 | if( fn ) { |
- | |
685 | // Add a progress sentinel to prevent the fx queue from being
|
602 | // Don't bring in undefined values
|
686 | // automatically dequeued
|
603 | else if ( copy !== undefined ) |
687 | if( type == "fx" ) queue.unshift("inprogress"); |
604 | target[ name ] = copy; |
688 | 605 | ||
689 | fn.call(elem, function() { jQuery.dequeue(elem, type); }); |
- | |
690 | }
|
606 | }
|
691 | }
|
- | |
692 | }); |
- | |
693 | 607 | ||
694 | jQuery.fn.extend({ |
- | |
695 | data: function( key, value ){ |
608 | // Return the modified object
|
696 | if ( typeof key === "undefined" && this.length ) { |
- | |
697 | return jQuery.data( this[0] ); |
609 | return target; |
698 | }
|
610 | }; |
699 | 611 | ||
- | 612 | // exclude the following css properties to add px
|
|
- | 613 | var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
|
700 | var parts = key.split("."); |
614 | // cache defaultView
|
701 | parts[1] = parts[1] ? "." + parts[1] : ""; |
615 | defaultView = document.defaultView || {}, |
- | 616 | toString = Object.prototype.toString; |
|
702 | 617 | ||
- | 618 | jQuery.extend({ |
|
703 | if ( value === undefined ) { |
619 | noConflict: function( deep ) { |
704 | var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
620 | window.$ = _$; |
705 | 621 | ||
706 | if ( data === undefined && this.length ) |
622 | if ( deep ) |
707 | data = jQuery.data( this[0], key ); |
623 | window.jQuery = _jQuery; |
708 | 624 | ||
709 | return data === undefined && parts[1] ? |
- | |
710 | this.data( parts[0] ) : |
- | |
711 | data;
|
- | |
712 | } else |
625 | return jQuery; |
713 | return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){ |
- | |
714 | jQuery.data( this, key, value ); |
- | |
715 | }); |
- | |
716 | }, |
626 | }, |
717 | 627 | ||
- | 628 | // See test/unit/core.js for details concerning isFunction.
|
|
718 | removeData: function( key ){ |
629 | // Since version 1.3, DOM methods and functions like alert
|
- | 630 | // aren't supported. They return false on IE (#2968).
|
|
719 | return this.each(function(){ |
631 | isFunction: function( obj ) { |
720 | jQuery.removeData( this, key ); |
632 | return toString.call(obj) === "[object Function]"; |
721 | }); |
- | |
722 | }, |
633 | }, |
723 | queue: function(type, data){ |
- | |
724 | if ( typeof type !== "string" ) { |
- | |
725 | data = type; |
- | |
726 | type = "fx"; |
- | |
727 | }
|
- | |
728 | - | ||
729 | if ( data === undefined ) |
- | |
730 | return jQuery.queue( this[0], type ); |
- | |
731 | 634 | ||
732 | return this.each(function(i, elem){ |
635 | isArray: function( obj ) { |
733 | var queue = jQuery.queue( this, type, data ); |
636 | return toString.call(obj) === "[object Array]"; |
734 | - | ||
735 | if( type == "fx" && queue[0] !== "inprogress" ) |
- | |
736 | jQuery.dequeue( this, type ) |
- | |
737 | }); |
- | |
738 | }, |
637 | }, |
- | 638 | ||
- | 639 | // check if an element is in a (or is an) XML document
|
|
739 | dequeue: function(type){ |
640 | isXMLDoc: function( elem ) { |
740 | return this.each(function(){ |
641 | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || |
741 | jQuery.dequeue( this, type ); |
642 | !!elem.ownerDocument && jQuery.isXMLDoc( elem.ownerDocument ); |
742 | }); |
- | |
743 | }, |
643 | }, |
744 | clearQueue: function(type){ |
- | |
745 | return this.queue( type || "fx", [] ); |
- | |
746 | }
|
- | |
747 | }); |
- | |
748 | /*
|
- | |
749 | * A number of helper functions used for managing events.
|
- | |
750 | * Many of the ideas behind this code originated from
|
- | |
751 | * Dean Edwards' addEvent library.
|
- | |
752 | */
|
- | |
753 | jQuery.event = { |
- | |
754 | 644 | ||
755 | // Bind an event to an element
|
645 | // Evalulates a script in a global context
|
756 | // Original by Dean Edwards
|
646 | globalEval: function( data ) { |
757 | add: function( elem, types, handler, data ) { |
647 | if ( data && /\S/.test(data) ) { |
758 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
648 | // Inspired by code by Andrea Giammarchi
|
- | 649 | // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
|
|
- | 650 | var head = document.getElementsByTagName("head")[0] || document.documentElement, |
|
759 | return; |
651 | script = document.createElement("script"); |
760 | }
|
- | |
761 | 652 | ||
762 | // For whatever reason, IE has trouble passing the window object
|
653 | script.type = "text/javascript"; |
763 | // around, causing it to be cloned in the process
|
654 | if ( jQuery.support.scriptEval ) |
764 | if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) { |
655 | script.appendChild( document.createTextNode( data ) ); |
765 | elem = window; |
656 | else
|
766 | }
|
657 | script.text = data; |
767 | 658 | ||
768 | // Make sure that the function being executed has a unique ID
|
659 | // Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
- | 660 | // This arises when a base node is used (#2709).
|
|
769 | if ( !handler.guid ) { |
661 | head.insertBefore( script, head.firstChild ); |
770 | handler.guid = this.guid++; |
662 | head.removeChild( script ); |
771 | }
|
663 | }
|
- | 664 | }, |
|
772 | 665 | ||
773 | // if data is passed, bind to handler
|
- | |
774 | if ( data !== undefined ) { |
666 | nodeName: function( elem, name ) { |
775 | // Create temporary function pointer to original handler
|
667 | return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase(); |
776 | var fn = handler; |
668 | }, |
777 | 669 | ||
- | 670 | // args is for internal usage only
|
|
778 | // Create unique handler function, wrapped around original handler
|
671 | each: function( object, callback, args ) { |
779 | handler = this.proxy( fn ); |
672 | var name, i = 0, length = object.length; |
780 | 673 | ||
- | 674 | if ( args ) { |
|
781 | // Store data in unique handler
|
675 | if ( length === undefined ) { |
- | 676 | for ( name in object ) |
|
- | 677 | if ( callback.apply( object[ name ], args ) === false ) |
|
- | 678 | break; |
|
- | 679 | } else |
|
782 | handler.data = data; |
680 | for ( ; i < length; ) |
- | 681 | if ( callback.apply( object[ i++ ], args ) === false ) |
|
- | 682 | break; |
|
- | 683 | ||
- | 684 | // A special, fast, case for the most common use of each
|
|
- | 685 | } else { |
|
- | 686 | if ( length === undefined ) { |
|
- | 687 | for ( name in object ) |
|
- | 688 | if ( callback.call( object[ name ], name, object[ name ] ) === false ) |
|
- | 689 | break; |
|
- | 690 | } else |
|
- | 691 | for ( var value = object[0]; |
|
- | 692 | i < length && callback.call( value, i, value ) !== false; value = object[++i] ){} |
|
783 | }
|
693 | }
|
784 | 694 | ||
785 | // Init the element's event structure
|
- | |
786 | var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ), |
- | |
787 | handle = jQuery.data( elem, "handle" ) || jQuery.data( elem, "handle", function() { |
- | |
788 | // Handle the second event of a trigger and when
|
- | |
789 | // an event is called after a page has unloaded
|
- | |
790 | return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
- | |
791 | jQuery.event.handle.apply( arguments.callee.elem, arguments ) : |
- | |
792 | undefined; |
695 | return object; |
793 | }); |
696 | }, |
794 | // Add elem as a property of the handle function
|
- | |
795 | // This is to prevent a memory leak with non-native
|
- | |
796 | // event in IE.
|
- | |
797 | handle.elem = elem; |
- | |
798 | 697 | ||
- | 698 | prop: function( elem, value, type, i, name ) { |
|
799 | // Handle multiple events separated by a space
|
699 | // Handle executable functions
|
800 | // jQuery(...).bind("mouseover mouseout", fn);
|
700 | if ( jQuery.isFunction( value ) ) |
801 | types = types.split( /\s+/ ); |
701 | value = value.call( elem, i ); |
- | 702 | ||
- | 703 | // Handle passing in a number to a CSS property
|
|
- | 704 | return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ? |
|
802 | var type, i=0; |
705 | value + "px" : |
- | 706 | value;
|
|
- | 707 | }, |
|
- | 708 | ||
- | 709 | className: { |
|
803 | while ( (type = types[ i++ ]) ) { |
710 | // internal only, use addClass("class")
|
804 | // Namespaced event handlers
|
711 | add: function( elem, classNames ) { |
805 | var namespaces = type.split("."); |
712 | jQuery.each((classNames || "").split(/\s+/), function(i, className){ |
806 | type = namespaces.shift(); |
713 | if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) |
807 | handler.type = namespaces.slice(0).sort().join("."); |
714 | elem.className += (elem.className ? " " : "") + className; |
- | 715 | }); |
|
- | 716 | }, |
|
808 | 717 | ||
- | 718 | // internal only, use removeClass("class")
|
|
809 | // Get the current list of functions bound to this event
|
719 | remove: function( elem, classNames ) { |
810 | var handlers = events[ type ], |
720 | if (elem.nodeType == 1) |
811 | special = this.special[ type ] || {}; |
721 | elem.className = classNames !== undefined ? |
- | 722 | jQuery.grep(elem.className.split(/\s+/), function(className){ |
|
- | 723 | return !jQuery.className.has( classNames, className ); |
|
- | 724 | }).join(" ") : |
|
- | 725 | ""; |
|
- | 726 | }, |
|
812 | 727 | ||
813 | if ( special.add ) { |
- | |
814 | var modifiedHandler = special.add.call( elem, handler, data, namespaces ); |
728 | // internal only, use hasClass("class")
|
815 | if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) { |
729 | has: function( elem, className ) { |
816 | modifiedHandler.guid = modifiedHandler.guid || handler.guid; |
730 | return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; |
817 | handler = modifiedHandler; |
- | |
818 | }
|
- | |
819 | }
|
731 | }
|
- | 732 | }, |
|
820 | 733 | ||
821 | // Init the event handler queue
|
- | |
822 | if ( !handlers ) { |
- | |
823 | handlers = events[ type ] = {}; |
- | |
824 | - | ||
825 | // Check for a special event handler
|
734 | // A method for quickly swapping in/out CSS properties to get correct calculations
|
826 | // Only use addEventListener/attachEvent if the special
|
735 | swap: function( elem, options, callback ) { |
827 | // events handler returns false
|
736 | var old = {}; |
828 | if ( !special.setup || special.setup.call( elem, data, namespaces ) === false ) { |
- | |
829 | // Bind the global event handler to the element
|
737 | // Remember the old values, and insert the new ones
|
830 | if ( elem.addEventListener ) { |
738 | for ( var name in options ) { |
831 | elem.addEventListener( type, handle, false ); |
- | |
832 | } else if ( elem.attachEvent ) { |
739 | old[ name ] = elem.style[ name ]; |
833 | elem.attachEvent( "on" + type, handle ); |
740 | elem.style[ name ] = options[ name ]; |
834 | }
|
- | |
835 | }
|
- | |
836 | }
|
741 | }
|
837 | 742 | ||
838 | // Add the function to the element's handler list
|
- | |
839 | handlers[ handler.guid ] = handler; |
- | |
840 | - | ||
841 | // Keep track of which events have been used, for global triggering
|
- | |
842 | this.global[ type ] = true; |
743 | callback.call( elem ); |
843 | }
|
- | |
844 | 744 | ||
845 | // Nullify elem to prevent memory leaks in IE
|
745 | // Revert the old values
|
- | 746 | for ( var name in options ) |
|
846 | elem = null; |
747 | elem.style[ name ] = old[ name ]; |
847 | }, |
748 | }, |
848 | 749 | ||
849 | guid: 1, |
750 | css: function( elem, name, force, extra ) { |
850 | global: {}, |
751 | if ( name == "width" || name == "height" ) { |
- | 752 | var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; |
|
851 | 753 | ||
852 | // Detach an event or set of events from an element
|
- | |
853 | remove: function( elem, types, handler ) { |
754 | function getWH() { |
854 | // don't do events on text and comment nodes
|
755 | val = name == "width" ? elem.offsetWidth : elem.offsetHeight; |
- | 756 | ||
855 | if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
757 | if ( extra === "border" ) |
856 | return; |
758 | return; |
- | 759 | ||
- | 760 | jQuery.each( which, function() { |
|
- | 761 | if ( !extra ) |
|
- | 762 | val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
|
- | 763 | if ( extra === "margin" ) |
|
- | 764 | val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; |
|
- | 765 | else
|
|
- | 766 | val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
|
- | 767 | }); |
|
857 | }
|
768 | }
|
858 | 769 | ||
- | 770 | if ( elem.offsetWidth !== 0 ) |
|
- | 771 | getWH(); |
|
- | 772 | else
|
|
859 | var events = jQuery.data( elem, "events" ), ret, type; |
773 | jQuery.swap( elem, props, getWH ); |
860 | 774 | ||
861 | if ( events ) { |
- | |
862 | // Unbind all events for the element
|
- | |
863 | if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) { |
- | |
864 | for ( type in events ) { |
- | |
865 | this.remove( elem, type + (types || "") ); |
- | |
866 | }
|
- | |
867 | } else { |
- | |
868 | // types is actually an event object here
|
775 | return Math.max(0, Math.round(val)); |
869 | if ( types.type ) { |
- | |
870 | handler = types.handler; |
- | |
871 | types = types.type; |
- | |
872 | }
|
776 | }
|
873 | 777 | ||
874 | // Handle multiple events seperated by a space
|
- | |
875 | // jQuery(...).unbind("mouseover mouseout", fn);
|
778 | return jQuery.curCSS( elem, name, force ); |
876 | types = types.split(/\s+/); |
- | |
877 | var i = 0; |
779 | }, |
878 | while ( (type = types[ i++ ]) ) { |
- | |
879 | // Namespaced event handlers
|
- | |
880 | var namespaces = type.split("."); |
- | |
881 | type = namespaces.shift(); |
- | |
882 | var all = !namespaces.length, |
- | |
883 | namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"), |
- | |
884 | special = this.special[ type ] || {}; |
- | |
885 | 780 | ||
886 | if ( events[ type ] ) { |
781 | curCSS: function( elem, name, force ) { |
887 | // remove the given handler for the given type
|
- | |
888 | if ( handler ) { |
- | |
889 | delete events[ type ][ handler.guid ]; |
782 | var ret, style = elem.style; |
890 | 783 | ||
891 | // remove all handlers for the given type
|
784 | // We need to handle opacity special in IE
|
892 | } else { |
- | |
893 | for ( var handle in events[ type ] ) { |
- | |
894 | // Handle the removal of namespaced events
|
- | |
895 | if ( all || namespace.test( events[ type ][ handle ].type ) ) { |
785 | if ( name == "opacity" && !jQuery.support.opacity ) { |
896 | delete events[ type ][ handle ]; |
786 | ret = jQuery.attr( style, "opacity" ); |
897 | }
|
- | |
898 | }
|
- | |
899 | }
|
- | |
900 | 787 | ||
901 | if ( special.remove ) { |
788 | return ret == "" ? |
- | 789 | "1" : |
|
902 | special.remove.call( elem, namespaces ); |
790 | ret;
|
903 | }
|
791 | }
|
904 | 792 | ||
905 | // remove generic event handler if no more handlers exist
|
793 | // Make sure we're using the right name for getting the float value
|
906 | for ( ret in events[ type ] ) { |
- | |
907 | break; |
- | |
908 | }
|
- | |
909 | if ( !ret ) { |
- | |
910 | if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { |
- | |
911 | if ( elem.removeEventListener ) { |
794 | if ( name.match( /float/i ) ) |
912 | elem.removeEventListener( type, jQuery.data( elem, "handle" ), false ); |
- | |
913 | } else if ( elem.detachEvent ) { |
- | |
914 | elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) ); |
- | |
915 | }
|
- | |
916 | }
|
- | |
917 | ret = null; |
795 | name = styleFloat; |
918 | delete events[ type ]; |
- | |
919 | }
|
- | |
920 | }
|
- | |
921 | }
|
- | |
922 | }
|
- | |
923 | 796 | ||
924 | // Remove the expando if it's no longer used
|
- | |
925 | for ( ret in events ) { |
- | |
926 | break; |
- | |
927 | }
|
- | |
928 | if ( !ret ) { |
- | |
929 | var handle = jQuery.data( elem, "handle" ); |
797 | if ( !force && style && style[ name ] ) |
930 | if ( handle ) { |
798 | ret = style[ name ]; |
931 | handle.elem = null; |
- | |
932 | }
|
- | |
933 | jQuery.removeData( elem, "events" ); |
- | |
934 | jQuery.removeData( elem, "handle" ); |
- | |
935 | }
|
- | |
936 | }
|
- | |
937 | }, |
- | |
938 | 799 | ||
939 | // bubbling is internal
|
- | |
940 | trigger: function( event, data, elem /*, bubbling */ ) { |
800 | else if ( defaultView.getComputedStyle ) { |
941 | // Event object or event type
|
- | |
942 | var type = event.type || event, |
- | |
943 | bubbling = arguments[3]; |
- | |
944 | 801 | ||
945 | if ( !bubbling ) { |
- | |
946 | event = typeof event === "object" ? |
- | |
947 | // jQuery.Event object
|
- | |
948 | event[expando] ? event : |
802 | // Only "float" is needed here
|
949 | // Object literal
|
- | |
950 | jQuery.extend( jQuery.Event(type), event ) : |
- | |
951 | // Just the event type (string)
|
803 | if ( name.match( /float/i ) ) |
952 | jQuery.Event(type); |
804 | name = "float"; |
953 | 805 | ||
954 | if ( type.indexOf("!") >= 0 ) { |
- | |
955 | event.type = type = type.slice(0, -1); |
806 | name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); |
956 | event.exclusive = true; |
- | |
957 | }
|
- | |
958 | 807 | ||
959 | // Handle a global trigger
|
- | |
960 | if ( !elem ) { |
- | |
961 | // Don't bubble custom events when global (to avoid too much overhead)
|
- | |
962 | event.stopPropagation(); |
- | |
963 | // Only trigger if we've ever bound an event for it
|
808 | var computedStyle = defaultView.getComputedStyle( elem, null ); |
964 | if ( this.global[ type ] ) { |
- | |
965 | jQuery.each( jQuery.cache, function() { |
- | |
966 | if ( this.events && this.events[type] ) { |
- | |
967 | jQuery.event.trigger( event, data, this.handle.elem ); |
- | |
968 | }
|
- | |
969 | }); |
- | |
970 | }
|
- | |
971 | }
|
- | |
972 | 809 | ||
- | 810 | if ( computedStyle ) |
|
973 | // Handle triggering a single element
|
811 | ret = computedStyle.getPropertyValue( name ); |
974 | 812 | ||
975 | // don't do events on text and comment nodes
|
813 | // We should always get a number back from opacity
|
976 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
814 | if ( name == "opacity" && ret == "" ) |
977 | return undefined; |
815 | ret = "1"; |
978 | }
|
- | |
979 | 816 | ||
980 | // Clean up in case it is reused
|
817 | } else if ( elem.currentStyle ) { |
981 | event.result = undefined; |
818 | var camelCase = name.replace(/\-(\w)/g, function(all, letter){ |
982 | event.target = elem; |
819 | return letter.toUpperCase(); |
- | 820 | }); |
|
983 | 821 | ||
984 | // Clone the incoming data, if any
|
- | |
985 | data = jQuery.makeArray( data ); |
822 | ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; |
986 | data.unshift( event ); |
- | |
987 | }
|
- | |
988 | 823 | ||
989 | event.currentTarget = elem; |
824 | // From the awesome hack by Dean Edwards
|
- | 825 | // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
|
990 | 826 | ||
- | 827 | // If we're not dealing with a regular pixel number
|
|
991 | // Trigger the event, it is assumed that "handle" is a function
|
828 | // but a number that has a weird ending, we need to convert it to pixels
|
992 | var handle = jQuery.data( elem, "handle" ); |
829 | if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { |
993 | if ( handle ) { |
830 | // Remember the original values
|
994 | handle.apply( elem, data ); |
831 | var left = style.left, rsLeft = elem.runtimeStyle.left; |
995 | }
|
- | |
996 | 832 | ||
997 | var nativeFn, nativeHandler; |
833 | // Put in the new values to get a computed value out
|
998 | try { |
- | |
999 | nativeFn = elem[ type ]; |
- | |
1000 | nativeHandler = elem[ "on" + type ]; |
834 | elem.runtimeStyle.left = elem.currentStyle.left; |
1001 | // prevent IE from throwing an error for some elements with some event types, see #3533
|
- | |
1002 | } catch (e) {} |
835 | style.left = ret || 0; |
1003 | // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
|
- | |
1004 | if ( (!nativeFn || (jQuery.nodeName(elem, 'a') && type === "click")) && nativeHandler && nativeHandler.apply( elem, data ) === false ) { |
- | |
1005 | event.result = false; |
836 | ret = style.pixelLeft + "px"; |
1006 | }
|
- | |
1007 | 837 | ||
1008 | // Trigger the native events (except for clicks on links)
|
- | |
1009 | if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type === "click") ) { |
- | |
1010 | this.triggered = true; |
838 | // Revert the changed values
|
1011 | try { |
- | |
1012 | nativeFn(); |
839 | style.left = left; |
1013 | // prevent IE from throwing an error for some hidden elements
|
840 | elem.runtimeStyle.left = rsLeft; |
1014 | } catch (e) {} |
841 | }
|
1015 | }
|
842 | }
|
1016 | 843 | ||
1017 | this.triggered = false; |
844 | return ret; |
- | 845 | }, |
|
1018 | 846 | ||
- | 847 | clean: function( elems, context, fragment ) { |
|
- | 848 | context = context || document; |
|
- | 849 | ||
- | 850 | // !context.createElement fails in IE with an error but returns typeof 'object'
|
|
1019 | if ( !event.isPropagationStopped() ) { |
851 | if ( typeof context.createElement === "undefined" ) |
- | 852 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
|
- | 853 | ||
- | 854 | // If a single string is passed in and it's a single tag
|
|
- | 855 | // just do a createElement and skip the rest
|
|
- | 856 | if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) { |
|
1020 | var parent = elem.parentNode || elem.ownerDocument; |
857 | var match = /^<(\w+)\s*\/?>$/.exec(elems[0]); |
1021 | if ( parent ) { |
858 | if ( match ) |
1022 | jQuery.event.trigger( event, data, parent, true ); |
859 | return [ context.createElement( match[1] ) ]; |
1023 | }
|
- | |
1024 | }
|
860 | }
|
1025 | }, |
- | |
1026 | 861 | ||
1027 | handle: function( event ) { |
- | |
1028 | // returned undefined or false
|
862 | var ret = [], scripts = [], div = context.createElement("div"); |
1029 | var all, handlers; |
- | |
1030 | 863 | ||
1031 | event = arguments[0] = jQuery.event.fix( event || window.event ); |
864 | jQuery.each(elems, function(i, elem){ |
1032 | event.currentTarget = this; |
865 | if ( typeof elem === "number" ) |
- | 866 | elem += ''; |
|
1033 | 867 | ||
1034 | // Namespaced event handlers
|
868 | if ( !elem ) |
1035 | var namespaces = event.type.split("."); |
- | |
1036 | event.type = namespaces.shift(); |
869 | return; |
1037 | 870 | ||
1038 | // Cache this now, all = true means, any handler
|
871 | // Convert html string into DOM nodes
|
- | 872 | if ( typeof elem === "string" ) { |
|
1039 | all = !namespaces.length && !event.exclusive; |
873 | // Fix "XHTML"-style tags in all browsers
|
- | 874 | elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ |
|
- | 875 | return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? |
|
- | 876 | all :
|
|
- | 877 | front + "></" + tag + ">"; |
|
- | 878 | }); |
|
1040 | 879 | ||
- | 880 | // Trim whitespace, otherwise indexOf won't work as expected
|
|
1041 | var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"); |
881 | var tags = elem.replace(/^\s+/, "").substring(0, 10).toLowerCase(); |
1042 | 882 | ||
- | 883 | var wrap = |
|
- | 884 | // option or optgroup
|
|
- | 885 | !tags.indexOf("<opt") && |
|
1043 | handlers = ( jQuery.data(this, "events") || {} )[ event.type ]; |
886 | [ 1, "<select multiple='multiple'>", "</select>" ] || |
1044 | 887 | ||
1045 | for ( var j in handlers ) { |
888 | !tags.indexOf("<leg") && |
1046 | var handler = handlers[ j ]; |
889 | [ 1, "<fieldset>", "</fieldset>" ] || |
1047 | 890 | ||
1048 | // Filter the functions by class
|
- | |
1049 | if ( all || namespace.test(handler.type) ) { |
891 | tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && |
1050 | // Pass in a reference to the handler function itself
|
- | |
1051 | // So that we can later remove it
|
892 | [ 1, "<table>", "</table>" ] || |
1052 | event.handler = handler; |
- | |
1053 | event.data = handler.data; |
- | |
1054 | 893 | ||
- | 894 | !tags.indexOf("<tr") && |
|
1055 | var ret = handler.apply( this, arguments ); |
895 | [ 2, "<table><tbody>", "</tbody></table>" ] || |
1056 | 896 | ||
1057 | if ( ret !== undefined ) { |
- | |
1058 | event.result = ret; |
- | |
1059 | if ( ret === false ) { |
897 | // <thead> matched above
|
1060 | event.preventDefault(); |
898 | (!tags.indexOf("<td") || !tags.indexOf("<th")) && |
1061 | event.stopPropagation(); |
899 | [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] || |
1062 | }
|
- | |
1063 | }
|
- | |
1064 | 900 | ||
1065 | if ( event.isImmediatePropagationStopped() ) { |
901 | !tags.indexOf("<col") && |
1066 | break; |
902 | [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] || |
1067 | }
|
- | |
1068 | 903 | ||
- | 904 | // IE can't serialize <link> and <script> tags normally
|
|
1069 | }
|
905 | !jQuery.support.htmlSerialize && |
1070 | }
|
- | |
1071 | }, |
906 | [ 1, "div<div>", "</div>" ] || |
1072 | 907 | ||
1073 | 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(" "), |
908 | [ 0, "", "" ]; |
1074 | 909 | ||
1075 | fix: function( event ) { |
910 | // Go to html and back, then peel off extra wrappers
|
1076 | if ( event[ expando ] ) { |
911 | div.innerHTML = wrap[1] + elem + wrap[2]; |
1077 | return event; |
- | |
1078 | }
|
- | |
1079 | 912 | ||
1080 | // store a copy of the original event object
|
913 | // Move to the right depth
|
1081 | // and "clone" to set read-only properties
|
914 | while ( wrap[0]-- ) |
1082 | var originalEvent = event; |
915 | div = div.lastChild; |
1083 | event = jQuery.Event( originalEvent ); |
- | |
1084 | 916 | ||
1085 | for ( var i = this.props.length, prop; i; ) { |
917 | // Remove IE's autoinserted <tbody> from table fragments
|
1086 | prop = this.props[ --i ]; |
918 | if ( !jQuery.support.tbody ) { |
1087 | event[ prop ] = originalEvent[ prop ]; |
- | |
1088 | }
|
- | |
1089 | 919 | ||
- | 920 | // String was a <table>, *may* have spurious <tbody>
|
|
1090 | // Fix target property, if necessary
|
921 | var hasBody = /<tbody/i.test(elem), |
1091 | if ( !event.target ) { |
922 | tbody = !tags.indexOf("<table") && !hasBody ? |
1092 | event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
923 | div.firstChild && div.firstChild.childNodes : |
1093 | }
|
- | |
1094 | 924 | ||
1095 | // check if target is a textnode (safari)
|
925 | // String was a bare <thead> or <tfoot>
|
1096 | if ( event.target.nodeType === 3 ) { |
926 | wrap[1] == "<table>" && !hasBody ? |
1097 | event.target = event.target.parentNode; |
927 | div.childNodes : |
1098 | }
|
928 | []; |
1099 | 929 | ||
1100 | // Add relatedTarget, if necessary
|
930 | for ( var j = tbody.length - 1; j >= 0 ; --j ) |
1101 | if ( !event.relatedTarget && event.fromElement ) { |
931 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) |
1102 | event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; |
932 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
1103 | }
|
- | |
1104 | 933 | ||
1105 | // Calculate pageX/Y if missing and clientX/Y available
|
- | |
1106 | if ( event.pageX == null && event.clientX != null ) { |
- | |
1107 | var doc = document.documentElement, body = document.body; |
- | |
1108 | event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); |
- | |
1109 | event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); |
- | |
1110 | }
|
934 | }
|
1111 | 935 | ||
1112 | // Add which for key events
|
936 | // IE completely kills leading whitespace when innerHTML is used
|
1113 | if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) { |
937 | if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) ) |
1114 | event.which = event.charCode || event.keyCode; |
938 | div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild ); |
1115 | }
|
- | |
1116 | 939 | ||
1117 | // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
- | |
1118 | if ( !event.metaKey && event.ctrlKey ) { |
940 | elem = jQuery.makeArray( div.childNodes ); |
1119 | event.metaKey = event.ctrlKey; |
- | |
1120 | }
|
941 | }
|
1121 | 942 | ||
1122 | // Add which for click: 1 == left; 2 == middle; 3 == right
|
- | |
1123 | // Note: button is not normalized, so don't use it
|
943 | if ( elem.nodeType ) |
1124 | if ( !event.which && event.button !== undefined ) { |
944 | ret.push( elem ); |
1125 | event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
- | |
1126 | }
|
945 | else
|
- | 946 | ret = jQuery.merge( ret, elem ); |
|
1127 | 947 | ||
1128 | return event; |
- | |
1129 | }, |
948 | }); |
1130 | 949 | ||
- | 950 | if ( fragment ) { |
|
1131 | proxy: function( fn, proxy, thisObject ) { |
951 | for ( var i = 0; ret[i]; i++ ) { |
- | 952 | if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
|
1132 | if ( proxy !== undefined && !jQuery.isFunction( proxy ) ) { |
953 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
1133 | thisObject = proxy; |
954 | } else { |
1134 | proxy = undefined; |
955 | if ( ret[i].nodeType === 1 ) |
- | 956 | ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
|
- | 957 | fragment.appendChild( ret[i] ); |
|
- | 958 | }
|
|
1135 | }
|
959 | }
|
1136 | // FIXME: Should proxy be redefined to be applied with thisObject if defined?
|
- | |
1137 | proxy = proxy || function() { return fn.apply( thisObject !== undefined ? thisObject : this, arguments ); }; |
- | |
1138 | // Set the guid of unique handler to the same of original handler, so it can be removed
|
- | |
1139 | proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++; |
- | |
1140 | // So proxy can be declared as an argument
|
- | |
1141 | return proxy; |
- | |
1142 | }, |
- | |
1143 | 960 | ||
1144 | special: { |
- | |
1145 | ready: { |
- | |
1146 | // Make sure the ready event is setup
|
- | |
1147 | setup: bindReady, |
961 | return scripts; |
1148 | teardown: function() {} |
- | |
1149 | }, |
962 | }
|
1150 | 963 | ||
1151 | live: { |
964 | return ret; |
1152 | add: function( proxy, data, namespaces ) { |
- | |
1153 | jQuery.extend( proxy, data || {} ); |
- | |
1154 | proxy.guid += data.selector + data.live; |
- | |
1155 | jQuery.event.add( this, data.live, liveHandler, data ); |
- | |
1156 | }, |
965 | }, |
1157 | 966 | ||
1158 | remove: function( namespaces ) { |
967 | attr: function( elem, name, value ) { |
1159 | if ( namespaces.length ) { |
968 | // don't set attributes on text and comment nodes
|
1160 | var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); |
969 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
- | 970 | return undefined; |
|
1161 | 971 | ||
1162 | jQuery.each( (jQuery.data(this, "events").live || {}), function() { |
972 | var notxml = !jQuery.isXMLDoc( elem ), |
1163 | if ( name.test(this.type) ) { |
973 | // Whether we are setting (or getting)
|
1164 | remove++;
|
974 | set = value !== undefined; |
1165 | }
|
- | |
1166 | }); |
- | |
1167 | 975 | ||
1168 | if ( remove < 1 ) { |
976 | // Try to normalize/fix the name
|
1169 | jQuery.event.remove( this, namespaces[0], liveHandler ); |
977 | name = notxml && jQuery.props[ name ] || name; |
1170 | }
|
- | |
1171 | }
|
- | |
1172 | }
|
- | |
1173 | }
|
- | |
1174 | }
|
- | |
1175 | }; |
- | |
1176 | 978 | ||
1177 | jQuery.Event = function( src ){ |
979 | // Only do all the following if this is a node (faster for style)
|
1178 | // Allow instantiation without the 'new' keyword
|
980 | // IE elem.getAttribute passes even for style
|
1179 | if ( !this.preventDefault ) { |
981 | if ( elem.tagName ) { |
1180 | return new jQuery.Event( src ); |
- | |
1181 | }
|
- | |
1182 | 982 | ||
1183 | // Event object
|
- | |
1184 | if ( src && src.type ) { |
- | |
1185 | this.originalEvent = src; |
983 | // These attributes require special treatment
|
1186 | this.type = src.type; |
984 | var special = /href|src|style/.test( name ); |
1187 | // Event type
|
- | |
1188 | } else { |
- | |
1189 | this.type = src; |
- | |
1190 | }
|
- | |
1191 | 985 | ||
- | 986 | // Safari mis-reports the default selected property of a hidden option
|
|
1192 | // timeStamp is buggy for some events on Firefox(#3843)
|
987 | // Accessing the parent's selectedIndex property fixes it
|
1193 | // So we won't rely on the native value
|
988 | if ( name == "selected" && elem.parentNode ) |
1194 | this.timeStamp = now(); |
989 | elem.parentNode.selectedIndex; |
1195 | 990 | ||
- | 991 | // If applicable, access the attribute via the DOM 0 way
|
|
- | 992 | if ( name in elem && notxml && !special ) { |
|
1196 | // Mark it as fixed
|
993 | if ( set ){ |
- | 994 | // We can't allow the type property to be changed (since it causes problems in IE)
|
|
- | 995 | if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode ) |
|
1197 | this[ expando ] = true; |
996 | throw "type property can't be changed"; |
1198 | }; |
- | |
1199 | 997 | ||
1200 | function returnFalse() { |
- | |
1201 | return false; |
998 | elem[ name ] = value; |
1202 | }
|
- | |
1203 | function returnTrue() { |
- | |
1204 | return true; |
- | |
1205 | }
|
999 | }
|
1206 | 1000 | ||
1207 | // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
1001 | // browsers index elements by id/name on forms, give priority to attributes.
|
1208 | // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
1002 | if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) |
1209 | jQuery.Event.prototype = { |
- | |
1210 | preventDefault: function() { |
- | |
1211 | this.isDefaultPrevented = returnTrue; |
1003 | return elem.getAttributeNode( name ).nodeValue; |
1212 | 1004 | ||
- | 1005 | // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
|
- | 1006 | // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
|
- | 1007 | if ( name == "tabIndex" ) { |
|
- | 1008 | var attributeNode = elem.getAttributeNode( "tabIndex" ); |
|
- | 1009 | return attributeNode && attributeNode.specified |
|
1213 | var e = this.originalEvent; |
1010 | ? attributeNode.value |
- | 1011 | : elem.nodeName.match(/(button|input|object|select|textarea)/i) |
|
1214 | if ( !e ) { |
1012 | ? 0 |
- | 1013 | : elem.nodeName.match(/^(a|area)$/i) && elem.href |
|
1215 | return; |
1014 | ? 0 |
- | 1015 | : undefined; |
|
1216 | }
|
1016 | }
|
1217 | 1017 | ||
1218 | // if preventDefault exists run it on the original event
|
- | |
1219 | if ( e.preventDefault ) { |
- | |
1220 | e.preventDefault(); |
1018 | return elem[ name ]; |
1221 | }
|
1019 | }
|
1222 | // otherwise set the returnValue property of the original event to false (IE)
|
- | |
1223 | e.returnValue = false; |
- | |
1224 | }, |
- | |
1225 | stopPropagation: function() { |
- | |
1226 | this.isPropagationStopped = returnTrue; |
- | |
1227 | 1020 | ||
1228 | var e = this.originalEvent; |
- | |
1229 | if ( !e ) { |
- | |
1230 | return; |
- | |
1231 | }
|
- | |
1232 | // if stopPropagation exists run it on the original event
|
1021 | if ( !jQuery.support.style && notxml && name == "style" ) |
1233 | if ( e.stopPropagation ) { |
- | |
1234 | e.stopPropagation(); |
- | |
1235 | }
|
- | |
1236 | // otherwise set the cancelBubble property of the original event to true (IE)
|
- | |
1237 | e.cancelBubble = true; |
- | |
1238 | }, |
- | |
1239 | stopImmediatePropagation: function(){ |
- | |
1240 | this.isImmediatePropagationStopped = returnTrue; |
- | |
1241 | this.stopPropagation(); |
- | |
1242 | }, |
- | |
1243 | isDefaultPrevented: returnFalse, |
- | |
1244 | isPropagationStopped: returnFalse, |
- | |
1245 | isImmediatePropagationStopped: returnFalse
|
- | |
1246 | }; |
- | |
1247 | // Checks if an event happened on an element within another element
|
- | |
1248 | // Used in jQuery.event.special.mouseenter and mouseleave handlers
|
1022 | return jQuery.attr( elem.style, "cssText", value ); |
1249 | var withinElement = function( event ) { |
- | |
1250 | // Check if mouse(over|out) are still within the same parent element
|
- | |
1251 | var parent = event.relatedTarget; |
- | |
1252 | // Traverse up the tree
|
- | |
1253 | while ( parent && parent != this ) { |
- | |
1254 | // Firefox sometimes assigns relatedTarget a XUL element
|
- | |
1255 | // which we cannot access the parentNode property of
|
- | |
1256 | try { parent = parent.parentNode; } |
- | |
1257 | // assuming we've left the element since we most likely mousedover a xul element
|
- | |
1258 | catch(e) { break; } |
- | |
1259 | }
|
- | |
1260 | 1023 | ||
1261 | if ( parent != this ) { |
1024 | if ( set ) |
1262 | // set the correct event type
|
- | |
1263 | event.type = event.data; |
- | |
1264 | // handle event if we actually just moused on to a non sub-element
|
1025 | // convert the value to a string (all browsers do this but IE) see #1070
|
1265 | jQuery.event.handle.apply( this, arguments ); |
1026 | elem.setAttribute( name, "" + value ); |
1266 | }
|
- | |
1267 | }; |
- | |
1268 | 1027 | ||
1269 | // Create mouseenter and mouseleave events
|
1028 | var attr = !jQuery.support.hrefNormalized && notxml && special |
1270 | jQuery.each({ |
- | |
1271 | mouseover: "mouseenter", |
- | |
1272 | mouseout: "mouseleave" |
- | |
1273 | }, function( orig, fix ) { |
1029 | // Some attributes require a special call on IE
|
1274 | jQuery.event.special[ fix ] = { |
1030 | ? elem.getAttribute( name, 2 ) |
1275 | setup: function(){ |
- | |
1276 | jQuery.event.add( this, orig, withinElement, fix ); |
1031 | : elem.getAttribute( name ); |
1277 | }, |
1032 | |
1278 | teardown: function(){ |
1033 | // Non-existent attributes return null, we normalize to undefined
|
1279 | jQuery.event.remove( this, orig, withinElement ); |
1034 | return attr === null ? undefined : attr; |
1280 | }
|
1035 | }
|
1281 | }; |
- | |
1282 | }); |
- | |
1283 | 1036 | ||
1284 | (function() { |
1037 | // elem is actually elem.style ... set the style
|
1285 | 1038 | ||
1286 | var event = jQuery.event, |
- | |
1287 | special = event.special, |
1039 | // IE uses filters for opacity
|
1288 | handle = event.handle; |
- | |
1289 | - | ||
1290 | special.submit = { |
- | |
1291 | setup: function(data, namespaces) { |
1040 | if ( !jQuery.support.opacity && name == "opacity" ) { |
1292 | if(data.selector) { |
1041 | if ( set ) { |
1293 | event.add(this, 'click.specialSubmit', function(e, eventData) { |
1042 | // IE has trouble with opacity if it does not have layout
|
1294 | if(jQuery(e.target).filter(":submit, :image").closest(data.selector).length) { |
1043 | // Force it by setting the zoom level
|
1295 | e.type = "submit"; |
1044 | elem.zoom = 1; |
1296 | return handle.call( this, e, eventData ); |
- | |
1297 | }
|
- | |
1298 | }); |
- | |
1299 | 1045 | ||
1300 | event.add(this, 'keypress.specialSubmit', function( e, eventData ) { |
1046 | // Set the alpha filter to set the opacity
|
1301 | if(jQuery(e.target).filter(":text, :password").closest(data.selector).length) { |
1047 | elem.filter = (elem.filter || "").replace( /alpha\([^)]*\)/, "" ) + |
1302 | e.type = "submit"; |
- | |
1303 | return handle.call( this, e, eventData ); |
1048 | (parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"); |
1304 | }
|
- | |
1305 | }); |
- | |
1306 | } else { |
- | |
1307 | return false; |
- | |
1308 | }
|
1049 | }
|
1309 | }, |
- | |
1310 | 1050 | ||
1311 | remove: function(namespaces) { |
- | |
1312 | event.remove(this, 'click.specialSubmit'); |
1051 | return elem.filter && elem.filter.indexOf("opacity=") >= 0 ? |
1313 | event.remove(this, 'keypress.specialSubmit'); |
1052 | (parseFloat( elem.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '': |
- | 1053 | ""; |
|
1314 | }
|
1054 | }
|
1315 | }; |
- | |
1316 | 1055 | ||
- | 1056 | name = name.replace(/-([a-z])/ig, function(all, letter){ |
|
- | 1057 | return letter.toUpperCase(); |
|
1317 | })(); |
1058 | }); |
1318 | 1059 | ||
1319 | // Create "bubbling" focus and blur events
|
- | |
1320 | jQuery.each({ |
- | |
1321 | focus: "focusin", |
- | |
1322 | blur: "focusout" |
1060 | if ( set ) |
1323 | }, function( orig, fix ){ |
- | |
1324 | var event = jQuery.event, |
- | |
1325 | special = event.special, |
- | |
1326 | handle = event.handle; |
1061 | elem[ name ] = value; |
1327 | 1062 | ||
1328 | function ieHandler() { |
1063 | return elem[ name ]; |
1329 | arguments[0].type = orig; |
- | |
1330 | return handle.apply(this, arguments); |
- | |
1331 | }
|
1064 | }, |
1332 | 1065 | ||
1333 | special[orig] = { |
- | |
1334 | setup:function() { |
1066 | trim: function( text ) { |
1335 | if ( this.addEventListener ) |
- | |
1336 | this.addEventListener( orig, handle, true ); |
1067 | return (text || "").replace( /^\s+|\s+$/g, "" ); |
1337 | else
|
- | |
1338 | jQuery.event.add( this, fix, ieHandler ); |
- | |
1339 | }, |
1068 | }, |
1340 | teardown:function() { |
- | |
1341 | if ( this.removeEventListener ) |
- | |
1342 | this.removeEventListener( orig, handle, true ); |
- | |
1343 | else
|
- | |
1344 | jQuery.event.remove( this, fix, ieHandler ); |
- | |
1345 | }
|
- | |
1346 | }; |
- | |
1347 | }); |
- | |
1348 | 1069 | ||
1349 | jQuery.fn.extend({ |
- | |
1350 | // TODO: make bind(), unbind() and one() DRY!
|
- | |
1351 | bind: function( type, data, fn, thisObject ) { |
- | |
1352 | // Handle object literals
|
- | |
1353 | if ( typeof type === "object" ) { |
- | |
1354 | for ( var key in type ) { |
1070 | makeArray: function( array ) { |
1355 | this.bind(key, data, type[key], fn); |
- | |
1356 | }
|
- | |
1357 | return this; |
1071 | var ret = []; |
1358 | }
|
- | |
1359 | 1072 | ||
1360 | if ( jQuery.isFunction( data ) ) { |
1073 | if( array != null ){ |
1361 | thisObject = fn; |
1074 | var i = array.length; |
- | 1075 | // The window, strings (and functions) also have 'length'
|
|
- | 1076 | if( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval ) |
|
1362 | fn = data; |
1077 | ret[0] = array; |
- | 1078 | else
|
|
- | 1079 | while( i ) |
|
1363 | data = undefined; |
1080 | ret[--i] = array[i]; |
1364 | }
|
1081 | }
|
1365 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
- | |
1366 | return type === "unload" ? this.one(type, data, fn, thisObject) : this.each(function() { |
- | |
1367 | jQuery.event.add( this, type, fn, data ); |
- | |
- | 1082 | ||
1368 | }); |
1083 | return ret; |
1369 | }, |
1084 | }, |
1370 | 1085 | ||
1371 | one: function( type, data, fn, thisObject ) { |
1086 | inArray: function( elem, array ) { |
1372 | // Handle object literals
|
1087 | for ( var i = 0, length = array.length; i < length; i++ ) |
1373 | if ( typeof type === "object" ) { |
1088 | // Use === because on IE, window == document
|
1374 | for ( var key in type ) { |
1089 | if ( array[ i ] === elem ) |
1375 | this.one(key, data, type[key], fn); |
- | |
1376 | }
|
- | |
1377 | return this; |
1090 | return i; |
1378 | }
|
- | |
1379 | 1091 | ||
1380 | if ( jQuery.isFunction( data ) ) { |
- | |
1381 | thisObject = fn; |
- | |
1382 | fn = data; |
1092 | return -1; |
1383 | data = undefined; |
- | |
1384 | }
|
- | |
1385 | fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject ); |
- | |
1386 | var one = jQuery.event.proxy( fn, function( event ) { |
- | |
1387 | jQuery( this ).unbind( event, one ); |
- | |
1388 | return fn.apply( this, arguments ); |
- | |
1389 | }); |
- | |
1390 | return this.each(function() { |
- | |
1391 | jQuery.event.add( this, type, one, data ); |
- | |
1392 | }); |
- | |
1393 | }, |
1093 | }, |
1394 | 1094 | ||
1395 | unbind: function( type, fn ) { |
1095 | merge: function( first, second ) { |
- | 1096 | // We have to loop this way because IE & Opera overwrite the length
|
|
1396 | // Handle object literals
|
1097 | // expando of getElementsByTagName
|
- | 1098 | var i = 0, elem, pos = first.length; |
|
- | 1099 | // Also, we need to make sure that the correct elements are being returned
|
|
1397 | if ( typeof type === "object" && !type.preventDefault ) { |
1100 | // (IE returns comment nodes in a '*' query)
|
1398 | for ( var key in type ) { |
1101 | if ( !jQuery.support.getAll ) { |
1399 | this.unbind(key, type[key]); |
1102 | while ( (elem = second[ i++ ]) != null ) |
1400 | }
|
1103 | if ( elem.nodeType != 8 ) |
1401 | return this; |
1104 | first[ pos++ ] = elem; |
1402 | }
|
- | |
1403 | 1105 | ||
1404 | return this.each(function() { |
1106 | } else |
1405 | jQuery.event.remove( this, type, fn ); |
1107 | while ( (elem = second[ i++ ]) != null ) |
1406 | }); |
1108 | first[ pos++ ] = elem; |
1407 | }, |
- | |
1408 | 1109 | ||
1409 | trigger: function( type, data ) { |
- | |
1410 | return this.each(function() { |
1110 | return first; |
1411 | jQuery.event.trigger( type, data, this ); |
- | |
1412 | }); |
- | |
1413 | }, |
1111 | }, |
1414 | 1112 | ||
1415 | triggerHandler: function( type, data ) { |
1113 | unique: function( array ) { |
1416 | if ( this[0] ) { |
- | |
1417 | var event = jQuery.Event( type ); |
1114 | var ret = [], done = {}; |
1418 | event.preventDefault(); |
- | |
1419 | event.stopPropagation(); |
- | |
1420 | jQuery.event.trigger( event, data, this[0] ); |
- | |
1421 | return event.result; |
- | |
1422 | }
|
- | |
1423 | }, |
- | |
1424 | 1115 | ||
1425 | toggle: function( fn ) { |
1116 | try { |
1426 | // Save reference to arguments for access in closure
|
- | |
1427 | var args = arguments, i = 1; |
- | |
1428 | 1117 | ||
1429 | // link all the functions, so any of them can unbind this click handler
|
1118 | for ( var i = 0, length = array.length; i < length; i++ ) { |
1430 | while( i < args.length ) { |
- | |
1431 | jQuery.event.proxy( fn, args[ i++ ] ); |
1119 | var id = jQuery.data( array[ i ] ); |
1432 | }
|
- | |
1433 | 1120 | ||
1434 | return this.click( jQuery.event.proxy( fn, function( event ) { |
1121 | if ( !done[ id ] ) { |
1435 | // Figure out which function to execute
|
1122 | done[ id ] = true; |
1436 | this.lastToggle = ( this.lastToggle || 0 ) % i; |
1123 | ret.push( array[ i ] ); |
- | 1124 | }
|
|
- | 1125 | }
|
|
1437 | 1126 | ||
1438 | // Make sure that clicks stop
|
1127 | } catch( e ) { |
1439 | event.preventDefault(); |
1128 | ret = array; |
- | 1129 | }
|
|
1440 | 1130 | ||
1441 | // and execute the function
|
- | |
1442 | return args[ this.lastToggle++ ].apply( this, arguments ) || false; |
- | |
1443 | })); |
1131 | return ret; |
1444 | }, |
1132 | }, |
1445 | 1133 | ||
1446 | hover: function( fnOver, fnOut ) { |
1134 | grep: function( elems, callback, inv ) { |
1447 | return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
- | |
1448 | }, |
1135 | var ret = []; |
1449 | 1136 | ||
1450 | ready: function( fn ) { |
1137 | // Go through the array, only saving the items
|
1451 | // Attach the listeners
|
1138 | // that pass the validator function
|
- | 1139 | for ( var i = 0, length = elems.length; i < length; i++ ) |
|
- | 1140 | if ( !inv != !callback( elems[ i ], i ) ) |
|
1452 | bindReady(); |
1141 | ret.push( elems[ i ] ); |
1453 | 1142 | ||
1454 | // If the DOM is already ready
|
- | |
1455 | if ( jQuery.isReady ) { |
1143 | return ret; |
1456 | // Execute the function immediately
|
- | |
1457 | fn.call( document, jQuery ); |
1144 | }, |
1458 | 1145 | ||
1459 | // Otherwise, remember the function for later
|
1146 | map: function( elems, callback ) { |
1460 | } else { |
1147 | var ret = []; |
1461 | // Add the function to the wait list
|
- | |
1462 | jQuery.readyList.push( fn ); |
- | |
1463 | }
|
- | |
1464 | 1148 | ||
- | 1149 | // Go through the array, translating each of the items to their
|
|
1465 | return this; |
1150 | // new value (or values).
|
1466 | }, |
- | |
- | 1151 | for ( var i = 0, length = elems.length; i < length; i++ ) { |
|
- | 1152 | var value = callback( elems[ i ], i ); |
|
1467 | 1153 | ||
1468 | live: function( type, data, fn, thisObject ) { |
- | |
1469 | if ( jQuery.isFunction( data ) ) { |
- | |
1470 | if ( fn !== undefined ) { |
1154 | if ( value != null ) |
1471 | thisObject = fn; |
1155 | ret[ ret.length ] = value; |
1472 | }
|
- | |
1473 | fn = data; |
- | |
1474 | data = undefined; |
- | |
1475 | }
|
1156 | }
|
1476 | jQuery( this.context ).bind( liveConvert( type, this.selector ), { |
- | |
1477 | data: data, selector: this.selector, live: type |
- | |
1478 | }, fn, thisObject ); |
- | |
1479 | return this; |
- | |
1480 | }, |
- | |
1481 | 1157 | ||
1482 | die: function( type, fn ) { |
1158 | return ret.concat.apply( [], ret ); |
1483 | jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null ); |
- | |
1484 | return this; |
- | |
1485 | }
|
1159 | }
|
1486 | }); |
1160 | }); |
1487 | 1161 | ||
1488 | function liveHandler( event ) { |
1162 | // Use of jQuery.browser is deprecated.
|
- | 1163 | // It's included for backwards compatibility and plugins,
|
|
1489 | var stop = true, elems = [], args = arguments; |
1164 | // although they should work to migrate away.
|
1490 | 1165 | ||
1491 | jQuery.each( jQuery.data( this, "events" ).live || [], function( i, fn ) { |
- | |
1492 | if ( fn.live === event.type ) { |
- | |
1493 | var elem = jQuery( event.target ).closest( fn.selector )[0]; |
1166 | var userAgent = navigator.userAgent.toLowerCase(); |
1494 | if ( elem ) { |
- | |
1495 | elems.push({ elem: elem, fn: fn }); |
- | |
1496 | }
|
- | |
1497 | }
|
- | |
1498 | }); |
- | |
1499 | 1167 | ||
- | 1168 | // Figure out what browser is being used
|
|
- | 1169 | jQuery.browser = { |
|
- | 1170 | version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1], |
|
- | 1171 | safari: /webkit/.test( userAgent ), |
|
1500 | elems.sort(function( a, b ) { |
1172 | opera: /opera/.test( userAgent ), |
1501 | return jQuery.data( a.elem, "closest" ) - jQuery.data( b.elem, "closest" ); |
1173 | msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), |
- | 1174 | mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) |
|
1502 | }); |
1175 | }; |
1503 | 1176 | ||
1504 | jQuery.each(elems, function() { |
1177 | jQuery.each({ |
- | 1178 | parent: function(elem){return elem.parentNode;}, |
|
- | 1179 | parents: function(elem){return jQuery.dir(elem,"parentNode");}, |
|
- | 1180 | next: function(elem){return jQuery.nth(elem,2,"nextSibling");}, |
|
- | 1181 | prev: function(elem){return jQuery.nth(elem,2,"previousSibling");}, |
|
- | 1182 | nextAll: function(elem){return jQuery.dir(elem,"nextSibling");}, |
|
- | 1183 | prevAll: function(elem){return jQuery.dir(elem,"previousSibling");}, |
|
- | 1184 | siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);}, |
|
- | 1185 | children: function(elem){return jQuery.sibling(elem.firstChild);}, |
|
- | 1186 | contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);} |
|
- | 1187 | }, function(name, fn){ |
|
1505 | event.currentTarget = this.elem; |
1188 | jQuery.fn[ name ] = function( selector ) { |
1506 | event.data = this.fn.data; |
1189 | var ret = jQuery.map( this, fn ); |
- | 1190 | ||
1507 | if ( this.fn.apply( this.elem, args ) === false ) { |
1191 | if ( selector && typeof selector == "string" ) |
1508 | return (stop = false); |
1192 | ret = jQuery.multiFilter( selector, ret ); |
- | 1193 | ||
- | 1194 | return this.pushStack( jQuery.unique( ret ), name, selector ); |
|
1509 | }
|
1195 | }; |
1510 | }); |
1196 | }); |
1511 | 1197 | ||
- | 1198 | jQuery.each({ |
|
- | 1199 | appendTo: "append", |
|
- | 1200 | prependTo: "prepend", |
|
- | 1201 | insertBefore: "before", |
|
1512 | return stop; |
1202 | insertAfter: "after", |
- | 1203 | replaceAll: "replaceWith" |
|
- | 1204 | }, function(name, original){ |
|
- | 1205 | jQuery.fn[ name ] = function( selector ) { |
|
- | 1206 | var ret = [], insert = jQuery( selector ); |
|
- | 1207 | ||
- | 1208 | for ( var i = 0, l = insert.length; i < l; i++ ) { |
|
- | 1209 | var elems = (i > 0 ? this.clone(true) : this).get(); |
|
- | 1210 | jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); |
|
- | 1211 | ret = ret.concat( elems ); |
|
1513 | }
|
1212 | }
|
1514 | 1213 | ||
1515 | function liveConvert( type, selector ) { |
1214 | return this.pushStack( ret, name, selector ); |
1516 | return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); |
- | |
1517 | }
|
- | |
1518 | - | ||
1519 | jQuery.extend({ |
- | |
1520 | isReady: false, |
- | |
1521 | readyList: [], |
- | |
1522 | // Handle when the DOM is ready
|
- | |
1523 | ready: function() { |
- | |
1524 | // Make sure that the DOM is not already loaded
|
- | |
1525 | if ( !jQuery.isReady ) { |
- | |
1526 | // Remember that the DOM is ready
|
- | |
1527 | jQuery.isReady = true; |
- | |
1528 | - | ||
1529 | // If there are functions bound, to execute
|
- | |
1530 | if ( jQuery.readyList ) { |
- | |
1531 | // Execute all of them
|
- | |
1532 | var fn, i = 0; |
- | |
1533 | while ( (fn = jQuery.readyList[ i++ ]) ) { |
- | |
1534 | fn.call( document, jQuery ); |
- | |
1535 | }
|
- | |
1536 | - | ||
1537 | // Reset the list of functions
|
- | |
1538 | jQuery.readyList = null; |
- | |
1539 | }
|
- | |
1540 | - | ||
1541 | // Trigger any bound ready events
|
- | |
1542 | jQuery( document ).triggerHandler( "ready" ); |
- | |
1543 | }
|
- | |
1544 | }
|
1215 | }; |
1545 | }); |
1216 | }); |
1546 | 1217 | ||
- | 1218 | jQuery.each({ |
|
- | 1219 | removeAttr: function( name ) { |
|
- | 1220 | jQuery.attr( this, name, "" ); |
|
1547 | var readyBound = false; |
1221 | if (this.nodeType == 1) |
- | 1222 | this.removeAttribute( name ); |
|
- | 1223 | }, |
|
1548 | 1224 | ||
1549 | function bindReady() { |
1225 | addClass: function( classNames ) { |
1550 | if ( readyBound ) return; |
1226 | jQuery.className.add( this, classNames ); |
1551 | readyBound = true; |
1227 | }, |
1552 | 1228 | ||
1553 | // Catch cases where $(document).ready() is called after the
|
- | |
1554 | // browser event has already occurred.
|
1229 | removeClass: function( classNames ) { |
1555 | if ( document.readyState === "complete" ) { |
1230 | jQuery.className.remove( this, classNames ); |
1556 | return jQuery.ready(); |
- | |
1557 | }
|
1231 | }, |
1558 | 1232 | ||
1559 | // Mozilla, Opera and webkit nightlies currently support this event
|
- | |
1560 | if ( document.addEventListener ) { |
1233 | toggleClass: function( classNames, state ) { |
1561 | // Use the handy event callback
|
1234 | if( typeof state !== "boolean" ) |
1562 | document.addEventListener( "DOMContentLoaded", function() { |
1235 | state = !jQuery.className.has( this, classNames ); |
1563 | document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
1236 | jQuery.className[ state ? "add" : "remove" ]( this, classNames ); |
1564 | jQuery.ready(); |
- | |
1565 | }, false ); |
1237 | }, |
1566 | 1238 | ||
1567 | // If IE event model is used
|
1239 | remove: function( selector ) { |
1568 | } else if ( document.attachEvent ) { |
1240 | if ( !selector || jQuery.filter( selector, [ this ] ).length ) { |
1569 | // ensure firing before onload,
|
1241 | // Prevent memory leaks
|
1570 | // maybe late but safe also for iframes
|
- | |
1571 | document.attachEvent("onreadystatechange", function() { |
1242 | jQuery( "*", this ).add([this]).each(function(){ |
1572 | if ( document.readyState === "complete" ) { |
1243 | jQuery.event.remove(this); |
1573 | document.detachEvent( "onreadystatechange", arguments.callee ); |
- | |
1574 | jQuery.ready(); |
1244 | jQuery.removeData(this); |
1575 | }
|
- | |
1576 | }); |
1245 | }); |
1577 | - | ||
1578 | // If IE and not an iframe
|
- | |
1579 | // continually check to see if the document is ready
|
- | |
1580 | // NOTE: DO NOT CHANGE TO ===, FAILS IN IE.
|
- | |
1581 | if ( document.documentElement.doScroll && window == window.top ) (function() { |
- | |
1582 | if ( jQuery.isReady ) { |
1246 | if (this.parentNode) |
1583 | return; |
- | |
1584 | }
|
- | |
1585 | - | ||
1586 | try { |
- | |
1587 | // If IE is used, use the trick by Diego Perini
|
- | |
1588 | // http://javascript.nwbox.com/IEContentLoaded/
|
- | |
1589 | document.documentElement.doScroll("left"); |
1247 | this.parentNode.removeChild( this ); |
1590 | } catch( error ) { |
- | |
1591 | setTimeout( arguments.callee, 0 ); |
- | |
1592 | return; |
- | |
1593 | }
|
1248 | }
|
- | 1249 | }, |
|
1594 | 1250 | ||
- | 1251 | empty: function() { |
|
1595 | // and execute any waiting functions
|
1252 | // Remove element nodes and prevent memory leaks
|
1596 | jQuery.ready(); |
1253 | jQuery(this).children().remove(); |
1597 | })(); |
- | |
1598 | }
|
- | |
1599 | 1254 | ||
1600 | // A fallback to window.onload, that will always work
|
1255 | // Remove any remaining nodes
|
- | 1256 | while ( this.firstChild ) |
|
1601 | jQuery.event.add( window, "load", jQuery.ready ); |
1257 | this.removeChild( this.firstChild ); |
1602 | }
|
1258 | }
|
1603 | - | ||
1604 | jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + |
- | |
1605 | "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," + |
- | |
1606 | "change,select,submit,keydown,keypress,keyup,error").split(","), function( i, name ) { |
- | |
1607 | - | ||
1608 | // Handle event binding
|
1259 | }, function(name, fn){ |
1609 | jQuery.fn[ name ] = function( fn ) { |
1260 | jQuery.fn[ name ] = function(){ |
1610 | return fn ? this.bind( name, fn ) : this.trigger( name ); |
1261 | return this.each( fn, arguments ); |
1611 | }; |
1262 | }; |
1612 | }); |
1263 | }); |
1613 | 1264 | ||
1614 | // Prevent memory leaks in IE
|
- | |
1615 | // Window isn't included so as not to unbind existing unload events
|
1265 | // Helper function used by the dimensions and offset modules
|
1616 | // More info:
|
- | |
1617 | // - http://isaacschlueter.com/2006/10/msie-memory-leaks/
|
- | |
1618 | /*@cc_on
|
- | |
1619 | jQuery( window ).bind( 'unload', function() {
|
- | |
1620 | for ( var id in jQuery.cache ) {
|
1266 | function num(elem, prop) { |
1621 | // Skip the window
|
- | |
1622 | if ( id != 1 && jQuery.cache[ id ].handle ) {
|
- | |
1623 | jQuery.event.remove( jQuery.cache[ id ].handle.elem );
|
1267 | return elem[0] && parseInt( jQuery.curCSS(elem[0], prop, true), 10 ) || 0; |
1624 | }
|
1268 | }
|
1625 | }
|
- | |
1626 | });
|
- | |
1627 | @*/
|
- | |
1628 | (function(){ |
1269 | var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
1629 | 1270 | ||
1630 | jQuery.support = {}; |
1271 | jQuery.extend({ |
- | 1272 | cache: {}, |
|
1631 | 1273 | ||
1632 | var root = document.documentElement, |
1274 | data: function( elem, name, data ) { |
1633 | script = document.createElement("script"), |
1275 | elem = elem == window ? |
1634 | div = document.createElement("div"), |
1276 | windowData :
|
1635 | id = "script" + (new Date).getTime(); |
1277 | elem;
|
1636 | 1278 | ||
1637 | div.style.display = "none"; |
1279 | var id = elem[ expando ]; |
1638 | div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select>'; |
- | |
1639 | 1280 | ||
1640 | var all = div.getElementsByTagName("*"), |
1281 | // Compute a unique ID for the element
|
- | 1282 | if ( !id ) |
|
1641 | a = div.getElementsByTagName("a")[0]; |
1283 | id = elem[ expando ] = ++uuid; |
1642 | 1284 | ||
1643 | // Can't get basic test support
|
1285 | // Only generate the data cache if we're
|
- | 1286 | // trying to access or manipulate it
|
|
1644 | if ( !all || !all.length || !a ) { |
1287 | if ( name && !jQuery.cache[ id ] ) |
1645 | return; |
1288 | jQuery.cache[ id ] = {}; |
1646 | }
|
- | |
1647 | 1289 | ||
1648 | jQuery.support = { |
- | |
1649 | // IE strips leading whitespace when .innerHTML is used
|
1290 | // Prevent overriding the named cache with undefined values
|
- | 1291 | if ( data !== undefined ) |
|
1650 | leadingWhitespace: div.firstChild.nodeType == 3, |
1292 | jQuery.cache[ id ][ name ] = data; |
1651 | 1293 | ||
1652 | // Make sure that tbody elements aren't automatically inserted
|
1294 | // Return the named cache data, or the ID for the element
|
1653 | // IE will insert them into empty tables
|
1295 | return name ? |
1654 | tbody: !div.getElementsByTagName("tbody").length, |
1296 | jQuery.cache[ id ][ name ] : |
- | 1297 | id;
|
|
- | 1298 | }, |
|
1655 | 1299 | ||
1656 | // Make sure that link elements get serialized correctly by innerHTML
|
1300 | removeData: function( elem, name ) { |
1657 | // This requires a wrapper element in IE
|
1301 | elem = elem == window ? |
1658 | htmlSerialize: !!div.getElementsByTagName("link").length, |
1302 | windowData :
|
- | 1303 | elem;
|
|
1659 | 1304 | ||
1660 | // Get the style information from getAttribute
|
- | |
1661 | // (IE uses .cssText insted)
|
1305 | var id = elem[ expando ]; |
1662 | style: /red/.test( a.getAttribute("style") ), |
- | |
1663 | 1306 | ||
1664 | // Make sure that URLs aren't manipulated
|
1307 | // If we want to remove a specific section of the element's data
|
- | 1308 | if ( name ) { |
|
1665 | // (IE normalizes it by default)
|
1309 | if ( jQuery.cache[ id ] ) { |
1666 | hrefNormalized: a.getAttribute("href") === "/a", |
1310 | // Remove the section of cache data
|
- | 1311 | delete jQuery.cache[ id ][ name ]; |
|
1667 | 1312 | ||
1668 | // Make sure that element opacity exists
|
1313 | // If we've removed all the data, remove the element's cache
|
1669 | // (IE uses filter instead)
|
- | |
1670 | opacity: a.style.opacity === "0.5", |
1314 | name = ""; |
1671 | 1315 | ||
1672 | // Verify style float existence
|
1316 | for ( name in jQuery.cache[ id ] ) |
1673 | // (IE uses styleFloat instead of cssFloat)
|
- | |
1674 | cssFloat: !!a.style.cssFloat, |
1317 | break; |
1675 | 1318 | ||
1676 | // Will be defined later
|
- | |
1677 | scriptEval: false, |
1319 | if ( !name ) |
1678 | noCloneEvent: true, |
1320 | jQuery.removeData( elem ); |
1679 | boxModel: null |
- | |
1680 | }; |
1321 | }
|
1681 | 1322 | ||
- | 1323 | // Otherwise, we want to remove all of the element's data
|
|
- | 1324 | } else { |
|
1682 | script.type = "text/javascript"; |
1325 | // Clean up the element expando
|
1683 | try { |
1326 | try { |
1684 | script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
1327 | delete elem[ expando ]; |
1685 | } catch(e){} |
1328 | } catch(e){ |
1686 | - | ||
1687 | root.insertBefore( script, root.firstChild ); |
- | |
1688 | - | ||
1689 | // Make sure that the execution of code works by injecting a script
|
- | |
1690 | // tag with appendChild/createTextNode
|
1329 | // IE has trouble directly removing the expando
|
1691 | // (IE doesn't support this, fails, and uses .text instead)
|
1330 | // but it's ok with using removeAttribute
|
1692 | if ( window[ id ] ) { |
1331 | if ( elem.removeAttribute ) |
1693 | jQuery.support.scriptEval = true; |
1332 | elem.removeAttribute( expando ); |
1694 | delete window[ id ]; |
- | |
1695 | }
|
1333 | }
|
1696 | 1334 | ||
1697 | root.removeChild( script ); |
- | |
1698 | - | ||
1699 | if ( div.attachEvent && div.fireEvent ) { |
- | |
1700 | div.attachEvent("onclick", function click(){ |
- | |
1701 | // Cloning a node shouldn't copy over any
|
- | |
1702 | // bound event handlers (IE does this)
|
1335 | // Completely remove the data cache
|
1703 | jQuery.support.noCloneEvent = false; |
- | |
1704 | div.detachEvent("onclick", click); |
1336 | delete jQuery.cache[ id ]; |
1705 | }); |
- | |
1706 | div.cloneNode(true).fireEvent("onclick"); |
- | |
1707 | }
|
1337 | }
|
- | 1338 | }, |
|
- | 1339 | queue: function( elem, type, data ) { |
|
- | 1340 | if ( elem ){ |
|
1708 | 1341 | ||
1709 | // Figure out if the W3C box model works as expected
|
- | |
1710 | // document.body must exist before we can do this
|
- | |
1711 | jQuery(function(){ |
- | |
1712 | var div = document.createElement("div"); |
- | |
1713 | div.style.width = div.style.paddingLeft = "1px"; |
1342 | type = (type || "fx") + "queue"; |
1714 | - | ||
1715 | document.body.appendChild( div ); |
- | |
1716 | jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
- | |
1717 | document.body.removeChild( div ).style.display = 'none'; |
- | |
1718 | div = null; |
- | |
1719 | }); |
- | |
1720 | 1343 | ||
1721 | // release memory in IE
|
- | |
1722 | root = script = div = all = a = null; |
1344 | var q = jQuery.data( elem, type ); |
1723 | })(); |
- | |
1724 | 1345 | ||
1725 | jQuery.props = { |
1346 | if ( !q || jQuery.isArray(data) ) |
1726 | "for": "htmlFor", |
- | |
1727 | "class": "className", |
- | |
1728 | readonly: "readOnly", |
1347 | q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
1729 | maxlength: "maxLength", |
1348 | else if( data ) |
1730 | cellspacing: "cellSpacing", |
- | |
1731 | rowspan: "rowSpan", |
1349 | q.push( data ); |
1732 | colspan: "colSpan", |
- | |
1733 | tabindex: "tabIndex" |
- | |
1734 | }; |
- | |
1735 | /*!
|
- | |
1736 | * Sizzle CSS Selector Engine - v1.0
|
- | |
1737 | * Copyright 2009, The Dojo Foundation
|
- | |
1738 | * Released under the MIT, BSD, and GPL Licenses.
|
- | |
1739 | * More information: http://sizzlejs.com/
|
- | |
1740 | */
|
- | |
1741 | (function(){ |
- | |
1742 | 1350 | ||
1743 | var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, |
- | |
1744 | done = 0, |
1351 | }
|
1745 | toString = Object.prototype.toString, |
- | |
1746 | hasDuplicate = false; |
1352 | return q; |
- | 1353 | }, |
|
1747 | 1354 | ||
1748 | var Sizzle = function(selector, context, results, seed) { |
1355 | dequeue: function( elem, type ){ |
1749 | results = results || []; |
1356 | var queue = jQuery.queue( elem, type ), |
1750 | var origContext = context = context || document; |
1357 | fn = queue.shift(); |
1751 | 1358 | ||
1752 | if ( context.nodeType !== 1 && context.nodeType !== 9 ) { |
1359 | if( !type || type === "fx" ) |
1753 | return []; |
1360 | fn = queue[0]; |
1754 | }
|
- | |
1755 | 1361 | ||
1756 | if ( !selector || typeof selector !== "string" ) { |
1362 | if( fn !== undefined ) |
1757 | return results; |
1363 | fn.call(elem); |
1758 | }
|
1364 | }
|
- | 1365 | }); |
|
1759 | 1366 | ||
- | 1367 | jQuery.fn.extend({ |
|
- | 1368 | data: function( key, value ){ |
|
- | 1369 | var parts = key.split("."); |
|
1760 | var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context); |
1370 | parts[1] = parts[1] ? "." + parts[1] : ""; |
1761 | 1371 | ||
1762 | // Reset the position of the chunker regexp (start from head)
|
1372 | if ( value === undefined ) { |
1763 | chunker.lastIndex = 0; |
1373 | var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
1764 | 1374 | ||
- | 1375 | if ( data === undefined && this.length ) |
|
- | 1376 | data = jQuery.data( this[0], key ); |
|
- | 1377 | ||
- | 1378 | return data === undefined && parts[1] ? |
|
- | 1379 | this.data( parts[0] ) : |
|
- | 1380 | data;
|
|
- | 1381 | } else |
|
- | 1382 | return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){ |
|
- | 1383 | jQuery.data( this, key, value ); |
|
- | 1384 | }); |
|
- | 1385 | }, |
|
- | 1386 | ||
- | 1387 | removeData: function( key ){ |
|
- | 1388 | return this.each(function(){ |
|
- | 1389 | jQuery.removeData( this, key ); |
|
- | 1390 | }); |
|
- | 1391 | }, |
|
- | 1392 | queue: function(type, data){ |
|
- | 1393 | if ( typeof type !== "string" ) { |
|
- | 1394 | data = type; |
|
- | 1395 | type = "fx"; |
|
- | 1396 | }
|
|
- | 1397 | ||
- | 1398 | if ( data === undefined ) |
|
- | 1399 | return jQuery.queue( this[0], type ); |
|
- | 1400 | ||
- | 1401 | return this.each(function(){ |
|
- | 1402 | var queue = jQuery.queue( this, type, data ); |
|
- | 1403 | ||
- | 1404 | if( type == "fx" && queue.length == 1 ) |
|
- | 1405 | queue[0].call(this); |
|
- | 1406 | }); |
|
- | 1407 | }, |
|
- | 1408 | dequeue: function(type){ |
|
- | 1409 | return this.each(function(){ |
|
- | 1410 | jQuery.dequeue( this, type ); |
|
- | 1411 | }); |
|
- | 1412 | }
|
|
- | 1413 | });/*! |
|
- | 1414 | * Sizzle CSS Selector Engine - v0.9.3
|
|
- | 1415 | * Copyright 2009, The Dojo Foundation
|
|
- | 1416 | * Released under the MIT, BSD, and GPL Licenses.
|
|
- | 1417 | * More information: http://sizzlejs.com/
|
|
- | 1418 | */
|
|
- | 1419 | (function(){ |
|
- | 1420 | ||
- | 1421 | var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g, |
|
- | 1422 | done = 0, |
|
- | 1423 | toString = Object.prototype.toString; |
|
- | 1424 | ||
- | 1425 | var Sizzle = function(selector, context, results, seed) { |
|
- | 1426 | results = results || []; |
|
- | 1427 | context = context || document; |
|
- | 1428 | ||
- | 1429 | if ( context.nodeType !== 1 && context.nodeType !== 9 ) |
|
- | 1430 | return []; |
|
- | 1431 | ||
- | 1432 | if ( !selector || typeof selector !== "string" ) { |
|
- | 1433 | return results; |
|
- | 1434 | }
|
|
- | 1435 | ||
- | 1436 | var parts = [], m, set, checkSet, check, mode, extra, prune = true; |
|
- | 1437 | ||
- | 1438 | // Reset the position of the chunker regexp (start from head)
|
|
- | 1439 | chunker.lastIndex = 0; |
|
- | 1440 | ||
1765 | while ( (m = chunker.exec(selector)) !== null ) { |
1441 | while ( (m = chunker.exec(selector)) !== null ) { |
1766 | parts.push( m[1] ); |
1442 | parts.push( m[1] ); |
1767 | 1443 | ||
1768 | if ( m[2] ) { |
1444 | if ( m[2] ) { |
1769 | extra = RegExp.rightContext; |
1445 | extra = RegExp.rightContext; |
1770 | break; |
1446 | break; |
1771 | }
|
1447 | }
|
Строка 1787... | Строка 1463... | ||
1787 | 1463 | ||
1788 | set = posProcess( selector, set ); |
1464 | set = posProcess( selector, set ); |
1789 | }
|
1465 | }
|
1790 | }
|
1466 | }
|
1791 | } else { |
1467 | } else { |
1792 | // Take a shortcut and set the context if the root selector is an ID
|
- | |
1793 | // (but not if it'll be faster if the inner selector is an ID)
|
- | |
1794 | if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && |
- | |
1795 | Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { |
- | |
1796 | var ret = Sizzle.find( parts.shift(), context, contextXML ); |
- | |
1797 | context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0]; |
- | |
1798 | }
|
- | |
1799 | - | ||
1800 | if ( context ) { |
- | |
1801 | var ret = seed ? |
1468 | var ret = seed ? |
1802 | { expr: parts.pop(), set: makeArray(seed) } : |
1469 | { expr: parts.pop(), set: makeArray(seed) } : |
1803 | Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); |
1470 | Sizzle.find( parts.pop(), parts.length === 1 && context.parentNode ? context.parentNode : context, isXML(context) ); |
1804 | set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set; |
1471 | set = Sizzle.filter( ret.expr, ret.set ); |
1805 | 1472 | ||
1806 | if ( parts.length > 0 ) { |
1473 | if ( parts.length > 0 ) { |
1807 | checkSet = makeArray(set); |
1474 | checkSet = makeArray(set); |
1808 | } else { |
1475 | } else { |
1809 | prune = false; |
1476 | prune = false; |
Строка 1820... | Строка 1487... | ||
1820 | 1487 | ||
1821 | if ( pop == null ) { |
1488 | if ( pop == null ) { |
1822 | pop = context; |
1489 | pop = context; |
1823 | }
|
1490 | }
|
1824 | 1491 | ||
1825 | Expr.relative[ cur ]( checkSet, pop, contextXML ); |
1492 | Expr.relative[ cur ]( checkSet, pop, isXML(context) ); |
1826 | }
|
- | |
1827 | } else { |
- | |
1828 | checkSet = parts = []; |
- | |
1829 | }
|
1493 | }
|
1830 | }
|
1494 | }
|
1831 | 1495 | ||
1832 | if ( !checkSet ) { |
1496 | if ( !checkSet ) { |
1833 | checkSet = set; |
1497 | checkSet = set; |
Строка 1838... | Строка 1502... | ||
1838 | }
|
1502 | }
|
1839 | 1503 | ||
1840 | if ( toString.call(checkSet) === "[object Array]" ) { |
1504 | if ( toString.call(checkSet) === "[object Array]" ) { |
1841 | if ( !prune ) { |
1505 | if ( !prune ) { |
1842 | results.push.apply( results, checkSet ); |
1506 | results.push.apply( results, checkSet ); |
1843 | } else if ( context && context.nodeType === 1 ) { |
1507 | } else if ( context.nodeType === 1 ) { |
1844 | for ( var i = 0; checkSet[i] != null; i++ ) { |
1508 | for ( var i = 0; checkSet[i] != null; i++ ) { |
1845 | if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { |
1509 | if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { |
1846 | results.push( set[i] ); |
1510 | results.push( set[i] ); |
1847 | }
|
1511 | }
|
1848 | }
|
1512 | }
|
Строка 1856... | Строка 1520... | ||
1856 | } else { |
1520 | } else { |
1857 | makeArray( checkSet, results ); |
1521 | makeArray( checkSet, results ); |
1858 | }
|
1522 | }
|
1859 | 1523 | ||
1860 | if ( extra ) { |
1524 | if ( extra ) { |
1861 | Sizzle( extra, origContext, results, seed ); |
1525 | Sizzle( extra, context, results, seed ); |
1862 | Sizzle.uniqueSort( results ); |
- | |
1863 | }
|
- | |
1864 | 1526 | ||
1865 | return results; |
- | |
1866 | }; |
- | |
1867 | - | ||
1868 | Sizzle.uniqueSort = function(results){ |
- | |
1869 | if ( sortOrder ) { |
1527 | if ( sortOrder ) { |
1870 | hasDuplicate = false; |
1528 | hasDuplicate = false; |
1871 | results.sort(sortOrder); |
1529 | results.sort(sortOrder); |
1872 | 1530 | ||
1873 | if ( hasDuplicate ) { |
1531 | if ( hasDuplicate ) { |
Строка 1876... | Строка 1534... | ||
1876 | results.splice(i--, 1); |
1534 | results.splice(i--, 1); |
1877 | }
|
1535 | }
|
1878 | }
|
1536 | }
|
1879 | }
|
1537 | }
|
1880 | }
|
1538 | }
|
- | 1539 | }
|
|
1881 | 1540 | ||
1882 | return results; |
1541 | return results; |
1883 | }; |
1542 | }; |
1884 | 1543 | ||
1885 | Sizzle.matches = function(expr, set){ |
1544 | Sizzle.matches = function(expr, set){ |
Строка 2066... | Строка 1725... | ||
2066 | }
|
1725 | }
|
2067 | }, |
1726 | }, |
2068 | "": function(checkSet, part, isXML){ |
1727 | "": function(checkSet, part, isXML){ |
2069 | var doneName = done++, checkFn = dirCheck; |
1728 | var doneName = done++, checkFn = dirCheck; |
2070 | 1729 | ||
2071 | if ( !/\W/.test(part) ) { |
1730 | if ( !part.match(/\W/) ) { |
2072 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
1731 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
2073 | checkFn = dirNodeCheck; |
1732 | checkFn = dirNodeCheck; |
2074 | }
|
1733 | }
|
2075 | 1734 | ||
2076 | checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
1735 | checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
2077 | }, |
1736 | }, |
2078 | "~": function(checkSet, part, isXML){ |
1737 | "~": function(checkSet, part, isXML){ |
2079 | var doneName = done++, checkFn = dirCheck; |
1738 | var doneName = done++, checkFn = dirCheck; |
2080 | 1739 | ||
2081 | if ( typeof part === "string" && !/\W/.test(part) ) { |
1740 | if ( typeof part === "string" && !part.match(/\W/) ) { |
2082 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
1741 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
2083 | checkFn = dirNodeCheck; |
1742 | checkFn = dirNodeCheck; |
2084 | }
|
1743 | }
|
2085 | 1744 | ||
2086 | checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
1745 | checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
Строка 2169... | Строка 1828... | ||
2169 | return match; |
1828 | return match; |
2170 | }, |
1829 | }, |
2171 | PSEUDO: function(match, curLoop, inplace, result, not){ |
1830 | PSEUDO: function(match, curLoop, inplace, result, not){ |
2172 | if ( match[1] === "not" ) { |
1831 | if ( match[1] === "not" ) { |
2173 | // If we're dealing with a complex expression, or a simple one
|
1832 | // If we're dealing with a complex expression, or a simple one
|
2174 | if ( chunker.exec(match[3]).length > 1 || /^\w/.test(match[3]) ) { |
1833 | if ( match[3].match(chunker).length > 1 || /^\w/.test(match[3]) ) { |
2175 | match[3] = Sizzle(match[3], null, null, curLoop); |
1834 | match[3] = Sizzle(match[3], null, null, curLoop); |
2176 | } else { |
1835 | } else { |
2177 | var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
1836 | var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
2178 | if ( !inplace ) { |
1837 | if ( !inplace ) { |
2179 | result.push.apply( result, ret ); |
1838 | result.push.apply( result, ret ); |
Строка 2299... | Строка 1958... | ||
2299 | CHILD: function(elem, match){ |
1958 | CHILD: function(elem, match){ |
2300 | var type = match[1], node = elem; |
1959 | var type = match[1], node = elem; |
2301 | switch (type) { |
1960 | switch (type) { |
2302 | case 'only': |
1961 | case 'only': |
2303 | case 'first': |
1962 | case 'first': |
2304 | while ( (node = node.previousSibling) ) { |
1963 | while (node = node.previousSibling) { |
2305 | if ( node.nodeType === 1 ) return false; |
1964 | if ( node.nodeType === 1 ) return false; |
2306 | }
|
1965 | }
|
2307 | if ( type == 'first') return true; |
1966 | if ( type == 'first') return true; |
2308 | node = elem; |
1967 | node = elem; |
2309 | case 'last': |
1968 | case 'last': |
2310 | while ( (node = node.nextSibling) ) { |
1969 | while (node = node.nextSibling) { |
2311 | if ( node.nodeType === 1 ) return false; |
1970 | if ( node.nodeType === 1 ) return false; |
2312 | }
|
1971 | }
|
2313 | return true; |
1972 | return true; |
2314 | case 'nth': |
1973 | case 'nth': |
2315 | var first = match[2], last = match[3]; |
1974 | var first = match[2], last = match[3]; |
Строка 2391... | Строка 2050... | ||
2391 | }; |
2050 | }; |
2392 | 2051 | ||
2393 | var origPOS = Expr.match.POS; |
2052 | var origPOS = Expr.match.POS; |
2394 | 2053 | ||
2395 | for ( var type in Expr.match ) { |
2054 | for ( var type in Expr.match ) { |
2396 | Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
2055 | Expr.match[ type ] = RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
2397 | }
|
2056 | }
|
2398 | 2057 | ||
2399 | var makeArray = function(array, results) { |
2058 | var makeArray = function(array, results) { |
2400 | array = Array.prototype.slice.call( array, 0 ); |
2059 | array = Array.prototype.slice.call( array ); |
2401 | 2060 | ||
2402 | if ( results ) { |
2061 | if ( results ) { |
2403 | results.push.apply( results, array ); |
2062 | results.push.apply( results, array ); |
2404 | return results; |
2063 | return results; |
2405 | }
|
2064 | }
|
Строка 2408... | Строка 2067... | ||
2408 | }; |
2067 | }; |
2409 | 2068 | ||
2410 | // Perform a simple check to determine if the browser is capable of
|
2069 | // Perform a simple check to determine if the browser is capable of
|
2411 | // converting a NodeList to an array using builtin methods.
|
2070 | // converting a NodeList to an array using builtin methods.
|
2412 | try { |
2071 | try { |
2413 | Array.prototype.slice.call( document.documentElement.childNodes, 0 ); |
2072 | Array.prototype.slice.call( document.documentElement.childNodes ); |
2414 | 2073 | ||
2415 | // Provide a fallback method if it does not work
|
2074 | // Provide a fallback method if it does not work
|
2416 | } catch(e){ |
2075 | } catch(e){ |
2417 | makeArray = function(array, results) { |
2076 | makeArray = function(array, results) { |
2418 | var ret = results || []; |
2077 | var ret = results || []; |
Строка 2437... | Строка 2096... | ||
2437 | 2096 | ||
2438 | var sortOrder; |
2097 | var sortOrder; |
2439 | 2098 | ||
2440 | if ( document.documentElement.compareDocumentPosition ) { |
2099 | if ( document.documentElement.compareDocumentPosition ) { |
2441 | sortOrder = function( a, b ) { |
2100 | sortOrder = function( a, b ) { |
2442 | if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { |
- | |
2443 | if ( a == b ) { |
- | |
2444 | hasDuplicate = true; |
- | |
2445 | }
|
- | |
2446 | return 0; |
- | |
2447 | }
|
- | |
2448 | - | ||
2449 | var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; |
2101 | var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; |
2450 | if ( ret === 0 ) { |
2102 | if ( ret === 0 ) { |
2451 | hasDuplicate = true; |
2103 | hasDuplicate = true; |
2452 | }
|
2104 | }
|
2453 | return ret; |
2105 | return ret; |
2454 | }; |
2106 | }; |
2455 | } else if ( "sourceIndex" in document.documentElement ) { |
2107 | } else if ( "sourceIndex" in document.documentElement ) { |
2456 | sortOrder = function( a, b ) { |
2108 | sortOrder = function( a, b ) { |
2457 | if ( !a.sourceIndex || !b.sourceIndex ) { |
- | |
2458 | if ( a == b ) { |
- | |
2459 | hasDuplicate = true; |
- | |
2460 | }
|
- | |
2461 | return 0; |
- | |
2462 | }
|
- | |
2463 | - | ||
2464 | var ret = a.sourceIndex - b.sourceIndex; |
2109 | var ret = a.sourceIndex - b.sourceIndex; |
2465 | if ( ret === 0 ) { |
2110 | if ( ret === 0 ) { |
2466 | hasDuplicate = true; |
2111 | hasDuplicate = true; |
2467 | }
|
2112 | }
|
2468 | return ret; |
2113 | return ret; |
2469 | }; |
2114 | }; |
2470 | } else if ( document.createRange ) { |
2115 | } else if ( document.createRange ) { |
2471 | sortOrder = function( a, b ) { |
2116 | sortOrder = function( a, b ) { |
2472 | if ( !a.ownerDocument || !b.ownerDocument ) { |
- | |
2473 | if ( a == b ) { |
- | |
2474 | hasDuplicate = true; |
- | |
2475 | }
|
- | |
2476 | return 0; |
- | |
2477 | }
|
- | |
2478 | - | ||
2479 | var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); |
2117 | var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); |
2480 | aRange.selectNode(a); |
2118 | aRange.selectNode(a); |
2481 | aRange.collapse(true); |
2119 | aRange.collapse(true); |
2482 | bRange.selectNode(b); |
2120 | bRange.selectNode(b); |
2483 | bRange.collapse(true); |
2121 | bRange.collapse(true); |
Строка 2491... | Строка 2129... | ||
2491 | 2129 | ||
2492 | // Check to see if the browser returns elements by name when
|
2130 | // Check to see if the browser returns elements by name when
|
2493 | // querying by getElementById (and provide a workaround)
|
2131 | // querying by getElementById (and provide a workaround)
|
2494 | (function(){ |
2132 | (function(){ |
2495 | // We're going to inject a fake input element with a specified name
|
2133 | // We're going to inject a fake input element with a specified name
|
2496 | var form = document.createElement("div"), |
2134 | var form = document.createElement("form"), |
2497 | id = "script" + (new Date).getTime(); |
2135 | id = "script" + (new Date).getTime(); |
2498 | form.innerHTML = "<a name='" + id + "'/>"; |
2136 | form.innerHTML = "<input name='" + id + "'/>"; |
2499 | 2137 | ||
2500 | // Inject it into the root element, check its status, and remove it quickly
|
2138 | // Inject it into the root element, check its status, and remove it quickly
|
2501 | var root = document.documentElement; |
2139 | var root = document.documentElement; |
2502 | root.insertBefore( form, root.firstChild ); |
2140 | root.insertBefore( form, root.firstChild ); |
2503 | 2141 | ||
Строка 2516... | Строка 2154... | ||
2516 | return elem.nodeType === 1 && node && node.nodeValue === match; |
2154 | return elem.nodeType === 1 && node && node.nodeValue === match; |
2517 | }; |
2155 | }; |
2518 | }
|
2156 | }
|
2519 | 2157 | ||
2520 | root.removeChild( form ); |
2158 | root.removeChild( form ); |
2521 | root = form = null; // release memory in IE |
- | |
2522 | })(); |
2159 | })(); |
2523 | 2160 | ||
2524 | (function(){ |
2161 | (function(){ |
2525 | // Check to see if the browser returns only elements
|
2162 | // Check to see if the browser returns only elements
|
2526 | // when doing getElementsByTagName("*")
|
2163 | // when doing getElementsByTagName("*")
|
Строка 2557... | Строка 2194... | ||
2557 | div.firstChild.getAttribute("href") !== "#" ) { |
2194 | div.firstChild.getAttribute("href") !== "#" ) { |
2558 | Expr.attrHandle.href = function(elem){ |
2195 | Expr.attrHandle.href = function(elem){ |
2559 | return elem.getAttribute("href", 2); |
2196 | return elem.getAttribute("href", 2); |
2560 | }; |
2197 | }; |
2561 | }
|
2198 | }
|
2562 | - | ||
2563 | div = null; // release memory in IE |
- | |
2564 | })(); |
2199 | })(); |
2565 | 2200 | ||
2566 | if ( document.querySelectorAll ) (function(){ |
2201 | if ( document.querySelectorAll ) (function(){ |
2567 | var oldSizzle = Sizzle, div = document.createElement("div"); |
2202 | var oldSizzle = Sizzle, div = document.createElement("div"); |
2568 | div.innerHTML = "<p class='TEST'></p>"; |
2203 | div.innerHTML = "<p class='TEST'></p>"; |
Строка 2585... | Строка 2220... | ||
2585 | }
|
2220 | }
|
2586 | 2221 | ||
2587 | return oldSizzle(query, context, extra, seed); |
2222 | return oldSizzle(query, context, extra, seed); |
2588 | }; |
2223 | }; |
2589 | 2224 | ||
2590 | for ( var prop in oldSizzle ) { |
2225 | Sizzle.find = oldSizzle.find; |
2591 | Sizzle[ prop ] = oldSizzle[ prop ]; |
2226 | Sizzle.filter = oldSizzle.filter; |
2592 | }
|
- | |
2593 | - | ||
- | 2227 | Sizzle.selectors = oldSizzle.selectors; |
|
2594 | div = null; // release memory in IE |
2228 | Sizzle.matches = oldSizzle.matches; |
2595 | })(); |
2229 | })(); |
2596 | 2230 | ||
2597 | if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ |
2231 | if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){ |
2598 | var div = document.createElement("div"); |
2232 | var div = document.createElement("div"); |
2599 | div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
2233 | div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
Строка 2612... | Строка 2246... | ||
2612 | Expr.find.CLASS = function(match, context, isXML) { |
2246 | Expr.find.CLASS = function(match, context, isXML) { |
2613 | if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
2247 | if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
2614 | return context.getElementsByClassName(match[1]); |
2248 | return context.getElementsByClassName(match[1]); |
2615 | }
|
2249 | }
|
2616 | }; |
2250 | }; |
2617 | - | ||
2618 | div = null; // release memory in IE |
- | |
2619 | })(); |
2251 | })(); |
2620 | 2252 | ||
2621 | function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
2253 | function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
2622 | var sibDir = dir == "previousSibling" && !isXML; |
2254 | var sibDir = dir == "previousSibling" && !isXML; |
2623 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
2255 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
Строка 2703... | Строка 2335... | ||
2703 | return a !== b && (a.contains ? a.contains(b) : true); |
2335 | return a !== b && (a.contains ? a.contains(b) : true); |
2704 | }; |
2336 | }; |
2705 | 2337 | ||
2706 | var isXML = function(elem){ |
2338 | var isXML = function(elem){ |
2707 | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || |
2339 | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || |
2708 | !!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML"; |
2340 | !!elem.ownerDocument && isXML( elem.ownerDocument ); |
2709 | }; |
2341 | }; |
2710 | 2342 | ||
2711 | var posProcess = function(selector, context){ |
2343 | var posProcess = function(selector, context){ |
2712 | var tmpSet = [], later = "", match, |
2344 | var tmpSet = [], later = "", match, |
2713 | root = context.nodeType ? [context] : context; |
2345 | root = context.nodeType ? [context] : context; |
Строка 2728... | Строка 2360... | ||
2728 | return Sizzle.filter( later, tmpSet ); |
2360 | return Sizzle.filter( later, tmpSet ); |
2729 | }; |
2361 | }; |
2730 | 2362 | ||
2731 | // EXPOSE
|
2363 | // EXPOSE
|
2732 | jQuery.find = Sizzle; |
2364 | jQuery.find = Sizzle; |
- | 2365 | jQuery.filter = Sizzle.filter; |
|
2733 | jQuery.expr = Sizzle.selectors; |
2366 | jQuery.expr = Sizzle.selectors; |
2734 | jQuery.expr[":"] = jQuery.expr.filters; |
2367 | jQuery.expr[":"] = jQuery.expr.filters; |
2735 | 2368 | ||
2736 | Sizzle.selectors.filters.hidden = function(elem){ |
2369 | Sizzle.selectors.filters.hidden = function(elem){ |
2737 | var width = elem.offsetWidth, height = elem.offsetHeight, |
2370 | return elem.offsetWidth === 0 || elem.offsetHeight === 0; |
2738 | force = /^tr$/i.test( elem.nodeName ); // ticket #4512 |
- | |
2739 | return ( width === 0 && height === 0 && !force ) ? |
- | |
2740 | true : |
- | |
2741 | ( width !== 0 && height !== 0 && !force ) ? |
- | |
2742 | false : |
- | |
2743 | !!( jQuery.curCSS(elem, "display") === "none" ); |
- | |
2744 | }; |
2371 | }; |
2745 | 2372 | ||
2746 | Sizzle.selectors.filters.visible = function(elem){ |
2373 | Sizzle.selectors.filters.visible = function(elem){ |
2747 | return !Sizzle.selectors.filters.hidden(elem); |
2374 | return elem.offsetWidth > 0 || elem.offsetHeight > 0; |
2748 | }; |
2375 | }; |
2749 | 2376 | ||
2750 | Sizzle.selectors.filters.animated = function(elem){ |
2377 | Sizzle.selectors.filters.animated = function(elem){ |
2751 | return jQuery.grep(jQuery.timers, function(fn){ |
2378 | return jQuery.grep(jQuery.timers, function(fn){ |
2752 | return elem === fn.elem; |
2379 | return elem === fn.elem; |
2753 | }).length; |
2380 | }).length; |
2754 | }; |
2381 | }; |
2755 | 2382 | ||
2756 | jQuery.filter = jQuery.multiFilter = function( expr, elems, not ) { |
2383 | jQuery.multiFilter = function( expr, elems, not ) { |
2757 | if ( not ) { |
2384 | if ( not ) { |
2758 | expr = ":not(" + expr + ")"; |
2385 | expr = ":not(" + expr + ")"; |
2759 | }
|
2386 | }
|
2760 | 2387 | ||
2761 | return Sizzle.matches(expr, elems); |
2388 | return Sizzle.matches(expr, elems); |
Строка 2791... | Строка 2418... | ||
2791 | }
|
2418 | }
|
2792 | 2419 | ||
2793 | return r; |
2420 | return r; |
2794 | }; |
2421 | }; |
2795 | 2422 | ||
2796 | jQuery.unique = Sizzle.uniqueSort; |
- | |
2797 | - | ||
2798 | return; |
2423 | return; |
2799 | 2424 | ||
2800 | window.Sizzle = Sizzle; |
2425 | window.Sizzle = Sizzle; |
2801 | 2426 | ||
2802 | })(); |
2427 | })(); |
2803 | var winnow = function( elements, qualifier, keep ) { |
- | |
2804 | if(jQuery.isFunction( qualifier )) { |
- | |
2805 | return jQuery.grep(elements, function(elem, i) { |
- | |
2806 | return !!qualifier.call( elem, i ) === keep; |
- | |
2807 | }); |
2428 | /*
|
2808 | } else if( qualifier.nodeType ) { |
2429 | * A number of helper functions used for managing events.
|
2809 | return jQuery.grep(elements, function(elem, i) { |
2430 | * Many of the ideas behind this code originated from
|
2810 | return (elem === qualifier) === keep; |
2431 | * Dean Edwards' addEvent library.
|
2811 | }) |
2432 | */
|
2812 | } else if( typeof qualifier === "string" ) { |
2433 | jQuery.event = { |
2813 | var filtered = jQuery.grep(elements, function(elem) { return elem.nodeType === 1 }); |
- | |
2814 | 2434 | ||
- | 2435 | // Bind an event to an element
|
|
- | 2436 | // Original by Dean Edwards
|
|
2815 | if(isSimple.test( qualifier )) return jQuery.multiFilter(qualifier, filtered, !keep); |
2437 | add: function(elem, types, handler, data) { |
2816 | else qualifier = jQuery.multiFilter( qualifier, elements ); |
2438 | if ( elem.nodeType == 3 || elem.nodeType == 8 ) |
2817 | }
|
2439 | return; |
2818 | 2440 | ||
- | 2441 | // For whatever reason, IE has trouble passing the window object
|
|
2819 | return jQuery.grep(elements, function(elem, i) { |
2442 | // around, causing it to be cloned in the process
|
2820 | return (jQuery.inArray( elem, qualifier ) >= 0) === keep; |
2443 | if ( elem.setInterval && elem != window ) |
2821 | }); |
2444 | elem = window; |
2822 | }
|
- | |
2823 | 2445 | ||
2824 | jQuery.fn.extend({ |
2446 | // Make sure that the function being executed has a unique ID
|
2825 | find: function( selector ) { |
2447 | if ( !handler.guid ) |
2826 | var ret = this.pushStack( "", "find", selector ), length = 0; |
2448 | handler.guid = this.guid++; |
2827 | 2449 | ||
2828 | for ( var i = 0, l = this.length; i < l; i++ ) { |
2450 | // if data is passed, bind to handler
|
2829 | length = ret.length; |
2451 | if ( data !== undefined ) { |
2830 | jQuery.find( selector, this[i], ret ); |
2452 | // Create temporary function pointer to original handler
|
- | 2453 | var fn = handler; |
|
2831 | 2454 | ||
2832 | if ( i > 0 ) { |
- | |
2833 | // Make sure that the results are unique
|
2455 | // Create unique handler function, wrapped around original handler
|
2834 | for ( var n = length; n < ret.length; n++ ) { |
- | |
2835 | for ( var r = 0; r < length; r++ ) { |
2456 | handler = this.proxy( fn ); |
- | 2457 | ||
2836 | if ( ret[r] === ret[n] ) { |
2458 | // Store data in unique handler
|
2837 | ret.splice(n--, 1); |
2459 | handler.data = data; |
2838 | break; |
- | |
2839 | }
|
- | |
2840 | }
|
- | |
2841 | }
|
- | |
2842 | }
|
- | |
2843 | }
|
2460 | }
|
2844 | 2461 | ||
- | 2462 | // Init the element's event structure
|
|
- | 2463 | var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}), |
|
- | 2464 | handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){ |
|
- | 2465 | // Handle the second event of a trigger and when
|
|
- | 2466 | // an event is called after a page has unloaded
|
|
- | 2467 | return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
|
- | 2468 | jQuery.event.handle.apply(arguments.callee.elem, arguments) : |
|
2845 | return ret; |
2469 | undefined; |
2846 | }, |
2470 | }); |
- | 2471 | // Add elem as a property of the handle function
|
|
- | 2472 | // This is to prevent a memory leak with non-native
|
|
- | 2473 | // event in IE.
|
|
- | 2474 | handle.elem = elem; |
|
2847 | 2475 | ||
2848 | not: function( selector ) { |
2476 | // Handle multiple events separated by a space
|
2849 | return this.pushStack( winnow(this, selector, false), "not", selector); |
2477 | // jQuery(...).bind("mouseover mouseout", fn);
|
- | 2478 | jQuery.each(types.split(/\s+/), function(index, type) { |
|
- | 2479 | // Namespaced event handlers
|
|
- | 2480 | var namespaces = type.split("."); |
|
2850 | }, |
2481 | type = namespaces.shift(); |
- | 2482 | handler.type = namespaces.slice().sort().join("."); |
|
2851 | 2483 | ||
2852 | filter: function( selector ) { |
2484 | // Get the current list of functions bound to this event
|
2853 | return this.pushStack( winnow(this, selector, true), "filter", selector ); |
2485 | var handlers = events[type]; |
2854 | }, |
- | |
2855 | 2486 | ||
2856 | closest: function( selector, context ) { |
2487 | if ( jQuery.event.specialAll[type] ) |
2857 | var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, |
2488 | jQuery.event.specialAll[type].setup.call(elem, data, namespaces); |
2858 | closer = 0; |
- | |
2859 | 2489 | ||
2860 | return this.map(function(){ |
2490 | // Init the event handler queue
|
2861 | var cur = this; |
2491 | if (!handlers) { |
- | 2492 | handlers = events[type] = {}; |
|
- | 2493 | ||
- | 2494 | // Check for a special event handler
|
|
2862 | while ( cur && cur.ownerDocument && cur !== context ) { |
2495 | // Only use addEventListener/attachEvent if the special
|
- | 2496 | // events handler returns false
|
|
- | 2497 | if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem, data, namespaces) === false ) { |
|
2863 | if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { |
2498 | // Bind the global event handler to the element
|
- | 2499 | if (elem.addEventListener) |
|
2864 | jQuery.data(cur, "closest", closer); |
2500 | elem.addEventListener(type, handle, false); |
2865 | return cur; |
2501 | else if (elem.attachEvent) |
- | 2502 | elem.attachEvent("on" + type, handle); |
|
2866 | }
|
2503 | }
|
2867 | cur = cur.parentNode; |
- | |
2868 | closer++;
|
- | |
2869 | }
|
2504 | }
|
2870 | }); |
- | |
2871 | }, |
- | |
2872 | - | ||
2873 | add: function( selector ) { |
- | |
2874 | var set = typeof selector === "string" ? |
- | |
2875 | jQuery( selector ) : |
- | |
2876 | jQuery.makeArray( selector ), |
- | |
2877 | all = jQuery.merge( this.get(), set ); |
- | |
2878 | - | ||
2879 | return this.pushStack( set[0] && (set[0].setInterval || set[0].nodeType === 9 || (set[0].parentNode && set[0].parentNode.nodeType !== 11)) ? |
- | |
2880 | jQuery.unique( all ) : |
- | |
2881 | all ); |
- | |
2882 | }, |
- | |
2883 | - | ||
2884 | eq: function( i ) { |
- | |
2885 | return i === -1 ? |
- | |
2886 | this.slice( i ) : |
- | |
2887 | this.slice( i, +i + 1 ); |
- | |
2888 | }, |
- | |
2889 | - | ||
2890 | first: function() { |
- | |
2891 | return this.eq( 0 ); |
- | |
2892 | }, |
- | |
2893 | 2505 | ||
2894 | last: function() { |
2506 | // Add the function to the element's handler list
|
2895 | return this.eq( -1 ); |
2507 | handlers[handler.guid] = handler; |
2896 | }, |
- | |
2897 | 2508 | ||
2898 | slice: function() { |
- | |
2899 | return this.pushStack( Array.prototype.slice.apply( this, arguments ), |
2509 | // Keep track of which events have been used, for global triggering
|
2900 | "slice", Array.prototype.slice.call(arguments).join(",") ); |
2510 | jQuery.event.global[type] = true; |
2901 | }, |
2511 | }); |
2902 | 2512 | ||
2903 | map: function( callback ) { |
- | |
2904 | return this.pushStack( jQuery.map(this, function(elem, i){ |
- | |
2905 | return callback.call( elem, i, elem ); |
2513 | // Nullify elem to prevent memory leaks in IE
|
2906 | })); |
2514 | elem = null; |
2907 | }, |
2515 | }, |
2908 | 2516 | ||
2909 | andSelf: function() { |
2517 | guid: 1, |
2910 | return this.add( this.prevObject ); |
- | |
2911 | }, |
2518 | global: {}, |
2912 | 2519 | ||
- | 2520 | // Detach an event or set of events from an element
|
|
2913 | end: function() { |
2521 | remove: function(elem, types, handler) { |
2914 | return this.prevObject || jQuery(null); |
2522 | // don't do events on text and comment nodes
|
2915 | }
|
- | |
- | 2523 | if ( elem.nodeType == 3 || elem.nodeType == 8 ) |
|
2916 | }); |
2524 | return; |
2917 | 2525 | ||
2918 | jQuery.each({ |
- | |
2919 | parent: function(elem){return elem.parentNode;}, |
- | |
2920 | parents: function(elem){return jQuery.dir(elem,"parentNode");}, |
- | |
2921 | next: function(elem){return jQuery.nth(elem,2,"nextSibling");}, |
- | |
2922 | prev: function(elem){return jQuery.nth(elem,2,"previousSibling");}, |
- | |
2923 | nextAll: function(elem){return jQuery.dir(elem,"nextSibling");}, |
- | |
2924 | prevAll: function(elem){return jQuery.dir(elem,"previousSibling");}, |
- | |
2925 | siblings: function(elem){return jQuery.sibling(elem.parentNode.firstChild,elem);}, |
- | |
2926 | children: function(elem){return jQuery.sibling(elem.firstChild);}, |
- | |
2927 | contents: function(elem){return jQuery.nodeName(elem,"iframe")?elem.contentDocument||elem.contentWindow.document:jQuery.makeArray(elem.childNodes);} |
- | |
2928 | }, function(name, fn){ |
- | |
2929 | jQuery.fn[ name ] = function( selector ) { |
- | |
2930 | var ret = jQuery.map( this, fn ); |
2526 | var events = jQuery.data(elem, "events"), ret, index; |
2931 | 2527 | ||
- | 2528 | if ( events ) { |
|
- | 2529 | // Unbind all events for the element
|
|
- | 2530 | if ( types === undefined || (typeof types === "string" && types.charAt(0) == ".") ) |
|
- | 2531 | for ( var type in events ) |
|
2932 | if ( selector && typeof selector === "string" ) { |
2532 | this.remove( elem, type + (types || "") ); |
- | 2533 | else { |
|
2933 | ret = jQuery.multiFilter( selector, ret ); |
2534 | // types is actually an event object here
|
- | 2535 | if ( types.type ) { |
|
- | 2536 | handler = types.handler; |
|
- | 2537 | types = types.type; |
|
2934 | }
|
2538 | }
|
2935 | 2539 | ||
2936 | ret = this.length > 1 ? jQuery.unique( ret ) : ret; |
2540 | // Handle multiple events seperated by a space
|
2937 | - | ||
- | 2541 | // jQuery(...).unbind("mouseover mouseout", fn);
|
|
- | 2542 | jQuery.each(types.split(/\s+/), function(index, type){ |
|
- | 2543 | // Namespaced event handlers
|
|
2938 | if ( name === "parents" && this.length > 1 ) { |
2544 | var namespaces = type.split("."); |
2939 | ret = ret.reverse(); |
2545 | type = namespaces.shift(); |
2940 | }
|
- | |
- | 2546 | var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); |
|
2941 | 2547 | ||
2942 | return this.pushStack( ret, name, selector ); |
2548 | if ( events[type] ) { |
2943 | }; |
- | |
2944 | }); |
- | |
2945 | jQuery.fn.extend({ |
2549 | // remove the given handler for the given type
|
2946 | attr: function( name, value ) { |
2550 | if ( handler ) |
2947 | return access(this, name, value, true, jQuery.attr); |
2551 | delete events[type][handler.guid]; |
2948 | }, |
- | |
2949 | 2552 | ||
- | 2553 | // remove all handlers for the given type
|
|
- | 2554 | else
|
|
2950 | addClass: function( value ) { |
2555 | for ( var handle in events[type] ) |
- | 2556 | // Handle the removal of namespaced events
|
|
2951 | if ( value && typeof value === "string" ) { |
2557 | if ( namespace.test(events[type][handle].type) ) |
2952 | var classNames = (value || "").split(/\s+/); |
2558 | delete events[type][handle]; |
2953 | 2559 | ||
2954 | for ( var i = 0, l = this.length; i < l; i++ ) { |
2560 | if ( jQuery.event.specialAll[type] ) |
2955 | var elem = this[i]; |
2561 | jQuery.event.specialAll[type].teardown.call(elem, namespaces); |
2956 | 2562 | ||
2957 | if ( elem.nodeType === 1 ) { |
2563 | // remove generic event handler if no more handlers exist
|
2958 | if ( !elem.className ) { |
2564 | for ( ret in events[type] ) break; |
2959 | elem.className = value; |
- | |
2960 | } else { |
2565 | if ( !ret ) { |
- | 2566 | if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem, namespaces) === false ) { |
|
2961 | var className = " " + elem.className + " "; |
2567 | if (elem.removeEventListener) |
2962 | for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
2568 | elem.removeEventListener(type, jQuery.data(elem, "handle"), false); |
2963 | if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { |
2569 | else if (elem.detachEvent) |
2964 | elem.className += " " + classNames[c]; |
2570 | elem.detachEvent("on" + type, jQuery.data(elem, "handle")); |
2965 | }
|
- | |
2966 | }
|
2571 | }
|
- | 2572 | ret = null; |
|
- | 2573 | delete events[type]; |
|
2967 | }
|
2574 | }
|
2968 | }
|
2575 | }
|
- | 2576 | }); |
|
2969 | }
|
2577 | }
|
2970 | }
|
- | |
2971 | - | ||
2972 | return this; |
- | |
2973 | }, |
- | |
2974 | - | ||
2975 | removeClass: function( value ) { |
- | |
2976 | if ( (value && typeof value === "string") || value === undefined ) { |
- | |
2977 | var classNames = (value || "").split(/\s+/); |
- | |
2978 | - | ||
2979 | for ( var i = 0, l = this.length; i < l; i++ ) { |
- | |
2980 | var elem = this[i]; |
- | |
2981 | - | ||
2982 | if ( elem.nodeType === 1 && elem.className ) { |
- | |
2983 | if ( value ) { |
- | |
2984 | var className = " " + elem.className + " "; |
- | |
2985 | for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
- | |
2986 | className = className.replace(" " + classNames[c] + " ", " "); |
- | |
2987 | }
|
- | |
2988 | elem.className = className.substring(1, className.length - 1); |
- | |
2989 | } else { |
- | |
2990 | elem.className = ""; |
- | |
2991 | }
|
- | |
2992 | }
|
- | |
2993 | }
|
- | |
2994 | }
|
- | |
2995 | - | ||
2996 | return this; |
- | |
2997 | }, |
- | |
2998 | 2578 | ||
- | 2579 | // Remove the expando if it's no longer used
|
|
2999 | hasClass: function( selector ) { |
2580 | for ( ret in events ) break; |
- | 2581 | if ( !ret ) { |
|
3000 | var className = " " + selector + " "; |
2582 | var handle = jQuery.data( elem, "handle" ); |
3001 | for ( var i = 0, l = this.length; i < l; i++ ) { |
2583 | if ( handle ) handle.elem = null; |
3002 | if ( (" " + this[i].className + " ").indexOf( className ) > -1 ) { |
2584 | jQuery.removeData( elem, "events" ); |
3003 | return true; |
2585 | jQuery.removeData( elem, "handle" ); |
3004 | }
|
2586 | }
|
3005 | }
|
2587 | }
|
3006 | - | ||
3007 | return false; |
- | |
3008 | }, |
2588 | }, |
3009 | 2589 | ||
3010 | val: function( value ) { |
2590 | // bubbling is internal
|
3011 | if ( value === undefined ) { |
- | |
3012 | var elem = this[0]; |
- | |
3013 | - | ||
3014 | if ( elem ) { |
- | |
3015 | if( jQuery.nodeName( elem, 'option' ) ) |
2591 | trigger: function( event, data, elem, bubbling ) { |
3016 | return (elem.attributes.value || {}).specified ? elem.value : elem.text; |
- | |
3017 | - | ||
3018 | // We need to handle select boxes special
|
2592 | // Event object or event type
|
3019 | if ( jQuery.nodeName( elem, "select" ) ) { |
- | |
3020 | var index = elem.selectedIndex, |
- | |
3021 | values = [], |
- | |
3022 | options = elem.options, |
- | |
3023 | one = elem.type == "select-one"; |
2593 | var type = event.type || event; |
3024 | - | ||
3025 | // Nothing was selected
|
- | |
3026 | if ( index < 0 ) |
- | |
3027 | return null; |
- | |
3028 | - | ||
3029 | // Loop through all the selected options
|
- | |
3030 | for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
- | |
3031 | var option = options[ i ]; |
- | |
3032 | - | ||
3033 | if ( option.selected ) { |
- | |
3034 | // Get the specifc value for the option
|
- | |
3035 | value = jQuery(option).val(); |
- | |
3036 | - | ||
3037 | // We don't need an array for one selects
|
- | |
3038 | if ( one ) |
- | |
3039 | return value; |
- | |
3040 | - | ||
3041 | // Multi-Selects return an array
|
- | |
3042 | values.push( value ); |
- | |
3043 | }
|
- | |
3044 | }
|
- | |
3045 | - | ||
3046 | return values; |
- | |
3047 | }
|
- | |
3048 | - | ||
3049 | // Everything else, we just grab the value
|
- | |
3050 | return (elem.value || "").replace(/\r/g, ""); |
- | |
3051 | - | ||
3052 | }
|
- | |
3053 | - | ||
3054 | return undefined; |
- | |
3055 | }
|
- | |
3056 | - | ||
3057 | // Typecast once if the value is a number
|
- | |
3058 | if ( typeof value === "number" ) |
- | |
3059 | value += ''; |
- | |
3060 | 2594 | ||
3061 | var val = value; |
2595 | if( !bubbling ){ |
- | 2596 | event = typeof event === "object" ? |
|
- | 2597 | // jQuery.Event object
|
|
- | 2598 | event[expando] ? event : |
|
- | 2599 | // Object literal
|
|
- | 2600 | jQuery.extend( jQuery.Event(type), event ) : |
|
- | 2601 | // Just the event type (string)
|
|
- | 2602 | jQuery.Event(type); |
|
3062 | 2603 | ||
3063 | return this.each(function(){ |
- | |
3064 | if(jQuery.isFunction(value)) { |
2604 | if ( type.indexOf("!") >= 0 ) { |
3065 | val = value.call(this); |
2605 | event.type = type = type.slice(0, -1); |
3066 | // Typecast each time if the value is a Function and the appended
|
- | |
3067 | // value is therefore different each time.
|
2606 | event.exclusive = true; |
3068 | if( typeof val === "number" ) val += ''; |
- | |
3069 | }
|
2607 | }
|
3070 | 2608 | ||
3071 | if ( this.nodeType != 1 ) |
2609 | // Handle a global trigger
|
3072 | return; |
2610 | if ( !elem ) { |
3073 | - | ||
3074 | if ( jQuery.isArray(val) && /radio|checkbox/.test( this.type ) ) |
2611 | // Don't bubble custom events when global (to avoid too much overhead)
|
3075 | this.checked = jQuery.inArray(this.value || this.name, val) >= 0; |
2612 | event.stopPropagation(); |
3076 | - | ||
3077 | else if ( jQuery.nodeName( this, "select" ) ) { |
2613 | // Only trigger if we've ever bound an event for it
|
3078 | var values = jQuery.makeArray(val); |
2614 | if ( this.global[type] ) |
3079 | - | ||
3080 | jQuery( "option", this ).each(function(){ |
2615 | jQuery.each( jQuery.cache, function(){ |
3081 | this.selected = jQuery.inArray( this.value || this.text, values ) >= 0; |
- | |
3082 | }); |
- | |
3083 | - | ||
3084 | if ( !values.length ) |
2616 | if ( this.events && this.events[type] ) |
3085 | this.selectedIndex = -1; |
2617 | jQuery.event.trigger( event, data, this.handle.elem ); |
3086 | - | ||
3087 | } else |
- | |
3088 | this.value = val; |
- | |
3089 | }); |
2618 | }); |
3090 | }
|
2619 | }
|
3091 | }); |
- | |
3092 | - | ||
3093 | jQuery.each({ |
- | |
3094 | removeAttr: function( name ) { |
- | |
3095 | jQuery.attr( this, name, "" ); |
- | |
3096 | if (this.nodeType == 1) |
- | |
3097 | this.removeAttribute( name ); |
- | |
3098 | }, |
- | |
3099 | 2620 | ||
3100 | toggleClass: function( classNames, state ) { |
- | |
3101 | var type = typeof classNames; |
- | |
3102 | if ( type === "string" ) { |
- | |
3103 | // toggle individual class names
|
2621 | // Handle triggering a single element
|
3104 | var isBool = typeof state === "boolean", className, i = 0, |
- | |
3105 | classNames = classNames.split( /\s+/ ); |
- | |
3106 | while ( (className = classNames[ i++ ]) ) { |
- | |
3107 | // check each className given, space seperated list
|
- | |
3108 | state = isBool ? state : !jQuery(this).hasClass( className ); |
- | |
3109 | jQuery(this)[ state ? "addClass" : "removeClass" ]( className ); |
- | |
3110 | }
|
- | |
3111 | } else if ( type === "undefined" || type === "boolean" ) { |
- | |
3112 | if ( this.className ) { |
- | |
3113 | // store className if set
|
- | |
3114 | jQuery.data( this, "__className__", this.className ); |
- | |
3115 | }
|
- | |
3116 | // toggle whole className
|
- | |
3117 | this.className = this.className || classNames === false ? "" : jQuery.data( this, "__className__" ) || ""; |
- | |
3118 | }
|
- | |
3119 | }
|
- | |
3120 | }, function(name, fn){ |
- | |
3121 | jQuery.fn[ name ] = function(){ |
- | |
3122 | return this.each( fn, arguments ); |
- | |
3123 | }; |
- | |
3124 | }); |
- | |
3125 | 2622 | ||
3126 | jQuery.extend({ |
- | |
3127 | attr: function( elem, name, value ) { |
- | |
3128 | // don't set attributes on text and comment nodes
|
2623 | // don't do events on text and comment nodes
|
3129 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
2624 | if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 ) |
3130 | return undefined; |
2625 | return undefined; |
3131 | 2626 | ||
3132 | if ( name in jQuery.fn && name !== "attr" ) { |
- | |
3133 | return jQuery(elem)[name](value); |
- | |
3134 | }
|
- | |
3135 | - | ||
3136 | var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), |
- | |
3137 | // Whether we are setting (or getting)
|
2627 | // Clean up in case it is reused
|
3138 | set = value !== undefined; |
2628 | event.result = undefined; |
3139 | - | ||
3140 | // Try to normalize/fix the name
|
- | |
3141 | name = notxml && jQuery.props[ name ] || name; |
- | |
3142 | - | ||
3143 | // Only do all the following if this is a node (faster for style)
|
- | |
3144 | if ( elem.nodeType === 1 ) { |
- | |
3145 | - | ||
3146 | // These attributes require special treatment
|
- | |
3147 | var special = /href|src|style/.test( name ); |
- | |
3148 | - | ||
3149 | // Safari mis-reports the default selected property of a hidden option
|
- | |
3150 | // Accessing the parent's selectedIndex property fixes it
|
- | |
3151 | if ( name == "selected" && elem.parentNode ) |
- | |
3152 | elem.parentNode.selectedIndex; |
- | |
3153 | - | ||
3154 | // If applicable, access the attribute via the DOM 0 way
|
- | |
3155 | if ( name in elem && notxml && !special ) { |
- | |
3156 | if ( set ){ |
- | |
3157 | // We can't allow the type property to be changed (since it causes problems in IE)
|
- | |
3158 | if ( name == "type" && /(button|input)/i.test(elem.nodeName) && elem.parentNode ) |
- | |
3159 | throw "type property can't be changed"; |
- | |
3160 | - | ||
3161 | elem[ name ] = value; |
- | |
3162 | }
|
- | |
3163 | - | ||
3164 | // browsers index elements by id/name on forms, give priority to attributes.
|
- | |
3165 | if( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) |
- | |
3166 | return elem.getAttributeNode( name ).nodeValue; |
- | |
3167 | - | ||
3168 | // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
|
- | |
3169 | // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
- | |
3170 | if ( name == "tabIndex" ) { |
- | |
3171 | var attributeNode = elem.getAttributeNode( "tabIndex" ); |
- | |
3172 | return attributeNode && attributeNode.specified |
- | |
3173 | ? attributeNode.value |
- | |
3174 | : /(button|input|object|select|textarea)/i.test(elem.nodeName) |
- | |
3175 | ? 0 |
- | |
3176 | : /^(a|area)$/i.test(elem.nodeName) && elem.href |
- | |
3177 | ? 0 |
- | |
3178 | : undefined; |
- | |
3179 | }
|
- | |
3180 | - | ||
3181 | return elem[ name ]; |
- | |
3182 | }
|
- | |
3183 | - | ||
3184 | if ( !jQuery.support.style && notxml && name == "style" ) { |
- | |
3185 | if ( set ) |
- | |
3186 | elem.style.cssText = "" + value; |
- | |
3187 | - | ||
3188 | return elem.style.cssText; |
- | |
3189 | }
|
- | |
3190 | - | ||
3191 | if ( set ) |
- | |
3192 | // convert the value to a string (all browsers do this but IE) see #1070
|
- | |
3193 | elem.setAttribute( name, "" + value ); |
- | |
3194 | - | ||
3195 | var attr = !jQuery.support.hrefNormalized && notxml && special |
- | |
3196 | // Some attributes require a special call on IE
|
- | |
3197 | ? elem.getAttribute( name, 2 ) |
- | |
3198 | : elem.getAttribute( name ); |
- | |
3199 | - | ||
3200 | // Non-existent attributes return null, we normalize to undefined
|
- | |
3201 | return attr === null ? undefined : attr; |
- | |
3202 | }
|
- | |
3203 | - | ||
3204 | // elem is actually elem.style ... set the style
|
- | |
3205 | // Using attr for specific style information is now deprecated. Use style insead.
|
- | |
3206 | return jQuery.style(elem, name, value); |
- | |
3207 | }
|
- | |
3208 | }); |
- | |
3209 | var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, |
- | |
3210 | rleadingWhitespace = /^\s+/, |
- | |
3211 | rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g, |
- | |
3212 | rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i, |
- | |
3213 | rtagName = /<([\w:]+)/, |
- | |
3214 | rtbody = /<tbody/i, |
- | |
3215 | rhtml = /</, |
- | |
3216 | fcloseTag = function(all, front, tag){ |
- | |
3217 | return rselfClosing.test(tag) ? |
- | |
3218 | all :
|
- | |
3219 | front + "></" + tag + ">"; |
- | |
3220 | }, |
- | |
3221 | wrapMap = { |
- | |
3222 | option: [ 1, "<select multiple='multiple'>", "</select>" ], |
- | |
3223 | legend: [ 1, "<fieldset>", "</fieldset>" ], |
- | |
3224 | thead: [ 1, "<table>", "</table>" ], |
- | |
3225 | tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
- | |
3226 | td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
- | |
3227 | col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], |
- | |
3228 | _default: [ 0, "", "" ] |
- | |
3229 | }; |
- | |
3230 | - | ||
3231 | wrapMap.optgroup = wrapMap.option; |
- | |
3232 | wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
- | |
3233 | wrapMap.th = wrapMap.td; |
- | |
3234 | - | ||
3235 | // IE can't serialize <link> and <script> tags normally
|
- | |
3236 | if ( !jQuery.support.htmlSerialize ) { |
- | |
3237 | wrapMap._default = [ 1, "div<div>", "</div>" ]; |
- | |
3238 | }
|
- | |
3239 | - | ||
3240 | jQuery.fn.extend({ |
- | |
3241 | text: function( text ) { |
- | |
3242 | if ( typeof text !== "object" && text !== undefined ) |
- | |
3243 | return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
- | |
3244 | - | ||
3245 | var ret = ""; |
- | |
3246 | - | ||
3247 | jQuery.each( text || this, function(){ |
- | |
3248 | jQuery.each( this.childNodes, function(){ |
- | |
3249 | if ( this.nodeType !== 8 ) { |
- | |
3250 | ret += this.nodeType !== 1 ? |
- | |
3251 | this.nodeValue : |
- | |
3252 | jQuery.fn.text( [ this ] ); |
- | |
3253 | }
|
- | |
3254 | }); |
- | |
3255 | }); |
- | |
3256 | - | ||
3257 | return ret; |
- | |
3258 | }, |
- | |
3259 | - | ||
3260 | wrapAll: function( html ) { |
- | |
3261 | if ( jQuery.isFunction( html ) ) { |
- | |
3262 | return this.each(function() { |
- | |
3263 | jQuery(this).wrapAll( html.apply(this, arguments) ); |
- | |
3264 | }); |
- | |
3265 | }
|
- | |
3266 | - | ||
3267 | if ( this[0] ) { |
- | |
3268 | // The elements to wrap the target around
|
- | |
3269 | var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(); |
- | |
3270 | - | ||
3271 | if ( this[0].parentNode ) { |
- | |
3272 | wrap.insertBefore( this[0] ); |
- | |
3273 | }
|
- | |
3274 | - | ||
3275 | wrap.map(function(){ |
- | |
3276 | var elem = this; |
- | |
3277 | - | ||
3278 | while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { |
- | |
3279 | elem = elem.firstChild; |
- | |
3280 | }
|
- | |
3281 | - | ||
3282 | return elem; |
2629 | event.target = elem; |
3283 | }).append(this); |
- | |
3284 | }
|
- | |
3285 | - | ||
3286 | return this; |
- | |
3287 | }, |
- | |
3288 | - | ||
3289 | wrapInner: function( html ) { |
- | |
3290 | return this.each(function(){ |
- | |
3291 | jQuery( this ).contents().wrapAll( html ); |
- | |
3292 | }); |
- | |
3293 | }, |
- | |
3294 | - | ||
3295 | wrap: function( html ) { |
- | |
3296 | return this.each(function(){ |
- | |
3297 | jQuery( this ).wrapAll( html ); |
- | |
3298 | }); |
- | |
3299 | }, |
- | |
3300 | - | ||
3301 | unwrap: function() { |
- | |
3302 | return this.parent().each(function(){ |
- | |
3303 | if ( !jQuery.nodeName( this, "body" ) ) { |
- | |
3304 | jQuery( this ).replaceWith( this.childNodes ); |
- | |
3305 | }
|
- | |
3306 | }).end(); |
- | |
3307 | }, |
- | |
3308 | 2630 | ||
3309 | append: function() { |
- | |
3310 | return this.domManip(arguments, true, function(elem){ |
2631 | // Clone the incoming data, if any
|
3311 | if ( this.nodeType === 1 ) { |
2632 | data = jQuery.makeArray(data); |
3312 | this.appendChild( elem ); |
2633 | data.unshift( event ); |
3313 | }
|
2634 | }
|
3314 | }); |
- | |
3315 | }, |
- | |
3316 | 2635 | ||
3317 | prepend: function() { |
- | |
3318 | return this.domManip(arguments, true, function(elem){ |
- | |
3319 | if ( this.nodeType === 1 ) { |
2636 | event.currentTarget = elem; |
3320 | this.insertBefore( elem, this.firstChild ); |
- | |
3321 | }
|
- | |
3322 | }); |
- | |
3323 | }, |
- | |
3324 | 2637 | ||
3325 | before: function() { |
- | |
3326 | if ( this[0] && this[0].parentNode ) { |
- | |
3327 | return this.domManip(arguments, false, function(elem){ |
2638 | // Trigger the event, it is assumed that "handle" is a function
|
3328 | this.parentNode.insertBefore( elem, this ); |
2639 | var handle = jQuery.data(elem, "handle"); |
3329 | }); |
- | |
3330 | } else if ( arguments.length ) { |
2640 | if ( handle ) |
3331 | var set = jQuery(arguments[0]); |
- | |
3332 | set.push.apply( set, this.toArray() ); |
2641 | handle.apply( elem, data ); |
3333 | return this.pushStack( set, "before", arguments ); |
- | |
3334 | }
|
- | |
3335 | }, |
- | |
3336 | 2642 | ||
3337 | after: function() { |
- | |
3338 | if ( this[0] && this[0].parentNode ) { |
- | |
3339 | return this.domManip(arguments, false, function(elem){ |
2643 | // Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
|
3340 | this.parentNode.insertBefore( elem, this.nextSibling ); |
2644 | if ( (!elem[type] || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false ) |
3341 | }); |
- | |
3342 | } else if ( arguments.length ) { |
- | |
3343 | var set = this.pushStack( this, "after", arguments ); |
- | |
3344 | set.push.apply( set, jQuery(arguments[0]).toArray() ); |
- | |
3345 | return set; |
2645 | event.result = false; |
3346 | }
|
- | |
3347 | }, |
- | |
3348 | 2646 | ||
3349 | clone: function( events ) { |
- | |
3350 | // Do the clone
|
- | |
3351 | var ret = this.map(function(){ |
- | |
3352 | if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { |
- | |
3353 | // IE copies events bound via attachEvent when
|
2647 | // Trigger the native events (except for clicks on links)
|
3354 | // using cloneNode. Calling detachEvent on the
|
- | |
3355 | // clone will also remove the events from the orignal
|
2648 | if ( !bubbling && elem[type] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type == "click") ) { |
3356 | // In order to get around this, we use innerHTML.
|
- | |
3357 | // Unfortunately, this means some modifications to
|
- | |
3358 | // attributes in IE that are actually only stored
|
- | |
3359 | // as properties will not be copied (such as the
|
- | |
3360 | // the name attribute on an input).
|
2649 | this.triggered = true; |
3361 | var html = this.outerHTML, ownerDocument = this.ownerDocument; |
- | |
3362 | if ( !html ) { |
2650 | try { |
3363 | var div = ownerDocument.createElement("div"); |
2651 | elem[ type ](); |
3364 | div.appendChild( this.cloneNode(true) ); |
2652 | // prevent IE from throwing an error for some hidden elements
|
3365 | html = div.innerHTML; |
2653 | } catch (e) {} |
3366 | }
|
2654 | }
|
3367 | 2655 | ||
- | 2656 | this.triggered = false; |
|
- | 2657 | ||
3368 | return jQuery.clean([html.replace(rinlinejQuery, "") |
2658 | if ( !event.isPropagationStopped() ) { |
3369 | .replace(rleadingWhitespace, "")], ownerDocument)[0]; |
2659 | var parent = elem.parentNode || elem.ownerDocument; |
3370 | } else { |
2660 | if ( parent ) |
3371 | return this.cloneNode(true); |
2661 | jQuery.event.trigger(event, data, parent, true); |
3372 | }
|
2662 | }
|
3373 | }); |
2663 | }, |
3374 | 2664 | ||
3375 | // Copy the events from the original to the clone
|
2665 | handle: function(event) { |
3376 | if ( events === true ) { |
2666 | // returned undefined or false
|
3377 | var orig = this.find("*").andSelf(), i = 0; |
2667 | var all, handlers; |
3378 | 2668 | ||
3379 | ret.find("*").andSelf().each(function(){ |
2669 | event = arguments[0] = jQuery.event.fix( event || window.event ); |
3380 | if ( this.nodeName !== orig[i].nodeName ) { return; } |
2670 | event.currentTarget = this; |
3381 | 2671 | ||
- | 2672 | // Namespaced event handlers
|
|
3382 | var events = jQuery.data( orig[i], "events" ); |
2673 | var namespaces = event.type.split("."); |
- | 2674 | event.type = namespaces.shift(); |
|
3383 | 2675 | ||
3384 | for ( var type in events ) { |
2676 | // Cache this now, all = true means, any handler
|
3385 | for ( var handler in events[ type ] ) { |
2677 | all = !namespaces.length && !event.exclusive; |
3386 | jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); |
- | |
3387 | }
|
- | |
3388 | }
|
- | |
3389 | 2678 | ||
3390 | i++;
|
- | |
3391 | }); |
- | |
3392 | }
|
- | |
- | 2679 | var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); |
|
3393 | 2680 | ||
3394 | // Return the cloned set
|
2681 | handlers = ( jQuery.data(this, "events") || {} )[event.type]; |
3395 | return ret; |
- | |
3396 | }, |
- | |
3397 | 2682 | ||
3398 | html: function( value ) { |
- | |
3399 | if ( value === undefined ) { |
2683 | for ( var j in handlers ) { |
3400 | return this[0] ? |
2684 | var handler = handlers[j]; |
3401 | this[0].innerHTML.replace(rinlinejQuery, "") : |
- | |
3402 | null; |
- | |
3403 | 2685 | ||
3404 | // See if we can take a shortcut and just use innerHTML
|
2686 | // Filter the functions by class
|
3405 | } else if ( typeof value === "string" && !/<script/i.test( value ) && |
2687 | if ( all || namespace.test(handler.type) ) { |
3406 | (!jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && |
2688 | // Pass in a reference to the handler function itself
|
3407 | !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { |
2689 | // So that we can later remove it
|
- | 2690 | event.handler = handler; |
|
- | 2691 | event.data = handler.data; |
|
3408 | 2692 | ||
3409 | try { |
- | |
3410 | for ( var i = 0, l = this.length; i < l; i++ ) { |
2693 | var ret = handler.apply(this, arguments); |
3411 | // Remove element nodes and prevent memory leaks
|
- | |
3412 | if ( this[i].nodeType === 1 ) { |
- | |
3413 | cleanData( this[i].getElementsByTagName("*") ); |
- | |
3414 | this[i].innerHTML = value; |
- | |
3415 | }
|
- | |
3416 | }
|
- | |
3417 | 2694 | ||
3418 | // If using innerHTML throws an exception, use the fallback method
|
2695 | if( ret !== undefined ){ |
- | 2696 | event.result = ret; |
|
3419 | } catch(e) { |
2697 | if ( ret === false ) { |
3420 | this.empty().append( value ); |
2698 | event.preventDefault(); |
- | 2699 | event.stopPropagation(); |
|
3421 | }
|
2700 | }
|
3422 | - | ||
3423 | } else { |
- | |
3424 | this.empty().append( value ); |
- | |
3425 | }
|
2701 | }
|
3426 | 2702 | ||
- | 2703 | if( event.isImmediatePropagationStopped() ) |
|
3427 | return this; |
2704 | break; |
3428 | }, |
- | |
3429 | 2705 | ||
3430 | replaceWith: function( value ) { |
- | |
3431 | if ( this[0] && this[0].parentNode ) { |
- | |
3432 | return this.after( value ).remove(); |
- | |
3433 | } else { |
2706 | }
|
3434 | return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ); |
- | |
3435 | }
|
2707 | }
|
3436 | }, |
2708 | }, |
3437 | 2709 | ||
3438 | detach: function( selector ) { |
- | |
3439 | return this.remove( selector, true ); |
2710 | props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), |
3440 | }, |
- | |
3441 | 2711 | ||
3442 | domManip: function( args, table, callback ) { |
2712 | fix: function(event) { |
3443 | var results, first, value = args[0], scripts = []; |
2713 | if ( event[expando] ) |
- | 2714 | return event; |
|
3444 | 2715 | ||
3445 | if ( jQuery.isFunction(value) ) { |
2716 | // store a copy of the original event object
|
3446 | return this.each(function() { |
2717 | // and "clone" to set read-only properties
|
3447 | args[0] = value.call(this); |
2718 | var originalEvent = event; |
3448 | return jQuery(this).domManip( args, table, callback ); |
2719 | event = jQuery.Event( originalEvent ); |
3449 | }); |
- | |
3450 | }
|
- | |
3451 | 2720 | ||
3452 | if ( this[0] ) { |
- | |
3453 | // If we're in a fragment, just use that instead of building a new one
|
- | |
3454 | if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) { |
2721 | for ( var i = this.props.length, prop; i; ){ |
3455 | results = { fragment: args[0].parentNode }; |
2722 | prop = this.props[ --i ]; |
3456 | } else { |
- | |
3457 | results = buildFragment( args, this, scripts ); |
2723 | event[ prop ] = originalEvent[ prop ]; |
3458 | }
|
2724 | }
|
3459 | 2725 | ||
3460 | first = results.fragment.firstChild; |
2726 | // Fix target property, if necessary
|
- | 2727 | if ( !event.target ) |
|
- | 2728 | event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
|
3461 | 2729 | ||
- | 2730 | // check if target is a textnode (safari)
|
|
3462 | if ( first ) { |
2731 | if ( event.target.nodeType == 3 ) |
3463 | table = table && jQuery.nodeName( first, "tr" ); |
2732 | event.target = event.target.parentNode; |
3464 | 2733 | ||
3465 | for ( var i = 0, l = this.length; i < l; i++ ) { |
- | |
3466 | callback.call( |
- | |
3467 | table ?
|
- | |
3468 | root(this[i], first) : |
2734 | // Add relatedTarget, if necessary
|
3469 | this[i], |
- | |
3470 | results.cacheable || this.length > 1 || i > 0 ? |
2735 | if ( !event.relatedTarget && event.fromElement ) |
3471 | results.fragment.cloneNode(true) : |
2736 | event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement; |
3472 | results.fragment
|
- | |
3473 | ); |
- | |
3474 | }
|
- | |
3475 | }
|
- | |
3476 | 2737 | ||
- | 2738 | // Calculate pageX/Y if missing and clientX/Y available
|
|
3477 | if ( scripts ) { |
2739 | if ( event.pageX == null && event.clientX != null ) { |
3478 | jQuery.each( scripts, evalScript ); |
2740 | var doc = document.documentElement, body = document.body; |
3479 | }
|
- | |
- | 2741 | event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0); |
|
- | 2742 | event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0); |
|
3480 | }
|
2743 | }
|
3481 | 2744 | ||
3482 | return this; |
2745 | // Add which for key events
|
- | 2746 | if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) |
|
- | 2747 | event.which = event.charCode || event.keyCode; |
|
3483 | 2748 | ||
- | 2749 | // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
|
|
3484 | function root( elem, cur ) { |
2750 | if ( !event.metaKey && event.ctrlKey ) |
3485 | return jQuery.nodeName(elem, "table") ? |
2751 | event.metaKey = event.ctrlKey; |
- | 2752 | ||
- | 2753 | // Add which for click: 1 == left; 2 == middle; 3 == right
|
|
3486 | (elem.getElementsByTagName("tbody")[0] || |
2754 | // Note: button is not normalized, so don't use it
|
- | 2755 | if ( !event.which && event.button ) |
|
3487 | elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
2756 | event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
- | 2757 | ||
3488 | elem;
|
2758 | return event; |
- | 2759 | }, |
|
- | 2760 | ||
- | 2761 | proxy: function( fn, proxy ){ |
|
- | 2762 | proxy = proxy || function(){ return fn.apply(this, arguments); }; |
|
- | 2763 | // Set the guid of unique handler to the same of original handler, so it can be removed
|
|
- | 2764 | proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++; |
|
- | 2765 | // So proxy can be declared as an argument
|
|
- | 2766 | return proxy; |
|
3489 | }
|
2767 | }, |
- | 2768 | ||
- | 2769 | special: { |
|
- | 2770 | ready: { |
|
- | 2771 | // Make sure the ready event is setup
|
|
- | 2772 | setup: bindReady, |
|
- | 2773 | teardown: function() {} |
|
3490 | }
|
2774 | }
|
3491 | }); |
2775 | }, |
- | 2776 | ||
- | 2777 | specialAll: { |
|
- | 2778 | live: { |
|
- | 2779 | setup: function( selector, namespaces ){ |
|
- | 2780 | jQuery.event.add( this, namespaces[0], liveHandler ); |
|
- | 2781 | }, |
|
- | 2782 | teardown: function( namespaces ){ |
|
- | 2783 | if ( namespaces.length ) { |
|
- | 2784 | var remove = 0, name = RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)"); |
|
3492 | 2785 | ||
3493 | function buildFragment(args, nodes, scripts){ |
2786 | jQuery.each( (jQuery.data(this, "events").live || {}), function(){ |
3494 | var fragment, cacheable, cached, cacheresults, doc; |
2787 | if ( name.test(this.type) ) |
- | 2788 | remove++;
|
|
- | 2789 | }); |
|
3495 | 2790 | ||
3496 | if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) { |
- | |
3497 | cacheable = true; |
- | |
3498 | cacheresults = jQuery.fragments[ args[0] ]; |
- | |
3499 | if ( cacheresults ) { |
- | |
3500 | if ( cacheresults !== 1 ) { |
2791 | if ( remove < 1 ) |
3501 | fragment = cacheresults; |
2792 | jQuery.event.remove( this, namespaces[0], liveHandler ); |
3502 | }
|
2793 | }
|
3503 | cached = true; |
- | |
3504 | }
|
2794 | }
|
3505 | }
|
2795 | }
|
3506 | - | ||
3507 | if ( !fragment ) { |
- | |
3508 | doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document); |
- | |
3509 | fragment = doc.createDocumentFragment(); |
- | |
3510 | jQuery.clean( args, doc, fragment, scripts ); |
- | |
3511 | }
|
2796 | }
|
- | 2797 | }; |
|
3512 | 2798 | ||
- | 2799 | jQuery.Event = function( src ){ |
|
- | 2800 | // Allow instantiation without the 'new' keyword
|
|
- | 2801 | if( !this.preventDefault ) |
|
- | 2802 | return new jQuery.Event(src); |
|
- | 2803 | ||
- | 2804 | // Event object
|
|
3513 | if ( cacheable ) { |
2805 | if( src && src.type ){ |
3514 | jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1; |
2806 | this.originalEvent = src; |
- | 2807 | this.type = src.type; |
|
- | 2808 | // Event type
|
|
- | 2809 | }else |
|
- | 2810 | this.type = src; |
|
3515 | }
|
2811 | |
- | 2812 | // timeStamp is buggy for some events on Firefox(#3843)
|
|
- | 2813 | // So we won't rely on the native value
|
|
- | 2814 | this.timeStamp = now(); |
|
3516 | 2815 | ||
- | 2816 | // Mark it as fixed
|
|
- | 2817 | this[expando] = true; |
|
- | 2818 | }; |
|
- | 2819 | ||
3517 | return { fragment: fragment, cacheable: cacheable }; |
2820 | function returnFalse(){ |
- | 2821 | return false; |
|
- | 2822 | }
|
|
- | 2823 | function returnTrue(){ |
|
- | 2824 | return true; |
|
3518 | }
|
2825 | }
|
3519 | 2826 | ||
- | 2827 | // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
|
|
- | 2828 | // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
|
|
3520 | jQuery.fragments = {}; |
2829 | jQuery.Event.prototype = { |
- | 2830 | preventDefault: function() { |
|
- | 2831 | this.isDefaultPrevented = returnTrue; |
|
3521 | 2832 | ||
- | 2833 | var e = this.originalEvent; |
|
3522 | jQuery.each({ |
2834 | if( !e ) |
3523 | appendTo: "append", |
2835 | return; |
3524 | prependTo: "prepend", |
2836 | // if preventDefault exists run it on the original event
|
3525 | insertBefore: "before", |
2837 | if (e.preventDefault) |
3526 | insertAfter: "after", |
2838 | e.preventDefault(); |
3527 | replaceAll: "replaceWith" |
2839 | // otherwise set the returnValue property of the original event to false (IE)
|
3528 | }, function(name, original){ |
2840 | e.returnValue = false; |
- | 2841 | }, |
|
3529 | jQuery.fn[ name ] = function( selector ) { |
2842 | stopPropagation: function() { |
3530 | var ret = [], insert = jQuery( selector ); |
2843 | this.isPropagationStopped = returnTrue; |
3531 | 2844 | ||
- | 2845 | var e = this.originalEvent; |
|
- | 2846 | if( !e ) |
|
- | 2847 | return; |
|
3532 | for ( var i = 0, l = insert.length; i < l; i++ ) { |
2848 | // if stopPropagation exists run it on the original event
|
- | 2849 | if (e.stopPropagation) |
|
- | 2850 | e.stopPropagation(); |
|
- | 2851 | // otherwise set the cancelBubble property of the original event to true (IE)
|
|
- | 2852 | e.cancelBubble = true; |
|
- | 2853 | }, |
|
- | 2854 | stopImmediatePropagation:function(){ |
|
3533 | var elems = (i > 0 ? this.clone(true) : this).get(); |
2855 | this.isImmediatePropagationStopped = returnTrue; |
- | 2856 | this.stopPropagation(); |
|
- | 2857 | }, |
|
- | 2858 | isDefaultPrevented: returnFalse, |
|
- | 2859 | isPropagationStopped: returnFalse, |
|
- | 2860 | isImmediatePropagationStopped: returnFalse
|
|
- | 2861 | }; |
|
3534 | jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); |
2862 | // Checks if an event happened on an element within another element
|
- | 2863 | // Used in jQuery.event.special.mouseenter and mouseleave handlers
|
|
- | 2864 | var withinElement = function(event) { |
|
- | 2865 | // Check if mouse(over|out) are still within the same parent element
|
|
- | 2866 | var parent = event.relatedTarget; |
|
- | 2867 | // Traverse up the tree
|
|
- | 2868 | while ( parent && parent != this ) |
|
- | 2869 | try { parent = parent.parentNode; } |
|
- | 2870 | catch(e) { parent = this; } |
|
- | 2871 | ||
- | 2872 | if( parent != this ){ |
|
3535 | ret = ret.concat( elems ); |
2873 | // set the correct event type
|
- | 2874 | event.type = event.data; |
|
- | 2875 | // handle event if we actually just moused on to a non sub-element
|
|
- | 2876 | jQuery.event.handle.apply( this, arguments ); |
|
3536 | }
|
2877 | }
|
3537 | return this.pushStack( ret, name, insert.selector ); |
- | |
3538 | }; |
2878 | }; |
3539 | }); |
- | |
3540 | 2879 | ||
3541 | jQuery.each({ |
2880 | jQuery.each({ |
3542 | // keepData is for internal use only--do not document
|
2881 | mouseover: 'mouseenter', |
- | 2882 | mouseout: 'mouseleave' |
|
3543 | remove: function( selector, keepData ) { |
2883 | }, function( orig, fix ){ |
3544 | if ( !selector || jQuery.multiFilter( selector, [ this ] ).length ) { |
2884 | jQuery.event.special[ fix ] = { |
3545 | if ( !keepData && this.nodeType === 1 ) { |
2885 | setup: function(){ |
3546 | cleanData( this.getElementsByTagName("*") ); |
2886 | jQuery.event.add( this, orig, withinElement, fix ); |
- | 2887 | }, |
|
3547 | cleanData( [ this ] ); |
2888 | teardown: function(){ |
- | 2889 | jQuery.event.remove( this, orig, withinElement ); |
|
3548 | }
|
2890 | }
|
- | 2891 | }; |
|
- | 2892 | }); |
|
3549 | 2893 | ||
- | 2894 | jQuery.fn.extend({ |
|
3550 | if ( this.parentNode ) { |
2895 | bind: function( type, data, fn ) { |
- | 2896 | return type == "unload" ? this.one(type, data, fn) : this.each(function(){ |
|
3551 | this.parentNode.removeChild( this ); |
2897 | jQuery.event.add( this, type, fn || data, fn && data ); |
3552 | }
|
- | |
3553 | }
|
2898 | }); |
3554 | }, |
2899 | }, |
3555 | 2900 | ||
3556 | empty: function() { |
2901 | one: function( type, data, fn ) { |
3557 | // Remove element nodes and prevent memory leaks
|
2902 | var one = jQuery.event.proxy( fn || data, function(event) { |
- | 2903 | jQuery(this).unbind(event, one); |
|
- | 2904 | return (fn || data).apply( this, arguments ); |
|
- | 2905 | }); |
|
3558 | if ( this.nodeType === 1 ) { |
2906 | return this.each(function(){ |
3559 | cleanData( this.getElementsByTagName("*") ); |
2907 | jQuery.event.add( this, type, one, fn && data); |
3560 | }
|
2908 | }); |
- | 2909 | }, |
|
3561 | 2910 | ||
3562 | // Remove any remaining nodes
|
- | |
3563 | while ( this.firstChild ) { |
- | |
3564 | this.removeChild( this.firstChild ); |
- | |
3565 | }
|
- | |
3566 | }
|
- | |
3567 | }, function(name, fn){ |
2911 | unbind: function( type, fn ) { |
3568 | jQuery.fn[ name ] = function(){ |
2912 | return this.each(function(){ |
3569 | return this.each( fn, arguments ); |
2913 | jQuery.event.remove( this, type, fn ); |
3570 | }; |
- | |
3571 | }); |
2914 | }); |
- | 2915 | }, |
|
3572 | 2916 | ||
3573 | jQuery.extend({ |
2917 | trigger: function( type, data ) { |
3574 | clean: function( elems, context, fragment, scripts ) { |
2918 | return this.each(function(){ |
3575 | context = context || document; |
2919 | jQuery.event.trigger( type, data, this ); |
- | 2920 | }); |
|
- | 2921 | }, |
|
3576 | 2922 | ||
3577 | // !context.createElement fails in IE with an error but returns typeof 'object'
|
2923 | triggerHandler: function( type, data ) { |
- | 2924 | if( this[0] ){ |
|
3578 | if ( typeof context.createElement === "undefined" ) { |
2925 | var event = jQuery.Event(type); |
- | 2926 | event.preventDefault(); |
|
- | 2927 | event.stopPropagation(); |
|
3579 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
2928 | jQuery.event.trigger( event, data, this[0] ); |
- | 2929 | return event.result; |
|
3580 | }
|
2930 | }
|
- | 2931 | }, |
|
3581 | 2932 | ||
- | 2933 | toggle: function( fn ) { |
|
3582 | var ret = [], div = context.createElement("div"); |
2934 | // Save reference to arguments for access in closure
|
- | 2935 | var args = arguments, i = 1; |
|
3583 | 2936 | ||
3584 | jQuery.each(elems, function(i, elem){ |
2937 | // link all the functions, so any of them can unbind this click handler
|
3585 | if ( typeof elem === "number" ) { |
2938 | while( i < args.length ) |
3586 | elem += ''; |
2939 | jQuery.event.proxy( fn, args[i++] ); |
3587 | }
|
- | |
3588 | 2940 | ||
- | 2941 | return this.click( jQuery.event.proxy( fn, function(event) { |
|
3589 | if ( !elem ) { return; } |
2942 | // Figure out which function to execute
|
- | 2943 | this.lastToggle = ( this.lastToggle || 0 ) % i; |
|
3590 | 2944 | ||
3591 | // Convert html string into DOM nodes
|
2945 | // Make sure that clicks stop
|
3592 | if ( typeof elem === "string" && !rhtml.test( elem ) ) { |
- | |
3593 | elem = context.createTextNode( elem ); |
2946 | event.preventDefault(); |
3594 | 2947 | ||
3595 | } else if ( typeof elem === "string" ) { |
2948 | // and execute the function
|
3596 | // Fix "XHTML"-style tags in all browsers
|
2949 | return args[ this.lastToggle++ ].apply( this, arguments ) || false; |
3597 | elem = elem.replace(rxhtmlTag, fcloseTag); |
2950 | })); |
- | 2951 | }, |
|
3598 | 2952 | ||
3599 | // Trim whitespace, otherwise indexOf won't work as expected
|
2953 | hover: function(fnOver, fnOut) { |
3600 | var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), |
- | |
3601 | wrap = wrapMap[ tag ] || wrapMap._default, |
2954 | return this.mouseenter(fnOver).mouseleave(fnOut); |
3602 | depth = wrap[0]; |
2955 | }, |
3603 | 2956 | ||
- | 2957 | ready: function(fn) { |
|
3604 | // Go to html and back, then peel off extra wrappers
|
2958 | // Attach the listeners
|
3605 | div.innerHTML = wrap[1] + elem + wrap[2]; |
2959 | bindReady(); |
3606 | 2960 | ||
3607 | // Move to the right depth
|
2961 | // If the DOM is already ready
|
3608 | while ( depth-- ) { |
2962 | if ( jQuery.isReady ) |
3609 | div = div.lastChild; |
2963 | // Execute the function immediately
|
3610 | }
|
2964 | fn.call( document, jQuery ); |
3611 | 2965 | ||
3612 | // Remove IE's autoinserted <tbody> from table fragments
|
2966 | // Otherwise, remember the function for later
|
- | 2967 | else
|
|
- | 2968 | // Add the function to the wait list
|
|
3613 | if ( !jQuery.support.tbody ) { |
2969 | jQuery.readyList.push( fn ); |
3614 | 2970 | ||
3615 | // String was a <table>, *may* have spurious <tbody>
|
- | |
3616 | var hasBody = rtbody.test(elem), |
2971 | return this; |
3617 | tbody = tag === "table" && !hasBody ? |
- | |
3618 | div.firstChild && div.firstChild.childNodes : |
- | |
- | 2972 | }, |
|
3619 | 2973 | ||
3620 | // String was a bare <thead> or <tfoot>
|
2974 | live: function( type, fn ){ |
3621 | wrap[1] == "<table>" && !hasBody ? |
2975 | var proxy = jQuery.event.proxy( fn ); |
3622 | div.childNodes : |
2976 | proxy.guid += this.selector + type; |
3623 | []; |
- | |
3624 | 2977 | ||
3625 | for ( var j = tbody.length - 1; j >= 0 ; --j ) { |
- | |
3626 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
2978 | jQuery(document).bind( liveConvert(type, this.selector), this.selector, proxy ); |
3627 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
- | |
3628 | }
|
- | |
3629 | }
|
- | |
3630 | 2979 | ||
- | 2980 | return this; |
|
3631 | }
|
2981 | }, |
3632 | 2982 | ||
3633 | // IE completely kills leading whitespace when innerHTML is used
|
2983 | die: function( type, fn ){ |
3634 | if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
2984 | jQuery(document).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null ); |
3635 | div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
2985 | return this; |
3636 | }
|
2986 | }
|
- | 2987 | }); |
|
3637 | 2988 | ||
- | 2989 | function liveHandler( event ){ |
|
3638 | elem = jQuery.makeArray( div.childNodes ); |
2990 | var check = RegExp("(^|\\.)" + event.type + "(\\.|$)"), |
- | 2991 | stop = true, |
|
3639 | }
|
2992 | elems = []; |
3640 | 2993 | ||
- | 2994 | jQuery.each(jQuery.data(this, "events").live || [], function(i, fn){ |
|
3641 | if ( elem.nodeType ) { |
2995 | if ( check.test(fn.type) ) { |
3642 | ret.push( elem ); |
2996 | var elem = jQuery(event.target).closest(fn.data)[0]; |
3643 | } else { |
2997 | if ( elem ) |
3644 | ret = jQuery.merge( ret, elem ); |
2998 | elems.push({ elem: elem, fn: fn }); |
3645 | }
|
2999 | }
|
3646 | - | ||
3647 | }); |
3000 | }); |
3648 | 3001 | ||
3649 | if ( fragment ) { |
3002 | elems.sort(function(a,b) { |
3650 | for ( var i = 0; ret[i]; i++ ) { |
- | |
3651 | if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
- | |
3652 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
- | |
3653 | } else { |
- | |
3654 | if ( ret[i].nodeType === 1 ) { |
- | |
3655 | ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
3003 | return jQuery.data(a.elem, "closest") - jQuery.data(b.elem, "closest"); |
3656 | }
|
- | |
3657 | fragment.appendChild( ret[i] ); |
- | |
3658 | }
|
- | |
3659 | }
|
3004 | }); |
3660 | }
|
- | |
3661 | 3005 | ||
- | 3006 | jQuery.each(elems, function(){ |
|
- | 3007 | if ( this.fn.call(this.elem, event, this.fn.data) === false ) |
|
3662 | return ret; |
3008 | return (stop = false); |
3663 | }
|
- | |
3664 | }); |
3009 | }); |
3665 | 3010 | ||
3666 | function cleanData( elems ) { |
- | |
3667 | for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) { |
- | |
3668 | if ( (id = elem[expando]) ) { |
- | |
3669 | delete jQuery.cache[ id ]; |
3011 | return stop; |
3670 | }
|
- | |
3671 | }
|
- | |
3672 | }
|
3012 | }
|
3673 | // exclude the following css properties to add px
|
- | |
3674 | var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
- | |
3675 | ralpha = /alpha\([^)]*\)/, |
- | |
3676 | ropacity = /opacity=([^)]*)/, |
- | |
3677 | rfloat = /float/i, |
- | |
3678 | rdashAlpha = /-([a-z])/ig, |
- | |
3679 | rupper = /([A-Z])/g, |
- | |
3680 | rnumpx = /^\d+(?:px)?$/i, |
- | |
3681 | rnum = /^\d/, |
- | |
3682 | - | ||
3683 | // cache check for defaultView.getComputedStyle
|
- | |
3684 | getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, |
- | |
3685 | // normalize float css property
|
- | |
3686 | styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat", |
- | |
3687 | fcamelCase = function(all, letter){ |
- | |
3688 | return letter.toUpperCase(); |
- | |
3689 | }; |
- | |
3690 | 3013 | ||
3691 | jQuery.fn.css = function( name, value ) { |
3014 | function liveConvert(type, selector){ |
3692 | return access( this, name, value, true, function( elem, name, value ) { |
3015 | return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); |
3693 | if (value === undefined) { |
- | |
3694 | return jQuery.css( elem, name ); |
- | |
3695 | }
|
3016 | }
|
3696 | 3017 | ||
- | 3018 | jQuery.extend({ |
|
- | 3019 | isReady: false, |
|
- | 3020 | readyList: [], |
|
- | 3021 | // Handle when the DOM is ready
|
|
- | 3022 | ready: function() { |
|
3697 | if ( typeof value === "number" && !rexclude.test(name) ) { |
3023 | // Make sure that the DOM is not already loaded
|
3698 | value += "px"; |
3024 | if ( !jQuery.isReady ) { |
- | 3025 | // Remember that the DOM is ready
|
|
3699 | }
|
3026 | jQuery.isReady = true; |
3700 | 3027 | ||
- | 3028 | // If there are functions bound, to execute
|
|
- | 3029 | if ( jQuery.readyList ) { |
|
- | 3030 | // Execute all of them
|
|
- | 3031 | jQuery.each( jQuery.readyList, function(){ |
|
3701 | jQuery.style( elem, name, value ); |
3032 | this.call( document, jQuery ); |
3702 | }); |
3033 | }); |
3703 | }; |
- | |
3704 | 3034 | ||
3705 | jQuery.extend({ |
- | |
3706 | style: function( elem, name, value ) { |
- | |
3707 | // don't set styles on text and comment nodes
|
3035 | // Reset the list of functions
|
3708 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
- | |
3709 | return undefined; |
3036 | jQuery.readyList = null; |
3710 | }
|
3037 | }
|
3711 | 3038 | ||
3712 | // ignore negative width and height values #1599
|
3039 | // Trigger any bound ready events
|
3713 | if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) { |
- | |
3714 | value = undefined; |
3040 | jQuery(document).triggerHandler("ready"); |
3715 | }
|
3041 | }
|
3716 | - | ||
3717 | var style = elem.style || elem, set = value !== undefined; |
- | |
3718 | - | ||
3719 | // IE uses filters for opacity
|
- | |
3720 | if ( !jQuery.support.opacity && name === "opacity" ) { |
- | |
3721 | if ( set ) { |
- | |
3722 | // IE has trouble with opacity if it does not have layout
|
- | |
3723 | // Force it by setting the zoom level
|
- | |
3724 | style.zoom = 1; |
- | |
3725 | - | ||
3726 | // Set the alpha filter to set the opacity
|
- | |
3727 | style.filter = (style.filter || "").replace( ralpha, "" ) + |
- | |
3728 | (parseInt( value ) + '' === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"); |
- | |
3729 | }
|
3042 | }
|
- | 3043 | }); |
|
3730 | 3044 | ||
3731 | return style.filter && style.filter.indexOf("opacity=") >= 0 ? |
- | |
3732 | (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + '': |
3045 | var readyBound = false; |
3733 | ""; |
- | |
3734 | }
|
- | |
3735 | 3046 | ||
3736 | // Make sure we're using the right name for getting the float value
|
3047 | function bindReady(){ |
3737 | if ( rfloat.test( name ) ) { |
3048 | if ( readyBound ) return; |
3738 | name = styleFloat; |
3049 | readyBound = true; |
3739 | }
|
- | |
3740 | 3050 | ||
- | 3051 | // Mozilla, Opera and webkit nightlies currently support this event
|
|
- | 3052 | if ( document.addEventListener ) { |
|
3741 | name = name.replace(rdashAlpha, fcamelCase); |
3053 | // Use the handy event callback
|
- | 3054 | document.addEventListener( "DOMContentLoaded", function(){ |
|
- | 3055 | document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
|
- | 3056 | jQuery.ready(); |
|
- | 3057 | }, false ); |
|
3742 | 3058 | ||
3743 | if ( set ) { |
3059 | // If IE event model is used
|
- | 3060 | } else if ( document.attachEvent ) { |
|
- | 3061 | // ensure firing before onload,
|
|
- | 3062 | // maybe late but safe also for iframes
|
|
- | 3063 | document.attachEvent("onreadystatechange", function(){ |
|
- | 3064 | if ( document.readyState === "complete" ) { |
|
- | 3065 | document.detachEvent( "onreadystatechange", arguments.callee ); |
|
3744 | style[ name ] = value; |
3066 | jQuery.ready(); |
3745 | }
|
3067 | }
|
- | 3068 | }); |
|
3746 | 3069 | ||
3747 | return style[ name ]; |
3070 | // If IE and not an iframe
|
3748 | }, |
- | |
3749 | - | ||
3750 | css: function( elem, name, force, extra ) { |
3071 | // continually check to see if the document is ready
|
3751 | if ( name === "width" || name === "height" ) { |
3072 | if ( document.documentElement.doScroll && window == window.top ) (function(){ |
3752 | var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name === "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; |
- | |
3753 | - | ||
3754 | function getWH() { |
- | |
3755 | val = name === "width" ? elem.offsetWidth : elem.offsetHeight; |
- | |
3756 | - | ||
3757 | if ( extra === "border" ) { return; } |
3073 | if ( jQuery.isReady ) return; |
3758 | - | ||
3759 | jQuery.each( which, function() { |
- | |
3760 | if ( !extra ) { |
- | |
3761 | val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
- | |
3762 | }
|
- | |
3763 | 3074 | ||
- | 3075 | try { |
|
3764 | if ( extra === "margin" ) { |
3076 | // If IE is used, use the trick by Diego Perini
|
3765 | val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; |
3077 | // http://javascript.nwbox.com/IEContentLoaded/
|
- | 3078 | document.documentElement.doScroll("left"); |
|
3766 | } else { |
3079 | } catch( error ) { |
3767 | val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
3080 | setTimeout( arguments.callee, 0 ); |
3768 | }
|
- | |
3769 | }); |
3081 | return; |
3770 | }
|
3082 | }
|
3771 | 3083 | ||
3772 | if ( elem.offsetWidth !== 0 ) { |
3084 | // and execute any waiting functions
|
3773 | getWH(); |
3085 | jQuery.ready(); |
3774 | } else { |
3086 | })(); |
3775 | jQuery.swap( elem, props, getWH ); |
- | |
3776 | }
|
3087 | }
|
3777 | 3088 | ||
- | 3089 | // A fallback to window.onload, that will always work
|
|
3778 | return Math.max(0, Math.round(val)); |
3090 | jQuery.event.add( window, "load", jQuery.ready ); |
3779 | }
|
3091 | }
|
3780 | 3092 | ||
3781 | return jQuery.curCSS( elem, name, force ); |
3093 | jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," + |
3782 | }, |
- | |
- | 3094 | "mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," + |
|
- | 3095 | "change,select,submit,keydown,keypress,keyup,error").split(","), function(i, name){ |
|
3783 | 3096 | ||
- | 3097 | // Handle event binding
|
|
3784 | curCSS: function( elem, name, force ) { |
3098 | jQuery.fn[name] = function(fn){ |
3785 | var ret, style = elem.style, filter; |
3099 | return fn ? this.bind(name, fn) : this.trigger(name); |
- | 3100 | }; |
|
- | 3101 | }); |
|
3786 | 3102 | ||
3787 | // IE uses filters for opacity
|
3103 | // Prevent memory leaks in IE
|
3788 | if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) { |
3104 | // And prevent errors on refresh with events like mouseover in other browsers
|
- | 3105 | // Window isn't included so as not to unbind existing unload events
|
|
- | 3106 | jQuery( window ).bind( 'unload', function(){ |
|
- | 3107 | for ( var id in jQuery.cache ) |
|
- | 3108 | // Skip the window
|
|
3789 | ret = ropacity.test(elem.currentStyle.filter || "") ? |
3109 | if ( id != 1 && jQuery.cache[ id ].handle ) |
3790 | (parseFloat(RegExp.$1) / 100) + "" : |
3110 | jQuery.event.remove( jQuery.cache[ id ].handle.elem ); |
3791 | ""; |
3111 | }); |
- | 3112 | (function(){ |
|
3792 | 3113 | ||
3793 | return ret === "" ? |
3114 | jQuery.support = {}; |
3794 | "1" : |
- | |
3795 | ret;
|
- | |
3796 | }
|
- | |
3797 | 3115 | ||
- | 3116 | var root = document.documentElement, |
|
3798 | // Make sure we're using the right name for getting the float value
|
3117 | script = document.createElement("script"), |
3799 | if ( rfloat.test( name ) ) { |
3118 | div = document.createElement("div"), |
3800 | name = styleFloat; |
3119 | id = "script" + (new Date).getTime(); |
3801 | }
|
- | |
3802 | 3120 | ||
3803 | if ( !force && style && style[ name ] ) { |
- | |
3804 | ret = style[ name ]; |
3121 | div.style.display = "none"; |
- | 3122 | div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>'; |
|
3805 | 3123 | ||
3806 | } else if ( getComputedStyle ) { |
3124 | var all = div.getElementsByTagName("*"), |
- | 3125 | a = div.getElementsByTagName("a")[0]; |
|
3807 | 3126 | ||
3808 | // Only "float" is needed here
|
3127 | // Can't get basic test support
|
3809 | if ( rfloat.test( name ) ) { |
3128 | if ( !all || !all.length || !a ) { |
3810 | name = "float"; |
3129 | return; |
3811 | }
|
3130 | }
|
3812 | 3131 | ||
- | 3132 | jQuery.support = { |
|
- | 3133 | // IE strips leading whitespace when .innerHTML is used
|
|
3813 | name = name.replace( rupper, "-$1" ).toLowerCase(); |
3134 | leadingWhitespace: div.firstChild.nodeType == 3, |
- | 3135 | ||
- | 3136 | // Make sure that tbody elements aren't automatically inserted
|
|
- | 3137 | // IE will insert them into empty tables
|
|
- | 3138 | tbody: !div.getElementsByTagName("tbody").length, |
|
- | 3139 | ||
- | 3140 | // Make sure that you can get all elements in an <object> element
|
|
- | 3141 | // IE 7 always returns no results
|
|
- | 3142 | objectAll: !!div.getElementsByTagName("object")[0] |
|
- | 3143 | .getElementsByTagName("*").length, |
|
3814 | 3144 | ||
3815 | var computedStyle = elem.ownerDocument.defaultView.getComputedStyle( elem, null ); |
3145 | // Make sure that link elements get serialized correctly by innerHTML
|
- | 3146 | // This requires a wrapper element in IE
|
|
- | 3147 | htmlSerialize: !!div.getElementsByTagName("link").length, |
|
3816 | 3148 | ||
- | 3149 | // Get the style information from getAttribute
|
|
3817 | if ( computedStyle ) { |
3150 | // (IE uses .cssText insted)
|
3818 | ret = computedStyle.getPropertyValue( name ); |
3151 | style: /red/.test( a.getAttribute("style") ), |
3819 | }
|
- | |
3820 | 3152 | ||
3821 | // We should always get a number back from opacity
|
3153 | // Make sure that URLs aren't manipulated
|
3822 | if ( name === "opacity" && ret === "" ) { |
3154 | // (IE normalizes it by default)
|
3823 | ret = "1"; |
3155 | hrefNormalized: a.getAttribute("href") === "/a", |
3824 | }
|
- | |
3825 | 3156 | ||
3826 | } else if ( elem.currentStyle ) { |
3157 | // Make sure that element opacity exists
|
- | 3158 | // (IE uses filter instead)
|
|
3827 | var camelCase = name.replace(rdashAlpha, fcamelCase); |
3159 | opacity: a.style.opacity === "0.5", |
3828 | 3160 | ||
- | 3161 | // Verify style float existence
|
|
3829 | ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; |
3162 | // (IE uses styleFloat instead of cssFloat)
|
- | 3163 | cssFloat: !!a.style.cssFloat, |
|
3830 | 3164 | ||
3831 | // From the awesome hack by Dean Edwards
|
3165 | // Will be defined later
|
- | 3166 | scriptEval: false, |
|
3832 | // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
3167 | noCloneEvent: true, |
- | 3168 | boxModel: null |
|
- | 3169 | }; |
|
3833 | 3170 | ||
3834 | // If we're not dealing with a regular pixel number
|
3171 | script.type = "text/javascript"; |
- | 3172 | try { |
|
3835 | // but a number that has a weird ending, we need to convert it to pixels
|
3173 | script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
3836 | if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { |
- | |
3837 | // Remember the original values
|
3174 | } catch(e){} |
3838 | var left = style.left, rsLeft = elem.runtimeStyle.left; |
- | |
3839 | 3175 | ||
3840 | // Put in the new values to get a computed value out
|
- | |
3841 | elem.runtimeStyle.left = elem.currentStyle.left; |
3176 | root.insertBefore( script, root.firstChild ); |
3842 | style.left = ret || 0; |
- | |
3843 | ret = style.pixelLeft + "px"; |
- | |
3844 | 3177 | ||
- | 3178 | // Make sure that the execution of code works by injecting a script
|
|
3845 | // Revert the changed values
|
3179 | // tag with appendChild/createTextNode
|
- | 3180 | // (IE doesn't support this, fails, and uses .text instead)
|
|
3846 | style.left = left; |
3181 | if ( window[ id ] ) { |
3847 | elem.runtimeStyle.left = rsLeft; |
3182 | jQuery.support.scriptEval = true; |
3848 | }
|
3183 | delete window[ id ]; |
3849 | }
|
3184 | }
|
3850 | 3185 | ||
3851 | return ret; |
- | |
3852 | }, |
- | |
3853 | - | ||
3854 | // A method for quickly swapping in/out CSS properties to get correct calculations
|
- | |
3855 | swap: function( elem, options, callback ) { |
- | |
3856 | var old = {}; |
3186 | root.removeChild( script ); |
3857 | 3187 | ||
- | 3188 | if ( div.attachEvent && div.fireEvent ) { |
|
- | 3189 | div.attachEvent("onclick", function(){ |
|
3858 | // Remember the old values, and insert the new ones
|
3190 | // Cloning a node shouldn't copy over any
|
3859 | for ( var name in options ) { |
3191 | // bound event handlers (IE does this)
|
3860 | old[ name ] = elem.style[ name ]; |
3192 | jQuery.support.noCloneEvent = false; |
3861 | elem.style[ name ] = options[ name ]; |
3193 | div.detachEvent("onclick", arguments.callee); |
- | 3194 | }); |
|
- | 3195 | div.cloneNode(true).fireEvent("onclick"); |
|
3862 | }
|
3196 | }
|
3863 | 3197 | ||
- | 3198 | // Figure out if the W3C box model works as expected
|
|
- | 3199 | // document.body must exist before we can do this
|
|
- | 3200 | jQuery(function(){ |
|
3864 | callback.call( elem ); |
3201 | var div = document.createElement("div"); |
- | 3202 | div.style.width = div.style.paddingLeft = "1px"; |
|
3865 | 3203 | ||
3866 | // Revert the old values
|
3204 | document.body.appendChild( div ); |
3867 | for ( var name in options ) { |
3205 | jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
3868 | elem.style[ name ] = old[ name ]; |
3206 | document.body.removeChild( div ).style.display = 'none'; |
3869 | }
|
- | |
3870 | }
|
- | |
3871 | }); |
3207 | }); |
3872 | var jsc = now(), |
3208 | })(); |
3873 | rscript = /<script(.|\s)*?\/script>/g, |
- | |
- | 3209 | ||
3874 | rselectTextarea = /select|textarea/i, |
3210 | var styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat"; |
3875 | rinput = /text|hidden|password|search/i, |
- | |
3876 | jsre = /=\?(&|$)/, |
- | |
3877 | rquery = /\?/, |
- | |
3878 | rts = /(\?|&)_=.*?(&|$)/, |
- | |
3879 | rurl = /^(\w+:)?\/\/([^\/?#]+)/, |
- | |
3880 | r20 = /%20/g; |
- | |
3881 | 3211 | ||
- | 3212 | jQuery.props = { |
|
- | 3213 | "for": "htmlFor", |
|
- | 3214 | "class": "className", |
|
- | 3215 | "float": styleFloat, |
|
- | 3216 | cssFloat: styleFloat, |
|
- | 3217 | styleFloat: styleFloat, |
|
- | 3218 | readonly: "readOnly", |
|
- | 3219 | maxlength: "maxLength", |
|
- | 3220 | cellspacing: "cellSpacing", |
|
- | 3221 | rowspan: "rowSpan", |
|
- | 3222 | tabindex: "tabIndex" |
|
- | 3223 | }; |
|
3882 | jQuery.fn.extend({ |
3224 | jQuery.fn.extend({ |
3883 | // Keep a copy of the old load
|
3225 | // Keep a copy of the old load
|
3884 | _load: jQuery.fn.load, |
3226 | _load: jQuery.fn.load, |
3885 | 3227 | ||
3886 | load: function( url, params, callback ) { |
3228 | load: function( url, params, callback ) { |
3887 | if ( typeof url !== "string" ) { |
3229 | if ( typeof url !== "string" ) |
3888 | return this._load( url ); |
3230 | return this._load( url ); |
3889 | }
|
- | |
3890 | 3231 | ||
3891 | var off = url.indexOf(" "); |
3232 | var off = url.indexOf(" "); |
3892 | if ( off >= 0 ) { |
3233 | if ( off >= 0 ) { |
3893 | var selector = url.slice(off, url.length); |
3234 | var selector = url.slice(off, url.length); |
3894 | url = url.slice(0, off); |
3235 | url = url.slice(0, off); |
Строка 3896... | Строка 3237... | ||
3896 | 3237 | ||
3897 | // Default to a GET request
|
3238 | // Default to a GET request
|
3898 | var type = "GET"; |
3239 | var type = "GET"; |
3899 | 3240 | ||
3900 | // If the second parameter was provided
|
3241 | // If the second parameter was provided
|
3901 | if ( params ) { |
3242 | if ( params ) |
3902 | // If it's a function
|
3243 | // If it's a function
|
3903 | if ( jQuery.isFunction( params ) ) { |
3244 | if ( jQuery.isFunction( params ) ) { |
3904 | // We assume that it's the callback
|
3245 | // We assume that it's the callback
|
3905 | callback = params; |
3246 | callback = params; |
3906 | params = null; |
3247 | params = null; |
Строка 3908... | Строка 3249... | ||
3908 | // Otherwise, build a param string
|
3249 | // Otherwise, build a param string
|
3909 | } else if ( typeof params === "object" ) { |
3250 | } else if( typeof params === "object" ) { |
3910 | params = jQuery.param( params ); |
3251 | params = jQuery.param( params ); |
3911 | type = "POST"; |
3252 | type = "POST"; |
3912 | }
|
3253 | }
|
3913 | }
|
3254 | |
- | 3255 | var self = this; |
|
3914 | 3256 | ||
3915 | // Request the remote document
|
3257 | // Request the remote document
|
3916 | jQuery.ajax({ |
3258 | jQuery.ajax({ |
3917 | url: url, |
3259 | url: url, |
3918 | type: type, |
3260 | type: type, |
3919 | dataType: "html", |
3261 | dataType: "html", |
3920 | data: params, |
3262 | data: params, |
3921 | context:this, |
- | |
3922 | complete: function(res, status){ |
3263 | complete: function(res, status){ |
3923 | // If successful, inject the HTML into all the matched elements
|
3264 | // If successful, inject the HTML into all the matched elements
|
3924 | if ( status === "success" || status === "notmodified" ) { |
3265 | if ( status == "success" || status == "notmodified" ) |
3925 | // See if a selector was specified
|
3266 | // See if a selector was specified
|
3926 | this.html( selector ? |
3267 | self.html( selector ? |
3927 | // Create a dummy div to hold the results
|
3268 | // Create a dummy div to hold the results
|
3928 | jQuery("<div />") |
3269 | jQuery("<div/>") |
3929 | // inject the contents of the document in, removing the scripts
|
3270 | // inject the contents of the document in, removing the scripts
|
3930 | // to avoid any 'Permission Denied' errors in IE
|
3271 | // to avoid any 'Permission Denied' errors in IE
|
3931 | .append(res.responseText.replace(rscript, "")) |
3272 | .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, "")) |
3932 | 3273 | ||
3933 | // Locate the specified elements
|
3274 | // Locate the specified elements
|
3934 | .find(selector) : |
3275 | .find(selector) : |
3935 | 3276 | ||
3936 | // If not, just inject the full result
|
3277 | // If not, just inject the full result
|
3937 | res.responseText ); |
3278 | res.responseText ); |
3938 | }
|
- | |
3939 | 3279 | ||
3940 | if ( callback ) { |
3280 | if( callback ) |
3941 | this.each( callback, [res.responseText, status, res] ); |
3281 | self.each( callback, [res.responseText, status, res] ); |
3942 | }
|
- | |
3943 | }
|
3282 | }
|
3944 | }); |
3283 | }); |
3945 | - | ||
3946 | return this; |
3284 | return this; |
3947 | }, |
3285 | }, |
3948 | 3286 | ||
3949 | serialize: function() { |
3287 | serialize: function() { |
3950 | return jQuery.param(this.serializeArray()); |
3288 | return jQuery.param(this.serializeArray()); |
Строка 3953... | Строка 3291... | ||
3953 | return this.map(function(){ |
3291 | return this.map(function(){ |
3954 | return this.elements ? jQuery.makeArray(this.elements) : this; |
3292 | return this.elements ? jQuery.makeArray(this.elements) : this; |
3955 | }) |
3293 | }) |
3956 | .filter(function(){ |
3294 | .filter(function(){ |
3957 | return this.name && !this.disabled && |
3295 | return this.name && !this.disabled && |
3958 | (this.checked || rselectTextarea.test(this.nodeName) || |
3296 | (this.checked || /select|textarea/i.test(this.nodeName) || |
3959 | rinput.test(this.type)); |
3297 | /text|hidden|password|search/i.test(this.type)); |
3960 | }) |
3298 | }) |
3961 | .map(function(i, elem){ |
3299 | .map(function(i, elem){ |
3962 | var val = jQuery(this).val(); |
3300 | var val = jQuery(this).val(); |
3963 | - | ||
3964 | return val == null ? |
3301 | return val == null ? null : |
3965 | null : |
- | |
3966 | jQuery.isArray(val) ? |
3302 | jQuery.isArray(val) ? |
3967 | jQuery.map( val, function(val, i){ |
3303 | jQuery.map( val, function(val, i){ |
3968 | return {name: elem.name, value: val}; |
3304 | return {name: elem.name, value: val}; |
3969 | }) : |
3305 | }) : |
3970 | {name: elem.name, value: val}; |
3306 | {name: elem.name, value: val}; |
Строка 3977... | Строка 3313... | ||
3977 | jQuery.fn[o] = function(f){ |
3313 | jQuery.fn[o] = function(f){ |
3978 | return this.bind(o, f); |
3314 | return this.bind(o, f); |
3979 | }; |
3315 | }; |
3980 | }); |
3316 | }); |
3981 | 3317 | ||
- | 3318 | var jsc = now(); |
|
- | 3319 | ||
3982 | jQuery.extend({ |
3320 | jQuery.extend({ |
3983 | 3321 | ||
3984 | get: function( url, data, callback, type ) { |
3322 | get: function( url, data, callback, type ) { |
3985 | // shift arguments if data argument was omited
|
3323 | // shift arguments if data argument was ommited
|
3986 | if ( jQuery.isFunction( data ) ) { |
3324 | if ( jQuery.isFunction( data ) ) { |
3987 | type = type || callback; |
- | |
3988 | callback = data; |
3325 | callback = data; |
3989 | data = null; |
3326 | data = null; |
3990 | }
|
3327 | }
|
3991 | 3328 | ||
3992 | return jQuery.ajax({ |
3329 | return jQuery.ajax({ |
Строка 4005... | Строка 3342... | ||
4005 | getJSON: function( url, data, callback ) { |
3342 | getJSON: function( url, data, callback ) { |
4006 | return jQuery.get(url, data, callback, "json"); |
3343 | return jQuery.get(url, data, callback, "json"); |
4007 | }, |
3344 | }, |
4008 | 3345 | ||
4009 | post: function( url, data, callback, type ) { |
3346 | post: function( url, data, callback, type ) { |
4010 | // shift arguments if data argument was omited
|
- | |
4011 | if ( jQuery.isFunction( data ) ) { |
3347 | if ( jQuery.isFunction( data ) ) { |
4012 | type = type || callback; |
- | |
4013 | callback = data; |
3348 | callback = data; |
4014 | data = {}; |
3349 | data = {}; |
4015 | }
|
3350 | }
|
4016 | 3351 | ||
4017 | return jQuery.ajax({ |
3352 | return jQuery.ajax({ |
Строка 4042... | Строка 3377... | ||
4042 | */
|
3377 | */
|
4043 | // Create the request object; Microsoft failed to properly
|
3378 | // Create the request object; Microsoft failed to properly
|
4044 | // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
|
3379 | // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
|
4045 | // This function can be overriden by calling jQuery.ajaxSetup
|
3380 | // This function can be overriden by calling jQuery.ajaxSetup
|
4046 | xhr: function(){ |
3381 | xhr:function(){ |
4047 | return window.ActiveXObject ? |
- | |
4048 | new ActiveXObject("Microsoft.XMLHTTP") : |
3382 | return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); |
4049 | new XMLHttpRequest(); |
- | |
4050 | }, |
3383 | }, |
4051 | accepts: { |
3384 | accepts: { |
4052 | xml: "application/xml, text/xml", |
3385 | xml: "application/xml, text/xml", |
4053 | html: "text/html", |
3386 | html: "text/html", |
4054 | script: "text/javascript, application/javascript", |
3387 | script: "text/javascript, application/javascript", |
Строка 4058... | Строка 3391... | ||
4058 | }
|
3391 | }
|
4059 | }, |
3392 | }, |
4060 | 3393 | ||
4061 | // Last-Modified header cache for next request
|
3394 | // Last-Modified header cache for next request
|
4062 | lastModified: {}, |
3395 | lastModified: {}, |
4063 | etag: {}, |
- | |
4064 | 3396 | ||
4065 | ajax: function( s ) { |
3397 | ajax: function( s ) { |
4066 | // Extend the settings, but re-extend 's' so that it can be
|
3398 | // Extend the settings, but re-extend 's' so that it can be
|
4067 | // checked again later (in the test suite, specifically)
|
3399 | // checked again later (in the test suite, specifically)
|
4068 | s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); |
3400 | s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); |
4069 | 3401 | ||
4070 | var jsonp, status, data, |
3402 | var jsonp, jsre = /=\?(&|$)/g, status, data, |
4071 | callbackContext = s.context || window, |
- | |
4072 | type = s.type.toUpperCase(); |
3403 | type = s.type.toUpperCase(); |
4073 | 3404 | ||
4074 | // convert data if not already a string
|
3405 | // convert data if not already a string
|
4075 | if ( s.data && s.processData && typeof s.data !== "string" ) { |
3406 | if ( s.data && s.processData && typeof s.data !== "string" ) |
4076 | s.data = jQuery.param(s.data); |
3407 | s.data = jQuery.param(s.data); |
4077 | }
|
- | |
4078 | 3408 | ||
4079 | // Handle JSONP Parameter Callbacks
|
3409 | // Handle JSONP Parameter Callbacks
|
4080 | if ( s.dataType === "jsonp" ) { |
3410 | if ( s.dataType == "jsonp" ) { |
4081 | if ( type === "GET" ) { |
3411 | if ( type == "GET" ) { |
4082 | if ( !jsre.test( s.url ) ) { |
3412 | if ( !s.url.match(jsre) ) |
4083 | s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
3413 | s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
4084 | }
|
- | |
4085 | } else if ( !s.data || !jsre.test(s.data) ) { |
3414 | } else if ( !s.data || !s.data.match(jsre) ) |
4086 | s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
3415 | s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
4087 | }
|
- | |
4088 | s.dataType = "json"; |
3416 | s.dataType = "json"; |
4089 | }
|
3417 | }
|
4090 | 3418 | ||
4091 | // Build temporary JSONP function
|
3419 | // Build temporary JSONP function
|
4092 | if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) { |
3420 | if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) { |
4093 | jsonp = "jsonp" + jsc++; |
3421 | jsonp = "jsonp" + jsc++; |
4094 | 3422 | ||
4095 | // Replace the =? sequence both in the query string and the data
|
3423 | // Replace the =? sequence both in the query string and the data
|
4096 | if ( s.data ) { |
3424 | if ( s.data ) |
4097 | s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
3425 | s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
4098 | }
|
- | |
4099 | - | ||
4100 | s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
3426 | s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
4101 | 3427 | ||
4102 | // We need to make sure
|
3428 | // We need to make sure
|
4103 | // that a JSONP style response is executed properly
|
3429 | // that a JSONP style response is executed properly
|
4104 | s.dataType = "script"; |
3430 | s.dataType = "script"; |
Строка 4109... | Строка 3435... | ||
4109 | success(); |
3435 | success(); |
4110 | complete(); |
3436 | complete(); |
4111 | // Garbage collect
|
3437 | // Garbage collect
|
4112 | window[ jsonp ] = undefined; |
3438 | window[ jsonp ] = undefined; |
4113 | try{ delete window[ jsonp ]; } catch(e){} |
3439 | try{ delete window[ jsonp ]; } catch(e){} |
4114 | if ( head ) { |
3440 | if ( head ) |
4115 | head.removeChild( script ); |
3441 | head.removeChild( script ); |
4116 | }
|
- | |
4117 | }; |
3442 | }; |
4118 | }
|
3443 | }
|
4119 | 3444 | ||
4120 | if ( s.dataType === "script" && s.cache === null ) { |
3445 | if ( s.dataType == "script" && s.cache == null ) |
4121 | s.cache = false; |
3446 | s.cache = false; |
4122 | }
|
- | |
4123 | 3447 | ||
4124 | if ( s.cache === false && type === "GET" ) { |
3448 | if ( s.cache === false && type == "GET" ) { |
4125 | var ts = now(); |
3449 | var ts = now(); |
4126 | - | ||
4127 | // try replacing _= if it is there
|
3450 | // try replacing _= if it is there
|
4128 | var ret = s.url.replace(rts, "$1_=" + ts + "$2"); |
3451 | var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2"); |
4129 | - | ||
4130 | // if nothing was replaced, add timestamp to the end
|
3452 | // if nothing was replaced, add timestamp to the end
|
4131 | s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : ""); |
3453 | s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : ""); |
4132 | }
|
3454 | }
|
4133 | 3455 | ||
4134 | // If data is available, append data to url for get requests
|
3456 | // If data is available, append data to url for get requests
|
4135 | if ( s.data && type === "GET" ) { |
3457 | if ( s.data && type == "GET" ) { |
4136 | s.url += (rquery.test(s.url) ? "&" : "?") + s.data; |
3458 | s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; |
- | 3459 | ||
- | 3460 | // IE likes to send both get and post data, prevent this
|
|
- | 3461 | s.data = null; |
|
4137 | }
|
3462 | }
|
4138 | 3463 | ||
4139 | // Watch for a new set of requests
|
3464 | // Watch for a new set of requests
|
4140 | if ( s.global && ! jQuery.active++ ) { |
3465 | if ( s.global && ! jQuery.active++ ) |
4141 | jQuery.event.trigger( "ajaxStart" ); |
3466 | jQuery.event.trigger( "ajaxStart" ); |
4142 | }
|
- | |
4143 | 3467 | ||
4144 | // Matches an absolute URL, and saves the domain
|
3468 | // Matches an absolute URL, and saves the domain
|
4145 | var parts = rurl.exec( s.url ); |
3469 | var parts = /^(\w+:)?\/\/([^\/?#]+)/.exec( s.url ); |
4146 | 3470 | ||
4147 | // If we're requesting a remote document
|
3471 | // If we're requesting a remote document
|
4148 | // and trying to load JSON or Script with a GET
|
3472 | // and trying to load JSON or Script with a GET
|
4149 | if ( s.dataType === "script" && type === "GET" && parts |
3473 | if ( s.dataType == "script" && type == "GET" && parts |
4150 | && ( parts[1] && parts[1] !== location.protocol || parts[2] !== location.host )) { |
3474 | && ( parts[1] && parts[1] != location.protocol || parts[2] != location.host )){ |
4151 | 3475 | ||
4152 | var head = document.getElementsByTagName("head")[0] || document.documentElement; |
3476 | var head = document.getElementsByTagName("head")[0]; |
4153 | var script = document.createElement("script"); |
3477 | var script = document.createElement("script"); |
4154 | script.src = s.url; |
3478 | script.src = s.url; |
4155 | if ( s.scriptCharset ) { |
3479 | if (s.scriptCharset) |
4156 | script.charset = s.scriptCharset; |
3480 | script.charset = s.scriptCharset; |
4157 | }
|
- | |
4158 | 3481 | ||
4159 | // Handle Script loading
|
3482 | // Handle Script loading
|
4160 | if ( !jsonp ) { |
3483 | if ( !jsonp ) { |
4161 | var done = false; |
3484 | var done = false; |
4162 | 3485 | ||
4163 | // Attach handlers for all browsers
|
3486 | // Attach handlers for all browsers
|
4164 | script.onload = script.onreadystatechange = function(){ |
3487 | script.onload = script.onreadystatechange = function(){ |
4165 | if ( !done && (!this.readyState || |
3488 | if ( !done && (!this.readyState || |
4166 | this.readyState === "loaded" || this.readyState === "complete") ) { |
3489 | this.readyState == "loaded" || this.readyState == "complete") ) { |
4167 | done = true; |
3490 | done = true; |
4168 | success(); |
3491 | success(); |
4169 | complete(); |
3492 | complete(); |
4170 | 3493 | ||
4171 | // Handle memory leak in IE
|
3494 | // Handle memory leak in IE
|
4172 | script.onload = script.onreadystatechange = null; |
3495 | script.onload = script.onreadystatechange = null; |
4173 | if ( head && script.parentNode ) { |
- | |
4174 | head.removeChild( script ); |
3496 | head.removeChild( script ); |
4175 | }
|
3497 | }
|
4176 | }
|
- | |
4177 | }; |
3498 | }; |
4178 | }
|
3499 | }
|
4179 | 3500 | ||
4180 | // Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
- | |
4181 | // This arises when a base node is used (#2709 and #4378).
|
- | |
4182 | head.insertBefore( script, head.firstChild ); |
3501 | head.appendChild(script); |
4183 | 3502 | ||
4184 | // We handle everything using the script element injection
|
3503 | // We handle everything using the script element injection
|
4185 | return undefined; |
3504 | return undefined; |
4186 | }
|
3505 | }
|
4187 | 3506 | ||
Строка 4190... | Строка 3509... | ||
4190 | // Create the request object
|
3509 | // Create the request object
|
4191 | var xhr = s.xhr(); |
3510 | var xhr = s.xhr(); |
4192 | 3511 | ||
4193 | // Open the socket
|
3512 | // Open the socket
|
4194 | // Passing null username, generates a login popup on Opera (#2865)
|
3513 | // Passing null username, generates a login popup on Opera (#2865)
|
4195 | if ( s.username ) { |
3514 | if( s.username ) |
4196 | xhr.open(type, s.url, s.async, s.username, s.password); |
3515 | xhr.open(type, s.url, s.async, s.username, s.password); |
4197 | } else { |
3516 | else
|
4198 | xhr.open(type, s.url, s.async); |
3517 | xhr.open(type, s.url, s.async); |
4199 | }
|
- | |
4200 | 3518 | ||
4201 | // Need an extra try/catch for cross domain requests in Firefox 3
|
3519 | // Need an extra try/catch for cross domain requests in Firefox 3
|
4202 | try { |
3520 | try { |
4203 | // Set the correct header, if data is being sent
|
3521 | // Set the correct header, if data is being sent
|
4204 | if ( s.data ) { |
3522 | if ( s.data ) |
4205 | xhr.setRequestHeader("Content-Type", s.contentType); |
3523 | xhr.setRequestHeader("Content-Type", s.contentType); |
4206 | }
|
- | |
4207 | - | ||
4208 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
- | |
4209 | if ( s.ifModified ) { |
- | |
4210 | if ( jQuery.lastModified[s.url] ) { |
- | |
4211 | xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]); |
- | |
4212 | }
|
- | |
4213 | 3524 | ||
- | 3525 | // Set the If-Modified-Since header, if ifModified mode.
|
|
4214 | if ( jQuery.etag[s.url] ) { |
3526 | if ( s.ifModified ) |
4215 | xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]); |
3527 | xhr.setRequestHeader("If-Modified-Since", |
4216 | }
|
- | |
4217 | }
|
- | |
- | 3528 | jQuery.lastModified[s.url] || "Thu, 01 Jan 1970 00:00:00 GMT" ); |
|
4218 | 3529 | ||
4219 | // Set header so the called script knows that it's an XMLHttpRequest
|
3530 | // Set header so the called script knows that it's an XMLHttpRequest
|
4220 | xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
3531 | xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
4221 | 3532 | ||
4222 | // Set the Accepts header for the server, depending on the dataType
|
3533 | // Set the Accepts header for the server, depending on the dataType
|
Строка 4224... | Строка 3535... | ||
4224 | s.accepts[ s.dataType ] + ", */*" : |
3535 | s.accepts[ s.dataType ] + ", */*" : |
4225 | s.accepts._default ); |
3536 | s.accepts._default ); |
4226 | } catch(e){} |
3537 | } catch(e){} |
4227 | 3538 | ||
4228 | // Allow custom headers/mimetypes and early abort
|
3539 | // Allow custom headers/mimetypes and early abort
|
4229 | if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) { |
3540 | if ( s.beforeSend && s.beforeSend(xhr, s) === false ) { |
4230 | // Handle the global AJAX counter
|
3541 | // Handle the global AJAX counter
|
4231 | if ( s.global && ! --jQuery.active ) { |
3542 | if ( s.global && ! --jQuery.active ) |
4232 | jQuery.event.trigger( "ajaxStop" ); |
3543 | jQuery.event.trigger( "ajaxStop" ); |
4233 | }
|
- | |
4234 | - | ||
4235 | // close opended socket
|
3544 | // close opended socket
|
4236 | xhr.abort(); |
3545 | xhr.abort(); |
4237 | return false; |
3546 | return false; |
4238 | }
|
3547 | }
|
4239 | 3548 | ||
4240 | if ( s.global ) { |
3549 | if ( s.global ) |
4241 | trigger("ajaxSend", [xhr, s]); |
3550 | jQuery.event.trigger("ajaxSend", [xhr, s]); |
4242 | }
|
- | |
4243 | 3551 | ||
4244 | // Wait for a response to come back
|
3552 | // Wait for a response to come back
|
4245 | var onreadystatechange = function(isTimeout){ |
3553 | var onreadystatechange = function(isTimeout){ |
4246 | // The request was aborted, clear the interval and decrement jQuery.active
|
3554 | // The request was aborted, clear the interval and decrement jQuery.active
|
4247 | if ( !xhr || xhr.readyState === 0 ) { |
3555 | if (xhr.readyState == 0) { |
4248 | if ( ival ) { |
3556 | if (ival) { |
4249 | // clear poll interval
|
3557 | // clear poll interval
|
4250 | clearInterval( ival ); |
3558 | clearInterval(ival); |
4251 | ival = null; |
3559 | ival = null; |
4252 | - | ||
4253 | // Handle the global AJAX counter
|
3560 | // Handle the global AJAX counter
|
4254 | if ( s.global && ! --jQuery.active ) { |
3561 | if ( s.global && ! --jQuery.active ) |
4255 | jQuery.event.trigger( "ajaxStop" ); |
3562 | jQuery.event.trigger( "ajaxStop" ); |
4256 | }
|
3563 | }
|
4257 | }
|
- | |
4258 | - | ||
4259 | // The transfer is complete and the data is available, or the request timed out
|
3564 | // The transfer is complete and the data is available, or the request timed out
|
4260 | } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) { |
3565 | } else if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) { |
4261 | requestDone = true; |
3566 | requestDone = true; |
4262 | 3567 | ||
4263 | // clear poll interval
|
3568 | // clear poll interval
|
4264 | if (ival) { |
3569 | if (ival) { |
4265 | clearInterval(ival); |
3570 | clearInterval(ival); |
4266 | ival = null; |
3571 | ival = null; |
4267 | }
|
3572 | }
|
4268 | 3573 | ||
4269 | status = isTimeout === "timeout" ? |
3574 | status = isTimeout == "timeout" ? "timeout" : |
4270 | "timeout" : |
- | |
4271 | !jQuery.httpSuccess( xhr ) ? |
3575 | !jQuery.httpSuccess( xhr ) ? "error" : |
4272 | "error" : |
- | |
4273 | s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? |
3576 | s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? "notmodified" : |
4274 | "notmodified" : |
- | |
4275 | "success"; |
3577 | "success"; |
4276 | 3578 | ||
4277 | if ( status === "success" ) { |
3579 | if ( status == "success" ) { |
4278 | // Watch for, and catch, XML document parse errors
|
3580 | // Watch for, and catch, XML document parse errors
|
4279 | try { |
3581 | try { |
4280 | // process the data (runs the xml through httpData regardless of callback)
|
3582 | // process the data (runs the xml through httpData regardless of callback)
|
4281 | data = jQuery.httpData( xhr, s.dataType, s ); |
3583 | data = jQuery.httpData( xhr, s.dataType, s ); |
4282 | } catch(e) { |
3584 | } catch(e) { |
4283 | status = "parsererror"; |
3585 | status = "parsererror"; |
4284 | }
|
3586 | }
|
4285 | }
|
3587 | }
|
4286 | 3588 | ||
4287 | // Make sure that the request was successful or notmodified
|
3589 | // Make sure that the request was successful or notmodified
|
4288 | if ( status === "success" || status === "notmodified" ) { |
3590 | if ( status == "success" ) { |
- | 3591 | // Cache Last-Modified header, if ifModified mode.
|
|
- | 3592 | var modRes; |
|
- | 3593 | try { |
|
- | 3594 | modRes = xhr.getResponseHeader("Last-Modified"); |
|
- | 3595 | } catch(e) {} // swallow exception thrown by FF if header is not available |
|
- | 3596 | ||
- | 3597 | if ( s.ifModified && modRes ) |
|
- | 3598 | jQuery.lastModified[s.url] = modRes; |
|
- | 3599 | ||
4289 | // JSONP handles its own success callback
|
3600 | // JSONP handles its own success callback
|
4290 | if ( !jsonp ) { |
3601 | if ( !jsonp ) |
4291 | success(); |
3602 | success(); |
4292 | }
|
- | |
4293 | } else { |
3603 | } else |
4294 | jQuery.handleError(s, xhr, status); |
3604 | jQuery.handleError(s, xhr, status); |
4295 | }
|
- | |
4296 | 3605 | ||
4297 | // Fire the complete handlers
|
3606 | // Fire the complete handlers
|
4298 | complete(); |
3607 | complete(); |
4299 | 3608 | ||
4300 | if ( isTimeout ) { |
3609 | if ( isTimeout ) |
4301 | xhr.abort(); |
3610 | xhr.abort(); |
4302 | }
|
- | |
4303 | 3611 | ||
4304 | // Stop memory leaks
|
3612 | // Stop memory leaks
|
4305 | if ( s.async ) { |
3613 | if ( s.async ) |
4306 | xhr = null; |
3614 | xhr = null; |
4307 | }
|
3615 | }
|
4308 | }
|
- | |
4309 | }; |
3616 | }; |
4310 | 3617 | ||
4311 | if ( s.async ) { |
3618 | if ( s.async ) { |
4312 | // don't attach the handler to the request, just poll it instead
|
3619 | // don't attach the handler to the request, just poll it instead
|
4313 | var ival = setInterval(onreadystatechange, 13); |
3620 | var ival = setInterval(onreadystatechange, 13); |
4314 | 3621 | ||
4315 | // Timeout checker
|
3622 | // Timeout checker
|
4316 | if ( s.timeout > 0 ) { |
3623 | if ( s.timeout > 0 ) |
4317 | setTimeout(function(){ |
3624 | setTimeout(function(){ |
4318 | // Check to see if the request is still happening
|
3625 | // Check to see if the request is still happening
|
4319 | if ( xhr && !requestDone ) { |
3626 | if ( xhr && !requestDone ) |
4320 | onreadystatechange( "timeout" ); |
3627 | onreadystatechange( "timeout" ); |
4321 | }
|
- | |
4322 | }, s.timeout); |
3628 | }, s.timeout); |
4323 | }
|
3629 | }
|
4324 | }
|
- | |
4325 | 3630 | ||
4326 | // Send the data
|
3631 | // Send the data
|
4327 | try { |
3632 | try { |
4328 | xhr.send( type === "POST" || type === "PUT" ? s.data : null ); |
3633 | xhr.send(s.data); |
4329 | } catch(e) { |
3634 | } catch(e) { |
4330 | jQuery.handleError(s, xhr, null, e); |
3635 | jQuery.handleError(s, xhr, null, e); |
4331 | }
|
3636 | }
|
4332 | 3637 | ||
4333 | // firefox 1.5 doesn't fire statechange for sync requests
|
3638 | // firefox 1.5 doesn't fire statechange for sync requests
|
4334 | if ( !s.async ) { |
3639 | if ( !s.async ) |
4335 | onreadystatechange(); |
3640 | onreadystatechange(); |
4336 | }
|
- | |
4337 | 3641 | ||
4338 | function success(){ |
3642 | function success(){ |
4339 | // If a local callback was specified, fire it and pass it the data
|
3643 | // If a local callback was specified, fire it and pass it the data
|
4340 | if ( s.success ) { |
3644 | if ( s.success ) |
4341 | s.success.call( callbackContext, data, status ); |
3645 | s.success( data, status ); |
4342 | }
|
- | |
4343 | 3646 | ||
4344 | // Fire the global callback
|
3647 | // Fire the global callback
|
4345 | if ( s.global ) { |
3648 | if ( s.global ) |
4346 | trigger( "ajaxSuccess", [xhr, s] ); |
3649 | jQuery.event.trigger( "ajaxSuccess", [xhr, s] ); |
4347 | }
|
- | |
4348 | }
|
3650 | }
|
4349 | 3651 | ||
4350 | function complete(){ |
3652 | function complete(){ |
4351 | // Process result
|
3653 | // Process result
|
4352 | if ( s.complete ) { |
3654 | if ( s.complete ) |
4353 | s.complete.call( callbackContext, xhr, status); |
3655 | s.complete(xhr, status); |
4354 | }
|
- | |
4355 | 3656 | ||
4356 | // The request was completed
|
3657 | // The request was completed
|
4357 | if ( s.global ) { |
3658 | if ( s.global ) |
4358 | trigger( "ajaxComplete", [xhr, s] ); |
3659 | jQuery.event.trigger( "ajaxComplete", [xhr, s] ); |
4359 | }
|
- | |
4360 | 3660 | ||
4361 | // Handle the global AJAX counter
|
3661 | // Handle the global AJAX counter
|
4362 | if ( s.global && ! --jQuery.active ) { |
3662 | if ( s.global && ! --jQuery.active ) |
4363 | jQuery.event.trigger( "ajaxStop" ); |
3663 | jQuery.event.trigger( "ajaxStop" ); |
4364 | }
|
3664 | }
|
4365 | }
|
- | |
4366 | - | ||
4367 | function trigger(type, args){ |
- | |
4368 | (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args); |
- | |
4369 | }
|
- | |
4370 | 3665 | ||
4371 | // return XMLHttpRequest to allow aborting the request etc.
|
3666 | // return XMLHttpRequest to allow aborting the request etc.
|
4372 | return xhr; |
3667 | return xhr; |
4373 | }, |
3668 | }, |
4374 | 3669 | ||
4375 | handleError: function( s, xhr, status, e ) { |
3670 | handleError: function( s, xhr, status, e ) { |
4376 | // If a local callback was specified, fire it
|
3671 | // If a local callback was specified, fire it
|
4377 | if ( s.error ) { |
- | |
4378 | s.error.call( s.context || window, xhr, status, e ); |
3672 | if ( s.error ) s.error( xhr, status, e ); |
4379 | }
|
- | |
4380 | 3673 | ||
4381 | // Fire the global callback
|
3674 | // Fire the global callback
|
4382 | if ( s.global ) { |
3675 | if ( s.global ) |
4383 | (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] ); |
3676 | jQuery.event.trigger( "ajaxError", [xhr, s, e] ); |
4384 | }
|
- | |
4385 | }, |
3677 | }, |
4386 | 3678 | ||
4387 | // Counter for holding the number of active queries
|
3679 | // Counter for holding the number of active queries
|
4388 | active: 0, |
3680 | active: 0, |
4389 | 3681 | ||
4390 | // Determines if an XMLHttpRequest was successful or not
|
3682 | // Determines if an XMLHttpRequest was successful or not
|
4391 | httpSuccess: function( xhr ) { |
3683 | httpSuccess: function( xhr ) { |
4392 | try { |
3684 | try { |
4393 | // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
|
3685 | // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
|
4394 | return !xhr.status && location.protocol === "file:" || |
3686 | return !xhr.status && location.protocol == "file:" || |
4395 | // Opera returns 0 when status is 304
|
- | |
4396 | ( xhr.status >= 200 && xhr.status < 300 ) || |
- | |
4397 | xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; |
3687 | ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223; |
4398 | } catch(e){} |
3688 | } catch(e){} |
4399 | - | ||
4400 | return false; |
3689 | return false; |
4401 | }, |
3690 | }, |
4402 | 3691 | ||
4403 | // Determines if an XMLHttpRequest returns NotModified
|
3692 | // Determines if an XMLHttpRequest returns NotModified
|
4404 | httpNotModified: function( xhr, url ) { |
3693 | httpNotModified: function( xhr, url ) { |
4405 | var lastModified = xhr.getResponseHeader("Last-Modified"), |
- | |
4406 | etag = xhr.getResponseHeader("Etag"); |
- | |
4407 | - | ||
4408 | if ( lastModified ) { |
- | |
4409 | jQuery.lastModified[url] = lastModified; |
- | |
4410 | }
|
3694 | try { |
4411 | - | ||
4412 | if ( etag ) { |
- | |
4413 | jQuery.etag[url] = etag; |
3695 | var xhrRes = xhr.getResponseHeader("Last-Modified"); |
4414 | }
|
- | |
4415 | 3696 | ||
4416 | // Opera returns 0 when status is 304
|
3697 | // Firefox always returns 200. check Last-Modified date
|
4417 | return xhr.status === 304 || xhr.status === 0; |
3698 | return xhr.status == 304 || xhrRes == jQuery.lastModified[url]; |
- | 3699 | } catch(e){} |
|
- | 3700 | return false; |
|
4418 | }, |
3701 | }, |
4419 | 3702 | ||
4420 | httpData: function( xhr, type, s ) { |
3703 | httpData: function( xhr, type, s ) { |
4421 | var ct = xhr.getResponseHeader("content-type"), |
3704 | var ct = xhr.getResponseHeader("content-type"), |
4422 | xml = type === "xml" || !type && ct && ct.indexOf("xml") >= 0, |
3705 | xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0, |
4423 | data = xml ? xhr.responseXML : xhr.responseText; |
3706 | data = xml ? xhr.responseXML : xhr.responseText; |
4424 | 3707 | ||
4425 | if ( xml && data.documentElement.nodeName === "parsererror" ) { |
3708 | if ( xml && data.documentElement.tagName == "parsererror" ) |
4426 | throw "parsererror"; |
3709 | throw "parsererror"; |
4427 | }
|
- | |
4428 | 3710 | ||
4429 | // Allow a pre-filtering function to sanitize the response
|
3711 | // Allow a pre-filtering function to sanitize the response
|
4430 | // s is checked to keep backwards compatibility
|
3712 | // s != null is checked to keep backwards compatibility
|
4431 | if ( s && s.dataFilter ) { |
3713 | if( s && s.dataFilter ) |
4432 | data = s.dataFilter( data, type ); |
3714 | data = s.dataFilter( data, type ); |
4433 | }
|
- | |
4434 | 3715 | ||
4435 | // The filter can actually parse the response
|
3716 | // The filter can actually parse the response
|
4436 | if ( typeof data === "string" ) { |
3717 | if( typeof data === "string" ){ |
4437 | 3718 | ||
4438 | // If the type is "script", eval it in global context
|
3719 | // If the type is "script", eval it in global context
|
4439 | if ( type === "script" ) { |
3720 | if ( type == "script" ) |
4440 | jQuery.globalEval( data ); |
3721 | jQuery.globalEval( data ); |
4441 | }
|
- | |
4442 | 3722 | ||
4443 | // Get the JavaScript object, if JSON is used.
|
3723 | // Get the JavaScript object, if JSON is used.
|
4444 | if ( type === "json" ) { |
3724 | if ( type == "json" ) |
4445 | if ( typeof JSON === "object" && JSON.parse ) { |
- | |
4446 | data = JSON.parse( data ); |
- | |
4447 | } else { |
- | |
4448 | data = (new Function("return " + data))(); |
3725 | data = window["eval"]("(" + data + ")"); |
4449 | }
|
- | |
4450 | }
|
- | |
4451 | }
|
3726 | }
|
4452 | 3727 | ||
4453 | return data; |
3728 | return data; |
4454 | }, |
3729 | }, |
4455 | 3730 | ||
4456 | // Serialize an array of form elements or a set of
|
3731 | // Serialize an array of form elements or a set of
|
4457 | // key/values into a query string
|
3732 | // key/values into a query string
|
4458 | param: function( a ) { |
3733 | param: function( a ) { |
4459 | var s = [], |
3734 | var s = [ ]; |
4460 | param_traditional = jQuery.param.traditional; |
- | |
4461 | 3735 | ||
4462 | function add( key, value ){ |
3736 | function add( key, value ){ |
4463 | // If value is a function, invoke it and return its value
|
- | |
4464 | value = jQuery.isFunction(value) ? value() : value; |
- | |
4465 | s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
3737 | s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
4466 | }
|
3738 | }; |
4467 | 3739 | ||
4468 | // If an array was passed in, assume that it is an array
|
3740 | // If an array was passed in, assume that it is an array
|
4469 | // of form elements
|
3741 | // of form elements
|
4470 | if ( jQuery.isArray(a) || a.jquery ) |
3742 | if ( jQuery.isArray(a) || a.jquery ) |
4471 | // Serialize the form elements
|
3743 | // Serialize the form elements
|
4472 | jQuery.each( a, function() { |
3744 | jQuery.each( a, function(){ |
4473 | add( this.name, this.value ); |
3745 | add( this.name, this.value ); |
4474 | }); |
3746 | }); |
4475 | 3747 | ||
- | 3748 | // Otherwise, assume that it's an object of key/value pairs
|
|
4476 | else
|
3749 | else
|
4477 | // Encode parameters from object, recursively. If
|
3750 | // Serialize the key/values
|
4478 | // jQuery.param.traditional is set, encode the "old" way
|
- | |
4479 | // (the way 1.3.2 or older did it)
|
3751 | for ( var j in a ) |
4480 | jQuery.each( a, function buildParams( prefix, obj ) { |
3752 | // If the value is an array then the key names need to be repeated
|
4481 | - | ||
4482 | if ( jQuery.isArray(obj) ) |
3753 | if ( jQuery.isArray(a[j]) ) |
4483 | jQuery.each( obj, function(i,v){ |
3754 | jQuery.each( a[j], function(){ |
4484 | // Due to rails' limited request param syntax, numeric array
|
- | |
4485 | // indices are not supported. To avoid serialization ambiguity
|
- | |
4486 | // issues, serialized arrays can only contain scalar values. php
|
- | |
4487 | // does not have this issue, but we should go with the lowest
|
- | |
4488 | // common denominator
|
- | |
4489 | add( prefix + ( param_traditional ? "" : "[]" ), v ); |
- | |
4490 | }); |
- | |
4491 | - | ||
4492 | else if ( typeof obj == "object" ) |
- | |
4493 | if ( param_traditional ) |
- | |
4494 | add( prefix, obj ); |
3755 | add( j, this ); |
4495 | - | ||
4496 | else
|
- | |
4497 | jQuery.each( obj, function(k,v){ |
- | |
4498 | buildParams( prefix ? prefix + "[" + k + "]" : k, v ); |
- | |
4499 | }); |
3756 | }); |
4500 | - | ||
4501 | else
|
3757 | else
|
4502 | add( prefix, obj ); |
3758 | add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] ); |
4503 | - | ||
4504 | }); |
- | |
4505 | 3759 | ||
4506 | // Return the resulting serialization
|
3760 | // Return the resulting serialization
|
4507 | return s.join("&").replace(r20, "+"); |
3761 | return s.join("&").replace(/%20/g, "+"); |
4508 | }
|
3762 | }
|
4509 | 3763 | ||
4510 | }); |
3764 | }); |
4511 | var elemdisplay = {}, |
3765 | var elemdisplay = {}, |
4512 | timerId,
|
3766 | timerId,
|
Строка 4527... | Строка 3781... | ||
4527 | return obj; |
3781 | return obj; |
4528 | }
|
3782 | }
|
4529 | 3783 | ||
4530 | jQuery.fn.extend({ |
3784 | jQuery.fn.extend({ |
4531 | show: function(speed,callback){ |
3785 | show: function(speed,callback){ |
4532 | if ( speed !== undefined ) { |
3786 | if ( speed ) { |
4533 | return this.animate( genFx("show", 3), speed, callback); |
3787 | return this.animate( genFx("show", 3), speed, callback); |
4534 | } else { |
3788 | } else { |
4535 | for ( var i = 0, l = this.length; i < l; i++ ){ |
3789 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4536 | var old = jQuery.data(this[i], "olddisplay"); |
3790 | var old = jQuery.data(this[i], "olddisplay"); |
4537 | 3791 | ||
4538 | this[i].style.display = old || ""; |
3792 | this[i].style.display = old || ""; |
4539 | 3793 | ||
4540 | if ( jQuery.css(this[i], "display") === "none" ) { |
3794 | if ( jQuery.css(this[i], "display") === "none" ) { |
4541 | var nodeName = this[i].nodeName, display; |
3795 | var tagName = this[i].tagName, display; |
4542 | 3796 | ||
4543 | if ( elemdisplay[ nodeName ] ) { |
3797 | if ( elemdisplay[ tagName ] ) { |
4544 | display = elemdisplay[ nodeName ]; |
3798 | display = elemdisplay[ tagName ]; |
4545 | } else { |
3799 | } else { |
4546 | var elem = jQuery("<" + nodeName + " />").appendTo("body"); |
3800 | var elem = jQuery("<" + tagName + " />").appendTo("body"); |
4547 | 3801 | ||
4548 | display = elem.css("display"); |
3802 | display = elem.css("display"); |
4549 | if ( display === "none" ) |
3803 | if ( display === "none" ) |
4550 | display = "block"; |
3804 | display = "block"; |
4551 | 3805 | ||
4552 | elem.remove(); |
3806 | elem.remove(); |
4553 | 3807 | ||
4554 | elemdisplay[ nodeName ] = display; |
3808 | elemdisplay[ tagName ] = display; |
4555 | }
|
3809 | }
|
4556 | 3810 | ||
4557 | jQuery.data(this[i], "olddisplay", display); |
3811 | jQuery.data(this[i], "olddisplay", display); |
4558 | }
|
3812 | }
|
4559 | }
|
3813 | }
|
Строка 4567... | Строка 3821... | ||
4567 | return this; |
3821 | return this; |
4568 | }
|
3822 | }
|
4569 | }, |
3823 | }, |
4570 | 3824 | ||
4571 | hide: function(speed,callback){ |
3825 | hide: function(speed,callback){ |
4572 | if ( speed !== undefined ) { |
3826 | if ( speed ) { |
4573 | return this.animate( genFx("hide", 3), speed, callback); |
3827 | return this.animate( genFx("hide", 3), speed, callback); |
4574 | } else { |
3828 | } else { |
4575 | for ( var i = 0, l = this.length; i < l; i++ ){ |
3829 | for ( var i = 0, l = this.length; i < l; i++ ){ |
4576 | var old = jQuery.data(this[i], "olddisplay"); |
3830 | var old = jQuery.data(this[i], "olddisplay"); |
4577 | if ( !old && old !== "none" ) |
3831 | if ( !old && old !== "none" ) |
Строка 4603... | Строка 3857... | ||
4603 | }) : |
3857 | }) : |
4604 | this.animate(genFx("toggle", 3), fn, fn2); |
3858 | this.animate(genFx("toggle", 3), fn, fn2); |
4605 | }, |
3859 | }, |
4606 | 3860 | ||
4607 | fadeTo: function(speed,to,callback){ |
3861 | fadeTo: function(speed,to,callback){ |
4608 | return this.filter(":hidden").css('opacity', 0).show().end() |
- | |
4609 | .animate({opacity: to}, speed, callback); |
3862 | return this.animate({opacity: to}, speed, callback); |
4610 | }, |
3863 | }, |
4611 | 3864 | ||
4612 | animate: function( prop, speed, easing, callback ) { |
3865 | animate: function( prop, speed, easing, callback ) { |
4613 | var optall = jQuery.speed(speed, easing, callback); |
3866 | var optall = jQuery.speed(speed, easing, callback); |
4614 | 3867 | ||
Строка 4617... | Строка 3870... | ||
4617 | var opt = jQuery.extend({}, optall), p, |
3870 | var opt = jQuery.extend({}, optall), p, |
4618 | hidden = this.nodeType == 1 && jQuery(this).is(":hidden"), |
3871 | hidden = this.nodeType == 1 && jQuery(this).is(":hidden"), |
4619 | self = this; |
3872 | self = this; |
4620 | 3873 | ||
4621 | for ( p in prop ) { |
3874 | for ( p in prop ) { |
4622 | var name = p.replace(rdashAlpha, fcamelCase); |
- | |
4623 | - | ||
4624 | if ( p !== name ) { |
- | |
4625 | prop[ name ] = prop[ p ]; |
- | |
4626 | delete prop[ p ]; |
- | |
4627 | p = name; |
- | |
4628 | }
|
- | |
4629 | - | ||
4630 | if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) |
3875 | if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) |
4631 | return opt.complete.call(this); |
3876 | return opt.complete.call(this); |
4632 | 3877 | ||
4633 | if ( ( p == "height" || p == "width" ) && this.style ) { |
3878 | if ( ( p == "height" || p == "width" ) && this.style ) { |
4634 | // Store display property
|
3879 | // Store display property
|
Строка 4648... | Строка 3893... | ||
4648 | var e = new jQuery.fx( self, opt, name ); |
3893 | var e = new jQuery.fx( self, opt, name ); |
4649 | 3894 | ||
4650 | if ( /toggle|show|hide/.test(val) ) |
3895 | if ( /toggle|show|hide/.test(val) ) |
4651 | e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
3896 | e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
4652 | else { |
3897 | else { |
4653 | var parts = /^([+-]=)?([\d+-.]+)(.*)$/.exec(val), |
3898 | var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/), |
4654 | start = e.cur(true) || 0; |
3899 | start = e.cur(true) || 0; |
4655 | 3900 | ||
4656 | if ( parts ) { |
3901 | if ( parts ) { |
4657 | var end = parseFloat(parts[2]), |
3902 | var end = parseFloat(parts[2]), |
4658 | unit = parts[3] || "px"; |
3903 | unit = parts[3] || "px"; |
Строка 4802... | Строка 4047... | ||
4802 | return self.step(gotoEnd); |
4047 | return self.step(gotoEnd); |
4803 | }
|
4048 | }
|
4804 | 4049 | ||
4805 | t.elem = this.elem; |
4050 | t.elem = this.elem; |
4806 | 4051 | ||
4807 | if ( t() && jQuery.timers.push(t) && !timerId ) |
4052 | if ( t() && jQuery.timers.push(t) && !timerId ) { |
4808 | timerId = setInterval(jQuery.fx.tick, 13); |
4053 | timerId = setInterval(function(){ |
- | 4054 | var timers = jQuery.timers; |
|
- | 4055 | ||
- | 4056 | for ( var i = 0; i < timers.length; i++ ) |
|
- | 4057 | if ( !timers[i]() ) |
|
- | 4058 | timers.splice(i--, 1); |
|
- | 4059 | ||
- | 4060 | if ( !timers.length ) { |
|
- | 4061 | clearInterval( timerId ); |
|
- | 4062 | timerId = undefined; |
|
- | 4063 | }
|
|
- | 4064 | }, 13); |
|
- | 4065 | }
|
|
4809 | }, |
4066 | }, |
4810 | 4067 | ||
4811 | // Simple 'show' function
|
4068 | // Simple 'show' function
|
4812 | show: function(){ |
4069 | show: function(){ |
4813 | // Remember where we started, so that we can go back to it later
|
4070 | // Remember where we started, so that we can go back to it later
|
4814 | this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); |
4071 | this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); |
4815 | this.options.show = true; |
4072 | this.options.show = true; |
4816 | 4073 | ||
4817 | // Begin the animation
|
4074 | // Begin the animation
|
4818 | // Make sure that we start at a small width/height to avoid any
|
4075 | // Make sure that we start at a small width/height to avoid any
|
4819 | // flash of content
|
4076 | // flash of content
|
Строка 4824... | Строка 4081... | ||
4824 | }, |
4081 | }, |
4825 | 4082 | ||
4826 | // Simple 'hide' function
|
4083 | // Simple 'hide' function
|
4827 | hide: function(){ |
4084 | hide: function(){ |
4828 | // Remember where we started, so that we can go back to it later
|
4085 | // Remember where we started, so that we can go back to it later
|
4829 | this.options.orig[this.prop] = jQuery.style( this.elem, this.prop ); |
4086 | this.options.orig[this.prop] = jQuery.attr( this.elem.style, this.prop ); |
4830 | this.options.hide = true; |
4087 | this.options.hide = true; |
4831 | 4088 | ||
4832 | // Begin the animation
|
4089 | // Begin the animation
|
4833 | this.custom(this.cur(), 0); |
4090 | this.custom(this.cur(), 0); |
4834 | }, |
4091 | }, |
Строка 4865... | Строка 4122... | ||
4865 | jQuery(this.elem).hide(); |
4122 | jQuery(this.elem).hide(); |
4866 | 4123 | ||
4867 | // Reset the properties, if the item has been hidden or shown
|
4124 | // Reset the properties, if the item has been hidden or shown
|
4868 | if ( this.options.hide || this.options.show ) |
4125 | if ( this.options.hide || this.options.show ) |
4869 | for ( var p in this.options.curAnim ) |
4126 | for ( var p in this.options.curAnim ) |
4870 | jQuery.style(this.elem, p, this.options.orig[p]); |
4127 | jQuery.attr(this.elem.style, p, this.options.orig[p]); |
4871 | 4128 | ||
4872 | // Execute the complete function
|
4129 | // Execute the complete function
|
4873 | this.options.complete.call( this.elem ); |
4130 | this.options.complete.call( this.elem ); |
4874 | }
|
4131 | }
|
4875 | 4132 | ||
Строка 4890... | Строка 4147... | ||
4890 | }
|
4147 | }
|
4891 | 4148 | ||
4892 | }; |
4149 | }; |
4893 | 4150 | ||
4894 | jQuery.extend( jQuery.fx, { |
4151 | jQuery.extend( jQuery.fx, { |
4895 | - | ||
4896 | tick:function(){ |
- | |
4897 | var timers = jQuery.timers; |
- | |
4898 | - | ||
4899 | for ( var i = 0; i < timers.length; i++ ) |
- | |
4900 | if ( !timers[i]() ) |
- | |
4901 | timers.splice(i--, 1); |
- | |
4902 | - | ||
4903 | if ( !timers.length ) |
- | |
4904 | jQuery.fx.stop(); |
- | |
4905 | }, |
- | |
4906 | - | ||
4907 | stop:function(){ |
- | |
4908 | clearInterval( timerId ); |
- | |
4909 | timerId = null; |
- | |
4910 | }, |
- | |
4911 | - | ||
4912 | speeds:{ |
4152 | speeds:{ |
4913 | slow: 600, |
4153 | slow: 600, |
4914 | fast: 200, |
4154 | fast: 200, |
4915 | // Default speed
|
4155 | // Default speed
|
4916 | _default: 400 |
4156 | _default: 400 |
4917 | }, |
4157 | }, |
4918 | - | ||
4919 | step: { |
4158 | step: { |
4920 | 4159 | ||
4921 | opacity: function(fx){ |
4160 | opacity: function(fx){ |
4922 | jQuery.style(fx.elem, "opacity", fx.now); |
4161 | jQuery.attr(fx.elem.style, "opacity", fx.now); |
4923 | }, |
4162 | }, |
4924 | 4163 | ||
4925 | _default: function(fx){ |
4164 | _default: function(fx){ |
4926 | if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) |
4165 | if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) |
4927 | fx.elem.style[ fx.prop ] = fx.now + fx.unit; |
4166 | fx.elem.style[ fx.prop ] = fx.now + fx.unit; |
4928 | else
|
4167 | else
|
4929 | fx.elem[ fx.prop ] = fx.now; |
4168 | fx.elem[ fx.prop ] = fx.now; |
4930 | }
|
4169 | }
|
4931 | }
|
4170 | }
|
4932 | }); |
4171 | }); |
4933 | if ( "getBoundingClientRect" in document.documentElement ) { |
4172 | if ( document.documentElement["getBoundingClientRect"] ) |
4934 | jQuery.fn.offset = function( options ) { |
4173 | jQuery.fn.offset = function() { |
4935 | var elem = this[0]; |
- | |
4936 | if ( !elem || !elem.ownerDocument ) { return null; } |
- | |
4937 | if ( options ) { |
- | |
4938 | return this.each(function() { |
- | |
4939 | jQuery.offset.setOffset( this, options ); |
- | |
4940 | }); |
- | |
4941 | }
|
- | |
4942 | if ( elem === elem.ownerDocument.body ) { |
4174 | if ( !this[0] ) return { top: 0, left: 0 }; |
4943 | return jQuery.offset.bodyOffset( elem ); |
4175 | if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] ); |
4944 | }
|
- | |
4945 | - | ||
4946 | var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, |
4176 | var box = this[0].getBoundingClientRect(), doc = this[0].ownerDocument, body = doc.body, docElem = doc.documentElement, |
4947 | clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
4177 | clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
4948 | top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
4178 | top = box.top + (self.pageYOffset || jQuery.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
4949 | left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
4179 | left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
4950 | return { top: top, left: left }; |
4180 | return { top: top, left: left }; |
4951 | }; |
4181 | }; |
4952 | } else { |
4182 | else
|
4953 | jQuery.fn.offset = function( options ) { |
4183 | jQuery.fn.offset = function() { |
4954 | var elem = this[0]; |
- | |
4955 | if ( !elem || !elem.ownerDocument ) { return null; } |
- | |
4956 | if ( options ) { |
- | |
4957 | return this.each(function() { |
- | |
4958 | jQuery.offset.setOffset( this, options ); |
- | |
4959 | }); |
- | |
4960 | }
|
- | |
4961 | if ( elem === elem.ownerDocument.body ) { |
4184 | if ( !this[0] ) return { top: 0, left: 0 }; |
4962 | return jQuery.offset.bodyOffset( elem ); |
4185 | if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] ); |
4963 | }
|
- | |
4964 | - | ||
4965 | jQuery.offset.initialize(); |
4186 | jQuery.offset.initialized || jQuery.offset.initialize(); |
4966 | 4187 | ||
4967 | var offsetParent = elem.offsetParent, prevOffsetParent = elem, |
4188 | var elem = this[0], offsetParent = elem.offsetParent, prevOffsetParent = elem, |
4968 | doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
4189 | doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
4969 | body = doc.body, defaultView = doc.defaultView, |
4190 | body = doc.body, defaultView = doc.defaultView, |
4970 | prevComputedStyle = defaultView.getComputedStyle( elem, null ), |
4191 | prevComputedStyle = defaultView.getComputedStyle(elem, null), |
4971 | top = elem.offsetTop, left = elem.offsetLeft; |
4192 | top = elem.offsetTop, left = elem.offsetLeft; |
4972 | 4193 | ||
4973 | while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
4194 | while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
4974 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { break; } |
- | |
4975 | - | ||
4976 | computedStyle = defaultView.getComputedStyle(elem, null); |
4195 | computedStyle = defaultView.getComputedStyle(elem, null); |
4977 | top -= elem.scrollTop; |
- | |
4978 | left -= elem.scrollLeft; |
4196 | top -= elem.scrollTop, left -= elem.scrollLeft; |
4979 | - | ||
4980 | if ( elem === offsetParent ) { |
4197 | if ( elem === offsetParent ) { |
4981 | top += elem.offsetTop; |
- | |
4982 | left += elem.offsetLeft; |
4198 | top += elem.offsetTop, left += elem.offsetLeft; |
4983 | - | ||
4984 | if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) { |
4199 | if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.tagName)) ) |
4985 | top += parseFloat( computedStyle.borderTopWidth ) || 0; |
4200 | top += parseInt( computedStyle.borderTopWidth, 10) || 0, |
4986 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
4201 | left += parseInt( computedStyle.borderLeftWidth, 10) || 0; |
4987 | }
|
- | |
4988 | - | ||
4989 | prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
4202 | prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
4990 | }
|
4203 | }
|
4991 | - | ||
4992 | if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) { |
4204 | if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) |
4993 | top += parseFloat( computedStyle.borderTopWidth ) || 0; |
4205 | top += parseInt( computedStyle.borderTopWidth, 10) || 0, |
4994 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
4206 | left += parseInt( computedStyle.borderLeftWidth, 10) || 0; |
4995 | }
|
- | |
4996 | - | ||
4997 | prevComputedStyle = computedStyle; |
4207 | prevComputedStyle = computedStyle; |
4998 | }
|
4208 | }
|
4999 | 4209 | ||
5000 | if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) { |
4210 | if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) |
5001 | top += body.offsetTop; |
4211 | top += body.offsetTop, |
5002 | left += body.offsetLeft; |
4212 | left += body.offsetLeft; |
5003 | }
|
- | |
5004 | 4213 | ||
5005 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { |
4214 | if ( prevComputedStyle.position === "fixed" ) |
5006 | top += Math.max( docElem.scrollTop, body.scrollTop ); |
4215 | top += Math.max(docElem.scrollTop, body.scrollTop), |
5007 | left += Math.max( docElem.scrollLeft, body.scrollLeft ); |
4216 | left += Math.max(docElem.scrollLeft, body.scrollLeft); |
5008 | }
|
- | |
5009 | 4217 | ||
5010 | return { top: top, left: left }; |
4218 | return { top: top, left: left }; |
5011 | }; |
4219 | }; |
5012 | }
|
- | |
5013 | 4220 | ||
5014 | jQuery.offset = { |
4221 | jQuery.offset = { |
5015 | initialize: function() { |
4222 | initialize: function() { |
- | 4223 | if ( this.initialized ) return; |
|
5016 | var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0, |
4224 | var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, rules, prop, bodyMarginTop = body.style.marginTop, |
5017 | 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>'; |
4225 | 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>'; |
5018 | 4226 | ||
5019 | jQuery.extend( container.style, { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' } ); |
4227 | rules = { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' }; |
- | 4228 | for ( prop in rules ) container.style[prop] = rules[prop]; |
|
5020 | 4229 | ||
5021 | container.innerHTML = html; |
4230 | container.innerHTML = html; |
5022 | body.insertBefore( container, body.firstChild ); |
4231 | body.insertBefore(container, body.firstChild); |
5023 | innerDiv = container.firstChild; |
- | |
5024 | checkDiv = innerDiv.firstChild; |
- | |
5025 | td = innerDiv.nextSibling.firstChild.firstChild; |
4232 | innerDiv = container.firstChild, checkDiv = innerDiv.firstChild, td = innerDiv.nextSibling.firstChild.firstChild; |
5026 | 4233 | ||
5027 | this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
4234 | this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
5028 | this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
4235 | this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
5029 | 4236 | ||
5030 | checkDiv.style.position = 'fixed', checkDiv.style.top = '20px'; |
- | |
5031 | // safari subtracts parent border width here which is 5px
|
- | |
5032 | this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); |
- | |
5033 | checkDiv.style.position = checkDiv.style.top = ''; |
- | |
5034 | - | ||
5035 | innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; |
4237 | innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; |
5036 | this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
4238 | this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
5037 | 4239 | ||
- | 4240 | body.style.marginTop = '1px'; |
|
5038 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
4241 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop === 0); |
- | 4242 | body.style.marginTop = bodyMarginTop; |
|
5039 | 4243 | ||
5040 | body.removeChild( container ); |
4244 | body.removeChild(container); |
5041 | body = container = innerDiv = checkDiv = table = td = null; |
- | |
5042 | jQuery.offset.initialize = function(){}; |
4245 | this.initialized = true; |
5043 | }, |
4246 | }, |
5044 | 4247 | ||
5045 | bodyOffset: function( body ) { |
4248 | bodyOffset: function(body) { |
- | 4249 | jQuery.offset.initialized || jQuery.offset.initialize(); |
|
5046 | var top = body.offsetTop, left = body.offsetLeft; |
4250 | var top = body.offsetTop, left = body.offsetLeft; |
5047 | - | ||
5048 | jQuery.offset.initialize(); |
- | |
5049 | - | ||
5050 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) { |
4251 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) |
5051 | top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0; |
4252 | top += parseInt( jQuery.curCSS(body, 'marginTop', true), 10 ) || 0, |
5052 | left += parseFloat( jQuery.curCSS(body, 'marginLeft', true) ) || 0; |
4253 | left += parseInt( jQuery.curCSS(body, 'marginLeft', true), 10 ) || 0; |
5053 | }
|
- | |
5054 | - | ||
5055 | return { top: top, left: left }; |
4254 | return { top: top, left: left }; |
5056 | }, |
- | |
5057 | - | ||
5058 | setOffset: function( elem, options ) { |
- | |
5059 | // set position first, in-case top/left are set even on static elem
|
- | |
5060 | if ( /static/.test( jQuery.curCSS( elem, 'position' ) ) ) { |
- | |
5061 | elem.style.position = 'relative'; |
- | |
5062 | }
|
- | |
5063 | var curElem = jQuery( elem ), |
- | |
5064 | curOffset = curElem.offset(), |
- | |
5065 | curTop = parseInt( jQuery.curCSS( elem, 'top', true ), 10 ) || 0, |
- | |
5066 | curLeft = parseInt( jQuery.curCSS( elem, 'left', true ), 10) || 0, |
- | |
5067 | props = { |
- | |
5068 | top: (options.top - curOffset.top) + curTop, |
- | |
5069 | left: (options.left - curOffset.left) + curLeft |
- | |
5070 | }; |
- | |
5071 | - | ||
5072 | if ( 'using' in options ) { |
- | |
5073 | options.using.call( elem, props ); |
- | |
5074 | } else { |
- | |
5075 | curElem.css( props ); |
- | |
5076 | }
|
- | |
5077 | }
|
4255 | }
|
5078 | }; |
4256 | }; |
5079 | 4257 | ||
5080 | 4258 | ||
5081 | jQuery.fn.extend({ |
4259 | jQuery.fn.extend({ |
5082 | position: function() { |
4260 | position: function() { |
5083 | if ( !this[0] ) { return null; } |
- | |
5084 | - | ||
5085 | var elem = this[0], |
4261 | var left = 0, top = 0, results; |
5086 | 4262 | ||
- | 4263 | if ( this[0] ) { |
|
5087 | // Get *real* offsetParent
|
4264 | // Get *real* offsetParent
|
5088 | offsetParent = this.offsetParent(), |
4265 | var offsetParent = this.offsetParent(), |
5089 | 4266 | ||
5090 | // Get correct offsets
|
4267 | // Get correct offsets
|
5091 | offset = this.offset(), |
4268 | offset = this.offset(), |
5092 | parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); |
4269 | parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset(); |
5093 | 4270 | ||
5094 | // Subtract element margins
|
4271 | // Subtract element margins
|
5095 | // note: when an element has margin: auto the offsetLeft and marginLeft
|
4272 | // note: when an element has margin: auto the offsetLeft and marginLeft
|
5096 | // are the same in Safari causing offset.left to incorrectly be 0
|
4273 | // are the same in Safari causing offset.left to incorrectly be 0
|
5097 | offset.top -= parseFloat( jQuery.curCSS(elem, 'marginTop', true) ) || 0; |
4274 | offset.top -= num( this, 'marginTop' ); |
5098 | offset.left -= parseFloat( jQuery.curCSS(elem, 'marginLeft', true) ) || 0; |
4275 | offset.left -= num( this, 'marginLeft' ); |
5099 | 4276 | ||
5100 | // Add offsetParent borders
|
4277 | // Add offsetParent borders
|
5101 | parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], 'borderTopWidth', true) ) || 0; |
4278 | parentOffset.top += num( offsetParent, 'borderTopWidth' ); |
5102 | parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], 'borderLeftWidth', true) ) || 0; |
4279 | parentOffset.left += num( offsetParent, 'borderLeftWidth' ); |
5103 | 4280 | ||
5104 | // Subtract the two offsets
|
4281 | // Subtract the two offsets
|
5105 | return { |
4282 | results = { |
5106 | top: offset.top - parentOffset.top, |
4283 | top: offset.top - parentOffset.top, |
5107 | left: offset.left - parentOffset.left |
4284 | left: offset.left - parentOffset.left |
5108 | }; |
4285 | }; |
- | 4286 | }
|
|
- | 4287 | ||
- | 4288 | return results; |
|
5109 | }, |
4289 | }, |
5110 | 4290 | ||
5111 | offsetParent: function() { |
4291 | offsetParent: function() { |
5112 | return this.map(function(){ |
- | |
5113 | var offsetParent = this.offsetParent || document.body; |
4292 | var offsetParent = this[0].offsetParent || document.body; |
5114 | while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, 'position') === 'static') ) { |
4293 | while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') ) |
5115 | offsetParent = offsetParent.offsetParent; |
4294 | offsetParent = offsetParent.offsetParent; |
5116 | }
|
- | |
5117 | return offsetParent; |
4295 | return jQuery(offsetParent); |
5118 | }); |
- | |
5119 | }
|
4296 | }
|
5120 | }); |
4297 | }); |
5121 | 4298 | ||
5122 | 4299 | ||
5123 | // Create scrollLeft and scrollTop methods
|
4300 | // Create scrollLeft and scrollTop methods
|
5124 | jQuery.each( ['Left', 'Top'], function(i, name) { |
4301 | jQuery.each( ['Left', 'Top'], function(i, name) { |
5125 | var method = 'scroll' + name; |
4302 | var method = 'scroll' + name; |
5126 | 4303 | ||
5127 | jQuery.fn[ method ] = function(val) { |
4304 | jQuery.fn[ method ] = function(val) { |
5128 | var elem = this[0], win; |
4305 | if (!this[0]) return null; |
5129 | 4306 | ||
5130 | if ( !elem ) { return null; } |
4307 | return val !== undefined ? |
5131 | 4308 | ||
5132 | if ( val !== undefined ) { |
- | |
5133 | // Set the scroll offset
|
4309 | // Set the scroll offset
|
5134 | return this.each(function() { |
4310 | this.each(function() { |
5135 | win = getWindow( this ); |
4311 | this == window || this == document ? |
5136 | - | ||
5137 | win ?
|
- | |
5138 | win.scrollTo( |
4312 | window.scrollTo( |
5139 | !i ? val : jQuery(win).scrollLeft(), |
4313 | !i ? val : jQuery(window).scrollLeft(), |
5140 | i ? val : jQuery(win).scrollTop() |
4314 | i ? val : jQuery(window).scrollTop() |
5141 | ) : |
4315 | ) : |
5142 | this[ method ] = val; |
4316 | this[ method ] = val; |
5143 | }); |
4317 | }) : |
5144 | } else { |
- | |
5145 | win = getWindow( elem ); |
- | |
5146 | 4318 | ||
5147 | // Return the scroll offset
|
4319 | // Return the scroll offset
|
- | 4320 | this[0] == window || this[0] == document ? |
|
5148 | return win ? ('pageXOffset' in win) ? win[ i ? 'pageYOffset' : 'pageXOffset' ] : |
4321 | self[ i ? 'pageYOffset' : 'pageXOffset' ] || |
5149 | jQuery.support.boxModel && win.document.documentElement[ method ] || |
4322 | jQuery.boxModel && document.documentElement[ method ] || |
5150 | win.document.body[ method ] : |
4323 | document.body[ method ] : |
5151 | elem[ method ]; |
4324 | this[0][ method ]; |
5152 | }
|
- | |
5153 | }; |
4325 | }; |
5154 | }); |
4326 | }); |
5155 | - | ||
5156 | function getWindow( elem ) { |
- | |
5157 | return ("scrollTo" in elem && elem.document) ? |
- | |
5158 | elem :
|
- | |
5159 | elem.nodeType === 9 ? |
- | |
5160 | elem.defaultView || elem.parentWindow : |
- | |
5161 | false; |
- | |
5162 | }
|
- | |
5163 | // Create innerHeight, innerWidth, outerHeight and outerWidth methods
|
4327 | // Create innerHeight, innerWidth, outerHeight and outerWidth methods
|
5164 | jQuery.each([ "Height", "Width" ], function(i, name){ |
4328 | jQuery.each([ "Height", "Width" ], function(i, name){ |
5165 | 4329 | ||
- | 4330 | var tl = i ? "Left" : "Top", // top or left |
|
- | 4331 | br = i ? "Right" : "Bottom", // bottom or right |
|
5166 | var type = name.toLowerCase(); |
4332 | lower = name.toLowerCase(); |
5167 | 4333 | ||
5168 | // innerHeight and innerWidth
|
4334 | // innerHeight and innerWidth
|
5169 | jQuery.fn["inner" + name] = function(){ |
4335 | jQuery.fn["inner" + name] = function(){ |
5170 | return this[0] ? |
4336 | return this[0] ? |
5171 | jQuery.css( this[0], type, false, "padding" ) : |
4337 | jQuery.css( this[0], lower, false, "padding" ) : |
5172 | null; |
4338 | null; |
5173 | }; |
4339 | }; |
5174 | 4340 | ||
5175 | // outerHeight and outerWidth
|
4341 | // outerHeight and outerWidth
|
5176 | jQuery.fn["outer" + name] = function(margin) { |
4342 | jQuery.fn["outer" + name] = function(margin) { |
5177 | return this[0] ? |
4343 | return this[0] ? |
5178 | jQuery.css( this[0], type, false, margin ? "margin" : "border" ) : |
4344 | jQuery.css( this[0], lower, false, margin ? "margin" : "border" ) : |
5179 | null; |
4345 | null; |
5180 | }; |
4346 | }; |
5181 | 4347 | ||
- | 4348 | var type = name.toLowerCase(); |
|
- | 4349 | ||
5182 | jQuery.fn[ type ] = function( size ) { |
4350 | jQuery.fn[ type ] = function( size ) { |
5183 | // Get window width or height
|
4351 | // Get window width or height
|
5184 | var elem = this[0]; |
4352 | return this[0] == window ? |
5185 | if ( !elem ) return null; |
- | |
5186 | return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window? |
- | |
5187 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
|
4353 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
|
5188 | elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || |
4354 | document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] || |
5189 | elem.document.body[ "client" + name ] : |
4355 | document.body[ "client" + name ] : |
5190 | 4356 | ||
5191 | // Get document width or height
|
4357 | // Get document width or height
|
5192 | (elem.nodeType === 9) ? // is it a document |
4358 | this[0] == document ? |
5193 | // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
|
4359 | // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
|
5194 | Math.max( |
4360 | Math.max( |
5195 | elem.documentElement["client" + name], |
4361 | document.documentElement["client" + name], |
5196 | elem.body["scroll" + name], elem.documentElement["scroll" + name], |
4362 | document.body["scroll" + name], document.documentElement["scroll" + name], |
5197 | elem.body["offset" + name], elem.documentElement["offset" + name] |
4363 | document.body["offset" + name], document.documentElement["offset" + name] |
5198 | ) : |
4364 | ) : |
5199 | 4365 | ||
5200 | // Get or set width or height on the element
|
4366 | // Get or set width or height on the element
|
5201 | size === undefined ? |
4367 | size === undefined ? |
5202 | // Get width or height on the element
|
4368 | // Get width or height on the element
|
5203 | jQuery.css( elem, type ) : |
4369 | (this.length ? jQuery.css( this[0], type ) : null) : |
5204 | 4370 | ||
5205 | // Set the width or height on the element (default to pixels if value is unitless)
|
4371 | // Set the width or height on the element (default to pixels if value is unitless)
|
5206 | this.css( type, typeof size === "string" ? size : size + "px" ); |
4372 | this.css( type, typeof size === "string" ? size : size + "px" ); |
5207 | }; |
4373 | }; |
5208 | 4374 | ||
5209 | }); |
4375 | }); |
5210 | // Expose jQuery to the global object
|
- | |
5211 | window.jQuery = window.$ = jQuery; |
- | |
5212 | - | ||
5213 | })(window); |
4376 | })(); |