Редакция 289 | К новейшей редакции | Весь файл | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 289 | Редакция 290 | ||
---|---|---|---|
Строка 4... | Строка 4... | ||
4 | *
|
4 | *
|
5 | * Copyright (c) 2009 John Resig
|
5 | * Copyright (c) 2009 John Resig
|
6 | * Dual licensed under the MIT and GPL licenses.
|
6 | * Dual licensed under the MIT and GPL licenses.
|
7 | * http://docs.jquery.com/License
|
7 | * http://docs.jquery.com/License
|
8 | *
|
8 | *
|
9 | * Date: 2009-06-17 09:31:45 +0700 (Срд, 17 Июн 2009)
|
9 | * Date: 2009-07-28 03:48:42 +0700 (Втр, 28 Июл 2009)
|
10 | * Revision: 6399
|
10 | * Revision: 6514
|
11 | */
|
11 | */
|
12 | (function(window, undefined){ |
12 | (function(window, undefined){ |
13 | 13 | ||
14 | // Define a local copy of jQuery
|
14 | // Define a local copy of jQuery
|
15 | var jQuery = function( selector, context ) { |
15 | var jQuery = function( selector, context ) { |
Строка 23... | Строка 23... | ||
23 | _jQuery = window.jQuery, |
23 | _jQuery = window.jQuery, |
24 | 24 | ||
25 | // Map over the $ in case of overwrite
|
25 | // Map over the $ in case of overwrite
|
26 | _$ = window.$, |
26 | _$ = window.$, |
27 | 27 | ||
- | 28 | // Use the correct document accordingly with window argument (sandbox)
|
|
- | 29 | document = window.document, |
|
- | 30 | ||
28 | // A central reference to the root jQuery(document)
|
31 | // A central reference to the root jQuery(document)
|
29 | rootjQuery,
|
32 | rootjQuery,
|
30 | 33 | ||
31 | // A simple way to check for HTML strings or ID strings
|
34 | // A simple way to check for HTML strings or ID strings
|
32 | // (both of which we optimize for)
|
35 | // (both of which we optimize for)
|
33 | quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/, |
36 | quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/, |
34 | 37 | ||
35 | // Is it a simple selector
|
38 | // Is it a simple selector
|
36 | isSimple = /^.[^:#\[\.,]*$/, |
39 | isSimple = /^.[^:#\[\.,]*$/, |
37 | 40 | ||
- | 41 | // Check if a string has a non-whitespace character in it
|
|
- | 42 | rnotwhite = /\S/, |
|
- | 43 | ||
- | 44 | // Used for trimming whitespace
|
|
- | 45 | rtrim = /^\s+|\s+$/g, |
|
- | 46 | ||
38 | // Keep a UserAgent string for use with jQuery.browser
|
47 | // Keep a UserAgent string for use with jQuery.browser
|
39 | userAgent = navigator.userAgent.toLowerCase(), |
48 | userAgent = navigator.userAgent.toLowerCase(), |
40 | 49 | ||
41 | // Save a reference to the core toString method
|
50 | // Save a reference to some core methods
|
42 | toString = Object.prototype.toString; |
51 | toString = Object.prototype.toString, |
- | 52 | push = Array.prototype.push, |
|
- | 53 | slice = Array.prototype.slice; |
|
43 | 54 | ||
44 | // Expose jQuery to the global object
|
55 | // Expose jQuery to the global object
|
45 | window.jQuery = window.$ = jQuery; |
56 | window.jQuery = window.$ = jQuery; |
46 | 57 | ||
47 | jQuery.fn = jQuery.prototype = { |
58 | jQuery.fn = jQuery.prototype = { |
48 | init: function( selector, context ) { |
59 | init: function( selector, context ) { |
49 | var match, elem, ret; |
60 | var match, elem, ret; |
50 | 61 | ||
51 | // Handle $(""), $(null), or $(undefined)
|
62 | // Handle $(""), $(null), or $(undefined)
|
52 | if ( !selector ) { |
63 | if ( !selector ) { |
53 | this.length = 0; |
- | |
54 | return this; |
64 | return this; |
55 | }
|
65 | }
|
56 | 66 | ||
57 | // Handle $(DOMElement)
|
67 | // Handle $(DOMElement)
|
58 | if ( selector.nodeType ) { |
68 | if ( selector.nodeType ) { |
59 | this[0] = selector; |
69 | this.context = this[0] = selector; |
60 | this.length = 1; |
70 | this.length++; |
61 | this.context = selector; |
- | |
62 | return this; |
71 | return this; |
63 | }
|
72 | }
|
64 | 73 | ||
65 | // Handle HTML strings
|
74 | // Handle HTML strings
|
66 | if ( typeof selector === "string" ) { |
75 | if ( typeof selector === "string" ) { |
Строка 74... | Строка 83... | ||
74 | if ( match[1] ) { |
83 | if ( match[1] ) { |
75 | selector = jQuery.clean( [ match[1] ], context ); |
84 | selector = jQuery.clean( [ match[1] ], context ); |
76 | 85 | ||
77 | // HANDLE: $("#id")
|
86 | // HANDLE: $("#id")
|
78 | } else { |
87 | } else { |
79 | elem = document.getElementById( match[3] ); |
88 | elem = document.getElementById( match[2] ); |
80 | 89 | ||
- | 90 | if ( elem ) { |
|
81 | // Handle the case where IE and Opera return items
|
91 | // Handle the case where IE and Opera return items
|
82 | // by name instead of ID
|
92 | // by name instead of ID
|
83 | if ( elem && elem.id !== match[3] ) { |
93 | if ( elem.id !== match[2] ) { |
84 | return rootjQuery.find( selector ); |
94 | return rootjQuery.find( selector ); |
85 | }
|
95 | }
|
86 | 96 | ||
87 | // Otherwise, we inject the element directly into the jQuery object
|
97 | // Otherwise, we inject the element directly into the jQuery object
|
- | 98 | this.length++; |
|
88 | ret = jQuery( elem || null ); |
99 | this[0] = elem; |
- | 100 | }
|
|
- | 101 | ||
89 | ret.context = document; |
102 | this.context = document; |
90 | ret.selector = selector; |
103 | this.selector = selector; |
91 | return ret; |
104 | return this; |
92 | }
|
105 | }
|
93 | 106 | ||
94 | // HANDLE: $(expr, $(...))
|
107 | // HANDLE: $(expr, $(...))
|
95 | } else if ( !context || context.jquery ) { |
108 | } else if ( !context || context.jquery ) { |
96 | return (context || rootjQuery).find( selector ); |
109 | return (context || rootjQuery).find( selector ); |
Строка 122... | Строка 135... | ||
122 | selector: "", |
135 | selector: "", |
123 | 136 | ||
124 | // The current version of jQuery being used
|
137 | // The current version of jQuery being used
|
125 | jquery: "1.3.3pre", |
138 | jquery: "1.3.3pre", |
126 | 139 | ||
- | 140 | // The default length of a jQuery object is 0
|
|
- | 141 | length: 0, |
|
- | 142 | ||
127 | // The number of elements contained in the matched element set
|
143 | // The number of elements contained in the matched element set
|
128 | size: function() { |
144 | size: function() { |
129 | return this.length; |
145 | return this.length; |
130 | }, |
146 | }, |
131 | 147 | ||
- | 148 | toArray: function(){ |
|
- | 149 | return slice.call( this, 0 ); |
|
- | 150 | }, |
|
- | 151 | ||
132 | // Get the Nth element in the matched element set OR
|
152 | // Get the Nth element in the matched element set OR
|
133 | // Get the whole matched element set as a clean array
|
153 | // Get the whole matched element set as a clean array
|
134 | get: function( num ) { |
154 | get: function( num ) { |
135 | return num == null ? |
155 | return num == null ? |
136 | 156 | ||
137 | // Return a 'clean' array
|
157 | // Return a 'clean' array
|
138 | Array.prototype.slice.call( this ) : |
158 | this.toArray() : |
139 | 159 | ||
140 | // Return just the object
|
160 | // Return just the object
|
141 | this[ num ]; |
161 | ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] ); |
142 | }, |
162 | }, |
143 | 163 | ||
144 | // Take an array of elements and push it onto the stack
|
164 | // Take an array of elements and push it onto the stack
|
145 | // (returning the new matched element set)
|
165 | // (returning the new matched element set)
|
146 | pushStack: function( elems, name, selector ) { |
166 | pushStack: function( elems, name, selector ) { |
Строка 167... | Строка 187... | ||
167 | // You should use pushStack() in order to do this, but maintain the stack
|
187 | // You should use pushStack() in order to do this, but maintain the stack
|
168 | setArray: function( elems ) { |
188 | setArray: function( elems ) { |
169 | // Resetting the length to 0, then using the native Array push
|
189 | // Resetting the length to 0, then using the native Array push
|
170 | // is a super-fast way to populate an object with array-like properties
|
190 | // is a super-fast way to populate an object with array-like properties
|
171 | this.length = 0; |
191 | this.length = 0; |
172 | Array.prototype.push.apply( this, elems ); |
192 | push.apply( this, elems ); |
173 | 193 | ||
174 | return this; |
194 | return this; |
175 | }, |
195 | }, |
176 | 196 | ||
177 | // Execute a callback for every element in the matched set.
|
197 | // Execute a callback for every element in the matched set.
|
Строка 200... | Строка 220... | ||
200 | return !!selector && jQuery.multiFilter( selector, this ).length > 0; |
220 | return !!selector && jQuery.multiFilter( selector, this ).length > 0; |
201 | }, |
221 | }, |
202 | 222 | ||
203 | // For internal use only.
|
223 | // For internal use only.
|
204 | // Behaves like an Array's method, not like a jQuery method.
|
224 | // Behaves like an Array's method, not like a jQuery method.
|
205 | push: [].push, |
225 | push: push, |
206 | sort: [].sort, |
226 | sort: [].sort, |
207 | splice: [].splice |
227 | splice: [].splice |
208 | }; |
228 | }; |
209 | 229 | ||
210 | // Give the init function the jQuery prototype for later instantiation
|
230 | // Give the init function the jQuery prototype for later instantiation
|
Строка 246... | Строка 266... | ||
246 | continue; |
266 | continue; |
247 | }
|
267 | }
|
248 | 268 | ||
249 | // Recurse if we're merging object values
|
269 | // Recurse if we're merging object values
|
250 | if ( deep && copy && typeof copy === "object" && !copy.nodeType ) { |
270 | if ( deep && copy && typeof copy === "object" && !copy.nodeType ) { |
- | 271 | var clone; |
|
- | 272 | ||
- | 273 | if ( src ) { |
|
- | 274 | clone = src; |
|
- | 275 | } else if ( jQuery.isArray(copy) ) { |
|
- | 276 | clone = []; |
|
251 | target[ name ] = jQuery.extend( deep, |
277 | } else if ( jQuery.isObject(copy) ) { |
- | 278 | clone = {}; |
|
- | 279 | } else { |
|
- | 280 | clone = copy; |
|
- | 281 | }
|
|
- | 282 | ||
252 | // Never move original objects, clone them
|
283 | // Never move original objects, clone them
|
253 | src || ( copy.length != null ? [ ] : { } ), copy ); |
284 | target[ name ] = jQuery.extend( deep, clone, copy ); |
254 | 285 | ||
255 | // Don't bring in undefined values
|
286 | // Don't bring in undefined values
|
256 | } else if ( copy !== undefined ) { |
287 | } else if ( copy !== undefined ) { |
257 | target[ name ] = copy; |
288 | target[ name ] = copy; |
258 | }
|
289 | }
|
Строка 284... | Строка 315... | ||
284 | 315 | ||
285 | isArray: function( obj ) { |
316 | isArray: function( obj ) { |
286 | return toString.call(obj) === "[object Array]"; |
317 | return toString.call(obj) === "[object Array]"; |
287 | }, |
318 | }, |
288 | 319 | ||
- | 320 | isObject: function( obj ) { |
|
- | 321 | return this.constructor.call(obj) === Object; |
|
- | 322 | }, |
|
- | 323 | ||
- | 324 | isEmptyObject: function( obj ) { |
|
- | 325 | for ( var name in obj ) { |
|
- | 326 | return false; |
|
- | 327 | }
|
|
- | 328 | return true; |
|
- | 329 | }, |
|
- | 330 | ||
289 | // check if an element is in a (or is an) XML document
|
331 | // check if an element is in a (or is an) XML document
|
290 | isXMLDoc: function( elem ) { |
332 | isXMLDoc: function( elem ) { |
291 | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || |
333 | // documentElement is verified for cases where it doesn't yet exist
|
- | 334 | // (such as loading iframes in IE - #4833)
|
|
292 | !!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML"; |
335 | return ((elem.ownerDocument || elem).documentElement || 0).nodeName !== "HTML"; |
293 | }, |
336 | }, |
294 | 337 | ||
295 | // Evalulates a script in a global context
|
338 | // Evalulates a script in a global context
|
296 | globalEval: function( data ) { |
339 | globalEval: function( data ) { |
297 | if ( data && /\S/.test(data) ) { |
340 | if ( data && rnotwhite.test(data) ) { |
298 | // Inspired by code by Andrea Giammarchi
|
341 | // Inspired by code by Andrea Giammarchi
|
299 | // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
|
342 | // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
|
300 | var head = document.getElementsByTagName("head")[0] || document.documentElement, |
343 | var head = document.getElementsByTagName("head")[0] || document.documentElement, |
301 | script = document.createElement("script"); |
344 | script = document.createElement("script"); |
302 | 345 | ||
303 | script.type = "text/javascript"; |
346 | script.type = "text/javascript"; |
- | 347 | ||
304 | if ( jQuery.support.scriptEval ) { |
348 | if ( jQuery.support.scriptEval ) { |
305 | script.appendChild( document.createTextNode( data ) ); |
349 | script.appendChild( document.createTextNode( data ) ); |
306 | } else { |
350 | } else { |
307 | script.text = data; |
351 | script.text = data; |
308 | }
|
352 | }
|
Строка 318... | Строка 362... | ||
318 | return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); |
362 | return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); |
319 | }, |
363 | }, |
320 | 364 | ||
321 | // args is for internal usage only
|
365 | // args is for internal usage only
|
322 | each: function( object, callback, args ) { |
366 | each: function( object, callback, args ) { |
- | 367 | var name, i = 0, |
|
323 | var name, i = 0, length = object.length; |
368 | length = object.length, |
- | 369 | isObj = length === undefined || jQuery.isFunction(object); |
|
324 | 370 | ||
325 | if ( args ) { |
371 | if ( args ) { |
326 | if ( length === undefined ) { |
372 | if ( isObj ) { |
327 | for ( name in object ) { |
373 | for ( name in object ) { |
328 | if ( callback.apply( object[ name ], args ) === false ) { |
374 | if ( callback.apply( object[ name ], args ) === false ) { |
329 | break; |
375 | break; |
330 | }
|
376 | }
|
331 | }
|
377 | }
|
Строка 337... | Строка 383... | ||
337 | }
|
383 | }
|
338 | }
|
384 | }
|
339 | 385 | ||
340 | // A special, fast, case for the most common use of each
|
386 | // A special, fast, case for the most common use of each
|
341 | } else { |
387 | } else { |
342 | if ( length === undefined ) { |
388 | if ( isObj ) { |
343 | for ( name in object ) { |
389 | for ( name in object ) { |
344 | if ( callback.call( object[ name ], name, object[ name ] ) === false ) { |
390 | if ( callback.call( object[ name ], name, object[ name ] ) === false ) { |
345 | break; |
391 | break; |
346 | }
|
392 | }
|
347 | }
|
393 | }
|
Строка 353... | Строка 399... | ||
353 | 399 | ||
354 | return object; |
400 | return object; |
355 | }, |
401 | }, |
356 | 402 | ||
357 | trim: function( text ) { |
403 | trim: function( text ) { |
358 | return (text || "").replace( /^\s+|\s+$/g, "" ); |
404 | return (text || "").replace( rtrim, "" ); |
359 | }, |
405 | }, |
360 | 406 | ||
361 | makeArray: function( array ) { |
407 | makeArray: function( array ) { |
362 | var ret = [], i; |
408 | var ret = [], i; |
363 | 409 | ||
Строка 461... | Строка 507... | ||
461 | 507 | ||
462 | // Use of jQuery.browser is deprecated.
|
508 | // Use of jQuery.browser is deprecated.
|
463 | // It's included for backwards compatibility and plugins,
|
509 | // It's included for backwards compatibility and plugins,
|
464 | // although they should work to migrate away.
|
510 | // although they should work to migrate away.
|
465 | browser: { |
511 | browser: { |
466 | version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1], |
512 | version: (/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/.exec(userAgent) || [0,'0'])[1], |
467 | safari: /webkit/.test( userAgent ), |
513 | safari: /webkit/.test( userAgent ), |
468 | opera: /opera/.test( userAgent ), |
514 | opera: /opera/.test( userAgent ), |
469 | msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), |
515 | msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), |
470 | mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) |
516 | mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) |
471 | }
|
517 | }
|
Строка 501... | Строка 547... | ||
501 | data: function( elem, name, data ) { |
547 | data: function( elem, name, data ) { |
502 | elem = elem == window ? |
548 | elem = elem == window ? |
503 | windowData :
|
549 | windowData :
|
504 | elem;
|
550 | elem;
|
505 | 551 | ||
506 | var id = elem[ expando ]; |
552 | var id = elem[ expando ], cache = jQuery.cache; |
507 | 553 | ||
508 | // Compute a unique ID for the element
|
554 | // Compute a unique ID for the element
|
509 | if ( !id ) |
- | |
510 | id = elem[ expando ] = ++uuid; |
555 | if(!id) id = elem[ expando ] = ++uuid; |
511 | 556 | ||
512 | // Only generate the data cache if we're
|
557 | // Only generate the data cache if we're
|
513 | // trying to access or manipulate it
|
558 | // trying to access or manipulate it
|
514 | if ( name && !jQuery.cache[ id ] ) |
559 | if ( name && !cache[ id ] ) |
515 | jQuery.cache[ id ] = {}; |
560 | cache[ id ] = {}; |
- | 561 | ||
- | 562 | var thisCache = cache[ id ]; |
|
516 | 563 | ||
517 | // Prevent overriding the named cache with undefined values
|
564 | // Prevent overriding the named cache with undefined values
|
518 | if ( data !== undefined ) |
565 | if ( data !== undefined ) thisCache[ name ] = data; |
519 | jQuery.cache[ id ][ name ] = data; |
- | |
520 | 566 | ||
521 | // Return the named cache data, or the ID for the element
|
567 | if(name === true) return thisCache |
522 | return name ? |
- | |
523 | jQuery.cache[ id ][ name ] : |
568 | else if(name) return thisCache[name] |
524 | id;
|
569 | else return id |
525 | }, |
570 | }, |
526 | 571 | ||
527 | removeData: function( elem, name ) { |
572 | removeData: function( elem, name ) { |
528 | elem = elem == window ? |
573 | elem = elem == window ? |
529 | windowData :
|
574 | windowData :
|
530 | elem;
|
575 | elem;
|
531 | 576 | ||
532 | var id = elem[ expando ]; |
577 | var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ]; |
533 | 578 | ||
534 | // If we want to remove a specific section of the element's data
|
579 | // If we want to remove a specific section of the element's data
|
535 | if ( name ) { |
580 | if ( name ) { |
536 | if ( jQuery.cache[ id ] ) { |
581 | if ( thisCache ) { |
537 | // Remove the section of cache data
|
582 | // Remove the section of cache data
|
538 | delete jQuery.cache[ id ][ name ]; |
583 | delete thisCache[ name ]; |
539 | 584 | ||
540 | // If we've removed all the data, remove the element's cache
|
585 | // If we've removed all the data, remove the element's cache
|
541 | name = ""; |
- | |
542 | - | ||
543 | for ( name in jQuery.cache[ id ] ) |
586 | if( jQuery.isEmptyObject(thisCache) ) |
544 | break; |
- | |
545 | - | ||
546 | if ( !name ) |
- | |
547 | jQuery.removeData( elem ); |
587 | jQuery.removeData( elem ); |
548 | }
|
588 | }
|
549 | 589 | ||
550 | // Otherwise, we want to remove all of the element's data
|
590 | // Otherwise, we want to remove all of the element's data
|
551 | } else { |
591 | } else { |
Строка 558... | Строка 598... | ||
558 | if ( elem.removeAttribute ) |
598 | if ( elem.removeAttribute ) |
559 | elem.removeAttribute( expando ); |
599 | elem.removeAttribute( expando ); |
560 | }
|
600 | }
|
561 | 601 | ||
562 | // Completely remove the data cache
|
602 | // Completely remove the data cache
|
563 | delete jQuery.cache[ id ]; |
603 | delete cache[ id ]; |
564 | }
|
604 | }
|
565 | }, |
605 | }, |
566 | queue: function( elem, type, data ) { |
606 | queue: function( elem, type, data ) { |
567 | if ( elem ){ |
607 | if( !elem ) return; |
568 | 608 | ||
569 | type = (type || "fx") + "queue"; |
609 | type = (type || "fx") + "queue"; |
570 | - | ||
571 | var q = jQuery.data( elem, type ); |
610 | var q = jQuery.data( elem, type ); |
572 | 611 | ||
- | 612 | // Speed up dequeue by getting out quickly if this is just a lookup
|
|
- | 613 | if( !data ) return q || []; |
|
- | 614 | ||
573 | if ( !q || jQuery.isArray(data) ) |
615 | if ( !q || jQuery.isArray(data) ) |
574 | q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
616 | q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
575 | else if( data ) |
617 | else
|
576 | q.push( data ); |
618 | q.push( data ); |
577 | 619 | ||
578 | }
|
- | |
579 | return q; |
620 | return q; |
580 | }, |
621 | }, |
581 | 622 | ||
582 | dequeue: function( elem, type ){ |
623 | dequeue: function( elem, type ){ |
583 | var queue = jQuery.queue( elem, type ), |
- | |
584 | fn = queue.shift(); |
624 | type = type || "fx"; |
585 | 625 | ||
586 | if( !type || type === "fx" ) |
626 | var queue = jQuery.queue( elem, type ), fn = queue.shift(); |
587 | fn = queue[0]; |
- | |
588 | 627 | ||
- | 628 | // If the fx queue is dequeued, always remove the progress sentinel
|
|
- | 629 | if( fn === "inprogress" ) fn = queue.shift(); |
|
- | 630 | ||
589 | if( fn !== undefined ) |
631 | if( fn ) { |
- | 632 | // Add a progress sentinel to prevent the fx queue from being
|
|
590 | fn.call(elem); |
633 | // automatically dequeued
|
- | 634 | if( type == "fx" ) queue.unshift("inprogress"); |
|
- | 635 | ||
- | 636 | fn.call(elem, function() { jQuery.dequeue(elem, type); }); |
|
- | 637 | }
|
|
591 | }
|
638 | }
|
592 | }); |
639 | }); |
593 | 640 | ||
594 | jQuery.fn.extend({ |
641 | jQuery.fn.extend({ |
595 | data: function( key, value ){ |
642 | data: function( key, value ){ |
- | 643 | if(typeof key === "undefined" && this.length) return jQuery.data(this[0], true); |
|
- | 644 | ||
596 | var parts = key.split("."); |
645 | var parts = key.split("."); |
597 | parts[1] = parts[1] ? "." + parts[1] : ""; |
646 | parts[1] = parts[1] ? "." + parts[1] : ""; |
598 | 647 | ||
599 | if ( value === undefined ) { |
648 | if ( value === undefined ) { |
600 | var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
649 | var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
Строка 623... | Строка 672... | ||
623 | }
|
672 | }
|
624 | 673 | ||
625 | if ( data === undefined ) |
674 | if ( data === undefined ) |
626 | return jQuery.queue( this[0], type ); |
675 | return jQuery.queue( this[0], type ); |
627 | 676 | ||
628 | return this.each(function(){ |
677 | return this.each(function(i, elem){ |
629 | var queue = jQuery.queue( this, type, data ); |
678 | var queue = jQuery.queue( this, type, data ); |
630 | 679 | ||
631 | if( type == "fx" && queue.length == 1 ) |
680 | if( type == "fx" && queue[0] !== "inprogress" ) |
632 | queue[0].call(this); |
681 | jQuery.dequeue( this, type ) |
633 | }); |
682 | }); |
634 | }, |
683 | }, |
635 | dequeue: function(type){ |
684 | dequeue: function(type){ |
636 | return this.each(function(){ |
685 | return this.each(function(){ |
637 | jQuery.dequeue( this, type ); |
686 | jQuery.dequeue( this, type ); |
638 | }); |
687 | }); |
- | 688 | }, |
|
- | 689 | clearQueue: function(type){ |
|
- | 690 | return this.queue( type || "fx", [] ); |
|
639 | }
|
691 | }
|
640 | });/*! |
692 | });/*! |
641 | * Sizzle CSS Selector Engine - v1.0
|
693 | * Sizzle CSS Selector Engine - v1.0
|
642 | * Copyright 2009, The Dojo Foundation
|
694 | * Copyright 2009, The Dojo Foundation
|
643 | * Released under the MIT, BSD, and GPL Licenses.
|
695 | * Released under the MIT, BSD, and GPL Licenses.
|
Строка 969... | Строка 1021... | ||
969 | }
|
1021 | }
|
970 | }, |
1022 | }, |
971 | "": function(checkSet, part, isXML){ |
1023 | "": function(checkSet, part, isXML){ |
972 | var doneName = done++, checkFn = dirCheck; |
1024 | var doneName = done++, checkFn = dirCheck; |
973 | 1025 | ||
974 | if ( !part.match(/\W/) ) { |
1026 | if ( !/\W/.test(part) ) { |
975 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
1027 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
976 | checkFn = dirNodeCheck; |
1028 | checkFn = dirNodeCheck; |
977 | }
|
1029 | }
|
978 | 1030 | ||
979 | checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
1031 | checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
980 | }, |
1032 | }, |
981 | "~": function(checkSet, part, isXML){ |
1033 | "~": function(checkSet, part, isXML){ |
982 | var doneName = done++, checkFn = dirCheck; |
1034 | var doneName = done++, checkFn = dirCheck; |
983 | 1035 | ||
984 | if ( typeof part === "string" && !part.match(/\W/) ) { |
1036 | if ( typeof part === "string" && !/\W/.test(part) ) { |
985 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
1037 | var nodeCheck = part = isXML ? part : part.toUpperCase(); |
986 | checkFn = dirNodeCheck; |
1038 | checkFn = dirNodeCheck; |
987 | }
|
1039 | }
|
988 | 1040 | ||
989 | checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
1041 | checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
Строка 1072... | Строка 1124... | ||
1072 | return match; |
1124 | return match; |
1073 | }, |
1125 | }, |
1074 | PSEUDO: function(match, curLoop, inplace, result, not){ |
1126 | PSEUDO: function(match, curLoop, inplace, result, not){ |
1075 | if ( match[1] === "not" ) { |
1127 | if ( match[1] === "not" ) { |
1076 | // If we're dealing with a complex expression, or a simple one
|
1128 | // If we're dealing with a complex expression, or a simple one
|
1077 | if ( match[3].match(chunker).length > 1 || /^\w/.test(match[3]) ) { |
1129 | if ( chunker.exec(match[3]).length > 1 || /^\w/.test(match[3]) ) { |
1078 | match[3] = Sizzle(match[3], null, null, curLoop); |
1130 | match[3] = Sizzle(match[3], null, null, curLoop); |
1079 | } else { |
1131 | } else { |
1080 | var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
1132 | var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
1081 | if ( !inplace ) { |
1133 | if ( !inplace ) { |
1082 | result.push.apply( result, ret ); |
1134 | result.push.apply( result, ret ); |
Строка 1298... | Строка 1350... | ||
1298 | for ( var type in Expr.match ) { |
1350 | for ( var type in Expr.match ) { |
1299 | Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
1351 | Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
1300 | }
|
1352 | }
|
1301 | 1353 | ||
1302 | var makeArray = function(array, results) { |
1354 | var makeArray = function(array, results) { |
1303 | array = Array.prototype.slice.call( array ); |
1355 | array = Array.prototype.slice.call( array, 0 ); |
1304 | 1356 | ||
1305 | if ( results ) { |
1357 | if ( results ) { |
1306 | results.push.apply( results, array ); |
1358 | results.push.apply( results, array ); |
1307 | return results; |
1359 | return results; |
1308 | }
|
1360 | }
|
Строка 1311... | Строка 1363... | ||
1311 | }; |
1363 | }; |
1312 | 1364 | ||
1313 | // Perform a simple check to determine if the browser is capable of
|
1365 | // Perform a simple check to determine if the browser is capable of
|
1314 | // converting a NodeList to an array using builtin methods.
|
1366 | // converting a NodeList to an array using builtin methods.
|
1315 | try { |
1367 | try { |
1316 | Array.prototype.slice.call( document.documentElement.childNodes ); |
1368 | Array.prototype.slice.call( document.documentElement.childNodes, 0 ); |
1317 | 1369 | ||
1318 | // Provide a fallback method if it does not work
|
1370 | // Provide a fallback method if it does not work
|
1319 | } catch(e){ |
1371 | } catch(e){ |
1320 | makeArray = function(array, results) { |
1372 | makeArray = function(array, results) { |
1321 | var ret = results || []; |
1373 | var ret = results || []; |
Строка 1614... | Строка 1666... | ||
1614 | jQuery.find = Sizzle; |
1666 | jQuery.find = Sizzle; |
1615 | jQuery.expr = Sizzle.selectors; |
1667 | jQuery.expr = Sizzle.selectors; |
1616 | jQuery.expr[":"] = jQuery.expr.filters; |
1668 | jQuery.expr[":"] = jQuery.expr.filters; |
1617 | 1669 | ||
1618 | Sizzle.selectors.filters.hidden = function(elem){ |
1670 | Sizzle.selectors.filters.hidden = function(elem){ |
1619 | var width = elem.offsetWidth, height = elem.offsetHeight; |
1671 | var width = elem.offsetWidth, height = elem.offsetHeight, |
- | 1672 | force = /^tr$/i.test( elem.nodeName ); // ticket #4512 |
|
1620 | return ( width === 0 && height === 0 ) ? |
1673 | return ( width === 0 && height === 0 && !force ) ? |
1621 | true : |
1674 | true : |
1622 | ( width !== 0 && height !== 0 ) ? |
1675 | ( width !== 0 && height !== 0 && !force ) ? |
1623 | false : |
1676 | false : |
1624 | !!( jQuery.curCSS(elem, "display") === "none" ); |
1677 | !!( jQuery.curCSS(elem, "display") === "none" ); |
1625 | }; |
1678 | }; |
1626 | 1679 | ||
1627 | Sizzle.selectors.filters.visible = function(elem){ |
1680 | Sizzle.selectors.filters.visible = function(elem){ |
1628 | var width = elem.offsetWidth, height = elem.offsetHeight; |
- | |
1629 | return ( width === 0 && height === 0 ) ? |
1681 | return !Sizzle.selectors.filters.hidden(elem); |
1630 | false : |
- | |
1631 | ( width > 0 && height > 0 ) ? |
- | |
1632 | true : |
- | |
1633 | !!( jQuery.curCSS(elem, "display") !== "none" ); |
- | |
1634 | }; |
1682 | }; |
1635 | 1683 | ||
1636 | Sizzle.selectors.filters.animated = function(elem){ |
1684 | Sizzle.selectors.filters.animated = function(elem){ |
1637 | return jQuery.grep(jQuery.timers, function(fn){ |
1685 | return jQuery.grep(jQuery.timers, function(fn){ |
1638 | return elem === fn.elem; |
1686 | return elem === fn.elem; |
Строка 1682... | Строка 1730... | ||
1682 | return; |
1730 | return; |
1683 | 1731 | ||
1684 | window.Sizzle = Sizzle; |
1732 | window.Sizzle = Sizzle; |
1685 | 1733 | ||
1686 | })(); |
1734 | })(); |
- | 1735 | jQuery.winnow = function( elements, qualifier, keep ) { |
|
- | 1736 | if(jQuery.isFunction( qualifier )) { |
|
- | 1737 | return jQuery.grep(elements, function(elem, i) { |
|
- | 1738 | return !!qualifier.call( elem, i ) === keep; |
|
- | 1739 | }); |
|
- | 1740 | } else if( qualifier.nodeType ) { |
|
- | 1741 | return jQuery.grep(elements, function(elem, i) { |
|
- | 1742 | return (elem === qualifier) === keep; |
|
- | 1743 | }) |
|
- | 1744 | } else if( typeof qualifier === "string" ) { |
|
- | 1745 | var filtered = jQuery.grep(elements, function(elem) { return elem.nodeType === 1 }); |
|
- | 1746 | ||
- | 1747 | if(isSimple.test( qualifier )) return jQuery.multiFilter(qualifier, filtered, !keep); |
|
- | 1748 | else qualifier = jQuery.multiFilter( qualifier, elements ); |
|
- | 1749 | }
|
|
- | 1750 | ||
- | 1751 | return jQuery.grep(elements, function(elem, i) { |
|
- | 1752 | return (jQuery.inArray( elem, qualifier ) >= 0) === keep; |
|
- | 1753 | }); |
|
- | 1754 | }
|
|
- | 1755 | ||
1687 | jQuery.fn.extend({ |
1756 | jQuery.fn.extend({ |
1688 | find: function( selector ) { |
1757 | find: function( selector ) { |
1689 | var ret = this.pushStack( "", "find", selector ), length = 0; |
1758 | var ret = this.pushStack( "", "find", selector ), length = 0; |
1690 | 1759 | ||
1691 | for ( var i = 0, l = this.length; i < l; i++ ) { |
1760 | for ( var i = 0, l = this.length; i < l; i++ ) { |
Строка 1706... | Строка 1775... | ||
1706 | }
|
1775 | }
|
1707 | 1776 | ||
1708 | return ret; |
1777 | return ret; |
1709 | }, |
1778 | }, |
1710 | 1779 | ||
- | 1780 | not: function( selector ) { |
|
- | 1781 | return this.pushStack( jQuery.winnow(this, selector, false), "not", selector); |
|
- | 1782 | }, |
|
- | 1783 | ||
1711 | filter: function( selector ) { |
1784 | filter: function( selector ) { |
1712 | return this.pushStack( |
- | |
1713 | jQuery.isFunction( selector ) && |
- | |
1714 | jQuery.grep(this, function(elem, i){ |
- | |
1715 | return selector.call( elem, i ); |
- | |
1716 | }) || |
- | |
1717 | - | ||
1718 | jQuery.multiFilter( selector, jQuery.grep(this, function(elem){ |
1785 | return this.pushStack( jQuery.winnow(this, selector, true), "filter", selector ); |
1719 | return elem.nodeType === 1; |
- | |
1720 | }) ), "filter", selector ); |
- | |
1721 | }, |
1786 | }, |
1722 | 1787 | ||
1723 | closest: function( selector ) { |
1788 | closest: function( selector ) { |
1724 | var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, |
1789 | var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, |
1725 | closer = 0; |
1790 | closer = 0, |
- | 1791 | context = this.context; |
|
1726 | 1792 | ||
1727 | return this.map(function(){ |
1793 | return this.map(function(){ |
1728 | var cur = this; |
1794 | var cur = this; |
1729 | while ( cur && cur.ownerDocument ) { |
1795 | while ( cur && cur.ownerDocument && cur !== context ) { |
1730 | if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { |
1796 | if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selector) ) { |
1731 | jQuery.data(cur, "closest", closer); |
1797 | jQuery.data(cur, "closest", closer); |
1732 | return cur; |
1798 | return cur; |
1733 | }
|
1799 | }
|
1734 | cur = cur.parentNode; |
1800 | cur = cur.parentNode; |
1735 | closer++;
|
1801 | closer++;
|
1736 | }
|
1802 | }
|
1737 | }); |
1803 | }); |
1738 | }, |
1804 | }, |
1739 | 1805 | ||
1740 | not: function( selector ) { |
- | |
1741 | if ( typeof selector === "string" ) |
- | |
1742 | // test special case where just one selector is passed in
|
- | |
1743 | if ( isSimple.test( selector ) ) |
- | |
1744 | return this.pushStack( jQuery.multiFilter( selector, this, true ), "not", selector ); |
- | |
1745 | else
|
- | |
1746 | selector = jQuery.multiFilter( selector, this ); |
- | |
1747 | - | ||
1748 | var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType; |
- | |
1749 | return this.filter(function() { |
- | |
1750 | return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector; |
- | |
1751 | }); |
- | |
1752 | }, |
- | |
1753 | - | ||
1754 | add: function( selector ) { |
1806 | add: function( selector ) { |
1755 | return this.pushStack( jQuery.unique( jQuery.merge( |
1807 | return this.pushStack( jQuery.unique( jQuery.merge( |
1756 | this.get(), |
1808 | this.get(), |
1757 | typeof selector === "string" ? |
1809 | typeof selector === "string" ? |
1758 | jQuery( selector ) : |
1810 | jQuery( selector ) : |
Строка 1801... | Строка 1853... | ||
1801 | if ( selector && typeof selector == "string" ) |
1853 | if ( selector && typeof selector == "string" ) |
1802 | ret = jQuery.multiFilter( selector, ret ); |
1854 | ret = jQuery.multiFilter( selector, ret ); |
1803 | 1855 | ||
1804 | return this.pushStack( jQuery.unique( ret ), name, selector ); |
1856 | return this.pushStack( jQuery.unique( ret ), name, selector ); |
1805 | }; |
1857 | }; |
- | 1858 | }); |
|
1806 | });jQuery.fn.extend({ |
1859 | jQuery.fn.extend({ |
1807 | attr: function( name, value ) { |
1860 | attr: function( name, value ) { |
1808 | var options = name, isFunction = jQuery.isFunction( value ); |
1861 | var elem, options, isFunction = jQuery.isFunction(value); |
1809 | 1862 | ||
1810 | if ( typeof name === "string" ) { |
1863 | if ( typeof name === "string" ) { // A single attribute |
1811 | // Are we setting the attribute?
|
- | |
1812 | if ( value === undefined ) { |
1864 | if ( value === undefined ) { // Query it on first element |
1813 | return this.length ? |
1865 | return this.length ? |
1814 | jQuery.attr( this[0], name ) : |
1866 | jQuery.attr( this[0], name ) : |
1815 | null; |
1867 | null; |
1816 | - | ||
1817 | // Convert name, value params to options hash format
|
1868 | } else { // Set it on all elements |
- | 1869 | for ( var i = 0, l = this.length; i < l; i++ ) { |
|
1818 | } else { |
1870 | elem = this[i]; |
1819 | options = {}; |
1871 | if ( isFunction ) |
- | 1872 | value = value.call(elem,i); |
|
1820 | options[ name ] = value; |
1873 | jQuery.attr( elem, name, value ); |
1821 | }
|
1874 | }
|
1822 | }
|
1875 | }
|
1823 | - | ||
- | 1876 | } else { // Multiple attributes to set on all |
|
1824 | // For each element...
|
1877 | options = name; |
1825 | for ( var i = 0, l = this.length; i < l; i++ ) { |
1878 | for ( var i = 0, l = this.length; i < l; i++ ) { |
1826 | var elem = this[i]; |
1879 | elem = this[i]; |
1827 | - | ||
1828 | // Set all the attributes
|
- | |
1829 | for ( var prop in options ) { |
1880 | for ( name in options ) { |
1830 | value = options[prop]; |
1881 | value = options[name]; |
1831 | - | ||
1832 | if ( isFunction ) { |
1882 | if ( jQuery.isFunction(value) ) |
1833 | value = value.call( elem, i ); |
1883 | value = value.call(elem,i); |
- | 1884 | jQuery.attr( elem, name, value ); |
|
1834 | }
|
1885 | }
|
1835 | - | ||
1836 | jQuery.attr( elem, prop, value ); |
- | |
1837 | }
|
1886 | }
|
1838 | }
|
1887 | }
|
1839 | 1888 | ||
1840 | return this; |
1889 | return this; |
1841 | }, |
1890 | }, |
Строка 1889... | Строка 1938... | ||
1889 | }
|
1938 | }
|
1890 | 1939 | ||
1891 | return undefined; |
1940 | return undefined; |
1892 | }
|
1941 | }
|
1893 | 1942 | ||
- | 1943 | // Typecast once if the value is a number
|
|
1894 | if ( typeof value === "number" ) |
1944 | if ( typeof value === "number" ) |
1895 | value += ''; |
1945 | value += ''; |
1896 | 1946 | ||
- | 1947 | var val = value; |
|
- | 1948 | ||
1897 | return this.each(function(){ |
1949 | return this.each(function(){ |
- | 1950 | if(jQuery.isFunction(value)) { |
|
- | 1951 | val = value.call(this); |
|
- | 1952 | // Typecast each time if the value is a Function and the appended
|
|
- | 1953 | // value is therefore different each time.
|
|
- | 1954 | if( typeof val === "number" ) val += ''; |
|
- | 1955 | }
|
|
- | 1956 | ||
1898 | if ( this.nodeType != 1 ) |
1957 | if ( this.nodeType != 1 ) |
1899 | return; |
1958 | return; |
1900 | 1959 | ||
1901 | if ( jQuery.isArray(value) && /radio|checkbox/.test( this.type ) ) |
1960 | if ( jQuery.isArray(val) && /radio|checkbox/.test( this.type ) ) |
1902 | this.checked = (jQuery.inArray(this.value, value) >= 0 || |
1961 | this.checked = jQuery.inArray(this.value || this.name, val) >= 0; |
1903 | jQuery.inArray(this.name, value) >= 0); |
- | |
1904 | 1962 | ||
1905 | else if ( jQuery.nodeName( this, "select" ) ) { |
1963 | else if ( jQuery.nodeName( this, "select" ) ) { |
1906 | var values = jQuery.makeArray(value); |
1964 | var values = jQuery.makeArray(val); |
1907 | 1965 | ||
1908 | jQuery( "option", this ).each(function(){ |
1966 | jQuery( "option", this ).each(function(){ |
1909 | this.selected = (jQuery.inArray( this.value, values ) >= 0 || |
1967 | this.selected = jQuery.inArray( this.value || this.text, values ) >= 0; |
1910 | jQuery.inArray( this.text, values ) >= 0); |
- | |
1911 | }); |
1968 | }); |
1912 | 1969 | ||
1913 | if ( !values.length ) |
1970 | if ( !values.length ) |
1914 | this.selectedIndex = -1; |
1971 | this.selectedIndex = -1; |
1915 | 1972 | ||
1916 | } else |
1973 | } else |
1917 | this.value = value; |
1974 | this.value = val; |
1918 | }); |
1975 | }); |
1919 | }
|
1976 | }
|
1920 | }); |
1977 | }); |
1921 | 1978 | ||
1922 | jQuery.each({ |
1979 | jQuery.each({ |
Строка 1989... | Строка 2046... | ||
1989 | attr: function( elem, name, value ) { |
2046 | attr: function( elem, name, value ) { |
1990 | // don't set attributes on text and comment nodes
|
2047 | // don't set attributes on text and comment nodes
|
1991 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
2048 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
1992 | return undefined; |
2049 | return undefined; |
1993 | 2050 | ||
1994 | var notxml = !elem.tagName || !jQuery.isXMLDoc( elem ), |
2051 | var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), |
1995 | // Whether we are setting (or getting)
|
2052 | // Whether we are setting (or getting)
|
1996 | set = value !== undefined; |
2053 | set = value !== undefined; |
1997 | 2054 | ||
1998 | // Try to normalize/fix the name
|
2055 | // Try to normalize/fix the name
|
1999 | name = notxml && jQuery.props[ name ] || name; |
2056 | name = notxml && jQuery.props[ name ] || name; |
2000 | 2057 | ||
2001 | // Only do all the following if this is a node (faster for style)
|
2058 | // Only do all the following if this is a node (faster for style)
|
2002 | if ( elem.tagName ) { |
2059 | if ( elem.nodeType === 1 ) { |
2003 | 2060 | ||
2004 | // These attributes require special treatment
|
2061 | // These attributes require special treatment
|
2005 | var special = /href|src|style/.test( name ); |
2062 | var special = /href|src|style/.test( name ); |
2006 | 2063 | ||
2007 | // Safari mis-reports the default selected property of a hidden option
|
2064 | // Safari mis-reports the default selected property of a hidden option
|
Строка 2011... | Строка 2068... | ||
2011 | 2068 | ||
2012 | // If applicable, access the attribute via the DOM 0 way
|
2069 | // If applicable, access the attribute via the DOM 0 way
|
2013 | if ( name in elem && notxml && !special ) { |
2070 | if ( name in elem && notxml && !special ) { |
2014 | if ( set ){ |
2071 | if ( set ){ |
2015 | // We can't allow the type property to be changed (since it causes problems in IE)
|
2072 | // We can't allow the type property to be changed (since it causes problems in IE)
|
2016 | if ( name == "type" && elem.nodeName.match(/(button|input)/i) && elem.parentNode ) |
2073 | if ( name == "type" && /(button|input)/i.test(elem.nodeName) && elem.parentNode ) |
2017 | throw "type property can't be changed"; |
2074 | throw "type property can't be changed"; |
2018 | 2075 | ||
2019 | elem[ name ] = value; |
2076 | elem[ name ] = value; |
2020 | }
|
2077 | }
|
2021 | 2078 | ||
Строка 2027... | Строка 2084... | ||
2027 | // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
2084 | // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
|
2028 | if ( name == "tabIndex" ) { |
2085 | if ( name == "tabIndex" ) { |
2029 | var attributeNode = elem.getAttributeNode( "tabIndex" ); |
2086 | var attributeNode = elem.getAttributeNode( "tabIndex" ); |
2030 | return attributeNode && attributeNode.specified |
2087 | return attributeNode && attributeNode.specified |
2031 | ? attributeNode.value |
2088 | ? attributeNode.value |
2032 | : elem.nodeName.match(/(button|input|object|select|textarea)/i) |
2089 | : /(button|input|object|select|textarea)/i.test(elem.nodeName) |
2033 | ? 0 |
2090 | ? 0 |
2034 | : elem.nodeName.match(/^(a|area)$/i) && elem.href |
2091 | : /^(a|area)$/i.test(elem.nodeName) && elem.href |
2035 | ? 0 |
2092 | ? 0 |
2036 | : undefined; |
2093 | : undefined; |
2037 | }
|
2094 | }
|
2038 | 2095 | ||
2039 | return elem[ name ]; |
2096 | return elem[ name ]; |
Строка 2061... | Строка 2118... | ||
2061 | 2118 | ||
2062 | // elem is actually elem.style ... set the style
|
2119 | // elem is actually elem.style ... set the style
|
2063 | // Using attr for specific style information is now deprecated. Use style insead.
|
2120 | // Using attr for specific style information is now deprecated. Use style insead.
|
2064 | return jQuery.style(elem, name, value); |
2121 | return jQuery.style(elem, name, value); |
2065 | }
|
2122 | }
|
- | 2123 | }); |
|
- | 2124 | var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, |
|
- | 2125 | rleadingWhitespace = /^\s+/, |
|
- | 2126 | rsingleTag = /^<(\w+)\s*\/?>$/, |
|
- | 2127 | rxhtmlTag = /(<(\w+)[^>]*?)\/>/g, |
|
- | 2128 | rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i, |
|
- | 2129 | rinsideTable = /^<(thead|tbody|tfoot|colg|cap)/, |
|
- | 2130 | rtbody = /<tbody/i, |
|
- | 2131 | fcloseTag = function(all, front, tag){ |
|
- | 2132 | return rselfClosing.test(tag) ? |
|
- | 2133 | all :
|
|
- | 2134 | front + "></" + tag + ">"; |
|
- | 2135 | }; |
|
- | 2136 | ||
2066 | });jQuery.fn.extend({ |
2137 | jQuery.fn.extend({ |
2067 | text: function( text ) { |
2138 | text: function( text ) { |
2068 | if ( typeof text !== "object" && text != null ) |
2139 | if ( typeof text !== "object" && text !== undefined ) |
2069 | return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
2140 | return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); |
2070 | 2141 | ||
2071 | var ret = ""; |
2142 | var ret = ""; |
2072 | 2143 | ||
2073 | jQuery.each( text || this, function(){ |
2144 | jQuery.each( text || this, function(){ |
2074 | jQuery.each( this.childNodes, function(){ |
2145 | jQuery.each( this.childNodes, function(){ |
2075 | if ( this.nodeType != 8 ) |
2146 | if ( this.nodeType !== 8 ) { |
2076 | ret += this.nodeType != 1 ? |
2147 | ret += this.nodeType !== 1 ? |
2077 | this.nodeValue : |
2148 | this.nodeValue : |
2078 | jQuery.fn.text( [ this ] ); |
2149 | jQuery.fn.text( [ this ] ); |
- | 2150 | }
|
|
2079 | }); |
2151 | }); |
2080 | }); |
2152 | }); |
2081 | 2153 | ||
2082 | return ret; |
2154 | return ret; |
2083 | }, |
2155 | }, |
2084 | 2156 | ||
2085 | wrapAll: function( html ) { |
2157 | wrapAll: function( html ) { |
- | 2158 | if ( jQuery.isFunction( html ) ) { |
|
- | 2159 | return this.each(function() { |
|
- | 2160 | jQuery(this).wrapAll( html.apply(this, arguments) ); |
|
- | 2161 | }); |
|
- | 2162 | }
|
|
- | 2163 | ||
2086 | if ( this[0] ) { |
2164 | if ( this[0] ) { |
2087 | // The elements to wrap the target around
|
2165 | // The elements to wrap the target around
|
2088 | var wrap = jQuery( html, this[0].ownerDocument ).clone(); |
2166 | var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(); |
2089 | 2167 | ||
2090 | if ( this[0].parentNode ) |
2168 | if ( this[0].parentNode ) { |
2091 | wrap.insertBefore( this[0] ); |
2169 | wrap.insertBefore( this[0] ); |
- | 2170 | }
|
|
2092 | 2171 | ||
2093 | wrap.map(function(){ |
2172 | wrap.map(function(){ |
2094 | var elem = this; |
2173 | var elem = this; |
2095 | 2174 | ||
2096 | while ( elem.firstChild ) |
2175 | while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { |
2097 | elem = elem.firstChild; |
2176 | elem = elem.firstChild; |
- | 2177 | }
|
|
2098 | 2178 | ||
2099 | return elem; |
2179 | return elem; |
2100 | }).append(this); |
2180 | }).append(this); |
2101 | }
|
2181 | }
|
2102 | 2182 | ||
Строка 2115... | Строка 2195... | ||
2115 | }); |
2195 | }); |
2116 | }, |
2196 | }, |
2117 | 2197 | ||
2118 | append: function() { |
2198 | append: function() { |
2119 | return this.domManip(arguments, true, function(elem){ |
2199 | return this.domManip(arguments, true, function(elem){ |
2120 | if (this.nodeType == 1) |
2200 | if ( this.nodeType === 1 ) { |
2121 | this.appendChild( elem ); |
2201 | this.appendChild( elem ); |
- | 2202 | }
|
|
2122 | }); |
2203 | }); |
2123 | }, |
2204 | }, |
2124 | 2205 | ||
2125 | prepend: function() { |
2206 | prepend: function() { |
2126 | return this.domManip(arguments, true, function(elem){ |
2207 | return this.domManip(arguments, true, function(elem){ |
2127 | if (this.nodeType == 1) |
2208 | if ( this.nodeType === 1 ) { |
2128 | this.insertBefore( elem, this.firstChild ); |
2209 | this.insertBefore( elem, this.firstChild ); |
- | 2210 | }
|
|
2129 | }); |
2211 | }); |
2130 | }, |
2212 | }, |
2131 | 2213 | ||
2132 | before: function() { |
2214 | before: function() { |
2133 | return this.domManip(arguments, false, function(elem){ |
2215 | return this.domManip(arguments, false, function(elem){ |
Строка 2158... | Строка 2240... | ||
2158 | var div = ownerDocument.createElement("div"); |
2240 | var div = ownerDocument.createElement("div"); |
2159 | div.appendChild( this.cloneNode(true) ); |
2241 | div.appendChild( this.cloneNode(true) ); |
2160 | html = div.innerHTML; |
2242 | html = div.innerHTML; |
2161 | }
|
2243 | }
|
2162 | 2244 | ||
2163 | return jQuery.clean([html.replace(/ jQuery\d+="(?:\d+|null)"/g, "").replace(/^\s*/, "")], ownerDocument)[0]; |
2245 | return jQuery.clean([html.replace(rinlinejQuery, "") |
- | 2246 | .replace(rleadingWhitespace, "")], ownerDocument)[0]; |
|
2164 | } else |
2247 | } else { |
2165 | return this.cloneNode(true); |
2248 | return this.cloneNode(true); |
- | 2249 | }
|
|
2166 | }); |
2250 | }); |
2167 | 2251 | ||
2168 | // Copy the events from the original to the clone
|
2252 | // Copy the events from the original to the clone
|
2169 | if ( events === true ) { |
2253 | if ( events === true ) { |
2170 | var orig = this.find("*").andSelf(), i = 0; |
2254 | var orig = this.find("*").andSelf(), i = 0; |
2171 | 2255 | ||
2172 | ret.find("*").andSelf().each(function(){ |
2256 | ret.find("*").andSelf().each(function(){ |
2173 | if ( this.nodeName !== orig[i].nodeName ) |
2257 | if ( this.nodeName !== orig[i].nodeName ) { return; } |
2174 | return; |
- | |
2175 | 2258 | ||
2176 | var events = jQuery.data( orig[i], "events" ); |
2259 | var events = jQuery.data( orig[i], "events" ); |
2177 | 2260 | ||
2178 | for ( var type in events ) { |
2261 | for ( var type in events ) { |
2179 | for ( var handler in events[ type ] ) { |
2262 | for ( var handler in events[ type ] ) { |
Строка 2190... | Строка 2273... | ||
2190 | }, |
2273 | }, |
2191 | 2274 | ||
2192 | html: function( value ) { |
2275 | html: function( value ) { |
2193 | return value === undefined ? |
2276 | return value === undefined ? |
2194 | (this[0] ? |
2277 | (this[0] ? |
2195 | this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g, "") : |
2278 | this[0].innerHTML.replace(rinlinejQuery, "") : |
2196 | null) : |
2279 | null) : |
2197 | this.empty().append( value ); |
2280 | this.empty().append( value ); |
2198 | }, |
2281 | }, |
2199 | 2282 | ||
2200 | replaceWith: function( value ) { |
2283 | replaceWith: function( value ) { |
2201 | return this.after( value ).remove(); |
2284 | return this.after( value ).remove(); |
2202 | }, |
2285 | }, |
2203 | 2286 | ||
- | 2287 | detach: function( selector ) { |
|
- | 2288 | return this.remove( selector, true ); |
|
- | 2289 | }, |
|
- | 2290 | ||
2204 | domManip: function( args, table, callback ) { |
2291 | domManip: function( args, table, callback ) { |
- | 2292 | var fragment, scripts, cacheable, cached, cacheresults, first, |
|
- | 2293 | value = args[0]; |
|
- | 2294 | ||
- | 2295 | if ( jQuery.isFunction(value) ) { |
|
- | 2296 | return this.each(function() { |
|
- | 2297 | args[0] = value.call(this); |
|
- | 2298 | return jQuery(this).domManip( args, table, callback ); |
|
- | 2299 | }); |
|
- | 2300 | }
|
|
- | 2301 | ||
2205 | if ( this[0] ) { |
2302 | if ( this[0] ) { |
- | 2303 | if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) { |
|
- | 2304 | cacheable = true; |
|
- | 2305 | cacheresults = jQuery.fragments[ args[0] ]; |
|
- | 2306 | if ( cacheresults ) { |
|
- | 2307 | if ( cacheresults !== 1 ) { |
|
- | 2308 | fragment = cacheresults; |
|
- | 2309 | }
|
|
- | 2310 | cached = true; |
|
- | 2311 | }
|
|
- | 2312 | }
|
|
- | 2313 | ||
- | 2314 | if ( !fragment ) { |
|
2206 | var fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(), |
2315 | fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(); |
2207 | scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ), |
2316 | scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ); |
- | 2317 | }
|
|
- | 2318 | ||
2208 | first = fragment.firstChild; |
2319 | first = fragment.firstChild; |
2209 | 2320 | ||
2210 | if ( first ) |
2321 | if ( first ) { |
- | 2322 | table = table && jQuery.nodeName( first, "tr" ); |
|
- | 2323 | ||
2211 | for ( var i = 0, l = this.length; i < l; i++ ) |
2324 | for ( var i = 0, l = this.length; i < l; i++ ) { |
- | 2325 | callback.call( |
|
- | 2326 | table ?
|
|
- | 2327 | root(this[i], first) : |
|
- | 2328 | this[i], |
|
2212 | callback.call( root(this[i], first), this.length > 1 || i > 0 ? |
2329 | cacheable || this.length > 1 || i > 0 ? |
2213 | fragment.cloneNode(true) : fragment ); |
2330 | fragment.cloneNode(true) : |
- | 2331 | fragment |
|
- | 2332 | ); |
|
- | 2333 | }
|
|
- | 2334 | }
|
|
2214 | 2335 | ||
2215 | if ( scripts ) |
2336 | if ( scripts ) { |
2216 | jQuery.each( scripts, evalScript ); |
2337 | jQuery.each( scripts, evalScript ); |
2217 | }
|
2338 | }
|
2218 | 2339 | ||
- | 2340 | if ( cacheable ) { |
|
- | 2341 | jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1; |
|
- | 2342 | }
|
|
- | 2343 | }
|
|
- | 2344 | ||
2219 | return this; |
2345 | return this; |
2220 | 2346 | ||
2221 | function root( elem, cur ) { |
2347 | function root( elem, cur ) { |
2222 | return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ? |
2348 | return jQuery.nodeName(elem, "table") ? |
2223 | (elem.getElementsByTagName("tbody")[0] || |
2349 | (elem.getElementsByTagName("tbody")[0] || |
2224 | elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
2350 | elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
2225 | elem;
|
2351 | elem;
|
2226 | }
|
2352 | }
|
2227 | }
|
2353 | }
|
2228 | }); |
2354 | }); |
2229 | 2355 | ||
- | 2356 | jQuery.fragments = {}; |
|
- | 2357 | ||
2230 | jQuery.each({ |
2358 | jQuery.each({ |
2231 | appendTo: "append", |
2359 | appendTo: "append", |
2232 | prependTo: "prepend", |
2360 | prependTo: "prepend", |
2233 | insertBefore: "before", |
2361 | insertBefore: "before", |
2234 | insertAfter: "after", |
2362 | insertAfter: "after", |
Строка 2246... | Строка 2374... | ||
2246 | return this.pushStack( ret, name, selector ); |
2374 | return this.pushStack( ret, name, selector ); |
2247 | }; |
2375 | }; |
2248 | }); |
2376 | }); |
2249 | 2377 | ||
2250 | jQuery.each({ |
2378 | jQuery.each({ |
- | 2379 | // keepData is for internal use only--do not document
|
|
2251 | remove: function( selector ) { |
2380 | remove: function( selector, keepData ) { |
2252 | if ( !selector || jQuery.multiFilter( selector, [ this ] ).length ) { |
2381 | if ( !selector || jQuery.multiFilter( selector, [ this ] ).length ) { |
2253 | if ( this.nodeType === 1 ) { |
2382 | if ( !keepData && this.nodeType === 1 ) { |
2254 | cleanData( jQuery("*", this).add(this) ); |
2383 | cleanData( jQuery("*", this).add(this) ); |
2255 | }
|
2384 | }
|
2256 | 2385 | ||
2257 | if ( this.parentNode ) { |
2386 | if ( this.parentNode ) { |
2258 | this.parentNode.removeChild( this ); |
2387 | this.parentNode.removeChild( this ); |
Строка 2280... | Строка 2409... | ||
2280 | jQuery.extend({ |
2409 | jQuery.extend({ |
2281 | clean: function( elems, context, fragment ) { |
2410 | clean: function( elems, context, fragment ) { |
2282 | context = context || document; |
2411 | context = context || document; |
2283 | 2412 | ||
2284 | // !context.createElement fails in IE with an error but returns typeof 'object'
|
2413 | // !context.createElement fails in IE with an error but returns typeof 'object'
|
2285 | if ( typeof context.createElement === "undefined" ) |
2414 | if ( typeof context.createElement === "undefined" ) { |
2286 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
2415 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
- | 2416 | }
|
|
2287 | 2417 | ||
2288 | // If a single string is passed in and it's a single tag
|
2418 | // If a single string is passed in and it's a single tag
|
2289 | // just do a createElement and skip the rest
|
2419 | // just do a createElement and skip the rest
|
2290 | if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) { |
2420 | if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) { |
2291 | var match = /^<(\w+)\s*\/?>$/.exec(elems[0]); |
2421 | var match = rsingleTag.exec(elems[0]); |
2292 | if ( match ) |
2422 | if ( match ) { |
2293 | return [ context.createElement( match[1] ) ]; |
2423 | return [ context.createElement( match[1] ) ]; |
2294 | }
|
2424 | }
|
- | 2425 | }
|
|
2295 | 2426 | ||
2296 | var ret = [], scripts = [], div = context.createElement("div"); |
2427 | var ret = [], scripts = [], div = context.createElement("div"); |
2297 | 2428 | ||
2298 | jQuery.each(elems, function(i, elem){ |
2429 | jQuery.each(elems, function(i, elem){ |
2299 | if ( typeof elem === "number" ) |
2430 | if ( typeof elem === "number" ) { |
2300 | elem += ''; |
2431 | elem += ''; |
- | 2432 | }
|
|
2301 | 2433 | ||
2302 | if ( !elem ) |
2434 | if ( !elem ) { return; } |
2303 | return; |
- | |
2304 | 2435 | ||
2305 | // Convert html string into DOM nodes
|
2436 | // Convert html string into DOM nodes
|
2306 | if ( typeof elem === "string" ) { |
2437 | if ( typeof elem === "string" ) { |
2307 | // Fix "XHTML"-style tags in all browsers
|
2438 | // Fix "XHTML"-style tags in all browsers
|
2308 | elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ |
2439 | elem = elem.replace(rxhtmlTag, fcloseTag); |
2309 | return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? |
- | |
2310 | all :
|
- | |
2311 | front + "></" + tag + ">"; |
- | |
2312 | }); |
- | |
2313 | 2440 | ||
2314 | // Trim whitespace, otherwise indexOf won't work as expected
|
2441 | // Trim whitespace, otherwise indexOf won't work as expected
|
2315 | var tags = elem.replace(/^\s+/, "").substring(0, 10).toLowerCase(); |
2442 | var tags = elem.replace(rleadingWhitespace, "") |
- | 2443 | .substring(0, 10).toLowerCase(); |
|
2316 | 2444 | ||
2317 | var wrap = |
2445 | var wrap = |
2318 | // option or optgroup
|
2446 | // option or optgroup
|
2319 | !tags.indexOf("<opt") && |
2447 | !tags.indexOf("<opt") && |
2320 | [ 1, "<select multiple='multiple'>", "</select>" ] || |
2448 | [ 1, "<select multiple='multiple'>", "</select>" ] || |
2321 | 2449 | ||
2322 | !tags.indexOf("<leg") && |
2450 | !tags.indexOf("<leg") && |
2323 | [ 1, "<fieldset>", "</fieldset>" ] || |
2451 | [ 1, "<fieldset>", "</fieldset>" ] || |
2324 | 2452 | ||
2325 | tags.match(/^<(thead|tbody|tfoot|colg|cap)/) && |
2453 | rinsideTable.test(tags) && |
2326 | [ 1, "<table>", "</table>" ] || |
2454 | [ 1, "<table>", "</table>" ] || |
2327 | 2455 | ||
2328 | !tags.indexOf("<tr") && |
2456 | !tags.indexOf("<tr") && |
2329 | [ 2, "<table><tbody>", "</tbody></table>" ] || |
2457 | [ 2, "<table><tbody>", "</tbody></table>" ] || |
2330 | 2458 | ||
Строка 2343... | Строка 2471... | ||
2343 | 2471 | ||
2344 | // Go to html and back, then peel off extra wrappers
|
2472 | // Go to html and back, then peel off extra wrappers
|
2345 | div.innerHTML = wrap[1] + elem + wrap[2]; |
2473 | div.innerHTML = wrap[1] + elem + wrap[2]; |
2346 | 2474 | ||
2347 | // Move to the right depth
|
2475 | // Move to the right depth
|
2348 | while ( wrap[0]-- ) |
2476 | while ( wrap[0]-- ) { |
2349 | div = div.lastChild; |
2477 | div = div.lastChild; |
- | 2478 | }
|
|
2350 | 2479 | ||
2351 | // Remove IE's autoinserted <tbody> from table fragments
|
2480 | // Remove IE's autoinserted <tbody> from table fragments
|
2352 | if ( !jQuery.support.tbody ) { |
2481 | if ( !jQuery.support.tbody ) { |
2353 | 2482 | ||
2354 | // String was a <table>, *may* have spurious <tbody>
|
2483 | // String was a <table>, *may* have spurious <tbody>
|
2355 | var hasBody = /<tbody/i.test(elem), |
2484 | var hasBody = rtbody.test(elem), |
2356 | tbody = !tags.indexOf("<table") && !hasBody ? |
2485 | tbody = !tags.indexOf("<table") && !hasBody ? |
2357 | div.firstChild && div.firstChild.childNodes : |
2486 | div.firstChild && div.firstChild.childNodes : |
2358 | 2487 | ||
2359 | // String was a bare <thead> or <tfoot>
|
2488 | // String was a bare <thead> or <tfoot>
|
2360 | wrap[1] == "<table>" && !hasBody ? |
2489 | wrap[1] == "<table>" && !hasBody ? |
2361 | div.childNodes : |
2490 | div.childNodes : |
2362 | []; |
2491 | []; |
2363 | 2492 | ||
2364 | for ( var j = tbody.length - 1; j >= 0 ; --j ) |
2493 | for ( var j = tbody.length - 1; j >= 0 ; --j ) { |
2365 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) |
2494 | if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
2366 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
2495 | tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
- | 2496 | }
|
|
- | 2497 | }
|
|
2367 | 2498 | ||
2368 | }
|
2499 | }
|
2369 | 2500 | ||
2370 | // IE completely kills leading whitespace when innerHTML is used
|
2501 | // IE completely kills leading whitespace when innerHTML is used
|
2371 | if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) ) |
2502 | if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
2372 | div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild ); |
2503 | div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
- | 2504 | }
|
|
2373 | 2505 | ||
2374 | elem = jQuery.makeArray( div.childNodes ); |
2506 | elem = jQuery.makeArray( div.childNodes ); |
2375 | }
|
2507 | }
|
2376 | 2508 | ||
2377 | if ( elem.nodeType ) |
2509 | if ( elem.nodeType ) { |
2378 | ret.push( elem ); |
2510 | ret.push( elem ); |
2379 | else
|
2511 | } else { |
2380 | ret = jQuery.merge( ret, elem ); |
2512 | ret = jQuery.merge( ret, elem ); |
- | 2513 | }
|
|
2381 | 2514 | ||
2382 | }); |
2515 | }); |
2383 | 2516 | ||
2384 | if ( fragment ) { |
2517 | if ( fragment ) { |
2385 | for ( var i = 0; ret[i]; i++ ) { |
2518 | for ( var i = 0; ret[i]; i++ ) { |
2386 | if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
2519 | if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
2387 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
2520 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
2388 | } else { |
2521 | } else { |
2389 | if ( ret[i].nodeType === 1 ) |
2522 | if ( ret[i].nodeType === 1 ) { |
2390 | ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
2523 | ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
- | 2524 | }
|
|
2391 | fragment.appendChild( ret[i] ); |
2525 | fragment.appendChild( ret[i] ); |
2392 | }
|
2526 | }
|
2393 | }
|
2527 | }
|
2394 | 2528 | ||
2395 | return scripts; |
2529 | return scripts; |
Строка 2464... | Строка 2598... | ||
2464 | var type, i=0; |
2598 | var type, i=0; |
2465 | while ( (type = types[ i++ ]) ) { |
2599 | while ( (type = types[ i++ ]) ) { |
2466 | // Namespaced event handlers
|
2600 | // Namespaced event handlers
|
2467 | var namespaces = type.split("."); |
2601 | var namespaces = type.split("."); |
2468 | type = namespaces.shift(); |
2602 | type = namespaces.shift(); |
2469 | handler.type = namespaces.slice().sort().join("."); |
2603 | handler.type = namespaces.slice(0).sort().join("."); |
2470 | 2604 | ||
2471 | // Get the current list of functions bound to this event
|
2605 | // Get the current list of functions bound to this event
|
2472 | var handlers = events[ type ], |
2606 | var handlers = events[ type ], |
2473 | special = this.special[ type ] || {}; |
2607 | special = this.special[ type ] || {}; |
2474 | 2608 | ||
Строка 2540... | Строка 2674... | ||
2540 | while ( (type = types[ i++ ]) ) { |
2674 | while ( (type = types[ i++ ]) ) { |
2541 | // Namespaced event handlers
|
2675 | // Namespaced event handlers
|
2542 | var namespaces = type.split("."); |
2676 | var namespaces = type.split("."); |
2543 | type = namespaces.shift(); |
2677 | type = namespaces.shift(); |
2544 | var all = !namespaces.length, |
2678 | var all = !namespaces.length, |
2545 | namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"), |
2679 | namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"), |
2546 | special = this.special[ type ] || {}; |
2680 | special = this.special[ type ] || {}; |
2547 | 2681 | ||
2548 | if ( events[ type ] ) { |
2682 | if ( events[ type ] ) { |
2549 | // remove the given handler for the given type
|
2683 | // remove the given handler for the given type
|
2550 | if ( handler ) { |
2684 | if ( handler ) { |
Строка 2698... | Строка 2832... | ||
2698 | event.type = namespaces.shift(); |
2832 | event.type = namespaces.shift(); |
2699 | 2833 | ||
2700 | // Cache this now, all = true means, any handler
|
2834 | // Cache this now, all = true means, any handler
|
2701 | all = !namespaces.length && !event.exclusive; |
2835 | all = !namespaces.length && !event.exclusive; |
2702 | 2836 | ||
2703 | var namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"); |
2837 | var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"); |
2704 | 2838 | ||
2705 | handlers = ( jQuery.data(this, "events") || {} )[ event.type ]; |
2839 | handlers = ( jQuery.data(this, "events") || {} )[ event.type ]; |
2706 | 2840 | ||
2707 | for ( var j in handlers ) { |
2841 | for ( var j in handlers ) { |
2708 | var handler = handlers[ j ]; |
2842 | var handler = handlers[ j ]; |
Строка 3122... | Строка 3256... | ||
3122 | 3256 | ||
3123 | function bindReady() { |
3257 | function bindReady() { |
3124 | if ( readyBound ) return; |
3258 | if ( readyBound ) return; |
3125 | readyBound = true; |
3259 | readyBound = true; |
3126 | 3260 | ||
- | 3261 | // Catch cases where $(document).ready() is called after the
|
|
- | 3262 | // browser event has already occurred.
|
|
- | 3263 | if ( document.readyState === "complete" ) { |
|
- | 3264 | return jQuery.ready(); |
|
- | 3265 | }
|
|
- | 3266 | ||
3127 | // Mozilla, Opera and webkit nightlies currently support this event
|
3267 | // Mozilla, Opera and webkit nightlies currently support this event
|
3128 | if ( document.addEventListener ) { |
3268 | if ( document.addEventListener ) { |
3129 | // Use the handy event callback
|
3269 | // Use the handy event callback
|
3130 | document.addEventListener( "DOMContentLoaded", function() { |
3270 | document.addEventListener( "DOMContentLoaded", function() { |
3131 | document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
3271 | document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
Строка 3298... | Строка 3438... | ||
3298 | rowspan: "rowSpan", |
3438 | rowspan: "rowSpan", |
3299 | colspan: "colSpan", |
3439 | colspan: "colSpan", |
3300 | tabindex: "tabIndex" |
3440 | tabindex: "tabIndex" |
3301 | }; |
3441 | }; |
3302 | // exclude the following css properties to add px
|
3442 | // exclude the following css properties to add px
|
3303 | var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
3443 | var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
- | 3444 | ralpha = /alpha\([^)]*\)/, |
|
- | 3445 | ropacity = /opacity=([^)]*)/, |
|
- | 3446 | rfloat = /float/i, |
|
- | 3447 | rdashAlpha = /-([a-z])/ig, |
|
- | 3448 | rupper = /([A-Z])/g, |
|
- | 3449 | rnumpx = /^\d+(?:px)?$/i, |
|
- | 3450 | rnum = /^\d/, |
|
- | 3451 | ||
3304 | // cache check for defaultView.getComputedStyle
|
3452 | // cache check for defaultView.getComputedStyle
|
3305 | getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, |
3453 | getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, |
3306 | // normalize float css property
|
3454 | // normalize float css property
|
3307 | styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat"; |
3455 | styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat", |
- | 3456 | fcamelCase = function(all, letter){ |
|
- | 3457 | return letter.toUpperCase(); |
|
- | 3458 | }; |
|
3308 | 3459 | ||
3309 | jQuery.fn.css = function( name, value ) { |
3460 | jQuery.fn.css = function( name, value ) { |
3310 | var options = name, isFunction = jQuery.isFunction( value ); |
3461 | var options = name, isFunction = jQuery.isFunction( value ); |
3311 | 3462 | ||
3312 | if ( typeof name === "string" ) { |
3463 | if ( typeof name === "string" ) { |
Строка 3321... | Строка 3472... | ||
3321 | options = {}; |
3472 | options = {}; |
3322 | options[ name ] = value; |
3473 | options[ name ] = value; |
3323 | }
|
3474 | }
|
3324 | }
|
3475 | }
|
3325 | 3476 | ||
- | 3477 | var isFunction = {}; |
|
- | 3478 | ||
- | 3479 | // For each value, determine whether it's a Function so we don't
|
|
- | 3480 | // need to determine it again for each element
|
|
- | 3481 | for ( var prop in options ) { |
|
- | 3482 | isFunction[prop] = jQuery.isFunction( options[prop] ); |
|
- | 3483 | }
|
|
- | 3484 | ||
3326 | // For each element...
|
3485 | // For each element...
|
3327 | for ( var i = 0, l = this.length; i < l; i++ ) { |
3486 | for ( var i = 0, l = this.length; i < l; i++ ) { |
3328 | var elem = this[i]; |
3487 | var elem = this[i]; |
3329 | 3488 | ||
3330 | // Set all the styles
|
3489 | // Set all the styles
|
3331 | for ( var prop in options ) { |
3490 | for ( var prop in options ) { |
3332 | value = options[prop]; |
3491 | value = options[prop]; |
3333 | 3492 | ||
3334 | if ( isFunction ) { |
3493 | if ( isFunction[prop] ) { |
3335 | value = value.call( elem, i ); |
3494 | value = value.call( elem, i ); |
3336 | }
|
3495 | }
|
3337 | 3496 | ||
3338 | if ( typeof value === "number" && !exclude.test(prop) ) { |
3497 | if ( typeof value === "number" && !rexclude.test(prop) ) { |
3339 | value = value + "px"; |
3498 | value = value + "px"; |
3340 | }
|
3499 | }
|
3341 | 3500 | ||
3342 | jQuery.style( elem, prop, value ); |
3501 | jQuery.style( elem, prop, value ); |
3343 | }
|
3502 | }
|
Строка 3347... | Строка 3506... | ||
3347 | }; |
3506 | }; |
3348 | 3507 | ||
3349 | jQuery.extend({ |
3508 | jQuery.extend({ |
3350 | style: function( elem, name, value ) { |
3509 | style: function( elem, name, value ) { |
3351 | // don't set styles on text and comment nodes
|
3510 | // don't set styles on text and comment nodes
|
3352 | if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
3511 | if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
3353 | return undefined; |
3512 | return undefined; |
- | 3513 | }
|
|
3354 | 3514 | ||
3355 | // ignore negative width and height values #1599
|
3515 | // ignore negative width and height values #1599
|
3356 | if ( (name == 'width' || name == 'height') && parseFloat(value) < 0 ) |
3516 | if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) { |
3357 | value = undefined; |
3517 | value = undefined; |
- | 3518 | }
|
|
3358 | 3519 | ||
3359 | var style = elem.style || elem, set = value !== undefined; |
3520 | var style = elem.style || elem, set = value !== undefined; |
3360 | 3521 | ||
3361 | // IE uses filters for opacity
|
3522 | // IE uses filters for opacity
|
3362 | if ( !jQuery.support.opacity && name == "opacity" ) { |
3523 | if ( !jQuery.support.opacity && name === "opacity" ) { |
3363 | if ( set ) { |
3524 | if ( set ) { |
3364 | // IE has trouble with opacity if it does not have layout
|
3525 | // IE has trouble with opacity if it does not have layout
|
3365 | // Force it by setting the zoom level
|
3526 | // Force it by setting the zoom level
|
3366 | style.zoom = 1; |
3527 | style.zoom = 1; |
3367 | 3528 | ||
3368 | // Set the alpha filter to set the opacity
|
3529 | // Set the alpha filter to set the opacity
|
3369 | style.filter = (style.filter || "").replace( /alpha\([^)]*\)/, "" ) + |
3530 | style.filter = (style.filter || "").replace( ralpha, "" ) + |
3370 | (parseInt( value ) + '' == "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"); |
3531 | (parseInt( value ) + '' === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"); |
3371 | }
|
3532 | }
|
3372 | 3533 | ||
3373 | return style.filter && style.filter.indexOf("opacity=") >= 0 ? |
3534 | return style.filter && style.filter.indexOf("opacity=") >= 0 ? |
3374 | (parseFloat( style.filter.match(/opacity=([^)]*)/)[1] ) / 100) + '': |
3535 | (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + '': |
3375 | ""; |
3536 | ""; |
3376 | }
|
3537 | }
|
3377 | 3538 | ||
3378 | // Make sure we're using the right name for getting the float value
|
3539 | // Make sure we're using the right name for getting the float value
|
3379 | if ( /float/i.test( name ) ) |
3540 | if ( rfloat.test( name ) ) { |
3380 | name = styleFloat; |
3541 | name = styleFloat; |
- | 3542 | }
|
|
3381 | 3543 | ||
3382 | name = name.replace(/-([a-z])/ig, function(all, letter){ |
3544 | name = name.replace(rdashAlpha, fcamelCase); |
3383 | return letter.toUpperCase(); |
- | |
3384 | }); |
- | |
3385 | 3545 | ||
3386 | if ( set ) |
3546 | if ( set ) { |
3387 | style[ name ] = value; |
3547 | style[ name ] = value; |
- | 3548 | }
|
|
3388 | 3549 | ||
3389 | return style[ name ]; |
3550 | return style[ name ]; |
3390 | }, |
3551 | }, |
3391 | 3552 | ||
3392 | css: function( elem, name, force, extra ) { |
3553 | css: function( elem, name, force, extra ) { |
3393 | if ( name == "width" || name == "height" ) { |
3554 | if ( name === "width" || name === "height" ) { |
3394 | var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name == "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; |
3555 | var val, props = { position: "absolute", visibility: "hidden", display:"block" }, which = name === "width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ]; |
3395 | 3556 | ||
3396 | function getWH() { |
3557 | function getWH() { |
3397 | val = name == "width" ? elem.offsetWidth : elem.offsetHeight; |
3558 | val = name === "width" ? elem.offsetWidth : elem.offsetHeight; |
3398 | 3559 | ||
3399 | if ( extra === "border" ) |
3560 | if ( extra === "border" ) { return; } |
3400 | return; |
- | |
3401 | 3561 | ||
3402 | jQuery.each( which, function() { |
3562 | jQuery.each( which, function() { |
3403 | if ( !extra ) |
3563 | if ( !extra ) { |
3404 | val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
3564 | val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
- | 3565 | }
|
|
- | 3566 | ||
3405 | if ( extra === "margin" ) |
3567 | if ( extra === "margin" ) { |
3406 | val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; |
3568 | val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; |
3407 | else
|
3569 | } else { |
3408 | val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
3570 | val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
- | 3571 | }
|
|
3409 | }); |
3572 | }); |
3410 | }
|
3573 | }
|
3411 | 3574 | ||
3412 | if ( elem.offsetWidth !== 0 ) |
3575 | if ( elem.offsetWidth !== 0 ) { |
3413 | getWH(); |
3576 | getWH(); |
3414 | else
|
3577 | } else { |
3415 | jQuery.swap( elem, props, getWH ); |
3578 | jQuery.swap( elem, props, getWH ); |
- | 3579 | }
|
|
3416 | 3580 | ||
3417 | return Math.max(0, Math.round(val)); |
3581 | return Math.max(0, Math.round(val)); |
3418 | }
|
3582 | }
|
3419 | 3583 | ||
3420 | return jQuery.curCSS( elem, name, force ); |
3584 | return jQuery.curCSS( elem, name, force ); |
Строка 3423... | Строка 3587... | ||
3423 | curCSS: function( elem, name, force ) { |
3587 | curCSS: function( elem, name, force ) { |
3424 | var ret, style = elem.style, filter; |
3588 | var ret, style = elem.style, filter; |
3425 | 3589 | ||
3426 | // IE uses filters for opacity
|
3590 | // IE uses filters for opacity
|
3427 | if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) { |
3591 | if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) { |
3428 | ret = (elem.currentStyle.filter || "").match(/opacity=([^)]*)/) ? |
3592 | ret = ropacity.test(elem.currentStyle.filter || "") ? |
3429 | (parseFloat(RegExp.$1) / 100) + "" : |
3593 | (parseFloat(RegExp.$1) / 100) + "" : |
3430 | ""; |
3594 | ""; |
3431 | 3595 | ||
3432 | return ret === "" ? |
3596 | return ret === "" ? |
3433 | "1" : |
3597 | "1" : |
3434 | ret;
|
3598 | ret;
|
3435 | }
|
3599 | }
|
3436 | 3600 | ||
3437 | // Make sure we're using the right name for getting the float value
|
3601 | // Make sure we're using the right name for getting the float value
|
3438 | if ( /float/i.test( name ) ) |
3602 | if ( rfloat.test( name ) ) { |
3439 | name = styleFloat; |
3603 | name = styleFloat; |
- | 3604 | }
|
|
3440 | 3605 | ||
3441 | if ( !force && style && style[ name ] ) { |
3606 | if ( !force && style && style[ name ] ) { |
3442 | ret = style[ name ]; |
3607 | ret = style[ name ]; |
3443 | 3608 | ||
3444 | } else if ( getComputedStyle ) { |
3609 | } else if ( getComputedStyle ) { |
3445 | 3610 | ||
3446 | // Only "float" is needed here
|
3611 | // Only "float" is needed here
|
3447 | if ( /float/i.test( name ) ) |
3612 | if ( rfloat.test( name ) ) { |
3448 | name = "float"; |
3613 | name = "float"; |
- | 3614 | }
|
|
3449 | 3615 | ||
3450 | name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase(); |
3616 | name = name.replace( rupper, "-$1" ).toLowerCase(); |
3451 | 3617 | ||
3452 | var computedStyle = elem.ownerDocument.defaultView.getComputedStyle( elem, null ); |
3618 | var computedStyle = elem.ownerDocument.defaultView.getComputedStyle( elem, null ); |
3453 | 3619 | ||
3454 | if ( computedStyle ) |
3620 | if ( computedStyle ) { |
3455 | ret = computedStyle.getPropertyValue( name ); |
3621 | ret = computedStyle.getPropertyValue( name ); |
- | 3622 | }
|
|
3456 | 3623 | ||
3457 | // We should always get a number back from opacity
|
3624 | // We should always get a number back from opacity
|
3458 | if ( name == "opacity" && ret == "" ) |
3625 | if ( name === "opacity" && ret === "" ) { |
3459 | ret = "1"; |
3626 | ret = "1"; |
- | 3627 | }
|
|
3460 | 3628 | ||
3461 | } else if ( elem.currentStyle ) { |
3629 | } else if ( elem.currentStyle ) { |
3462 | var camelCase = name.replace(/\-(\w)/g, function(all, letter){ |
3630 | var camelCase = name.replace(rdashAlpha, fcamelCase); |
3463 | return letter.toUpperCase(); |
- | |
3464 | }); |
- | |
3465 | 3631 | ||
3466 | ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; |
3632 | ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; |
3467 | 3633 | ||
3468 | // From the awesome hack by Dean Edwards
|
3634 | // From the awesome hack by Dean Edwards
|
3469 | // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
3635 | // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
|
3470 | 3636 | ||
3471 | // If we're not dealing with a regular pixel number
|
3637 | // If we're not dealing with a regular pixel number
|
3472 | // but a number that has a weird ending, we need to convert it to pixels
|
3638 | // but a number that has a weird ending, we need to convert it to pixels
|
3473 | if ( !/^\d+(px)?$/i.test( ret ) && /^\d/.test( ret ) ) { |
3639 | if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { |
3474 | // Remember the original values
|
3640 | // Remember the original values
|
3475 | var left = style.left, rsLeft = elem.runtimeStyle.left; |
3641 | var left = style.left, rsLeft = elem.runtimeStyle.left; |
3476 | 3642 | ||
3477 | // Put in the new values to get a computed value out
|
3643 | // Put in the new values to get a computed value out
|
3478 | elem.runtimeStyle.left = elem.currentStyle.left; |
3644 | elem.runtimeStyle.left = elem.currentStyle.left; |
Строка 3489... | Строка 3655... | ||
3489 | }, |
3655 | }, |
3490 | 3656 | ||
3491 | // A method for quickly swapping in/out CSS properties to get correct calculations
|
3657 | // A method for quickly swapping in/out CSS properties to get correct calculations
|
3492 | swap: function( elem, options, callback ) { |
3658 | swap: function( elem, options, callback ) { |
3493 | var old = {}; |
3659 | var old = {}; |
- | 3660 | ||
3494 | // Remember the old values, and insert the new ones
|
3661 | // Remember the old values, and insert the new ones
|
3495 | for ( var name in options ) { |
3662 | for ( var name in options ) { |
3496 | old[ name ] = elem.style[ name ]; |
3663 | old[ name ] = elem.style[ name ]; |
3497 | elem.style[ name ] = options[ name ]; |
3664 | elem.style[ name ] = options[ name ]; |
3498 | }
|
3665 | }
|
3499 | 3666 | ||
3500 | callback.call( elem ); |
3667 | callback.call( elem ); |
3501 | 3668 | ||
3502 | // Revert the old values
|
3669 | // Revert the old values
|
3503 | for ( var name in options ) |
3670 | for ( var name in options ) { |
3504 | elem.style[ name ] = old[ name ]; |
3671 | elem.style[ name ] = old[ name ]; |
3505 | }
|
3672 | }
|
- | 3673 | }
|
|
- | 3674 | }); |
|
- | 3675 | var jsc = now(), |
|
- | 3676 | rscript = /<script(.|\s)*?\/script>/g, |
|
- | 3677 | rselectTextarea = /select|textarea/i, |
|
- | 3678 | rinput = /text|hidden|password|search/i, |
|
- | 3679 | jsre = /=\?(&|$)/, |
|
- | 3680 | rquery = /\?/, |
|
- | 3681 | rts = /(\?|&)_=.*?(&|$)/, |
|
- | 3682 | rurl = /^(\w+:)?\/\/([^\/?#]+)/, |
|
- | 3683 | r20 = /%20/g; |
|
- | 3684 | ||
3506 | });jQuery.fn.extend({ |
3685 | jQuery.fn.extend({ |
3507 | // Keep a copy of the old load
|
3686 | // Keep a copy of the old load
|
3508 | _load: jQuery.fn.load, |
3687 | _load: jQuery.fn.load, |
3509 | 3688 | ||
3510 | load: function( url, params, callback ) { |
3689 | load: function( url, params, callback ) { |
3511 | if ( typeof url !== "string" ) |
3690 | if ( typeof url !== "string" ) { |
3512 | return this._load( url ); |
3691 | return this._load( url ); |
- | 3692 | }
|
|
3513 | 3693 | ||
3514 | var off = url.indexOf(" "); |
3694 | var off = url.indexOf(" "); |
3515 | if ( off >= 0 ) { |
3695 | if ( off >= 0 ) { |
3516 | var selector = url.slice(off, url.length); |
3696 | var selector = url.slice(off, url.length); |
3517 | url = url.slice(0, off); |
3697 | url = url.slice(0, off); |
Строка 3519... | Строка 3699... | ||
3519 | 3699 | ||
3520 | // Default to a GET request
|
3700 | // Default to a GET request
|
3521 | var type = "GET"; |
3701 | var type = "GET"; |
3522 | 3702 | ||
3523 | // If the second parameter was provided
|
3703 | // If the second parameter was provided
|
3524 | if ( params ) |
3704 | if ( params ) { |
3525 | // If it's a function
|
3705 | // If it's a function
|
3526 | if ( jQuery.isFunction( params ) ) { |
3706 | if ( jQuery.isFunction( params ) ) { |
3527 | // We assume that it's the callback
|
3707 | // We assume that it's the callback
|
3528 | callback = params; |
3708 | callback = params; |
3529 | params = null; |
3709 | params = null; |
Строка 3531... | Строка 3711... | ||
3531 | // Otherwise, build a param string
|
3711 | // Otherwise, build a param string
|
3532 | } else if( typeof params === "object" ) { |
3712 | } else if ( typeof params === "object" ) { |
3533 | params = jQuery.param( params ); |
3713 | params = jQuery.param( params ); |
3534 | type = "POST"; |
3714 | type = "POST"; |
3535 | }
|
3715 | }
|
- | 3716 | }
|
|
3536 | 3717 | ||
3537 | var self = this; |
3718 | var self = this; |
3538 | 3719 | ||
3539 | // Request the remote document
|
3720 | // Request the remote document
|
3540 | jQuery.ajax({ |
3721 | jQuery.ajax({ |
Строка 3542... | Строка 3723... | ||
3542 | type: type, |
3723 | type: type, |
3543 | dataType: "html", |
3724 | dataType: "html", |
3544 | data: params, |
3725 | data: params, |
3545 | complete: function(res, status){ |
3726 | complete: function(res, status){ |
3546 | // If successful, inject the HTML into all the matched elements
|
3727 | // If successful, inject the HTML into all the matched elements
|
3547 | if ( status == "success" || status == "notmodified" ) |
3728 | if ( status === "success" || status === "notmodified" ) { |
3548 | // See if a selector was specified
|
3729 | // See if a selector was specified
|
3549 | self.html( selector ? |
3730 | self.html( selector ? |
3550 | // Create a dummy div to hold the results
|
3731 | // Create a dummy div to hold the results
|
3551 | jQuery("<div/>") |
3732 | jQuery("<div/>") |
3552 | // inject the contents of the document in, removing the scripts
|
3733 | // inject the contents of the document in, removing the scripts
|
3553 | // to avoid any 'Permission Denied' errors in IE
|
3734 | // to avoid any 'Permission Denied' errors in IE
|
3554 | .append(res.responseText.replace(/<script(.|\s)*?\/script>/g, "")) |
3735 | .append(res.responseText.replace(rscript, "")) |
3555 | 3736 | ||
3556 | // Locate the specified elements
|
3737 | // Locate the specified elements
|
3557 | .find(selector) : |
3738 | .find(selector) : |
3558 | 3739 | ||
3559 | // If not, just inject the full result
|
3740 | // If not, just inject the full result
|
3560 | res.responseText ); |
3741 | res.responseText ); |
- | 3742 | }
|
|
3561 | 3743 | ||
3562 | if( callback ) |
3744 | if ( callback ) { |
3563 | self.each( callback, [res.responseText, status, res] ); |
3745 | self.each( callback, [res.responseText, status, res] ); |
3564 | }
|
3746 | }
|
- | 3747 | }
|
|
3565 | }); |
3748 | }); |
- | 3749 | ||
3566 | return this; |
3750 | return this; |
3567 | }, |
3751 | }, |
3568 | 3752 | ||
3569 | serialize: function() { |
3753 | serialize: function() { |
3570 | return jQuery.param(this.serializeArray()); |
3754 | return jQuery.param(this.serializeArray()); |
Строка 3573... | Строка 3757... | ||
3573 | return this.map(function(){ |
3757 | return this.map(function(){ |
3574 | return this.elements ? jQuery.makeArray(this.elements) : this; |
3758 | return this.elements ? jQuery.makeArray(this.elements) : this; |
3575 | }) |
3759 | }) |
3576 | .filter(function(){ |
3760 | .filter(function(){ |
3577 | return this.name && !this.disabled && |
3761 | return this.name && !this.disabled && |
3578 | (this.checked || /select|textarea/i.test(this.nodeName) || |
3762 | (this.checked || rselectTextarea.test(this.nodeName) || |
3579 | /text|hidden|password|search/i.test(this.type)); |
3763 | rinput.test(this.type)); |
3580 | }) |
3764 | }) |
3581 | .map(function(i, elem){ |
3765 | .map(function(i, elem){ |
3582 | var val = jQuery(this).val(); |
3766 | var val = jQuery(this).val(); |
- | 3767 | ||
3583 | return val == null ? null : |
3768 | return val == null ? |
- | 3769 | null : |
|
3584 | jQuery.isArray(val) ? |
3770 | jQuery.isArray(val) ? |
3585 | jQuery.map( val, function(val, i){ |
3771 | jQuery.map( val, function(val, i){ |
3586 | return {name: elem.name, value: val}; |
3772 | return {name: elem.name, value: val}; |
3587 | }) : |
3773 | }) : |
3588 | {name: elem.name, value: val}; |
3774 | {name: elem.name, value: val}; |
Строка 3595... | Строка 3781... | ||
3595 | jQuery.fn[o] = function(f){ |
3781 | jQuery.fn[o] = function(f){ |
3596 | return this.bind(o, f); |
3782 | return this.bind(o, f); |
3597 | }; |
3783 | }; |
3598 | }); |
3784 | }); |
3599 | 3785 | ||
3600 | var jsc = now(); |
- | |
3601 | - | ||
3602 | jQuery.extend({ |
3786 | jQuery.extend({ |
3603 | 3787 | ||
3604 | get: function( url, data, callback, type ) { |
3788 | get: function( url, data, callback, type ) { |
3605 | // shift arguments if data argument was ommited
|
3789 | // shift arguments if data argument was ommited
|
3606 | if ( jQuery.isFunction( data ) ) { |
3790 | if ( jQuery.isFunction( data ) ) { |
Строка 3659... | Строка 3843... | ||
3659 | */
|
3843 | */
|
3660 | // Create the request object; Microsoft failed to properly
|
3844 | // Create the request object; Microsoft failed to properly
|
3661 | // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
|
3845 | // implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available
|
3662 | // This function can be overriden by calling jQuery.ajaxSetup
|
3846 | // This function can be overriden by calling jQuery.ajaxSetup
|
3663 | xhr:function(){ |
3847 | xhr: function(){ |
- | 3848 | return window.ActiveXObject ? |
|
3664 | return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); |
3849 | new ActiveXObject("Microsoft.XMLHTTP") : |
- | 3850 | new XMLHttpRequest(); |
|
3665 | }, |
3851 | }, |
3666 | accepts: { |
3852 | accepts: { |
3667 | xml: "application/xml, text/xml", |
3853 | xml: "application/xml, text/xml", |
3668 | html: "text/html", |
3854 | html: "text/html", |
3669 | script: "text/javascript, application/javascript", |
3855 | script: "text/javascript, application/javascript", |
Строка 3680... | Строка 3866... | ||
3680 | ajax: function( s ) { |
3866 | ajax: function( s ) { |
3681 | // Extend the settings, but re-extend 's' so that it can be
|
3867 | // Extend the settings, but re-extend 's' so that it can be
|
3682 | // checked again later (in the test suite, specifically)
|
3868 | // checked again later (in the test suite, specifically)
|
3683 | s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); |
3869 | s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); |
3684 | 3870 | ||
3685 | var jsonp, jsre = /=\?(&|$)/g, status, data, |
3871 | var jsonp, status, data, |
3686 | type = s.type.toUpperCase(); |
3872 | type = s.type.toUpperCase(); |
3687 | 3873 | ||
3688 | // convert data if not already a string
|
3874 | // convert data if not already a string
|
3689 | if ( s.data && s.processData && typeof s.data !== "string" ) |
3875 | if ( s.data && s.processData && typeof s.data !== "string" ) { |
3690 | s.data = jQuery.param(s.data); |
3876 | s.data = jQuery.param(s.data); |
- | 3877 | }
|
|
3691 | 3878 | ||
3692 | // Handle JSONP Parameter Callbacks
|
3879 | // Handle JSONP Parameter Callbacks
|
3693 | if ( s.dataType == "jsonp" ) { |
3880 | if ( s.dataType === "jsonp" ) { |
3694 | if ( type == "GET" ) { |
3881 | if ( type === "GET" ) { |
3695 | if ( !s.url.match(jsre) ) |
3882 | if ( !jsre.test( s.url ) ) { |
3696 | s.url += (s.url.match(/\?/) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
3883 | s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
- | 3884 | }
|
|
3697 | } else if ( !s.data || !s.data.match(jsre) ) |
3885 | } else if ( !s.data || !jsre.test(s.data) ) { |
3698 | s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
3886 | s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
- | 3887 | }
|
|
3699 | s.dataType = "json"; |
3888 | s.dataType = "json"; |
3700 | }
|
3889 | }
|
3701 | 3890 | ||
3702 | // Build temporary JSONP function
|
3891 | // Build temporary JSONP function
|
3703 | if ( s.dataType == "json" && (s.data && s.data.match(jsre) || s.url.match(jsre)) ) { |
3892 | if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) { |
3704 | jsonp = "jsonp" + jsc++; |
3893 | jsonp = "jsonp" + jsc++; |
3705 | 3894 | ||
3706 | // Replace the =? sequence both in the query string and the data
|
3895 | // Replace the =? sequence both in the query string and the data
|
3707 | if ( s.data ) |
3896 | if ( s.data ) { |
3708 | s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
3897 | s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
- | 3898 | }
|
|
- | 3899 | ||
3709 | s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
3900 | s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
3710 | 3901 | ||
3711 | // We need to make sure
|
3902 | // We need to make sure
|
3712 | // that a JSONP style response is executed properly
|
3903 | // that a JSONP style response is executed properly
|
3713 | s.dataType = "script"; |
3904 | s.dataType = "script"; |
Строка 3718... | Строка 3909... | ||
3718 | success(); |
3909 | success(); |
3719 | complete(); |
3910 | complete(); |
3720 | // Garbage collect
|
3911 | // Garbage collect
|
3721 | window[ jsonp ] = undefined; |
3912 | window[ jsonp ] = undefined; |
3722 | try{ delete window[ jsonp ]; } catch(e){} |
3913 | try{ delete window[ jsonp ]; } catch(e){} |
3723 | if ( head ) |
3914 | if ( head ) { |
3724 | head.removeChild( script ); |
3915 | head.removeChild( script ); |
- | 3916 | }
|
|
3725 | }; |
3917 | }; |
3726 | }
|
3918 | }
|
3727 | 3919 | ||
3728 | if ( s.dataType == "script" && s.cache == null ) |
3920 | if ( s.dataType === "script" && s.cache === null ) { |
3729 | s.cache = false; |
3921 | s.cache = false; |
- | 3922 | }
|
|
3730 | 3923 | ||
3731 | if ( s.cache === false && type == "GET" ) { |
3924 | if ( s.cache === false && type === "GET" ) { |
3732 | var ts = now(); |
3925 | var ts = now(); |
- | 3926 | ||
3733 | // try replacing _= if it is there
|
3927 | // try replacing _= if it is there
|
3734 | var ret = s.url.replace(/(\?|&)_=.*?(&|$)/, "$1_=" + ts + "$2"); |
3928 | var ret = s.url.replace(rts, "$1_=" + ts + "$2"); |
- | 3929 | ||
3735 | // if nothing was replaced, add timestamp to the end
|
3930 | // if nothing was replaced, add timestamp to the end
|
3736 | s.url = ret + ((ret == s.url) ? (s.url.match(/\?/) ? "&" : "?") + "_=" + ts : ""); |
3931 | s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : ""); |
3737 | }
|
3932 | }
|
3738 | 3933 | ||
3739 | // If data is available, append data to url for get requests
|
3934 | // If data is available, append data to url for get requests
|
3740 | if ( s.data && type == "GET" ) { |
3935 | if ( s.data && type === "GET" ) { |
3741 | s.url += (s.url.match(/\?/) ? "&" : "?") + s.data; |
3936 | s.url += (rquery.test(s.url) ? "&" : "?") + s.data; |
3742 | }
|
3937 | }
|
3743 | 3938 | ||
3744 | // Watch for a new set of requests
|
3939 | // Watch for a new set of requests
|
3745 | if ( s.global && ! jQuery.active++ ) |
3940 | if ( s.global && ! jQuery.active++ ) { |
3746 | jQuery.event.trigger( "ajaxStart" ); |
3941 | jQuery.event.trigger( "ajaxStart" ); |
- | 3942 | }
|
|
3747 | 3943 | ||
3748 | // Matches an absolute URL, and saves the domain
|
3944 | // Matches an absolute URL, and saves the domain
|
3749 | var parts = /^(\w+:)?\/\/([^\/?#]+)/.exec( s.url ); |
3945 | var parts = rurl.exec( s.url ); |
3750 | 3946 | ||
3751 | // If we're requesting a remote document
|
3947 | // If we're requesting a remote document
|
3752 | // and trying to load JSON or Script with a GET
|
3948 | // and trying to load JSON or Script with a GET
|
3753 | if ( s.dataType == "script" && type == "GET" && parts |
3949 | if ( s.dataType === "script" && type === "GET" && parts |
3754 | && ( parts[1] && parts[1] != location.protocol || parts[2] != location.host )){ |
3950 | && ( parts[1] && parts[1] !== location.protocol || parts[2] !== location.host )) { |
3755 | 3951 | ||
3756 | var head = document.getElementsByTagName("head")[0]; |
3952 | var head = document.getElementsByTagName("head")[0]; |
3757 | var script = document.createElement("script"); |
3953 | var script = document.createElement("script"); |
3758 | script.src = s.url; |
3954 | script.src = s.url; |
3759 | if (s.scriptCharset) |
3955 | if ( s.scriptCharset ) { |
3760 | script.charset = s.scriptCharset; |
3956 | script.charset = s.scriptCharset; |
- | 3957 | }
|
|
3761 | 3958 | ||
3762 | // Handle Script loading
|
3959 | // Handle Script loading
|
3763 | if ( !jsonp ) { |
3960 | if ( !jsonp ) { |
3764 | var done = false; |
3961 | var done = false; |
3765 | 3962 | ||
3766 | // Attach handlers for all browsers
|
3963 | // Attach handlers for all browsers
|
3767 | script.onload = script.onreadystatechange = function(){ |
3964 | script.onload = script.onreadystatechange = function(){ |
3768 | if ( !done && (!this.readyState || |
3965 | if ( !done && (!this.readyState || |
3769 | this.readyState == "loaded" || this.readyState == "complete") ) { |
3966 | this.readyState === "loaded" || this.readyState === "complete") ) { |
3770 | done = true; |
3967 | done = true; |
3771 | success(); |
3968 | success(); |
3772 | complete(); |
3969 | complete(); |
3773 | 3970 | ||
3774 | // Handle memory leak in IE
|
3971 | // Handle memory leak in IE
|
3775 | script.onload = script.onreadystatechange = null; |
3972 | script.onload = script.onreadystatechange = null; |
- | 3973 | if ( head && script.parentNode ) { |
|
3776 | head.removeChild( script ); |
3974 | head.removeChild( script ); |
3777 | }
|
3975 | }
|
- | 3976 | }
|
|
3778 | }; |
3977 | }; |
3779 | }
|
3978 | }
|
3780 | 3979 | ||
3781 | // Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
3980 | // Use insertBefore instead of appendChild to circumvent an IE6 bug.
|
3782 | // This arises when a base node is used (#2709 and #4378).
|
3981 | // This arises when a base node is used (#2709 and #4378).
|
Строка 3791... | Строка 3990... | ||
3791 | // Create the request object
|
3990 | // Create the request object
|
3792 | var xhr = s.xhr(); |
3991 | var xhr = s.xhr(); |
3793 | 3992 | ||
3794 | // Open the socket
|
3993 | // Open the socket
|
3795 | // Passing null username, generates a login popup on Opera (#2865)
|
3994 | // Passing null username, generates a login popup on Opera (#2865)
|
3796 | if( s.username ) |
3995 | if ( s.username ) { |
3797 | xhr.open(type, s.url, s.async, s.username, s.password); |
3996 | xhr.open(type, s.url, s.async, s.username, s.password); |
3798 | else
|
3997 | } else { |
3799 | xhr.open(type, s.url, s.async); |
3998 | xhr.open(type, s.url, s.async); |
- | 3999 | }
|
|
3800 | 4000 | ||
3801 | // Need an extra try/catch for cross domain requests in Firefox 3
|
4001 | // Need an extra try/catch for cross domain requests in Firefox 3
|
3802 | try { |
4002 | try { |
3803 | // Set the correct header, if data is being sent
|
4003 | // Set the correct header, if data is being sent
|
3804 | if ( s.data ) |
4004 | if ( s.data ) { |
3805 | xhr.setRequestHeader("Content-Type", s.contentType); |
4005 | xhr.setRequestHeader("Content-Type", s.contentType); |
- | 4006 | }
|
|
3806 | 4007 | ||
3807 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
4008 | // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
|
3808 | if ( s.ifModified ) { |
4009 | if ( s.ifModified ) { |
3809 | if (jQuery.lastModified[s.url]) |
4010 | if ( jQuery.lastModified[s.url] ) { |
3810 | xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]); |
4011 | xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]); |
- | 4012 | }
|
|
- | 4013 | ||
3811 | if (jQuery.etag[s.url]) |
4014 | if ( jQuery.etag[s.url] ) { |
3812 | xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]); |
4015 | xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]); |
3813 | }
|
4016 | }
|
- | 4017 | }
|
|
3814 | 4018 | ||
3815 | // Set header so the called script knows that it's an XMLHttpRequest
|
4019 | // Set header so the called script knows that it's an XMLHttpRequest
|
3816 | xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
4020 | xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
3817 | 4021 | ||
3818 | // Set the Accepts header for the server, depending on the dataType
|
4022 | // Set the Accepts header for the server, depending on the dataType
|
Строка 3822... | Строка 4026... | ||
3822 | } catch(e){} |
4026 | } catch(e){} |
3823 | 4027 | ||
3824 | // Allow custom headers/mimetypes and early abort
|
4028 | // Allow custom headers/mimetypes and early abort
|
3825 | if ( s.beforeSend && s.beforeSend(xhr, s) === false ) { |
4029 | if ( s.beforeSend && s.beforeSend(xhr, s) === false ) { |
3826 | // Handle the global AJAX counter
|
4030 | // Handle the global AJAX counter
|
3827 | if ( s.global && ! --jQuery.active ) |
4031 | if ( s.global && ! --jQuery.active ) { |
3828 | jQuery.event.trigger( "ajaxStop" ); |
4032 | jQuery.event.trigger( "ajaxStop" ); |
- | 4033 | }
|
|
- | 4034 | ||
3829 | // close opended socket
|
4035 | // close opended socket
|
3830 | xhr.abort(); |
4036 | xhr.abort(); |
3831 | return false; |
4037 | return false; |
3832 | }
|
4038 | }
|
3833 | 4039 | ||
3834 | if ( s.global ) |
4040 | if ( s.global ) { |
3835 | jQuery.event.trigger("ajaxSend", [xhr, s]); |
4041 | jQuery.event.trigger("ajaxSend", [xhr, s]); |
- | 4042 | }
|
|
3836 | 4043 | ||
3837 | // Wait for a response to come back
|
4044 | // Wait for a response to come back
|
3838 | var onreadystatechange = function(isTimeout){ |
4045 | var onreadystatechange = function(isTimeout){ |
3839 | // The request was aborted, clear the interval and decrement jQuery.active
|
4046 | // The request was aborted, clear the interval and decrement jQuery.active
|
3840 | if (xhr.readyState == 0) { |
4047 | if ( xhr.readyState === 0 ) { |
3841 | if (ival) { |
4048 | if ( ival ) { |
3842 | // clear poll interval
|
4049 | // clear poll interval
|
3843 | clearInterval(ival); |
4050 | clearInterval( ival ); |
3844 | ival = null; |
4051 | ival = null; |
- | 4052 | ||
3845 | // Handle the global AJAX counter
|
4053 | // Handle the global AJAX counter
|
3846 | if ( s.global && ! --jQuery.active ) |
4054 | if ( s.global && ! --jQuery.active ) { |
3847 | jQuery.event.trigger( "ajaxStop" ); |
4055 | jQuery.event.trigger( "ajaxStop" ); |
3848 | }
|
4056 | }
|
- | 4057 | }
|
|
- | 4058 | ||
3849 | // The transfer is complete and the data is available, or the request timed out
|
4059 | // The transfer is complete and the data is available, or the request timed out
|
3850 | } else if ( !requestDone && xhr && (xhr.readyState == 4 || isTimeout == "timeout") ) { |
4060 | } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) { |
3851 | requestDone = true; |
4061 | requestDone = true; |
3852 | 4062 | ||
3853 | // clear poll interval
|
4063 | // clear poll interval
|
3854 | if (ival) { |
4064 | if (ival) { |
3855 | clearInterval(ival); |
4065 | clearInterval(ival); |
3856 | ival = null; |
4066 | ival = null; |
3857 | }
|
4067 | }
|
3858 | 4068 | ||
3859 | status = isTimeout == "timeout" ? "timeout" : |
4069 | status = isTimeout === "timeout" ? |
- | 4070 | "timeout" : |
|
3860 | !jQuery.httpSuccess( xhr ) ? "error" : |
4071 | !jQuery.httpSuccess( xhr ) ? |
- | 4072 | "error" : |
|
3861 | s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? "notmodified" : |
4073 | s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? |
- | 4074 | "notmodified" : |
|
3862 | "success"; |
4075 | "success"; |
3863 | 4076 | ||
3864 | if ( status == "success" ) { |
4077 | if ( status === "success" ) { |
3865 | // Watch for, and catch, XML document parse errors
|
4078 | // Watch for, and catch, XML document parse errors
|
3866 | try { |
4079 | try { |
3867 | // process the data (runs the xml through httpData regardless of callback)
|
4080 | // process the data (runs the xml through httpData regardless of callback)
|
3868 | data = jQuery.httpData( xhr, s.dataType, s ); |
4081 | data = jQuery.httpData( xhr, s.dataType, s ); |
3869 | } catch(e) { |
4082 | } catch(e) { |
3870 | status = "parsererror"; |
4083 | status = "parsererror"; |
3871 | }
|
4084 | }
|
3872 | }
|
4085 | }
|
3873 | 4086 | ||
3874 | // Make sure that the request was successful or notmodified
|
4087 | // Make sure that the request was successful or notmodified
|
3875 | if ( status == "success" || status == "notmodified" ) { |
4088 | if ( status === "success" || status === "notmodified" ) { |
3876 | // JSONP handles its own success callback
|
4089 | // JSONP handles its own success callback
|
3877 | if ( !jsonp ) |
4090 | if ( !jsonp ) { |
3878 | success(); |
4091 | success(); |
- | 4092 | }
|
|
3879 | } else |
4093 | } else { |
3880 | jQuery.handleError(s, xhr, status); |
4094 | jQuery.handleError(s, xhr, status); |
- | 4095 | }
|
|
3881 | 4096 | ||
3882 | // Fire the complete handlers
|
4097 | // Fire the complete handlers
|
3883 | complete(); |
4098 | complete(); |
3884 | 4099 | ||
3885 | if ( isTimeout ) |
4100 | if ( isTimeout ) { |
3886 | xhr.abort(); |
4101 | xhr.abort(); |
- | 4102 | }
|
|
3887 | 4103 | ||
3888 | // Stop memory leaks
|
4104 | // Stop memory leaks
|
3889 | if ( s.async ) |
4105 | if ( s.async ) { |
3890 | xhr = null; |
4106 | xhr = null; |
3891 | }
|
4107 | }
|
- | 4108 | }
|
|
3892 | }; |
4109 | }; |
3893 | 4110 | ||
3894 | if ( s.async ) { |
4111 | if ( s.async ) { |
3895 | // don't attach the handler to the request, just poll it instead
|
4112 | // don't attach the handler to the request, just poll it instead
|
3896 | var ival = setInterval(onreadystatechange, 13); |
4113 | var ival = setInterval(onreadystatechange, 13); |
3897 | 4114 | ||
3898 | // Timeout checker
|
4115 | // Timeout checker
|
3899 | if ( s.timeout > 0 ) |
4116 | if ( s.timeout > 0 ) { |
3900 | setTimeout(function(){ |
4117 | setTimeout(function(){ |
3901 | // Check to see if the request is still happening
|
4118 | // Check to see if the request is still happening
|
3902 | if ( xhr && !requestDone ) |
4119 | if ( xhr && !requestDone ) { |
3903 | onreadystatechange( "timeout" ); |
4120 | onreadystatechange( "timeout" ); |
- | 4121 | }
|
|
3904 | }, s.timeout); |
4122 | }, s.timeout); |
3905 | }
|
4123 | }
|
- | 4124 | }
|
|
3906 | 4125 | ||
3907 | // Send the data
|
4126 | // Send the data
|
3908 | try { |
4127 | try { |
3909 | xhr.send( type === "POST" ? s.data : null ); |
4128 | xhr.send( type === "POST" || type === "PUT" ? s.data : null ); |
3910 | } catch(e) { |
4129 | } catch(e) { |
3911 | jQuery.handleError(s, xhr, null, e); |
4130 | jQuery.handleError(s, xhr, null, e); |
3912 | }
|
4131 | }
|
3913 | 4132 | ||
3914 | // firefox 1.5 doesn't fire statechange for sync requests
|
4133 | // firefox 1.5 doesn't fire statechange for sync requests
|
3915 | if ( !s.async ) |
4134 | if ( !s.async ) { |
3916 | onreadystatechange(); |
4135 | onreadystatechange(); |
- | 4136 | }
|
|
3917 | 4137 | ||
3918 | function success(){ |
4138 | function success(){ |
3919 | // If a local callback was specified, fire it and pass it the data
|
4139 | // If a local callback was specified, fire it and pass it the data
|
3920 | if ( s.success ) |
4140 | if ( s.success ) { |
3921 | s.success( data, status ); |
4141 | s.success( data, status ); |
- | 4142 | }
|
|
3922 | 4143 | ||
3923 | // Fire the global callback
|
4144 | // Fire the global callback
|
3924 | if ( s.global ) |
4145 | if ( s.global ) { |
3925 | jQuery.event.trigger( "ajaxSuccess", [xhr, s] ); |
4146 | jQuery.event.trigger( "ajaxSuccess", [xhr, s] ); |
3926 | }
|
4147 | }
|
- | 4148 | }
|
|
3927 | 4149 | ||
3928 | function complete(){ |
4150 | function complete(){ |
3929 | // Process result
|
4151 | // Process result
|
3930 | if ( s.complete ) |
4152 | if ( s.complete ) { |
3931 | s.complete(xhr, status); |
4153 | s.complete(xhr, status); |
- | 4154 | }
|
|
3932 | 4155 | ||
3933 | // The request was completed
|
4156 | // The request was completed
|
3934 | if ( s.global ) |
4157 | if ( s.global ) { |
3935 | jQuery.event.trigger( "ajaxComplete", [xhr, s] ); |
4158 | jQuery.event.trigger( "ajaxComplete", [xhr, s] ); |
- | 4159 | }
|
|
3936 | 4160 | ||
3937 | // Handle the global AJAX counter
|
4161 | // Handle the global AJAX counter
|
3938 | if ( s.global && ! --jQuery.active ) |
4162 | if ( s.global && ! --jQuery.active ) { |
3939 | jQuery.event.trigger( "ajaxStop" ); |
4163 | jQuery.event.trigger( "ajaxStop" ); |
3940 | }
|
4164 | }
|
- | 4165 | }
|
|
3941 | 4166 | ||
3942 | // return XMLHttpRequest to allow aborting the request etc.
|
4167 | // return XMLHttpRequest to allow aborting the request etc.
|
3943 | return xhr; |
4168 | return xhr; |
3944 | }, |
4169 | }, |
3945 | 4170 | ||
3946 | handleError: function( s, xhr, status, e ) { |
4171 | handleError: function( s, xhr, status, e ) { |
3947 | // If a local callback was specified, fire it
|
4172 | // If a local callback was specified, fire it
|
- | 4173 | if ( s.error ) { |
|
3948 | if ( s.error ) s.error( xhr, status, e ); |
4174 | s.error( xhr, status, e ); |
- | 4175 | }
|
|
3949 | 4176 | ||
3950 | // Fire the global callback
|
4177 | // Fire the global callback
|
3951 | if ( s.global ) |
4178 | if ( s.global ) { |
3952 | jQuery.event.trigger( "ajaxError", [xhr, s, e] ); |
4179 | jQuery.event.trigger( "ajaxError", [xhr, s, e] ); |
- | 4180 | }
|
|
3953 | }, |
4181 | }, |
3954 | 4182 | ||
3955 | // Counter for holding the number of active queries
|
4183 | // Counter for holding the number of active queries
|
3956 | active: 0, |
4184 | active: 0, |
3957 | 4185 | ||
3958 | // Determines if an XMLHttpRequest was successful or not
|
4186 | // Determines if an XMLHttpRequest was successful or not
|
3959 | httpSuccess: function( xhr ) { |
4187 | httpSuccess: function( xhr ) { |
3960 | try { |
4188 | try { |
3961 | // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
|
4189 | // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
|
3962 | return !xhr.status && location.protocol == "file:" || |
4190 | return !xhr.status && location.protocol === "file:" || |
- | 4191 | // Opera returns 0 when status is 304
|
|
- | 4192 | ( xhr.status >= 200 && xhr.status < 300 ) || |
|
3963 | ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223; |
4193 | xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; |
3964 | } catch(e){} |
4194 | } catch(e){} |
- | 4195 | ||
3965 | return false; |
4196 | return false; |
3966 | }, |
4197 | }, |
3967 | 4198 | ||
3968 | // Determines if an XMLHttpRequest returns NotModified
|
4199 | // Determines if an XMLHttpRequest returns NotModified
|
3969 | httpNotModified: function( xhr, url ) { |
4200 | httpNotModified: function( xhr, url ) { |
3970 | var last_modified = xhr.getResponseHeader("Last-Modified"); |
4201 | var last_modified = xhr.getResponseHeader("Last-Modified"), |
3971 | var etag = xhr.getResponseHeader("Etag"); |
4202 | etag = xhr.getResponseHeader("Etag"); |
3972 | 4203 | ||
3973 | if (last_modified) |
4204 | if ( last_modified ) { |
3974 | jQuery.lastModified[url] = last_modified; |
4205 | jQuery.lastModified[url] = last_modified; |
- | 4206 | }
|
|
3975 | 4207 | ||
3976 | if (etag) |
4208 | if ( etag ) { |
3977 | jQuery.etag[url] = etag; |
4209 | jQuery.etag[url] = etag; |
- | 4210 | }
|
|
3978 | 4211 | ||
- | 4212 | // Opera returns 0 when status is 304
|
|
3979 | return xhr.status == 304; |
4213 | return xhr.status === 304 || xhr.status === 0; |
3980 | }, |
4214 | }, |
3981 | 4215 | ||
3982 | httpData: function( xhr, type, s ) { |
4216 | httpData: function( xhr, type, s ) { |
3983 | var ct = xhr.getResponseHeader("content-type"), |
4217 | var ct = xhr.getResponseHeader("content-type"), |
3984 | xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0, |
4218 | xml = type === "xml" || !type && ct && ct.indexOf("xml") >= 0, |
3985 | data = xml ? xhr.responseXML : xhr.responseText; |
4219 | data = xml ? xhr.responseXML : xhr.responseText; |
3986 | 4220 | ||
3987 | if ( xml && data.documentElement.tagName == "parsererror" ) { |
4221 | if ( xml && data.documentElement.nodeName === "parsererror" ) { |
3988 | throw "parsererror"; |
4222 | throw "parsererror"; |
3989 | }
|
4223 | }
|
3990 | 4224 | ||
3991 | // Allow a pre-filtering function to sanitize the response
|
4225 | // Allow a pre-filtering function to sanitize the response
|
3992 | // s != null is checked to keep backwards compatibility
|
4226 | // s is checked to keep backwards compatibility
|
3993 | if ( s && s.dataFilter ) { |
4227 | if ( s && s.dataFilter ) { |
3994 | data = s.dataFilter( data, type ); |
4228 | data = s.dataFilter( data, type ); |
3995 | }
|
4229 | }
|
3996 | 4230 | ||
3997 | // The filter can actually parse the response
|
4231 | // The filter can actually parse the response
|
Строка 4001... | Строка 4235... | ||
4001 | if ( type === "script" ) { |
4235 | if ( type === "script" ) { |
4002 | jQuery.globalEval( data ); |
4236 | jQuery.globalEval( data ); |
4003 | }
|
4237 | }
|
4004 | 4238 | ||
4005 | // Get the JavaScript object, if JSON is used.
|
4239 | // Get the JavaScript object, if JSON is used.
|
4006 | if ( type == "json" ) { |
4240 | if ( type === "json" ) { |
4007 | if ( typeof JSON === "object" && JSON.parse ) { |
4241 | if ( typeof JSON === "object" && JSON.parse ) { |
4008 | data = JSON.parse( data ); |
4242 | data = JSON.parse( data ); |
4009 | } else { |
4243 | } else { |
4010 | data = (new Function("return " + data))(); |
4244 | data = (new Function("return " + data))(); |
4011 | }
|
4245 | }
|
Строка 4020... | Строка 4254... | ||
4020 | param: function( a ) { |
4254 | param: function( a ) { |
4021 | var s = [ ]; |
4255 | var s = []; |
4022 | 4256 | ||
4023 | function add( key, value ){ |
4257 | function add( key, value ){ |
4024 | s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
4258 | s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
4025 | }; |
4259 | }
|
4026 | 4260 | ||
4027 | // If an array was passed in, assume that it is an array
|
4261 | // If an array was passed in, assume that it is an array
|
4028 | // of form elements
|
4262 | // of form elements
|
4029 | if ( jQuery.isArray(a) || a.jquery ) |
4263 | if ( jQuery.isArray(a) || a.jquery ) { |
4030 | // Serialize the form elements
|
4264 | // Serialize the form elements
|
4031 | jQuery.each( a, function(){ |
4265 | jQuery.each( a, function(){ |
4032 | add( this.name, this.value ); |
4266 | add( this.name, this.value ); |
4033 | }); |
4267 | }); |
4034 | 4268 | ||
4035 | // Otherwise, assume that it's an object of key/value pairs
|
4269 | // Otherwise, assume that it's an object of key/value pairs
|
4036 | else
|
4270 | } else { |
4037 | // Serialize the key/values
|
4271 | // Serialize the key/values
|
4038 | for ( var j in a ) |
4272 | for ( var j in a ) { |
4039 | // If the value is an array then the key names need to be repeated
|
4273 | // If the value is an array then the key names need to be repeated
|
4040 | if ( jQuery.isArray(a[j]) ) |
4274 | if ( jQuery.isArray(a[j]) ) { |
4041 | jQuery.each( a[j], function(){ |
4275 | jQuery.each( a[j], function(){ |
4042 | add( j, this ); |
4276 | add( j, this ); |
4043 | }); |
4277 | }); |
4044 | else
|
4278 | } else { |
4045 | add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] ); |
4279 | add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] ); |
- | 4280 | }
|
|
- | 4281 | }
|
|
- | 4282 | }
|
|
4046 | 4283 | ||
4047 | // Return the resulting serialization
|
4284 | // Return the resulting serialization
|
4048 | return s.join("&").replace(/%20/g, "+"); |
4285 | return s.join("&").replace(r20, "+"); |
4049 | }
|
4286 | }
|
4050 | 4287 | ||
4051 | }); |
4288 | }); |
4052 | var elemdisplay = {}, |
4289 | var elemdisplay = {}, |
4053 | timerId,
|
4290 | timerId,
|
Строка 4077... | Строка 4314... | ||
4077 | var old = jQuery.data(this[i], "olddisplay"); |
4314 | var old = jQuery.data(this[i], "olddisplay"); |
4078 | 4315 | ||
4079 | this[i].style.display = old || ""; |
4316 | this[i].style.display = old || ""; |
4080 | 4317 | ||
4081 | if ( jQuery.css(this[i], "display") === "none" ) { |
4318 | if ( jQuery.css(this[i], "display") === "none" ) { |
4082 | var tagName = this[i].tagName, display; |
4319 | var nodeName = this[i].nodeName, display; |
4083 | 4320 | ||
4084 | if ( elemdisplay[ tagName ] ) { |
4321 | if ( elemdisplay[ nodeName ] ) { |
4085 | display = elemdisplay[ tagName ]; |
4322 | display = elemdisplay[ nodeName ]; |
4086 | } else { |
4323 | } else { |
4087 | var elem = jQuery("<" + tagName + " />").appendTo("body"); |
4324 | var elem = jQuery("<" + nodeName + " />").appendTo("body"); |
4088 | 4325 | ||
4089 | display = elem.css("display"); |
4326 | display = elem.css("display"); |
4090 | if ( display === "none" ) |
4327 | if ( display === "none" ) |
4091 | display = "block"; |
4328 | display = "block"; |
4092 | 4329 | ||
4093 | elem.remove(); |
4330 | elem.remove(); |
4094 | 4331 | ||
4095 | elemdisplay[ tagName ] = display; |
4332 | elemdisplay[ nodeName ] = display; |
4096 | }
|
4333 | }
|
4097 | 4334 | ||
4098 | jQuery.data(this[i], "olddisplay", display); |
4335 | jQuery.data(this[i], "olddisplay", display); |
4099 | }
|
4336 | }
|
4100 | }
|
4337 | }
|
Строка 4158... | Строка 4395... | ||
4158 | var opt = jQuery.extend({}, optall), p, |
4395 | var opt = jQuery.extend({}, optall), p, |
4159 | hidden = this.nodeType == 1 && jQuery(this).is(":hidden"), |
4396 | hidden = this.nodeType == 1 && jQuery(this).is(":hidden"), |
4160 | self = this; |
4397 | self = this; |
4161 | 4398 | ||
4162 | for ( p in prop ) { |
4399 | for ( p in prop ) { |
- | 4400 | var name = p.replace(rdashAlpha, fcamelCase); |
|
- | 4401 | ||
- | 4402 | if ( p !== name ) { |
|
- | 4403 | prop[ name ] = prop[ p ]; |
|
- | 4404 | delete prop[ p ]; |
|
- | 4405 | p = name; |
|
- | 4406 | }
|
|
- | 4407 | ||
4163 | if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) |
4408 | if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden ) |
4164 | return opt.complete.call(this); |
4409 | return opt.complete.call(this); |
4165 | 4410 | ||
4166 | if ( ( p == "height" || p == "width" ) && this.style ) { |
4411 | if ( ( p == "height" || p == "width" ) && this.style ) { |
4167 | // Store display property
|
4412 | // Store display property
|
Строка 4181... | Строка 4426... | ||
4181 | var e = new jQuery.fx( self, opt, name ); |
4426 | var e = new jQuery.fx( self, opt, name ); |
4182 | 4427 | ||
4183 | if ( /toggle|show|hide/.test(val) ) |
4428 | if ( /toggle|show|hide/.test(val) ) |
4184 | e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
4429 | e[ val == "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
4185 | else { |
4430 | else { |
4186 | var parts = val.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/), |
4431 | var parts = /^([+-]=)?([\d+-.]+)(.*)$/.exec(val), |
4187 | start = e.cur(true) || 0; |
4432 | start = e.cur(true) || 0; |
4188 | 4433 | ||
4189 | if ( parts ) { |
4434 | if ( parts ) { |
4190 | var end = parseFloat(parts[2]), |
4435 | var end = parseFloat(parts[2]), |
4191 | unit = parts[3] || "px"; |
4436 | unit = parts[3] || "px"; |
Строка 4461... | Строка 4706... | ||
4461 | else
|
4706 | else
|
4462 | fx.elem[ fx.prop ] = fx.now; |
4707 | fx.elem[ fx.prop ] = fx.now; |
4463 | }
|
4708 | }
|
4464 | }
|
4709 | }
|
4465 | }); |
4710 | }); |
4466 | if ( "getBoundingClientRect" in document.documentElement ) |
4711 | if ( "getBoundingClientRect" in document.documentElement ) { |
4467 | jQuery.fn.offset = function() { |
4712 | jQuery.fn.offset = function() { |
4468 | var elem = this[0]; |
4713 | var elem = this[0]; |
4469 | if ( !elem || !elem.ownerDocument ) return null; |
4714 | if ( !elem || !elem.ownerDocument ) { return null; } |
- | 4715 | if ( elem === elem.ownerDocument.body ) { |
|
4470 | if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem ); |
4716 | return jQuery.offset.bodyOffset( elem ); |
- | 4717 | }
|
|
- | 4718 | ||
4471 | var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, |
4719 | var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, |
4472 | clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
4720 | clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
4473 | top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
4721 | top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
4474 | left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
4722 | left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
4475 | return { top: top, left: left }; |
4723 | return { top: top, left: left }; |
4476 | }; |
4724 | }; |
4477 | else
|
4725 | } else { |
4478 | jQuery.fn.offset = function() { |
4726 | jQuery.fn.offset = function() { |
4479 | var elem = this[0]; |
4727 | var elem = this[0]; |
4480 | if ( !elem || !elem.ownerDocument ) return null; |
4728 | if ( !elem || !elem.ownerDocument ) { return null; } |
- | 4729 | if ( elem === elem.ownerDocument.body ) { |
|
4481 | if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem ); |
4730 | return jQuery.offset.bodyOffset( elem ); |
- | 4731 | }
|
|
- | 4732 | ||
4482 | jQuery.offset.initialize(); |
4733 | jQuery.offset.initialize(); |
4483 | 4734 | ||
4484 | var offsetParent = elem.offsetParent, prevOffsetParent = elem, |
4735 | var offsetParent = elem.offsetParent, prevOffsetParent = elem, |
4485 | doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
4736 | doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
4486 | body = doc.body, defaultView = doc.defaultView, |
4737 | body = doc.body, defaultView = doc.defaultView, |
4487 | prevComputedStyle = defaultView.getComputedStyle(elem, null), |
4738 | prevComputedStyle = defaultView.getComputedStyle(elem, null), |
4488 | top = elem.offsetTop, left = elem.offsetLeft; |
4739 | top = elem.offsetTop, left = elem.offsetLeft; |
4489 | 4740 | ||
4490 | while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
4741 | while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
4491 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) break; |
4742 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { break; } |
- | 4743 | ||
4492 | computedStyle = defaultView.getComputedStyle(elem, null); |
4744 | computedStyle = defaultView.getComputedStyle(elem, null); |
- | 4745 | top -= elem.scrollTop; |
|
4493 | top -= elem.scrollTop, left -= elem.scrollLeft; |
4746 | left -= elem.scrollLeft; |
- | 4747 | ||
4494 | if ( elem === offsetParent ) { |
4748 | if ( elem === offsetParent ) { |
- | 4749 | top += elem.offsetTop; |
|
4495 | top += elem.offsetTop, left += elem.offsetLeft; |
4750 | left += elem.offsetLeft; |
- | 4751 | ||
4496 | if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.tagName)) ) |
4752 | if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) { |
4497 | top += parseFloat( computedStyle.borderTopWidth ) || 0, |
4753 | top += parseFloat( computedStyle.borderTopWidth ) || 0; |
4498 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
4754 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
- | 4755 | }
|
|
- | 4756 | ||
4499 | prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
4757 | prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
4500 | }
|
4758 | }
|
- | 4759 | ||
4501 | if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) |
4760 | if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) { |
4502 | top += parseFloat( computedStyle.borderTopWidth ) || 0, |
4761 | top += parseFloat( computedStyle.borderTopWidth ) || 0; |
4503 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
4762 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
- | 4763 | }
|
|
- | 4764 | ||
4504 | prevComputedStyle = computedStyle; |
4765 | prevComputedStyle = computedStyle; |
4505 | }
|
4766 | }
|
4506 | 4767 | ||
4507 | if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) |
4768 | if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) { |
4508 | top += body.offsetTop, |
4769 | top += body.offsetTop; |
4509 | left += body.offsetLeft; |
4770 | left += body.offsetLeft; |
- | 4771 | }
|
|
4510 | 4772 | ||
4511 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) |
4773 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { |
4512 | top += Math.max( docElem.scrollTop, body.scrollTop ), |
4774 | top += Math.max( docElem.scrollTop, body.scrollTop ); |
4513 | left += Math.max( docElem.scrollLeft, body.scrollLeft ); |
4775 | left += Math.max( docElem.scrollLeft, body.scrollLeft ); |
- | 4776 | }
|
|
4514 | 4777 | ||
4515 | return { top: top, left: left }; |
4778 | return { top: top, left: left }; |
4516 | }; |
4779 | }; |
- | 4780 | }
|
|
4517 | 4781 | ||
4518 | jQuery.offset = { |
4782 | jQuery.offset = { |
4519 | initialize: function() { |
4783 | initialize: function() { |
4520 | var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0, |
4784 | var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0, |
4521 | html = '<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>'; |
4785 | html = '<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>'; |
4522 | 4786 | ||
4523 | jQuery.extend( container.style, { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' } ); |
4787 | jQuery.extend( container.style, { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' } ); |
4524 | 4788 | ||
4525 | container.innerHTML = html; |
4789 | container.innerHTML = html; |
4526 | body.insertBefore( container, body.firstChild ); |
4790 | body.insertBefore( container, body.firstChild ); |
- | 4791 | innerDiv = container.firstChild; |
|
- | 4792 | checkDiv = innerDiv.firstChild; |
|
4527 | innerDiv = container.firstChild, checkDiv = innerDiv.firstChild, td = innerDiv.nextSibling.firstChild.firstChild; |
4793 | td = innerDiv.nextSibling.firstChild.firstChild; |
4528 | 4794 | ||
4529 | this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
4795 | this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
4530 | this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
4796 | this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
4531 | 4797 | ||
4532 | checkDiv.style.position = 'fixed', checkDiv.style.top = '20px'; |
4798 | checkDiv.style.position = 'fixed', checkDiv.style.top = '20px'; |
- | 4799 | // safari subtracts parent border width here which is 5px
|
|
4533 | this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); // safari subtracts parent border width here which is 5px |
4800 | this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); |
4534 | checkDiv.style.position = '', checkDiv.style.top = ''; |
4801 | checkDiv.style.position = checkDiv.style.top = ''; |
4535 | 4802 | ||
4536 | innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; |
4803 | innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative'; |
4537 | this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
4804 | this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
4538 | 4805 | ||
4539 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
4806 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
4540 | 4807 | ||
4541 | body.removeChild( container ); |
4808 | body.removeChild( container ); |
4542 | jQuery.offset.initialize = function(){}; |
- | |
4543 | - | ||
4544 | body = container = innerDiv = checkDiv = table = td = null; |
4809 | body = container = innerDiv = checkDiv = table = td = null; |
- | 4810 | jQuery.offset.initialize = function(){}; |
|
4545 | }, |
4811 | }, |
4546 | 4812 | ||
4547 | bodyOffset: function(body) { |
4813 | bodyOffset: function(body) { |
4548 | jQuery.offset.initialize(); |
- | |
4549 | var top = body.offsetTop, left = body.offsetLeft; |
4814 | var top = body.offsetTop, left = body.offsetLeft; |
- | 4815 | ||
- | 4816 | jQuery.offset.initialize(); |
|
- | 4817 | ||
4550 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) |
4818 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) { |
4551 | top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0, |
4819 | top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0; |
4552 | left += parseFloat( jQuery.curCSS(body, 'marginLeft', true) ) || 0; |
4820 | left += parseFloat( jQuery.curCSS(body, 'marginLeft', true) ) || 0; |
- | 4821 | }
|
|
- | 4822 | ||
4553 | return { top: top, left: left }; |
4823 | return { top: top, left: left }; |
4554 | }
|
4824 | }
|
4555 | }; |
4825 | }; |
4556 | 4826 | ||
4557 | 4827 | ||
4558 | jQuery.fn.extend({ |
4828 | jQuery.fn.extend({ |
4559 | position: function() { |
4829 | position: function() { |
4560 | if ( !this[0] ) return null; |
4830 | if ( !this[0] ) { return null; } |
4561 | 4831 | ||
4562 | var elem = this[0], |
4832 | var elem = this[0], |
4563 | 4833 | ||
4564 | // Get *real* offsetParent
|
4834 | // Get *real* offsetParent
|
4565 | offsetParent = this.offsetParent(), |
4835 | offsetParent = this.offsetParent(), |
4566 | 4836 | ||
4567 | // Get correct offsets
|
4837 | // Get correct offsets
|
4568 | offset = this.offset(), |
4838 | offset = this.offset(), |
4569 | parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset(); |
4839 | parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); |
4570 | 4840 | ||
4571 | // Subtract element margins
|
4841 | // Subtract element margins
|
4572 | // note: when an element has margin: auto the offsetLeft and marginLeft
|
4842 | // note: when an element has margin: auto the offsetLeft and marginLeft
|
4573 | // are the same in Safari causing offset.left to incorrectly be 0
|
4843 | // are the same in Safari causing offset.left to incorrectly be 0
|
4574 | offset.top -= parseFloat( jQuery.curCSS(elem, 'marginTop', true) ) || 0; |
4844 | offset.top -= parseFloat( jQuery.curCSS(elem, 'marginTop', true) ) || 0; |
Строка 4584... | Строка 4854... | ||
4584 | left: offset.left - parentOffset.left |
4854 | left: offset.left - parentOffset.left |
4585 | }; |
4855 | }; |
4586 | }, |
4856 | }, |
4587 | 4857 | ||
4588 | offsetParent: function() { |
4858 | offsetParent: function() { |
- | 4859 | return this.map(function(){ |
|
4589 | var offsetParent = this[0].offsetParent || document.body; |
4860 | var offsetParent = this.offsetParent || document.body; |
4590 | while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') === 'static') ) |
4861 | while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, 'position') === 'static') ) { |
4591 | offsetParent = offsetParent.offsetParent; |
4862 | offsetParent = offsetParent.offsetParent; |
- | 4863 | }
|
|
4592 | return jQuery( offsetParent ); |
4864 | return offsetParent; |
- | 4865 | }); |
|
4593 | }
|
4866 | }
|
4594 | }); |
4867 | }); |
4595 | 4868 | ||
4596 | 4869 | ||
4597 | // Create scrollLeft and scrollTop methods
|
4870 | // Create scrollLeft and scrollTop methods
|
4598 | jQuery.each( ['Left', 'Top'], function(i, name) { |
4871 | jQuery.each( ['Left', 'Top'], function(i, name) { |
4599 | var method = 'scroll' + name; |
4872 | var method = 'scroll' + name; |
4600 | 4873 | ||
4601 | jQuery.fn[ method ] = function(val) { |
4874 | jQuery.fn[ method ] = function(val) { |
4602 | if ( !this[0] ) return null; |
4875 | var elem = this[0], win; |
4603 | 4876 | ||
4604 | var elem = this[0], win = ("scrollTo" in elem && elem.document) ? elem : |
- | |
4605 | (elem.nodeName === "#document") ? elem.defaultView || elem.parentWindow : |
- | |
4606 | false; |
- | |
4607 | - | ||
4608 | return val !== undefined ? |
4877 | if ( !elem ) { return null; } |
4609 | 4878 | ||
- | 4879 | if ( val !== undefined ) { |
|
4610 | // Set the scroll offset
|
4880 | // Set the scroll offset
|
4611 | this.each(function() { |
4881 | return this.each(function() { |
4612 | win = ("scrollTo" in this && this.document) ? this : |
4882 | win = getWindow( this ); |
4613 | (this.nodeName === "#document") ? this.defaultView || this.parentWindow : |
- | |
4614 | false; |
- | |
4615 | 4883 | ||
4616 | win ?
|
4884 | win ?
|
4617 | win.scrollTo( |
4885 | win.scrollTo( |
4618 | !i ? val : jQuery(win).scrollLeft(), |
4886 | !i ? val : jQuery(win).scrollLeft(), |
4619 | i ? val : jQuery(win).scrollTop() |
4887 | i ? val : jQuery(win).scrollTop() |
4620 | ) : |
4888 | ) : |
4621 | this[ method ] = val; |
4889 | this[ method ] = val; |
4622 | }) : |
4890 | }); |
- | 4891 | } else { |
|
- | 4892 | win = getWindow( elem ); |
|
4623 | 4893 | ||
4624 | // Return the scroll offset
|
4894 | // Return the scroll offset
|
4625 | win ?
|
- | |
4626 | win[ i ? 'pageYOffset' : 'pageXOffset' ] || |
4895 | return win ? ('pageXOffset' in win) ? win[ i ? 'pageYOffset' : 'pageXOffset' ] : |
4627 | jQuery.support.boxModel && win.document.documentElement[ method ] || |
4896 | jQuery.support.boxModel && win.document.documentElement[ method ] || |
4628 | win.document.body[ method ] : |
4897 | win.document.body[ method ] : |
4629 | elem[ method ]; |
4898 | elem[ method ]; |
- | 4899 | }
|
|
4630 | }; |
4900 | }; |
4631 | }); |
4901 | }); |
- | 4902 | ||
- | 4903 | function getWindow( elem ) { |
|
- | 4904 | return ("scrollTo" in elem && elem.document) ? |
|
- | 4905 | elem :
|
|
- | 4906 | elem.nodeType === 9 ? |
|
- | 4907 | elem.defaultView || elem.parentWindow : |
|
- | 4908 | false; |
|
- | 4909 | }
|
|
4632 | // Create innerHeight, innerWidth, outerHeight and outerWidth methods
|
4910 | // Create innerHeight, innerWidth, outerHeight and outerWidth methods
|
4633 | jQuery.each([ "Height", "Width" ], function(i, name){ |
4911 | jQuery.each([ "Height", "Width" ], function(i, name){ |
4634 | 4912 | ||
4635 | var type = name.toLowerCase(); |
4913 | var type = name.toLowerCase(); |
4636 | 4914 | ||
Строка 4656... | Строка 4934... | ||
4656 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
|
4934 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
|
4657 | elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || |
4935 | elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || |
4658 | elem.document.body[ "client" + name ] : |
4936 | elem.document.body[ "client" + name ] : |
4659 | 4937 | ||
4660 | // Get document width or height
|
4938 | // Get document width or height
|
4661 | (elem.nodeName === "#document") ? // is it a document |
4939 | (elem.nodeType === 9) ? // is it a document |
4662 | // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
|
4940 | // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
|
4663 | Math.max( |
4941 | Math.max( |
4664 | elem.documentElement["client" + name], |
4942 | elem.documentElement["client" + name], |
4665 | elem.body["scroll" + name], elem.documentElement["scroll" + name], |
4943 | elem.body["scroll" + name], elem.documentElement["scroll" + name], |
4666 | elem.body["offset" + name], elem.documentElement["offset" + name] |
4944 | elem.body["offset" + name], elem.documentElement["offset" + name] |