Index: branches/REL1_18/phase3/maintenance/backupPrefetch.inc |
— | — | @@ -51,7 +51,12 @@ |
52 | 52 | $this->infiles = explode(';',$infile); |
53 | 53 | $this->reader = new XMLReader(); |
54 | 54 | $infile = array_shift($this->infiles); |
55 | | - $this->reader->open( $infile ); |
| 55 | + if (defined( 'LIBXML_PARSEHUGE' ) ) { |
| 56 | + $this->reader->open( $infile, null, LIBXML_PARSEHUGE ); |
| 57 | + } |
| 58 | + else { |
| 59 | + $this->reader->open( $infile ); |
| 60 | + } |
56 | 61 | } |
57 | 62 | |
58 | 63 | /** |
Property changes on: branches/REL1_18/phase3/maintenance/backupPrefetch.inc |
___________________________________________________________________ |
Added: svn:mergeinfo |
59 | 64 | Merged /branches/REL1_15/phase3/maintenance/backupPrefetch.inc:r51646 |
60 | 65 | Merged /branches/REL1_17/phase3/maintenance/backupPrefetch.inc:r81445,81448 |
61 | 66 | Merged /branches/sqlite/maintenance/backupPrefetch.inc:r58211-58321 |
62 | 67 | Merged /trunk/phase3/maintenance/backupPrefetch.inc:r87586,87627-87628,87630,87632,87636,87640,87644,87840,87998,88085,88118,88124,88134,88231-88232,88250,88492,88498,88513,88750,89099,89108,90602,90612,90618,90626,90630-90631,90637,90655,90657,90666,90812,91967 |
63 | 68 | Merged /branches/new-installer/phase3/maintenance/backupPrefetch.inc:r43664-66004 |
Index: branches/REL1_18/phase3/includes/Import.php |
— | — | @@ -45,7 +45,12 @@ |
46 | 46 | |
47 | 47 | stream_wrapper_register( 'uploadsource', 'UploadSourceAdapter' ); |
48 | 48 | $id = UploadSourceAdapter::registerSource( $source ); |
49 | | - $this->reader->open( "uploadsource://$id" ); |
| 49 | + if (defined( 'LIBXML_PARSEHUGE' ) ) { |
| 50 | + $this->reader->open( "uploadsource://$id", null, LIBXML_PARSEHUGE ); |
| 51 | + } |
| 52 | + else { |
| 53 | + $this->reader->open( "uploadsource://$id" ); |
| 54 | + } |
50 | 55 | |
51 | 56 | // Default callbacks |
52 | 57 | $this->setRevisionCallback( array( $this, "importRevision" ) ); |
Property changes on: branches/REL1_18/phase3/includes/Import.php |
___________________________________________________________________ |
Added: svn:mergeinfo |
53 | 58 | Merged /branches/new-installer/phase3/includes/Import.php:r43664-66004 |
54 | 59 | Merged /branches/wmf-deployment/includes/Import.php:r53381 |
55 | 60 | Merged /branches/REL1_15/phase3/includes/Import.php:r51646 |
56 | 61 | Merged /branches/sqlite/includes/Import.php:r58211-58321 |
57 | 62 | Merged /trunk/phase3/includes/Import.php:r87586,87627-87628,87630,87840,87998,88085,88118,88124,88134,88231-88232,88250,88492,88498,88513,89099,89108,90602,90612,90618,90626,90630-90631,90637,90655,90657,90666,90812,91967 |
Index: branches/REL1_18/phase3/resources/jquery/jquery.js |
— | — | @@ -1,28 +1,30 @@ |
2 | 2 | /*! |
3 | | - * jQuery JavaScript Library v1.4.4 |
| 3 | + * jQuery JavaScript Library v1.6.2 |
4 | 4 | * http://jquery.com/ |
5 | 5 | * |
6 | | - * Copyright 2010, John Resig |
| 6 | + * Copyright 2011, John Resig |
7 | 7 | * Dual licensed under the MIT or GPL Version 2 licenses. |
8 | 8 | * http://jquery.org/license |
9 | 9 | * |
10 | 10 | * Includes Sizzle.js |
11 | 11 | * http://sizzlejs.com/ |
12 | | - * Copyright 2010, The Dojo Foundation |
| 12 | + * Copyright 2011, The Dojo Foundation |
13 | 13 | * Released under the MIT, BSD, and GPL Licenses. |
14 | 14 | * |
15 | | - * Date: Thu Nov 11 19:04:53 2010 -0500 |
| 15 | + * Date: Thu Jun 30 14:16:56 2011 -0400 |
16 | 16 | */ |
17 | 17 | (function( window, undefined ) { |
18 | 18 | |
19 | 19 | // Use the correct document accordingly with window argument (sandbox) |
20 | | -var document = window.document; |
| 20 | +var document = window.document, |
| 21 | + navigator = window.navigator, |
| 22 | + location = window.location; |
21 | 23 | var jQuery = (function() { |
22 | 24 | |
23 | 25 | // Define a local copy of jQuery |
24 | 26 | var jQuery = function( selector, context ) { |
25 | 27 | // The jQuery object is actually just the init constructor 'enhanced' |
26 | | - return new jQuery.fn.init( selector, context ); |
| 28 | + return new jQuery.fn.init( selector, context, rootjQuery ); |
27 | 29 | }, |
28 | 30 | |
29 | 31 | // Map over jQuery in case of overwrite |
— | — | @@ -36,22 +38,15 @@ |
37 | 39 | |
38 | 40 | // A simple way to check for HTML strings or ID strings |
39 | 41 | // (both of which we optimize for) |
40 | | - quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/, |
| 42 | + quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, |
41 | 43 | |
42 | | - // Is it a simple selector |
43 | | - isSimple = /^.[^:#\[\.,]*$/, |
44 | | - |
45 | 44 | // Check if a string has a non-whitespace character in it |
46 | 45 | rnotwhite = /\S/, |
47 | | - rwhite = /\s/, |
48 | 46 | |
49 | 47 | // Used for trimming whitespace |
50 | 48 | trimLeft = /^\s+/, |
51 | 49 | trimRight = /\s+$/, |
52 | 50 | |
53 | | - // Check for non-word characters |
54 | | - rnonword = /\W/, |
55 | | - |
56 | 51 | // Check for digits |
57 | 52 | rdigit = /\d/, |
58 | 53 | |
— | — | @@ -70,18 +65,23 @@ |
71 | 66 | rmsie = /(msie) ([\w.]+)/, |
72 | 67 | rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, |
73 | 68 | |
| 69 | + // Matches dashed string for camelizing |
| 70 | + rdashAlpha = /-([a-z])/ig, |
| 71 | + |
| 72 | + // Used by jQuery.camelCase as callback to replace() |
| 73 | + fcamelCase = function( all, letter ) { |
| 74 | + return letter.toUpperCase(); |
| 75 | + }, |
| 76 | + |
74 | 77 | // Keep a UserAgent string for use with jQuery.browser |
75 | 78 | userAgent = navigator.userAgent, |
76 | 79 | |
77 | 80 | // For matching the engine and version of the browser |
78 | 81 | browserMatch, |
79 | | - |
80 | | - // Has the ready events already been bound? |
81 | | - readyBound = false, |
82 | | - |
83 | | - // The functions to execute on DOM ready |
84 | | - readyList = [], |
85 | 82 | |
| 83 | + // The deferred used on DOM ready |
| 84 | + readyList, |
| 85 | + |
86 | 86 | // The ready event handler |
87 | 87 | DOMContentLoaded, |
88 | 88 | |
— | — | @@ -92,12 +92,13 @@ |
93 | 93 | slice = Array.prototype.slice, |
94 | 94 | trim = String.prototype.trim, |
95 | 95 | indexOf = Array.prototype.indexOf, |
96 | | - |
| 96 | + |
97 | 97 | // [[Class]] -> type pairs |
98 | 98 | class2type = {}; |
99 | 99 | |
100 | 100 | jQuery.fn = jQuery.prototype = { |
101 | | - init: function( selector, context ) { |
| 101 | + constructor: jQuery, |
| 102 | + init: function( selector, context, rootjQuery ) { |
102 | 103 | var match, elem, ret, doc; |
103 | 104 | |
104 | 105 | // Handle $(""), $(null), or $(undefined) |
— | — | @@ -111,12 +112,12 @@ |
112 | 113 | this.length = 1; |
113 | 114 | return this; |
114 | 115 | } |
115 | | - |
| 116 | + |
116 | 117 | // The body element only exists once, optimize finding it |
117 | 118 | if ( selector === "body" && !context && document.body ) { |
118 | 119 | this.context = document; |
119 | 120 | this[0] = document.body; |
120 | | - this.selector = "body"; |
| 121 | + this.selector = selector; |
121 | 122 | this.length = 1; |
122 | 123 | return this; |
123 | 124 | } |
— | — | @@ -124,13 +125,20 @@ |
125 | 126 | // Handle HTML strings |
126 | 127 | if ( typeof selector === "string" ) { |
127 | 128 | // Are we dealing with HTML string or an ID? |
128 | | - match = quickExpr.exec( selector ); |
| 129 | + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { |
| 130 | + // Assume that strings that start and end with <> are HTML and skip the regex check |
| 131 | + match = [ null, selector, null ]; |
129 | 132 | |
| 133 | + } else { |
| 134 | + match = quickExpr.exec( selector ); |
| 135 | + } |
| 136 | + |
130 | 137 | // Verify a match, and that no context was specified for #id |
131 | 138 | if ( match && (match[1] || !context) ) { |
132 | 139 | |
133 | 140 | // HANDLE: $(html) -> $(array) |
134 | 141 | if ( match[1] ) { |
| 142 | + context = context instanceof jQuery ? context[0] : context; |
135 | 143 | doc = (context ? context.ownerDocument || context : document); |
136 | 144 | |
137 | 145 | // If a single string is passed in and it's a single tag |
— | — | @@ -148,11 +156,11 @@ |
149 | 157 | |
150 | 158 | } else { |
151 | 159 | ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); |
152 | | - selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; |
| 160 | + selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes; |
153 | 161 | } |
154 | | - |
| 162 | + |
155 | 163 | return jQuery.merge( this, selector ); |
156 | | - |
| 164 | + |
157 | 165 | // HANDLE: $("#id") |
158 | 166 | } else { |
159 | 167 | elem = document.getElementById( match[2] ); |
— | — | @@ -176,13 +184,6 @@ |
177 | 185 | return this; |
178 | 186 | } |
179 | 187 | |
180 | | - // HANDLE: $("TAG") |
181 | | - } else if ( !context && !rnonword.test( selector ) ) { |
182 | | - this.selector = selector; |
183 | | - this.context = document; |
184 | | - selector = document.getElementsByTagName( selector ); |
185 | | - return jQuery.merge( this, selector ); |
186 | | - |
187 | 188 | // HANDLE: $(expr, $(...)) |
188 | 189 | } else if ( !context || context.jquery ) { |
189 | 190 | return (context || rootjQuery).find( selector ); |
— | — | @@ -190,7 +191,7 @@ |
191 | 192 | // HANDLE: $(expr, context) |
192 | 193 | // (which is just equivalent to: $(context).find(expr) |
193 | 194 | } else { |
194 | | - return jQuery( context ).find( selector ); |
| 195 | + return this.constructor( context ).find( selector ); |
195 | 196 | } |
196 | 197 | |
197 | 198 | // HANDLE: $(function) |
— | — | @@ -211,7 +212,7 @@ |
212 | 213 | selector: "", |
213 | 214 | |
214 | 215 | // The current version of jQuery being used |
215 | | - jquery: "1.4.4", |
| 216 | + jquery: "1.6.2", |
216 | 217 | |
217 | 218 | // The default length of a jQuery object is 0 |
218 | 219 | length: 0, |
— | — | @@ -234,18 +235,18 @@ |
235 | 236 | this.toArray() : |
236 | 237 | |
237 | 238 | // Return just the object |
238 | | - ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] ); |
| 239 | + ( num < 0 ? this[ this.length + num ] : this[ num ] ); |
239 | 240 | }, |
240 | 241 | |
241 | 242 | // Take an array of elements and push it onto the stack |
242 | 243 | // (returning the new matched element set) |
243 | 244 | pushStack: function( elems, name, selector ) { |
244 | 245 | // Build a new jQuery matched element set |
245 | | - var ret = jQuery(); |
| 246 | + var ret = this.constructor(); |
246 | 247 | |
247 | 248 | if ( jQuery.isArray( elems ) ) { |
248 | 249 | push.apply( ret, elems ); |
249 | | - |
| 250 | + |
250 | 251 | } else { |
251 | 252 | jQuery.merge( ret, elems ); |
252 | 253 | } |
— | — | @@ -271,25 +272,17 @@ |
272 | 273 | each: function( callback, args ) { |
273 | 274 | return jQuery.each( this, callback, args ); |
274 | 275 | }, |
275 | | - |
| 276 | + |
276 | 277 | ready: function( fn ) { |
277 | 278 | // Attach the listeners |
278 | 279 | jQuery.bindReady(); |
279 | 280 | |
280 | | - // If the DOM is already ready |
281 | | - if ( jQuery.isReady ) { |
282 | | - // Execute the function immediately |
283 | | - fn.call( document, jQuery ); |
| 281 | + // Add the callback |
| 282 | + readyList.done( fn ); |
284 | 283 | |
285 | | - // Otherwise, remember the function for later |
286 | | - } else if ( readyList ) { |
287 | | - // Add the function to the wait list |
288 | | - readyList.push( fn ); |
289 | | - } |
290 | | - |
291 | 284 | return this; |
292 | 285 | }, |
293 | | - |
| 286 | + |
294 | 287 | eq: function( i ) { |
295 | 288 | return i === -1 ? |
296 | 289 | this.slice( i ) : |
— | — | @@ -314,9 +307,9 @@ |
315 | 308 | return callback.call( elem, i, elem ); |
316 | 309 | })); |
317 | 310 | }, |
318 | | - |
| 311 | + |
319 | 312 | end: function() { |
320 | | - return this.prevObject || jQuery(null); |
| 313 | + return this.prevObject || this.constructor(null); |
321 | 314 | }, |
322 | 315 | |
323 | 316 | // For internal use only. |
— | — | @@ -330,7 +323,7 @@ |
331 | 324 | jQuery.fn.init.prototype = jQuery.fn; |
332 | 325 | |
333 | 326 | jQuery.extend = jQuery.fn.extend = function() { |
334 | | - var options, name, src, copy, copyIsArray, clone, |
| 327 | + var options, name, src, copy, copyIsArray, clone, |
335 | 328 | target = arguments[0] || {}, |
336 | 329 | i = 1, |
337 | 330 | length = arguments.length, |
— | — | @@ -395,31 +388,37 @@ |
396 | 389 | |
397 | 390 | jQuery.extend({ |
398 | 391 | noConflict: function( deep ) { |
399 | | - window.$ = _$; |
| 392 | + if ( window.$ === jQuery ) { |
| 393 | + window.$ = _$; |
| 394 | + } |
400 | 395 | |
401 | | - if ( deep ) { |
| 396 | + if ( deep && window.jQuery === jQuery ) { |
402 | 397 | window.jQuery = _jQuery; |
403 | 398 | } |
404 | 399 | |
405 | 400 | return jQuery; |
406 | 401 | }, |
407 | | - |
| 402 | + |
408 | 403 | // Is the DOM ready to be used? Set to true once it occurs. |
409 | 404 | isReady: false, |
410 | 405 | |
411 | 406 | // A counter to track how many items to wait for before |
412 | 407 | // the ready event fires. See #6781 |
413 | 408 | readyWait: 1, |
414 | | - |
| 409 | + |
| 410 | + // Hold (or release) the ready event |
| 411 | + holdReady: function( hold ) { |
| 412 | + if ( hold ) { |
| 413 | + jQuery.readyWait++; |
| 414 | + } else { |
| 415 | + jQuery.ready( true ); |
| 416 | + } |
| 417 | + }, |
| 418 | + |
415 | 419 | // Handle when the DOM is ready |
416 | 420 | ready: function( wait ) { |
417 | | - // A third-party is pushing the ready event forwards |
418 | | - if ( wait === true ) { |
419 | | - jQuery.readyWait--; |
420 | | - } |
421 | | - |
422 | | - // Make sure that the DOM is not already loaded |
423 | | - if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) { |
| 421 | + // Either a released hold or an DOMready/load event and not yet ready |
| 422 | + if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { |
424 | 423 | // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). |
425 | 424 | if ( !document.body ) { |
426 | 425 | return setTimeout( jQuery.ready, 1 ); |
— | — | @@ -434,33 +433,21 @@ |
435 | 434 | } |
436 | 435 | |
437 | 436 | // If there are functions bound, to execute |
438 | | - if ( readyList ) { |
439 | | - // Execute all of them |
440 | | - var fn, |
441 | | - i = 0, |
442 | | - ready = readyList; |
| 437 | + readyList.resolveWith( document, [ jQuery ] ); |
443 | 438 | |
444 | | - // Reset the list of functions |
445 | | - readyList = null; |
446 | | - |
447 | | - while ( (fn = ready[ i++ ]) ) { |
448 | | - fn.call( document, jQuery ); |
449 | | - } |
450 | | - |
451 | | - // Trigger any bound ready events |
452 | | - if ( jQuery.fn.trigger ) { |
453 | | - jQuery( document ).trigger( "ready" ).unbind( "ready" ); |
454 | | - } |
| 439 | + // Trigger any bound ready events |
| 440 | + if ( jQuery.fn.trigger ) { |
| 441 | + jQuery( document ).trigger( "ready" ).unbind( "ready" ); |
455 | 442 | } |
456 | 443 | } |
457 | 444 | }, |
458 | | - |
| 445 | + |
459 | 446 | bindReady: function() { |
460 | | - if ( readyBound ) { |
| 447 | + if ( readyList ) { |
461 | 448 | return; |
462 | 449 | } |
463 | 450 | |
464 | | - readyBound = true; |
| 451 | + readyList = jQuery._Deferred(); |
465 | 452 | |
466 | 453 | // Catch cases where $(document).ready() is called after the |
467 | 454 | // browser event has already occurred. |
— | — | @@ -473,7 +460,7 @@ |
474 | 461 | if ( document.addEventListener ) { |
475 | 462 | // Use the handy event callback |
476 | 463 | document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
477 | | - |
| 464 | + |
478 | 465 | // A fallback to window.onload, that will always work |
479 | 466 | window.addEventListener( "load", jQuery.ready, false ); |
480 | 467 | |
— | — | @@ -481,8 +468,8 @@ |
482 | 469 | } else if ( document.attachEvent ) { |
483 | 470 | // ensure firing before onload, |
484 | 471 | // maybe late but safe also for iframes |
485 | | - document.attachEvent("onreadystatechange", DOMContentLoaded); |
486 | | - |
| 472 | + document.attachEvent( "onreadystatechange", DOMContentLoaded ); |
| 473 | + |
487 | 474 | // A fallback to window.onload, that will always work |
488 | 475 | window.attachEvent( "onload", jQuery.ready ); |
489 | 476 | |
— | — | @@ -533,20 +520,20 @@ |
534 | 521 | if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { |
535 | 522 | return false; |
536 | 523 | } |
537 | | - |
| 524 | + |
538 | 525 | // Not own constructor property must be Object |
539 | 526 | if ( obj.constructor && |
540 | 527 | !hasOwn.call(obj, "constructor") && |
541 | 528 | !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { |
542 | 529 | return false; |
543 | 530 | } |
544 | | - |
| 531 | + |
545 | 532 | // Own properties are enumerated firstly, so to speed up, |
546 | 533 | // if last one is own, then all properties are own. |
547 | | - |
| 534 | + |
548 | 535 | var key; |
549 | 536 | for ( key in obj ) {} |
550 | | - |
| 537 | + |
551 | 538 | return key === undefined || hasOwn.call( obj, key ); |
552 | 539 | }, |
553 | 540 | |
— | — | @@ -556,11 +543,11 @@ |
557 | 544 | } |
558 | 545 | return true; |
559 | 546 | }, |
560 | | - |
| 547 | + |
561 | 548 | error: function( msg ) { |
562 | 549 | throw msg; |
563 | 550 | }, |
564 | | - |
| 551 | + |
565 | 552 | parseJSON: function( data ) { |
566 | 553 | if ( typeof data !== "string" || !data ) { |
567 | 554 | return null; |
— | — | @@ -568,48 +555,68 @@ |
569 | 556 | |
570 | 557 | // Make sure leading/trailing whitespace is removed (IE can't handle it) |
571 | 558 | data = jQuery.trim( data ); |
572 | | - |
| 559 | + |
| 560 | + // Attempt to parse using the native JSON parser first |
| 561 | + if ( window.JSON && window.JSON.parse ) { |
| 562 | + return window.JSON.parse( data ); |
| 563 | + } |
| 564 | + |
573 | 565 | // Make sure the incoming data is actual JSON |
574 | 566 | // Logic borrowed from http://json.org/json2.js |
575 | | - if ( rvalidchars.test(data.replace(rvalidescape, "@") |
576 | | - .replace(rvalidtokens, "]") |
577 | | - .replace(rvalidbraces, "")) ) { |
| 567 | + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) |
| 568 | + .replace( rvalidtokens, "]" ) |
| 569 | + .replace( rvalidbraces, "")) ) { |
578 | 570 | |
579 | | - // Try to use the native JSON parser first |
580 | | - return window.JSON && window.JSON.parse ? |
581 | | - window.JSON.parse( data ) : |
582 | | - (new Function("return " + data))(); |
| 571 | + return (new Function( "return " + data ))(); |
583 | 572 | |
584 | | - } else { |
585 | | - jQuery.error( "Invalid JSON: " + data ); |
586 | 573 | } |
| 574 | + jQuery.error( "Invalid JSON: " + data ); |
587 | 575 | }, |
588 | 576 | |
589 | | - noop: function() {}, |
| 577 | + // Cross-browser xml parsing |
| 578 | + // (xml & tmp used internally) |
| 579 | + parseXML: function( data , xml , tmp ) { |
590 | 580 | |
591 | | - // Evalulates a script in a global context |
592 | | - globalEval: function( data ) { |
593 | | - if ( data && rnotwhite.test(data) ) { |
594 | | - // Inspired by code by Andrea Giammarchi |
595 | | - // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html |
596 | | - var head = document.getElementsByTagName("head")[0] || document.documentElement, |
597 | | - script = document.createElement("script"); |
| 581 | + if ( window.DOMParser ) { // Standard |
| 582 | + tmp = new DOMParser(); |
| 583 | + xml = tmp.parseFromString( data , "text/xml" ); |
| 584 | + } else { // IE |
| 585 | + xml = new ActiveXObject( "Microsoft.XMLDOM" ); |
| 586 | + xml.async = "false"; |
| 587 | + xml.loadXML( data ); |
| 588 | + } |
598 | 589 | |
599 | | - script.type = "text/javascript"; |
| 590 | + tmp = xml.documentElement; |
600 | 591 | |
601 | | - if ( jQuery.support.scriptEval ) { |
602 | | - script.appendChild( document.createTextNode( data ) ); |
603 | | - } else { |
604 | | - script.text = data; |
605 | | - } |
| 592 | + if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) { |
| 593 | + jQuery.error( "Invalid XML: " + data ); |
| 594 | + } |
606 | 595 | |
607 | | - // Use insertBefore instead of appendChild to circumvent an IE6 bug. |
608 | | - // This arises when a base node is used (#2709). |
609 | | - head.insertBefore( script, head.firstChild ); |
610 | | - head.removeChild( script ); |
| 596 | + return xml; |
| 597 | + }, |
| 598 | + |
| 599 | + noop: function() {}, |
| 600 | + |
| 601 | + // Evaluates a script in a global context |
| 602 | + // Workarounds based on findings by Jim Driscoll |
| 603 | + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context |
| 604 | + globalEval: function( data ) { |
| 605 | + if ( data && rnotwhite.test( data ) ) { |
| 606 | + // We use execScript on Internet Explorer |
| 607 | + // We use an anonymous function so that context is window |
| 608 | + // rather than jQuery in Firefox |
| 609 | + ( window.execScript || function( data ) { |
| 610 | + window[ "eval" ].call( window, data ); |
| 611 | + } )( data ); |
611 | 612 | } |
612 | 613 | }, |
613 | 614 | |
| 615 | + // Converts a dashed string to camelCased string; |
| 616 | + // Used by both the css and data modules |
| 617 | + camelCase: function( string ) { |
| 618 | + return string.replace( rdashAlpha, fcamelCase ); |
| 619 | + }, |
| 620 | + |
614 | 621 | nodeName: function( elem, name ) { |
615 | 622 | return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); |
616 | 623 | }, |
— | — | @@ -618,7 +625,7 @@ |
619 | 626 | each: function( object, callback, args ) { |
620 | 627 | var name, i = 0, |
621 | 628 | length = object.length, |
622 | | - isObj = length === undefined || jQuery.isFunction(object); |
| 629 | + isObj = length === undefined || jQuery.isFunction( object ); |
623 | 630 | |
624 | 631 | if ( args ) { |
625 | 632 | if ( isObj ) { |
— | — | @@ -644,8 +651,11 @@ |
645 | 652 | } |
646 | 653 | } |
647 | 654 | } else { |
648 | | - for ( var value = object[0]; |
649 | | - i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {} |
| 655 | + for ( ; i < length; ) { |
| 656 | + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { |
| 657 | + break; |
| 658 | + } |
| 659 | + } |
650 | 660 | } |
651 | 661 | } |
652 | 662 | |
— | — | @@ -676,7 +686,7 @@ |
677 | 687 | // The extra typeof function check is to prevent crashes |
678 | 688 | // in Safari 2 (See: #3039) |
679 | 689 | // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 |
680 | | - var type = jQuery.type(array); |
| 690 | + var type = jQuery.type( array ); |
681 | 691 | |
682 | 692 | if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { |
683 | 693 | push.call( ret, array ); |
— | — | @@ -689,8 +699,9 @@ |
690 | 700 | }, |
691 | 701 | |
692 | 702 | inArray: function( elem, array ) { |
693 | | - if ( array.indexOf ) { |
694 | | - return array.indexOf( elem ); |
| 703 | + |
| 704 | + if ( indexOf ) { |
| 705 | + return indexOf.call( array, elem ); |
695 | 706 | } |
696 | 707 | |
697 | 708 | for ( var i = 0, length = array.length; i < length; i++ ) { |
— | — | @@ -710,7 +721,7 @@ |
711 | 722 | for ( var l = second.length; j < l; j++ ) { |
712 | 723 | first[ i++ ] = second[ j ]; |
713 | 724 | } |
714 | | - |
| 725 | + |
715 | 726 | } else { |
716 | 727 | while ( second[j] !== undefined ) { |
717 | 728 | first[ i++ ] = second[ j++ ]; |
— | — | @@ -740,57 +751,72 @@ |
741 | 752 | |
742 | 753 | // arg is for internal usage only |
743 | 754 | map: function( elems, callback, arg ) { |
744 | | - var ret = [], value; |
| 755 | + var value, key, ret = [], |
| 756 | + i = 0, |
| 757 | + length = elems.length, |
| 758 | + // jquery objects are treated as arrays |
| 759 | + isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; |
745 | 760 | |
746 | 761 | // Go through the array, translating each of the items to their |
747 | | - // new value (or values). |
748 | | - for ( var i = 0, length = elems.length; i < length; i++ ) { |
749 | | - value = callback( elems[ i ], i, arg ); |
| 762 | + if ( isArray ) { |
| 763 | + for ( ; i < length; i++ ) { |
| 764 | + value = callback( elems[ i ], i, arg ); |
750 | 765 | |
751 | | - if ( value != null ) { |
752 | | - ret[ ret.length ] = value; |
| 766 | + if ( value != null ) { |
| 767 | + ret[ ret.length ] = value; |
| 768 | + } |
753 | 769 | } |
| 770 | + |
| 771 | + // Go through every key on the object, |
| 772 | + } else { |
| 773 | + for ( key in elems ) { |
| 774 | + value = callback( elems[ key ], key, arg ); |
| 775 | + |
| 776 | + if ( value != null ) { |
| 777 | + ret[ ret.length ] = value; |
| 778 | + } |
| 779 | + } |
754 | 780 | } |
755 | 781 | |
| 782 | + // Flatten any nested arrays |
756 | 783 | return ret.concat.apply( [], ret ); |
757 | 784 | }, |
758 | 785 | |
759 | 786 | // A global GUID counter for objects |
760 | 787 | guid: 1, |
761 | 788 | |
762 | | - proxy: function( fn, proxy, thisObject ) { |
763 | | - if ( arguments.length === 2 ) { |
764 | | - if ( typeof proxy === "string" ) { |
765 | | - thisObject = fn; |
766 | | - fn = thisObject[ proxy ]; |
767 | | - proxy = undefined; |
| 789 | + // Bind a function to a context, optionally partially applying any |
| 790 | + // arguments. |
| 791 | + proxy: function( fn, context ) { |
| 792 | + if ( typeof context === "string" ) { |
| 793 | + var tmp = fn[ context ]; |
| 794 | + context = fn; |
| 795 | + fn = tmp; |
| 796 | + } |
768 | 797 | |
769 | | - } else if ( proxy && !jQuery.isFunction( proxy ) ) { |
770 | | - thisObject = proxy; |
771 | | - proxy = undefined; |
772 | | - } |
| 798 | + // Quick check to determine if target is callable, in the spec |
| 799 | + // this throws a TypeError, but we will just return undefined. |
| 800 | + if ( !jQuery.isFunction( fn ) ) { |
| 801 | + return undefined; |
773 | 802 | } |
774 | 803 | |
775 | | - if ( !proxy && fn ) { |
| 804 | + // Simulated bind |
| 805 | + var args = slice.call( arguments, 2 ), |
776 | 806 | proxy = function() { |
777 | | - return fn.apply( thisObject || this, arguments ); |
| 807 | + return fn.apply( context, args.concat( slice.call( arguments ) ) ); |
778 | 808 | }; |
779 | | - } |
780 | 809 | |
781 | 810 | // Set the guid of unique handler to the same of original handler, so it can be removed |
782 | | - if ( fn ) { |
783 | | - proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; |
784 | | - } |
| 811 | + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; |
785 | 812 | |
786 | | - // So proxy can be declared as an argument |
787 | 813 | return proxy; |
788 | 814 | }, |
789 | 815 | |
790 | 816 | // Mutifunctional method to get and set values to a collection |
791 | | - // The value/s can be optionally by executed if its a function |
| 817 | + // The value/s can optionally be executed if it's a function |
792 | 818 | access: function( elems, key, value, exec, fn, pass ) { |
793 | 819 | var length = elems.length; |
794 | | - |
| 820 | + |
795 | 821 | // Setting many attributes |
796 | 822 | if ( typeof key === "object" ) { |
797 | 823 | for ( var k in key ) { |
— | — | @@ -798,19 +824,19 @@ |
799 | 825 | } |
800 | 826 | return elems; |
801 | 827 | } |
802 | | - |
| 828 | + |
803 | 829 | // Setting one attribute |
804 | 830 | if ( value !== undefined ) { |
805 | 831 | // Optionally, function values get executed if exec is true |
806 | 832 | exec = !pass && exec && jQuery.isFunction(value); |
807 | | - |
| 833 | + |
808 | 834 | for ( var i = 0; i < length; i++ ) { |
809 | 835 | fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); |
810 | 836 | } |
811 | | - |
| 837 | + |
812 | 838 | return elems; |
813 | 839 | } |
814 | | - |
| 840 | + |
815 | 841 | // Getting an attribute |
816 | 842 | return length ? fn( elems[0], key ) : undefined; |
817 | 843 | }, |
— | — | @@ -833,6 +859,27 @@ |
834 | 860 | return { browser: match[1] || "", version: match[2] || "0" }; |
835 | 861 | }, |
836 | 862 | |
| 863 | + sub: function() { |
| 864 | + function jQuerySub( selector, context ) { |
| 865 | + return new jQuerySub.fn.init( selector, context ); |
| 866 | + } |
| 867 | + jQuery.extend( true, jQuerySub, this ); |
| 868 | + jQuerySub.superclass = this; |
| 869 | + jQuerySub.fn = jQuerySub.prototype = this(); |
| 870 | + jQuerySub.fn.constructor = jQuerySub; |
| 871 | + jQuerySub.sub = this.sub; |
| 872 | + jQuerySub.fn.init = function init( selector, context ) { |
| 873 | + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { |
| 874 | + context = jQuerySub( context ); |
| 875 | + } |
| 876 | + |
| 877 | + return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); |
| 878 | + }; |
| 879 | + jQuerySub.fn.init.prototype = jQuerySub.fn; |
| 880 | + var rootjQuerySub = jQuerySub(document); |
| 881 | + return jQuerySub; |
| 882 | + }, |
| 883 | + |
837 | 884 | browser: {} |
838 | 885 | }); |
839 | 886 | |
— | — | @@ -852,15 +899,8 @@ |
853 | 900 | jQuery.browser.safari = true; |
854 | 901 | } |
855 | 902 | |
856 | | -if ( indexOf ) { |
857 | | - jQuery.inArray = function( elem, array ) { |
858 | | - return indexOf.call( array, elem ); |
859 | | - }; |
860 | | -} |
861 | | - |
862 | | -// Verify that \s matches non-breaking spaces |
863 | | -// (IE fails on this test) |
864 | | -if ( !rwhite.test( "\xA0" ) ) { |
| 903 | +// IE doesn't match non-breaking spaces with \s |
| 904 | +if ( rnotwhite.test( "\xA0" ) ) { |
865 | 905 | trimLeft = /^[\s\xA0]+/; |
866 | 906 | trimRight = /[\s\xA0]+$/; |
867 | 907 | } |
— | — | @@ -904,53 +944,267 @@ |
905 | 945 | jQuery.ready(); |
906 | 946 | } |
907 | 947 | |
908 | | -// Expose jQuery to the global object |
909 | | -return (window.jQuery = window.$ = jQuery); |
| 948 | +return jQuery; |
910 | 949 | |
911 | 950 | })(); |
912 | 951 | |
913 | 952 | |
914 | | -(function() { |
| 953 | +var // Promise methods |
| 954 | + promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ), |
| 955 | + // Static reference to slice |
| 956 | + sliceDeferred = [].slice; |
915 | 957 | |
916 | | - jQuery.support = {}; |
| 958 | +jQuery.extend({ |
| 959 | + // Create a simple deferred (one callbacks list) |
| 960 | + _Deferred: function() { |
| 961 | + var // callbacks list |
| 962 | + callbacks = [], |
| 963 | + // stored [ context , args ] |
| 964 | + fired, |
| 965 | + // to avoid firing when already doing so |
| 966 | + firing, |
| 967 | + // flag to know if the deferred has been cancelled |
| 968 | + cancelled, |
| 969 | + // the deferred itself |
| 970 | + deferred = { |
917 | 971 | |
918 | | - var root = document.documentElement, |
919 | | - script = document.createElement("script"), |
920 | | - div = document.createElement("div"), |
921 | | - id = "script" + jQuery.now(); |
| 972 | + // done( f1, f2, ...) |
| 973 | + done: function() { |
| 974 | + if ( !cancelled ) { |
| 975 | + var args = arguments, |
| 976 | + i, |
| 977 | + length, |
| 978 | + elem, |
| 979 | + type, |
| 980 | + _fired; |
| 981 | + if ( fired ) { |
| 982 | + _fired = fired; |
| 983 | + fired = 0; |
| 984 | + } |
| 985 | + for ( i = 0, length = args.length; i < length; i++ ) { |
| 986 | + elem = args[ i ]; |
| 987 | + type = jQuery.type( elem ); |
| 988 | + if ( type === "array" ) { |
| 989 | + deferred.done.apply( deferred, elem ); |
| 990 | + } else if ( type === "function" ) { |
| 991 | + callbacks.push( elem ); |
| 992 | + } |
| 993 | + } |
| 994 | + if ( _fired ) { |
| 995 | + deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] ); |
| 996 | + } |
| 997 | + } |
| 998 | + return this; |
| 999 | + }, |
922 | 1000 | |
923 | | - div.style.display = "none"; |
924 | | - div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>"; |
| 1001 | + // resolve with given context and args |
| 1002 | + resolveWith: function( context, args ) { |
| 1003 | + if ( !cancelled && !fired && !firing ) { |
| 1004 | + // make sure args are available (#8421) |
| 1005 | + args = args || []; |
| 1006 | + firing = 1; |
| 1007 | + try { |
| 1008 | + while( callbacks[ 0 ] ) { |
| 1009 | + callbacks.shift().apply( context, args ); |
| 1010 | + } |
| 1011 | + } |
| 1012 | + finally { |
| 1013 | + fired = [ context, args ]; |
| 1014 | + firing = 0; |
| 1015 | + } |
| 1016 | + } |
| 1017 | + return this; |
| 1018 | + }, |
925 | 1019 | |
926 | | - var all = div.getElementsByTagName("*"), |
927 | | - a = div.getElementsByTagName("a")[0], |
928 | | - select = document.createElement("select"), |
929 | | - opt = select.appendChild( document.createElement("option") ); |
| 1020 | + // resolve with this as context and given arguments |
| 1021 | + resolve: function() { |
| 1022 | + deferred.resolveWith( this, arguments ); |
| 1023 | + return this; |
| 1024 | + }, |
930 | 1025 | |
| 1026 | + // Has this deferred been resolved? |
| 1027 | + isResolved: function() { |
| 1028 | + return !!( firing || fired ); |
| 1029 | + }, |
| 1030 | + |
| 1031 | + // Cancel |
| 1032 | + cancel: function() { |
| 1033 | + cancelled = 1; |
| 1034 | + callbacks = []; |
| 1035 | + return this; |
| 1036 | + } |
| 1037 | + }; |
| 1038 | + |
| 1039 | + return deferred; |
| 1040 | + }, |
| 1041 | + |
| 1042 | + // Full fledged deferred (two callbacks list) |
| 1043 | + Deferred: function( func ) { |
| 1044 | + var deferred = jQuery._Deferred(), |
| 1045 | + failDeferred = jQuery._Deferred(), |
| 1046 | + promise; |
| 1047 | + // Add errorDeferred methods, then and promise |
| 1048 | + jQuery.extend( deferred, { |
| 1049 | + then: function( doneCallbacks, failCallbacks ) { |
| 1050 | + deferred.done( doneCallbacks ).fail( failCallbacks ); |
| 1051 | + return this; |
| 1052 | + }, |
| 1053 | + always: function() { |
| 1054 | + return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments ); |
| 1055 | + }, |
| 1056 | + fail: failDeferred.done, |
| 1057 | + rejectWith: failDeferred.resolveWith, |
| 1058 | + reject: failDeferred.resolve, |
| 1059 | + isRejected: failDeferred.isResolved, |
| 1060 | + pipe: function( fnDone, fnFail ) { |
| 1061 | + return jQuery.Deferred(function( newDefer ) { |
| 1062 | + jQuery.each( { |
| 1063 | + done: [ fnDone, "resolve" ], |
| 1064 | + fail: [ fnFail, "reject" ] |
| 1065 | + }, function( handler, data ) { |
| 1066 | + var fn = data[ 0 ], |
| 1067 | + action = data[ 1 ], |
| 1068 | + returned; |
| 1069 | + if ( jQuery.isFunction( fn ) ) { |
| 1070 | + deferred[ handler ](function() { |
| 1071 | + returned = fn.apply( this, arguments ); |
| 1072 | + if ( returned && jQuery.isFunction( returned.promise ) ) { |
| 1073 | + returned.promise().then( newDefer.resolve, newDefer.reject ); |
| 1074 | + } else { |
| 1075 | + newDefer[ action ]( returned ); |
| 1076 | + } |
| 1077 | + }); |
| 1078 | + } else { |
| 1079 | + deferred[ handler ]( newDefer[ action ] ); |
| 1080 | + } |
| 1081 | + }); |
| 1082 | + }).promise(); |
| 1083 | + }, |
| 1084 | + // Get a promise for this deferred |
| 1085 | + // If obj is provided, the promise aspect is added to the object |
| 1086 | + promise: function( obj ) { |
| 1087 | + if ( obj == null ) { |
| 1088 | + if ( promise ) { |
| 1089 | + return promise; |
| 1090 | + } |
| 1091 | + promise = obj = {}; |
| 1092 | + } |
| 1093 | + var i = promiseMethods.length; |
| 1094 | + while( i-- ) { |
| 1095 | + obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ]; |
| 1096 | + } |
| 1097 | + return obj; |
| 1098 | + } |
| 1099 | + }); |
| 1100 | + // Make sure only one callback list will be used |
| 1101 | + deferred.done( failDeferred.cancel ).fail( deferred.cancel ); |
| 1102 | + // Unexpose cancel |
| 1103 | + delete deferred.cancel; |
| 1104 | + // Call given func if any |
| 1105 | + if ( func ) { |
| 1106 | + func.call( deferred, deferred ); |
| 1107 | + } |
| 1108 | + return deferred; |
| 1109 | + }, |
| 1110 | + |
| 1111 | + // Deferred helper |
| 1112 | + when: function( firstParam ) { |
| 1113 | + var args = arguments, |
| 1114 | + i = 0, |
| 1115 | + length = args.length, |
| 1116 | + count = length, |
| 1117 | + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? |
| 1118 | + firstParam : |
| 1119 | + jQuery.Deferred(); |
| 1120 | + function resolveFunc( i ) { |
| 1121 | + return function( value ) { |
| 1122 | + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; |
| 1123 | + if ( !( --count ) ) { |
| 1124 | + // Strange bug in FF4: |
| 1125 | + // Values changed onto the arguments object sometimes end up as undefined values |
| 1126 | + // outside the $.when method. Cloning the object into a fresh array solves the issue |
| 1127 | + deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) ); |
| 1128 | + } |
| 1129 | + }; |
| 1130 | + } |
| 1131 | + if ( length > 1 ) { |
| 1132 | + for( ; i < length; i++ ) { |
| 1133 | + if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) { |
| 1134 | + args[ i ].promise().then( resolveFunc(i), deferred.reject ); |
| 1135 | + } else { |
| 1136 | + --count; |
| 1137 | + } |
| 1138 | + } |
| 1139 | + if ( !count ) { |
| 1140 | + deferred.resolveWith( deferred, args ); |
| 1141 | + } |
| 1142 | + } else if ( deferred !== firstParam ) { |
| 1143 | + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); |
| 1144 | + } |
| 1145 | + return deferred.promise(); |
| 1146 | + } |
| 1147 | +}); |
| 1148 | + |
| 1149 | + |
| 1150 | + |
| 1151 | +jQuery.support = (function() { |
| 1152 | + |
| 1153 | + var div = document.createElement( "div" ), |
| 1154 | + documentElement = document.documentElement, |
| 1155 | + all, |
| 1156 | + a, |
| 1157 | + select, |
| 1158 | + opt, |
| 1159 | + input, |
| 1160 | + marginDiv, |
| 1161 | + support, |
| 1162 | + fragment, |
| 1163 | + body, |
| 1164 | + testElementParent, |
| 1165 | + testElement, |
| 1166 | + testElementStyle, |
| 1167 | + tds, |
| 1168 | + events, |
| 1169 | + eventName, |
| 1170 | + i, |
| 1171 | + isSupported; |
| 1172 | + |
| 1173 | + // Preliminary tests |
| 1174 | + div.setAttribute("className", "t"); |
| 1175 | + div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>"; |
| 1176 | + |
| 1177 | + all = div.getElementsByTagName( "*" ); |
| 1178 | + a = div.getElementsByTagName( "a" )[ 0 ]; |
| 1179 | + |
931 | 1180 | // Can't get basic test support |
932 | 1181 | if ( !all || !all.length || !a ) { |
933 | | - return; |
| 1182 | + return {}; |
934 | 1183 | } |
935 | 1184 | |
936 | | - jQuery.support = { |
| 1185 | + // First batch of supports tests |
| 1186 | + select = document.createElement( "select" ); |
| 1187 | + opt = select.appendChild( document.createElement("option") ); |
| 1188 | + input = div.getElementsByTagName( "input" )[ 0 ]; |
| 1189 | + |
| 1190 | + support = { |
937 | 1191 | // IE strips leading whitespace when .innerHTML is used |
938 | | - leadingWhitespace: div.firstChild.nodeType === 3, |
| 1192 | + leadingWhitespace: ( div.firstChild.nodeType === 3 ), |
939 | 1193 | |
940 | 1194 | // Make sure that tbody elements aren't automatically inserted |
941 | 1195 | // IE will insert them into empty tables |
942 | | - tbody: !div.getElementsByTagName("tbody").length, |
| 1196 | + tbody: !div.getElementsByTagName( "tbody" ).length, |
943 | 1197 | |
944 | 1198 | // Make sure that link elements get serialized correctly by innerHTML |
945 | 1199 | // This requires a wrapper element in IE |
946 | | - htmlSerialize: !!div.getElementsByTagName("link").length, |
| 1200 | + htmlSerialize: !!div.getElementsByTagName( "link" ).length, |
947 | 1201 | |
948 | 1202 | // Get the style information from getAttribute |
949 | | - // (IE uses .cssText insted) |
950 | | - style: /red/.test( a.getAttribute("style") ), |
| 1203 | + // (IE uses .cssText instead) |
| 1204 | + style: /top/.test( a.getAttribute("style") ), |
951 | 1205 | |
952 | 1206 | // Make sure that URLs aren't manipulated |
953 | 1207 | // (IE normalizes it by default) |
954 | | - hrefNormalized: a.getAttribute("href") === "/a", |
| 1208 | + hrefNormalized: ( a.getAttribute( "href" ) === "/a" ), |
955 | 1209 | |
956 | 1210 | // Make sure that element opacity exists |
957 | 1211 | // (IE uses filter instead) |
— | — | @@ -964,159 +1218,203 @@ |
965 | 1219 | // Make sure that if no value is specified for a checkbox |
966 | 1220 | // that it defaults to "on". |
967 | 1221 | // (WebKit defaults to "" instead) |
968 | | - checkOn: div.getElementsByTagName("input")[0].value === "on", |
| 1222 | + checkOn: ( input.value === "on" ), |
969 | 1223 | |
970 | 1224 | // Make sure that a selected-by-default option has a working selected property. |
971 | 1225 | // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) |
972 | 1226 | optSelected: opt.selected, |
973 | 1227 | |
| 1228 | + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) |
| 1229 | + getSetAttribute: div.className !== "t", |
| 1230 | + |
974 | 1231 | // Will be defined later |
| 1232 | + submitBubbles: true, |
| 1233 | + changeBubbles: true, |
| 1234 | + focusinBubbles: false, |
975 | 1235 | deleteExpando: true, |
976 | | - optDisabled: false, |
977 | | - checkClone: false, |
978 | | - scriptEval: false, |
979 | 1236 | noCloneEvent: true, |
980 | | - boxModel: null, |
981 | 1237 | inlineBlockNeedsLayout: false, |
982 | 1238 | shrinkWrapBlocks: false, |
983 | | - reliableHiddenOffsets: true |
| 1239 | + reliableMarginRight: true |
984 | 1240 | }; |
985 | 1241 | |
| 1242 | + // Make sure checked status is properly cloned |
| 1243 | + input.checked = true; |
| 1244 | + support.noCloneChecked = input.cloneNode( true ).checked; |
| 1245 | + |
986 | 1246 | // Make sure that the options inside disabled selects aren't marked as disabled |
987 | | - // (WebKit marks them as diabled) |
| 1247 | + // (WebKit marks them as disabled) |
988 | 1248 | select.disabled = true; |
989 | | - jQuery.support.optDisabled = !opt.disabled; |
| 1249 | + support.optDisabled = !opt.disabled; |
990 | 1250 | |
991 | | - script.type = "text/javascript"; |
992 | | - try { |
993 | | - script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
994 | | - } catch(e) {} |
995 | | - |
996 | | - root.insertBefore( script, root.firstChild ); |
997 | | - |
998 | | - // Make sure that the execution of code works by injecting a script |
999 | | - // tag with appendChild/createTextNode |
1000 | | - // (IE doesn't support this, fails, and uses .text instead) |
1001 | | - if ( window[ id ] ) { |
1002 | | - jQuery.support.scriptEval = true; |
1003 | | - delete window[ id ]; |
1004 | | - } |
1005 | | - |
1006 | 1251 | // Test to see if it's possible to delete an expando from an element |
1007 | 1252 | // Fails in Internet Explorer |
1008 | 1253 | try { |
1009 | | - delete script.test; |
1010 | | - |
1011 | | - } catch(e) { |
1012 | | - jQuery.support.deleteExpando = false; |
| 1254 | + delete div.test; |
| 1255 | + } catch( e ) { |
| 1256 | + support.deleteExpando = false; |
1013 | 1257 | } |
1014 | 1258 | |
1015 | | - root.removeChild( script ); |
1016 | | - |
1017 | | - if ( div.attachEvent && div.fireEvent ) { |
1018 | | - div.attachEvent("onclick", function click() { |
| 1259 | + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { |
| 1260 | + div.attachEvent( "onclick", function() { |
1019 | 1261 | // Cloning a node shouldn't copy over any |
1020 | 1262 | // bound event handlers (IE does this) |
1021 | | - jQuery.support.noCloneEvent = false; |
1022 | | - div.detachEvent("onclick", click); |
| 1263 | + support.noCloneEvent = false; |
1023 | 1264 | }); |
1024 | | - div.cloneNode(true).fireEvent("onclick"); |
| 1265 | + div.cloneNode( true ).fireEvent( "onclick" ); |
1025 | 1266 | } |
1026 | 1267 | |
1027 | | - div = document.createElement("div"); |
1028 | | - div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>"; |
| 1268 | + // Check if a radio maintains it's value |
| 1269 | + // after being appended to the DOM |
| 1270 | + input = document.createElement("input"); |
| 1271 | + input.value = "t"; |
| 1272 | + input.setAttribute("type", "radio"); |
| 1273 | + support.radioValue = input.value === "t"; |
1029 | 1274 | |
1030 | | - var fragment = document.createDocumentFragment(); |
| 1275 | + input.setAttribute("checked", "checked"); |
| 1276 | + div.appendChild( input ); |
| 1277 | + fragment = document.createDocumentFragment(); |
1031 | 1278 | fragment.appendChild( div.firstChild ); |
1032 | 1279 | |
1033 | 1280 | // WebKit doesn't clone checked state correctly in fragments |
1034 | | - jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked; |
| 1281 | + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; |
1035 | 1282 | |
| 1283 | + div.innerHTML = ""; |
| 1284 | + |
1036 | 1285 | // Figure out if the W3C box model works as expected |
1037 | | - // document.body must exist before we can do this |
1038 | | - jQuery(function() { |
1039 | | - var div = document.createElement("div"); |
1040 | | - div.style.width = div.style.paddingLeft = "1px"; |
| 1286 | + div.style.width = div.style.paddingLeft = "1px"; |
1041 | 1287 | |
1042 | | - document.body.appendChild( div ); |
1043 | | - jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
| 1288 | + body = document.getElementsByTagName( "body" )[ 0 ]; |
| 1289 | + // We use our own, invisible, body unless the body is already present |
| 1290 | + // in which case we use a div (#9239) |
| 1291 | + testElement = document.createElement( body ? "div" : "body" ); |
| 1292 | + testElementStyle = { |
| 1293 | + visibility: "hidden", |
| 1294 | + width: 0, |
| 1295 | + height: 0, |
| 1296 | + border: 0, |
| 1297 | + margin: 0 |
| 1298 | + }; |
| 1299 | + if ( body ) { |
| 1300 | + jQuery.extend( testElementStyle, { |
| 1301 | + position: "absolute", |
| 1302 | + left: -1000, |
| 1303 | + top: -1000 |
| 1304 | + }); |
| 1305 | + } |
| 1306 | + for ( i in testElementStyle ) { |
| 1307 | + testElement.style[ i ] = testElementStyle[ i ]; |
| 1308 | + } |
| 1309 | + testElement.appendChild( div ); |
| 1310 | + testElementParent = body || documentElement; |
| 1311 | + testElementParent.insertBefore( testElement, testElementParent.firstChild ); |
1044 | 1312 | |
1045 | | - if ( "zoom" in div.style ) { |
1046 | | - // Check if natively block-level elements act like inline-block |
1047 | | - // elements when setting their display to 'inline' and giving |
1048 | | - // them layout |
1049 | | - // (IE < 8 does this) |
1050 | | - div.style.display = "inline"; |
1051 | | - div.style.zoom = 1; |
1052 | | - jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2; |
| 1313 | + // Check if a disconnected checkbox will retain its checked |
| 1314 | + // value of true after appended to the DOM (IE6/7) |
| 1315 | + support.appendChecked = input.checked; |
1053 | 1316 | |
1054 | | - // Check if elements with layout shrink-wrap their children |
1055 | | - // (IE 6 does this) |
1056 | | - div.style.display = ""; |
1057 | | - div.innerHTML = "<div style='width:4px;'></div>"; |
1058 | | - jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2; |
1059 | | - } |
| 1317 | + support.boxModel = div.offsetWidth === 2; |
1060 | 1318 | |
1061 | | - div.innerHTML = "<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>"; |
1062 | | - var tds = div.getElementsByTagName("td"); |
| 1319 | + if ( "zoom" in div.style ) { |
| 1320 | + // Check if natively block-level elements act like inline-block |
| 1321 | + // elements when setting their display to 'inline' and giving |
| 1322 | + // them layout |
| 1323 | + // (IE < 8 does this) |
| 1324 | + div.style.display = "inline"; |
| 1325 | + div.style.zoom = 1; |
| 1326 | + support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); |
1063 | 1327 | |
1064 | | - // Check if table cells still have offsetWidth/Height when they are set |
1065 | | - // to display:none and there are still other visible table cells in a |
1066 | | - // table row; if so, offsetWidth/Height are not reliable for use when |
1067 | | - // determining if an element has been hidden directly using |
1068 | | - // display:none (it is still safe to use offsets if a parent element is |
1069 | | - // hidden; don safety goggles and see bug #4512 for more information). |
1070 | | - // (only IE 8 fails this test) |
1071 | | - jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0; |
| 1328 | + // Check if elements with layout shrink-wrap their children |
| 1329 | + // (IE 6 does this) |
| 1330 | + div.style.display = ""; |
| 1331 | + div.innerHTML = "<div style='width:4px;'></div>"; |
| 1332 | + support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); |
| 1333 | + } |
1072 | 1334 | |
1073 | | - tds[0].style.display = ""; |
1074 | | - tds[1].style.display = "none"; |
| 1335 | + div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>"; |
| 1336 | + tds = div.getElementsByTagName( "td" ); |
1075 | 1337 | |
1076 | | - // Check if empty table cells still have offsetWidth/Height |
1077 | | - // (IE < 8 fail this test) |
1078 | | - jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0; |
1079 | | - div.innerHTML = ""; |
| 1338 | + // Check if table cells still have offsetWidth/Height when they are set |
| 1339 | + // to display:none and there are still other visible table cells in a |
| 1340 | + // table row; if so, offsetWidth/Height are not reliable for use when |
| 1341 | + // determining if an element has been hidden directly using |
| 1342 | + // display:none (it is still safe to use offsets if a parent element is |
| 1343 | + // hidden; don safety goggles and see bug #4512 for more information). |
| 1344 | + // (only IE 8 fails this test) |
| 1345 | + isSupported = ( tds[ 0 ].offsetHeight === 0 ); |
1080 | 1346 | |
1081 | | - document.body.removeChild( div ).style.display = "none"; |
1082 | | - div = tds = null; |
1083 | | - }); |
| 1347 | + tds[ 0 ].style.display = ""; |
| 1348 | + tds[ 1 ].style.display = "none"; |
1084 | 1349 | |
| 1350 | + // Check if empty table cells still have offsetWidth/Height |
| 1351 | + // (IE < 8 fail this test) |
| 1352 | + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); |
| 1353 | + div.innerHTML = ""; |
| 1354 | + |
| 1355 | + // Check if div with explicit width and no margin-right incorrectly |
| 1356 | + // gets computed margin-right based on width of container. For more |
| 1357 | + // info see bug #3333 |
| 1358 | + // Fails in WebKit before Feb 2011 nightlies |
| 1359 | + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
| 1360 | + if ( document.defaultView && document.defaultView.getComputedStyle ) { |
| 1361 | + marginDiv = document.createElement( "div" ); |
| 1362 | + marginDiv.style.width = "0"; |
| 1363 | + marginDiv.style.marginRight = "0"; |
| 1364 | + div.appendChild( marginDiv ); |
| 1365 | + support.reliableMarginRight = |
| 1366 | + ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; |
| 1367 | + } |
| 1368 | + |
| 1369 | + // Remove the body element we added |
| 1370 | + testElement.innerHTML = ""; |
| 1371 | + testElementParent.removeChild( testElement ); |
| 1372 | + |
1085 | 1373 | // Technique from Juriy Zaytsev |
1086 | 1374 | // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ |
1087 | | - var eventSupported = function( eventName ) { |
1088 | | - var el = document.createElement("div"); |
1089 | | - eventName = "on" + eventName; |
1090 | | - |
1091 | | - var isSupported = (eventName in el); |
1092 | | - if ( !isSupported ) { |
1093 | | - el.setAttribute(eventName, "return;"); |
1094 | | - isSupported = typeof el[eventName] === "function"; |
| 1375 | + // We only care about the case where non-standard event systems |
| 1376 | + // are used, namely in IE. Short-circuiting here helps us to |
| 1377 | + // avoid an eval call (in setAttribute) which can cause CSP |
| 1378 | + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP |
| 1379 | + if ( div.attachEvent ) { |
| 1380 | + for( i in { |
| 1381 | + submit: 1, |
| 1382 | + change: 1, |
| 1383 | + focusin: 1 |
| 1384 | + } ) { |
| 1385 | + eventName = "on" + i; |
| 1386 | + isSupported = ( eventName in div ); |
| 1387 | + if ( !isSupported ) { |
| 1388 | + div.setAttribute( eventName, "return;" ); |
| 1389 | + isSupported = ( typeof div[ eventName ] === "function" ); |
| 1390 | + } |
| 1391 | + support[ i + "Bubbles" ] = isSupported; |
1095 | 1392 | } |
1096 | | - el = null; |
| 1393 | + } |
1097 | 1394 | |
1098 | | - return isSupported; |
1099 | | - }; |
| 1395 | + // Null connected elements to avoid leaks in IE |
| 1396 | + testElement = fragment = select = opt = body = marginDiv = div = input = null; |
1100 | 1397 | |
1101 | | - jQuery.support.submitBubbles = eventSupported("submit"); |
1102 | | - jQuery.support.changeBubbles = eventSupported("change"); |
1103 | | - |
1104 | | - // release memory in IE |
1105 | | - root = script = div = all = a = null; |
| 1398 | + return support; |
1106 | 1399 | })(); |
1107 | 1400 | |
| 1401 | +// Keep track of boxModel |
| 1402 | +jQuery.boxModel = jQuery.support.boxModel; |
1108 | 1403 | |
1109 | 1404 | |
1110 | | -var windowData = {}, |
1111 | | - rbrace = /^(?:\{.*\}|\[.*\])$/; |
1112 | 1405 | |
| 1406 | + |
| 1407 | +var rbrace = /^(?:\{.*\}|\[.*\])$/, |
| 1408 | + rmultiDash = /([a-z])([A-Z])/g; |
| 1409 | + |
1113 | 1410 | jQuery.extend({ |
1114 | 1411 | cache: {}, |
1115 | 1412 | |
1116 | 1413 | // Please use with caution |
1117 | 1414 | uuid: 0, |
1118 | 1415 | |
1119 | | - // Unique for each copy of jQuery on the page |
1120 | | - expando: "jQuery" + jQuery.now(), |
| 1416 | + // Unique for each copy of jQuery on the page |
| 1417 | + // Non-digits removed to match rinlinejQuery |
| 1418 | + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), |
1121 | 1419 | |
1122 | 1420 | // The following elements throw uncatchable exceptions if you |
1123 | 1421 | // attempt to add expando properties to them. |
— | — | @@ -1127,103 +1425,188 @@ |
1128 | 1426 | "applet": true |
1129 | 1427 | }, |
1130 | 1428 | |
1131 | | - data: function( elem, name, data ) { |
| 1429 | + hasData: function( elem ) { |
| 1430 | + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; |
| 1431 | + |
| 1432 | + return !!elem && !isEmptyDataObject( elem ); |
| 1433 | + }, |
| 1434 | + |
| 1435 | + data: function( elem, name, data, pvt /* Internal Use Only */ ) { |
1132 | 1436 | if ( !jQuery.acceptData( elem ) ) { |
1133 | 1437 | return; |
1134 | 1438 | } |
1135 | 1439 | |
1136 | | - elem = elem == window ? |
1137 | | - windowData : |
1138 | | - elem; |
| 1440 | + var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache, |
1139 | 1441 | |
1140 | | - var isNode = elem.nodeType, |
1141 | | - id = isNode ? elem[ jQuery.expando ] : null, |
1142 | | - cache = jQuery.cache, thisCache; |
| 1442 | + // We have to handle DOM nodes and JS objects differently because IE6-7 |
| 1443 | + // can't GC object references properly across the DOM-JS boundary |
| 1444 | + isNode = elem.nodeType, |
1143 | 1445 | |
1144 | | - if ( isNode && !id && typeof name === "string" && data === undefined ) { |
| 1446 | + // Only DOM nodes need the global jQuery cache; JS object data is |
| 1447 | + // attached directly to the object so GC can occur automatically |
| 1448 | + cache = isNode ? jQuery.cache : elem, |
| 1449 | + |
| 1450 | + // Only defining an ID for JS objects if its cache already exists allows |
| 1451 | + // the code to shortcut on the same path as a DOM node with no cache |
| 1452 | + id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando; |
| 1453 | + |
| 1454 | + // Avoid doing any more work than we need to when trying to get data on an |
| 1455 | + // object that has no data at all |
| 1456 | + if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) { |
1145 | 1457 | return; |
1146 | 1458 | } |
1147 | 1459 | |
1148 | | - // Get the data from the object directly |
1149 | | - if ( !isNode ) { |
1150 | | - cache = elem; |
| 1460 | + if ( !id ) { |
| 1461 | + // Only DOM nodes need a new unique ID for each element since their data |
| 1462 | + // ends up in the global cache |
| 1463 | + if ( isNode ) { |
| 1464 | + elem[ jQuery.expando ] = id = ++jQuery.uuid; |
| 1465 | + } else { |
| 1466 | + id = jQuery.expando; |
| 1467 | + } |
| 1468 | + } |
1151 | 1469 | |
1152 | | - // Compute a unique ID for the element |
1153 | | - } else if ( !id ) { |
1154 | | - elem[ jQuery.expando ] = id = ++jQuery.uuid; |
| 1470 | + if ( !cache[ id ] ) { |
| 1471 | + cache[ id ] = {}; |
| 1472 | + |
| 1473 | + // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery |
| 1474 | + // metadata on plain JS objects when the object is serialized using |
| 1475 | + // JSON.stringify |
| 1476 | + if ( !isNode ) { |
| 1477 | + cache[ id ].toJSON = jQuery.noop; |
| 1478 | + } |
1155 | 1479 | } |
1156 | 1480 | |
1157 | | - // Avoid generating a new cache unless none exists and we |
1158 | | - // want to manipulate it. |
1159 | | - if ( typeof name === "object" ) { |
1160 | | - if ( isNode ) { |
| 1481 | + // An object can be passed to jQuery.data instead of a key/value pair; this gets |
| 1482 | + // shallow copied over onto the existing cache |
| 1483 | + if ( typeof name === "object" || typeof name === "function" ) { |
| 1484 | + if ( pvt ) { |
| 1485 | + cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name); |
| 1486 | + } else { |
1161 | 1487 | cache[ id ] = jQuery.extend(cache[ id ], name); |
| 1488 | + } |
| 1489 | + } |
1162 | 1490 | |
1163 | | - } else { |
1164 | | - jQuery.extend( cache, name ); |
| 1491 | + thisCache = cache[ id ]; |
| 1492 | + |
| 1493 | + // Internal jQuery data is stored in a separate object inside the object's data |
| 1494 | + // cache in order to avoid key collisions between internal data and user-defined |
| 1495 | + // data |
| 1496 | + if ( pvt ) { |
| 1497 | + if ( !thisCache[ internalKey ] ) { |
| 1498 | + thisCache[ internalKey ] = {}; |
1165 | 1499 | } |
1166 | 1500 | |
1167 | | - } else if ( isNode && !cache[ id ] ) { |
1168 | | - cache[ id ] = {}; |
| 1501 | + thisCache = thisCache[ internalKey ]; |
1169 | 1502 | } |
1170 | 1503 | |
1171 | | - thisCache = isNode ? cache[ id ] : cache; |
1172 | | - |
1173 | | - // Prevent overriding the named cache with undefined values |
1174 | 1504 | if ( data !== undefined ) { |
1175 | | - thisCache[ name ] = data; |
| 1505 | + thisCache[ jQuery.camelCase( name ) ] = data; |
1176 | 1506 | } |
1177 | 1507 | |
1178 | | - return typeof name === "string" ? thisCache[ name ] : thisCache; |
| 1508 | + // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should |
| 1509 | + // not attempt to inspect the internal events object using jQuery.data, as this |
| 1510 | + // internal data object is undocumented and subject to change. |
| 1511 | + if ( name === "events" && !thisCache[name] ) { |
| 1512 | + return thisCache[ internalKey ] && thisCache[ internalKey ].events; |
| 1513 | + } |
| 1514 | + |
| 1515 | + return getByName ? |
| 1516 | + // Check for both converted-to-camel and non-converted data property names |
| 1517 | + thisCache[ jQuery.camelCase( name ) ] || thisCache[ name ] : |
| 1518 | + thisCache; |
1179 | 1519 | }, |
1180 | 1520 | |
1181 | | - removeData: function( elem, name ) { |
| 1521 | + removeData: function( elem, name, pvt /* Internal Use Only */ ) { |
1182 | 1522 | if ( !jQuery.acceptData( elem ) ) { |
1183 | 1523 | return; |
1184 | 1524 | } |
1185 | 1525 | |
1186 | | - elem = elem == window ? |
1187 | | - windowData : |
1188 | | - elem; |
| 1526 | + var internalKey = jQuery.expando, isNode = elem.nodeType, |
1189 | 1527 | |
1190 | | - var isNode = elem.nodeType, |
1191 | | - id = isNode ? elem[ jQuery.expando ] : elem, |
1192 | | - cache = jQuery.cache, |
1193 | | - thisCache = isNode ? cache[ id ] : id; |
| 1528 | + // See jQuery.data for more information |
| 1529 | + cache = isNode ? jQuery.cache : elem, |
1194 | 1530 | |
1195 | | - // If we want to remove a specific section of the element's data |
| 1531 | + // See jQuery.data for more information |
| 1532 | + id = isNode ? elem[ jQuery.expando ] : jQuery.expando; |
| 1533 | + |
| 1534 | + // If there is already no cache entry for this object, there is no |
| 1535 | + // purpose in continuing |
| 1536 | + if ( !cache[ id ] ) { |
| 1537 | + return; |
| 1538 | + } |
| 1539 | + |
1196 | 1540 | if ( name ) { |
| 1541 | + var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ]; |
| 1542 | + |
1197 | 1543 | if ( thisCache ) { |
1198 | | - // Remove the section of cache data |
1199 | 1544 | delete thisCache[ name ]; |
1200 | 1545 | |
1201 | | - // If we've removed all the data, remove the element's cache |
1202 | | - if ( isNode && jQuery.isEmptyObject(thisCache) ) { |
1203 | | - jQuery.removeData( elem ); |
| 1546 | + // If there is no data left in the cache, we want to continue |
| 1547 | + // and let the cache object itself get destroyed |
| 1548 | + if ( !isEmptyDataObject(thisCache) ) { |
| 1549 | + return; |
1204 | 1550 | } |
1205 | 1551 | } |
| 1552 | + } |
1206 | 1553 | |
1207 | | - // Otherwise, we want to remove all of the element's data |
| 1554 | + // See jQuery.data for more information |
| 1555 | + if ( pvt ) { |
| 1556 | + delete cache[ id ][ internalKey ]; |
| 1557 | + |
| 1558 | + // Don't destroy the parent cache unless the internal data object |
| 1559 | + // had been the only thing left in it |
| 1560 | + if ( !isEmptyDataObject(cache[ id ]) ) { |
| 1561 | + return; |
| 1562 | + } |
| 1563 | + } |
| 1564 | + |
| 1565 | + var internalCache = cache[ id ][ internalKey ]; |
| 1566 | + |
| 1567 | + // Browsers that fail expando deletion also refuse to delete expandos on |
| 1568 | + // the window, but it will allow it on all other JS objects; other browsers |
| 1569 | + // don't care |
| 1570 | + if ( jQuery.support.deleteExpando || cache != window ) { |
| 1571 | + delete cache[ id ]; |
1208 | 1572 | } else { |
1209 | | - if ( isNode && jQuery.support.deleteExpando ) { |
| 1573 | + cache[ id ] = null; |
| 1574 | + } |
| 1575 | + |
| 1576 | + // We destroyed the entire user cache at once because it's faster than |
| 1577 | + // iterating through each key, but we need to continue to persist internal |
| 1578 | + // data if it existed |
| 1579 | + if ( internalCache ) { |
| 1580 | + cache[ id ] = {}; |
| 1581 | + // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery |
| 1582 | + // metadata on plain JS objects when the object is serialized using |
| 1583 | + // JSON.stringify |
| 1584 | + if ( !isNode ) { |
| 1585 | + cache[ id ].toJSON = jQuery.noop; |
| 1586 | + } |
| 1587 | + |
| 1588 | + cache[ id ][ internalKey ] = internalCache; |
| 1589 | + |
| 1590 | + // Otherwise, we need to eliminate the expando on the node to avoid |
| 1591 | + // false lookups in the cache for entries that no longer exist |
| 1592 | + } else if ( isNode ) { |
| 1593 | + // IE does not allow us to delete expando properties from nodes, |
| 1594 | + // nor does it have a removeAttribute function on Document nodes; |
| 1595 | + // we must handle all of these cases |
| 1596 | + if ( jQuery.support.deleteExpando ) { |
1210 | 1597 | delete elem[ jQuery.expando ]; |
1211 | | - |
1212 | 1598 | } else if ( elem.removeAttribute ) { |
1213 | 1599 | elem.removeAttribute( jQuery.expando ); |
1214 | | - |
1215 | | - // Completely remove the data cache |
1216 | | - } else if ( isNode ) { |
1217 | | - delete cache[ id ]; |
1218 | | - |
1219 | | - // Remove all fields from the object |
1220 | 1600 | } else { |
1221 | | - for ( var n in elem ) { |
1222 | | - delete elem[ n ]; |
1223 | | - } |
| 1601 | + elem[ jQuery.expando ] = null; |
1224 | 1602 | } |
1225 | 1603 | } |
1226 | 1604 | }, |
1227 | 1605 | |
| 1606 | + // For internal use only. |
| 1607 | + _data: function( elem, name, data ) { |
| 1608 | + return jQuery.data( elem, name, data, true ); |
| 1609 | + }, |
| 1610 | + |
1228 | 1611 | // A method for determining if a DOM node can handle the data expando |
1229 | 1612 | acceptData: function( elem ) { |
1230 | 1613 | if ( elem.nodeName ) { |
— | — | @@ -1244,15 +1627,18 @@ |
1245 | 1628 | |
1246 | 1629 | if ( typeof key === "undefined" ) { |
1247 | 1630 | if ( this.length ) { |
1248 | | - var attr = this[0].attributes, name; |
1249 | 1631 | data = jQuery.data( this[0] ); |
1250 | 1632 | |
1251 | | - for ( var i = 0, l = attr.length; i < l; i++ ) { |
1252 | | - name = attr[i].name; |
| 1633 | + if ( this[0].nodeType === 1 ) { |
| 1634 | + var attr = this[0].attributes, name; |
| 1635 | + for ( var i = 0, l = attr.length; i < l; i++ ) { |
| 1636 | + name = attr[i].name; |
1253 | 1637 | |
1254 | | - if ( name.indexOf( "data-" ) === 0 ) { |
1255 | | - name = name.substr( 5 ); |
1256 | | - dataAttr( this[0], name, data[ name ] ); |
| 1638 | + if ( name.indexOf( "data-" ) === 0 ) { |
| 1639 | + name = jQuery.camelCase( name.substring(5) ); |
| 1640 | + |
| 1641 | + dataAttr( this[0], name, data[ name ] ); |
| 1642 | + } |
1257 | 1643 | } |
1258 | 1644 | } |
1259 | 1645 | } |
— | — | @@ -1304,8 +1690,10 @@ |
1305 | 1691 | // If nothing was found internally, try to fetch any |
1306 | 1692 | // data from the HTML5 data-* attribute |
1307 | 1693 | if ( data === undefined && elem.nodeType === 1 ) { |
1308 | | - data = elem.getAttribute( "data-" + key ); |
| 1694 | + var name = "data-" + key.replace( rmultiDash, "$1-$2" ).toLowerCase(); |
1309 | 1695 | |
| 1696 | + data = elem.getAttribute( name ); |
| 1697 | + |
1310 | 1698 | if ( typeof data === "string" ) { |
1311 | 1699 | try { |
1312 | 1700 | data = data === "true" ? true : |
— | — | @@ -1327,38 +1715,92 @@ |
1328 | 1716 | return data; |
1329 | 1717 | } |
1330 | 1718 | |
| 1719 | +// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON |
| 1720 | +// property to be considered empty objects; this property always exists in |
| 1721 | +// order to make sure JSON.stringify does not expose internal metadata |
| 1722 | +function isEmptyDataObject( obj ) { |
| 1723 | + for ( var name in obj ) { |
| 1724 | + if ( name !== "toJSON" ) { |
| 1725 | + return false; |
| 1726 | + } |
| 1727 | + } |
1331 | 1728 | |
| 1729 | + return true; |
| 1730 | +} |
1332 | 1731 | |
1333 | 1732 | |
1334 | | -jQuery.extend({ |
1335 | | - queue: function( elem, type, data ) { |
1336 | | - if ( !elem ) { |
1337 | | - return; |
1338 | | - } |
1339 | 1733 | |
1340 | | - type = (type || "fx") + "queue"; |
1341 | | - var q = jQuery.data( elem, type ); |
1342 | 1734 | |
1343 | | - // Speed up dequeue by getting out quickly if this is just a lookup |
1344 | | - if ( !data ) { |
1345 | | - return q || []; |
1346 | | - } |
| 1735 | +function handleQueueMarkDefer( elem, type, src ) { |
| 1736 | + var deferDataKey = type + "defer", |
| 1737 | + queueDataKey = type + "queue", |
| 1738 | + markDataKey = type + "mark", |
| 1739 | + defer = jQuery.data( elem, deferDataKey, undefined, true ); |
| 1740 | + if ( defer && |
| 1741 | + ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) && |
| 1742 | + ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) { |
| 1743 | + // Give room for hard-coded callbacks to fire first |
| 1744 | + // and eventually mark/queue something else on the element |
| 1745 | + setTimeout( function() { |
| 1746 | + if ( !jQuery.data( elem, queueDataKey, undefined, true ) && |
| 1747 | + !jQuery.data( elem, markDataKey, undefined, true ) ) { |
| 1748 | + jQuery.removeData( elem, deferDataKey, true ); |
| 1749 | + defer.resolve(); |
| 1750 | + } |
| 1751 | + }, 0 ); |
| 1752 | + } |
| 1753 | +} |
1347 | 1754 | |
1348 | | - if ( !q || jQuery.isArray(data) ) { |
1349 | | - q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
| 1755 | +jQuery.extend({ |
1350 | 1756 | |
1351 | | - } else { |
1352 | | - q.push( data ); |
| 1757 | + _mark: function( elem, type ) { |
| 1758 | + if ( elem ) { |
| 1759 | + type = (type || "fx") + "mark"; |
| 1760 | + jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true ); |
1353 | 1761 | } |
| 1762 | + }, |
1354 | 1763 | |
1355 | | - return q; |
| 1764 | + _unmark: function( force, elem, type ) { |
| 1765 | + if ( force !== true ) { |
| 1766 | + type = elem; |
| 1767 | + elem = force; |
| 1768 | + force = false; |
| 1769 | + } |
| 1770 | + if ( elem ) { |
| 1771 | + type = type || "fx"; |
| 1772 | + var key = type + "mark", |
| 1773 | + count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 ); |
| 1774 | + if ( count ) { |
| 1775 | + jQuery.data( elem, key, count, true ); |
| 1776 | + } else { |
| 1777 | + jQuery.removeData( elem, key, true ); |
| 1778 | + handleQueueMarkDefer( elem, type, "mark" ); |
| 1779 | + } |
| 1780 | + } |
1356 | 1781 | }, |
1357 | 1782 | |
| 1783 | + queue: function( elem, type, data ) { |
| 1784 | + if ( elem ) { |
| 1785 | + type = (type || "fx") + "queue"; |
| 1786 | + var q = jQuery.data( elem, type, undefined, true ); |
| 1787 | + // Speed up dequeue by getting out quickly if this is just a lookup |
| 1788 | + if ( data ) { |
| 1789 | + if ( !q || jQuery.isArray(data) ) { |
| 1790 | + q = jQuery.data( elem, type, jQuery.makeArray(data), true ); |
| 1791 | + } else { |
| 1792 | + q.push( data ); |
| 1793 | + } |
| 1794 | + } |
| 1795 | + return q || []; |
| 1796 | + } |
| 1797 | + }, |
| 1798 | + |
1358 | 1799 | dequeue: function( elem, type ) { |
1359 | 1800 | type = type || "fx"; |
1360 | 1801 | |
1361 | 1802 | var queue = jQuery.queue( elem, type ), |
1362 | | - fn = queue.shift(); |
| 1803 | + fn = queue.shift(), |
| 1804 | + defer; |
1363 | 1805 | |
1364 | 1806 | // If the fx queue is dequeued, always remove the progress sentinel |
1365 | 1807 | if ( fn === "inprogress" ) { |
— | — | @@ -1376,6 +1818,11 @@ |
1377 | 1819 | jQuery.dequeue(elem, type); |
1378 | 1820 | }); |
1379 | 1821 | } |
| 1822 | + |
| 1823 | + if ( !queue.length ) { |
| 1824 | + jQuery.removeData( elem, type + "queue", true ); |
| 1825 | + handleQueueMarkDefer( elem, type, "queue" ); |
| 1826 | + } |
1380 | 1827 | } |
1381 | 1828 | }); |
1382 | 1829 | |
— | — | @@ -1389,7 +1836,7 @@ |
1390 | 1837 | if ( data === undefined ) { |
1391 | 1838 | return jQuery.queue( this[0], type ); |
1392 | 1839 | } |
1393 | | - return this.each(function( i ) { |
| 1840 | + return this.each(function() { |
1394 | 1841 | var queue = jQuery.queue( this, type, data ); |
1395 | 1842 | |
1396 | 1843 | if ( type === "fx" && queue[0] !== "inprogress" ) { |
— | — | @@ -1402,7 +1849,6 @@ |
1403 | 1850 | jQuery.dequeue( this, type ); |
1404 | 1851 | }); |
1405 | 1852 | }, |
1406 | | - |
1407 | 1853 | // Based off of the plugin by Clint Helfers, with permission. |
1408 | 1854 | // http://blindsignals.com/index.php/2009/07/jquery-delay/ |
1409 | 1855 | delay: function( time, type ) { |
— | — | @@ -1416,76 +1862,109 @@ |
1417 | 1863 | }, time ); |
1418 | 1864 | }); |
1419 | 1865 | }, |
1420 | | - |
1421 | 1866 | clearQueue: function( type ) { |
1422 | 1867 | return this.queue( type || "fx", [] ); |
| 1868 | + }, |
| 1869 | + // Get a promise resolved when queues of a certain type |
| 1870 | + // are emptied (fx is the type by default) |
| 1871 | + promise: function( type, object ) { |
| 1872 | + if ( typeof type !== "string" ) { |
| 1873 | + object = type; |
| 1874 | + type = undefined; |
| 1875 | + } |
| 1876 | + type = type || "fx"; |
| 1877 | + var defer = jQuery.Deferred(), |
| 1878 | + elements = this, |
| 1879 | + i = elements.length, |
| 1880 | + count = 1, |
| 1881 | + deferDataKey = type + "defer", |
| 1882 | + queueDataKey = type + "queue", |
| 1883 | + markDataKey = type + "mark", |
| 1884 | + tmp; |
| 1885 | + function resolve() { |
| 1886 | + if ( !( --count ) ) { |
| 1887 | + defer.resolveWith( elements, [ elements ] ); |
| 1888 | + } |
| 1889 | + } |
| 1890 | + while( i-- ) { |
| 1891 | + if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || |
| 1892 | + ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || |
| 1893 | + jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && |
| 1894 | + jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) { |
| 1895 | + count++; |
| 1896 | + tmp.done( resolve ); |
| 1897 | + } |
| 1898 | + } |
| 1899 | + resolve(); |
| 1900 | + return defer.promise(); |
1423 | 1901 | } |
1424 | 1902 | }); |
1425 | 1903 | |
1426 | 1904 | |
1427 | 1905 | |
1428 | 1906 | |
1429 | | -var rclass = /[\n\t]/g, |
1430 | | - rspaces = /\s+/, |
| 1907 | +var rclass = /[\n\t\r]/g, |
| 1908 | + rspace = /\s+/, |
1431 | 1909 | rreturn = /\r/g, |
1432 | | - rspecialurl = /^(?:href|src|style)$/, |
1433 | 1910 | rtype = /^(?:button|input)$/i, |
1434 | 1911 | rfocusable = /^(?:button|input|object|select|textarea)$/i, |
1435 | 1912 | rclickable = /^a(?:rea)?$/i, |
1436 | | - rradiocheck = /^(?:radio|checkbox)$/i; |
| 1913 | + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, |
| 1914 | + rinvalidChar = /\:|^on/, |
| 1915 | + formHook, boolHook; |
1437 | 1916 | |
1438 | | -jQuery.props = { |
1439 | | - "for": "htmlFor", |
1440 | | - "class": "className", |
1441 | | - readonly: "readOnly", |
1442 | | - maxlength: "maxLength", |
1443 | | - cellspacing: "cellSpacing", |
1444 | | - rowspan: "rowSpan", |
1445 | | - colspan: "colSpan", |
1446 | | - tabindex: "tabIndex", |
1447 | | - usemap: "useMap", |
1448 | | - frameborder: "frameBorder" |
1449 | | -}; |
1450 | | - |
1451 | 1917 | jQuery.fn.extend({ |
1452 | 1918 | attr: function( name, value ) { |
1453 | 1919 | return jQuery.access( this, name, value, true, jQuery.attr ); |
1454 | 1920 | }, |
1455 | 1921 | |
1456 | | - removeAttr: function( name, fn ) { |
1457 | | - return this.each(function(){ |
1458 | | - jQuery.attr( this, name, "" ); |
1459 | | - if ( this.nodeType === 1 ) { |
1460 | | - this.removeAttribute( name ); |
1461 | | - } |
| 1922 | + removeAttr: function( name ) { |
| 1923 | + return this.each(function() { |
| 1924 | + jQuery.removeAttr( this, name ); |
1462 | 1925 | }); |
1463 | 1926 | }, |
| 1927 | + |
| 1928 | + prop: function( name, value ) { |
| 1929 | + return jQuery.access( this, name, value, true, jQuery.prop ); |
| 1930 | + }, |
| 1931 | + |
| 1932 | + removeProp: function( name ) { |
| 1933 | + name = jQuery.propFix[ name ] || name; |
| 1934 | + return this.each(function() { |
| 1935 | + // try/catch handles cases where IE balks (such as removing a property on window) |
| 1936 | + try { |
| 1937 | + this[ name ] = undefined; |
| 1938 | + delete this[ name ]; |
| 1939 | + } catch( e ) {} |
| 1940 | + }); |
| 1941 | + }, |
1464 | 1942 | |
1465 | 1943 | addClass: function( value ) { |
1466 | | - if ( jQuery.isFunction(value) ) { |
1467 | | - return this.each(function(i) { |
1468 | | - var self = jQuery(this); |
1469 | | - self.addClass( value.call(this, i, self.attr("class")) ); |
| 1944 | + var classNames, i, l, elem, |
| 1945 | + setClass, c, cl; |
| 1946 | + |
| 1947 | + if ( jQuery.isFunction( value ) ) { |
| 1948 | + return this.each(function( j ) { |
| 1949 | + jQuery( this ).addClass( value.call(this, j, this.className) ); |
1470 | 1950 | }); |
1471 | 1951 | } |
1472 | 1952 | |
1473 | 1953 | if ( value && typeof value === "string" ) { |
1474 | | - var classNames = (value || "").split( rspaces ); |
| 1954 | + classNames = value.split( rspace ); |
1475 | 1955 | |
1476 | | - for ( var i = 0, l = this.length; i < l; i++ ) { |
1477 | | - var elem = this[i]; |
| 1956 | + for ( i = 0, l = this.length; i < l; i++ ) { |
| 1957 | + elem = this[ i ]; |
1478 | 1958 | |
1479 | 1959 | if ( elem.nodeType === 1 ) { |
1480 | | - if ( !elem.className ) { |
| 1960 | + if ( !elem.className && classNames.length === 1 ) { |
1481 | 1961 | elem.className = value; |
1482 | 1962 | |
1483 | 1963 | } else { |
1484 | | - var className = " " + elem.className + " ", |
1485 | | - setClass = elem.className; |
| 1964 | + setClass = " " + elem.className + " "; |
1486 | 1965 | |
1487 | | - for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
1488 | | - if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { |
1489 | | - setClass += " " + classNames[c]; |
| 1966 | + for ( c = 0, cl = classNames.length; c < cl; c++ ) { |
| 1967 | + if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { |
| 1968 | + setClass += classNames[ c ] + " "; |
1490 | 1969 | } |
1491 | 1970 | } |
1492 | 1971 | elem.className = jQuery.trim( setClass ); |
— | — | @@ -1498,24 +1977,25 @@ |
1499 | 1978 | }, |
1500 | 1979 | |
1501 | 1980 | removeClass: function( value ) { |
1502 | | - if ( jQuery.isFunction(value) ) { |
1503 | | - return this.each(function(i) { |
1504 | | - var self = jQuery(this); |
1505 | | - self.removeClass( value.call(this, i, self.attr("class")) ); |
| 1981 | + var classNames, i, l, elem, className, c, cl; |
| 1982 | + |
| 1983 | + if ( jQuery.isFunction( value ) ) { |
| 1984 | + return this.each(function( j ) { |
| 1985 | + jQuery( this ).removeClass( value.call(this, j, this.className) ); |
1506 | 1986 | }); |
1507 | 1987 | } |
1508 | 1988 | |
1509 | 1989 | if ( (value && typeof value === "string") || value === undefined ) { |
1510 | | - var classNames = (value || "").split( rspaces ); |
| 1990 | + classNames = (value || "").split( rspace ); |
1511 | 1991 | |
1512 | | - for ( var i = 0, l = this.length; i < l; i++ ) { |
1513 | | - var elem = this[i]; |
| 1992 | + for ( i = 0, l = this.length; i < l; i++ ) { |
| 1993 | + elem = this[ i ]; |
1514 | 1994 | |
1515 | 1995 | if ( elem.nodeType === 1 && elem.className ) { |
1516 | 1996 | if ( value ) { |
1517 | | - var className = (" " + elem.className + " ").replace(rclass, " "); |
1518 | | - for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
1519 | | - className = className.replace(" " + classNames[c] + " ", " "); |
| 1997 | + className = (" " + elem.className + " ").replace( rclass, " " ); |
| 1998 | + for ( c = 0, cl = classNames.length; c < cl; c++ ) { |
| 1999 | + className = className.replace(" " + classNames[ c ] + " ", " "); |
1520 | 2000 | } |
1521 | 2001 | elem.className = jQuery.trim( className ); |
1522 | 2002 | |
— | — | @@ -1534,9 +2014,8 @@ |
1535 | 2015 | isBool = typeof stateVal === "boolean"; |
1536 | 2016 | |
1537 | 2017 | if ( jQuery.isFunction( value ) ) { |
1538 | | - return this.each(function(i) { |
1539 | | - var self = jQuery(this); |
1540 | | - self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal ); |
| 2018 | + return this.each(function( i ) { |
| 2019 | + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); |
1541 | 2020 | }); |
1542 | 2021 | } |
1543 | 2022 | |
— | — | @@ -1547,7 +2026,7 @@ |
1548 | 2027 | i = 0, |
1549 | 2028 | self = jQuery( this ), |
1550 | 2029 | state = stateVal, |
1551 | | - classNames = value.split( rspaces ); |
| 2030 | + classNames = value.split( rspace ); |
1552 | 2031 | |
1553 | 2032 | while ( (className = classNames[ i++ ]) ) { |
1554 | 2033 | // check each className given, space seperated list |
— | — | @@ -1558,11 +2037,11 @@ |
1559 | 2038 | } else if ( type === "undefined" || type === "boolean" ) { |
1560 | 2039 | if ( this.className ) { |
1561 | 2040 | // store className if set |
1562 | | - jQuery.data( this, "__className__", this.className ); |
| 2041 | + jQuery._data( this, "__className__", this.className ); |
1563 | 2042 | } |
1564 | 2043 | |
1565 | 2044 | // toggle whole className |
1566 | | - this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || ""; |
| 2045 | + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; |
1567 | 2046 | } |
1568 | 2047 | }); |
1569 | 2048 | }, |
— | — | @@ -1579,78 +2058,42 @@ |
1580 | 2059 | }, |
1581 | 2060 | |
1582 | 2061 | val: function( value ) { |
| 2062 | + var hooks, ret, |
| 2063 | + elem = this[0]; |
| 2064 | + |
1583 | 2065 | if ( !arguments.length ) { |
1584 | | - var elem = this[0]; |
1585 | | - |
1586 | 2066 | if ( elem ) { |
1587 | | - if ( jQuery.nodeName( elem, "option" ) ) { |
1588 | | - // attributes.value is undefined in Blackberry 4.7 but |
1589 | | - // uses .value. See #6932 |
1590 | | - var val = elem.attributes.value; |
1591 | | - return !val || val.specified ? elem.value : elem.text; |
1592 | | - } |
| 2067 | + hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; |
1593 | 2068 | |
1594 | | - // We need to handle select boxes special |
1595 | | - if ( jQuery.nodeName( elem, "select" ) ) { |
1596 | | - var index = elem.selectedIndex, |
1597 | | - values = [], |
1598 | | - options = elem.options, |
1599 | | - one = elem.type === "select-one"; |
1600 | | - |
1601 | | - // Nothing was selected |
1602 | | - if ( index < 0 ) { |
1603 | | - return null; |
1604 | | - } |
1605 | | - |
1606 | | - // Loop through all the selected options |
1607 | | - for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
1608 | | - var option = options[ i ]; |
1609 | | - |
1610 | | - // Don't return options that are disabled or in a disabled optgroup |
1611 | | - if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && |
1612 | | - (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { |
1613 | | - |
1614 | | - // Get the specific value for the option |
1615 | | - value = jQuery(option).val(); |
1616 | | - |
1617 | | - // We don't need an array for one selects |
1618 | | - if ( one ) { |
1619 | | - return value; |
1620 | | - } |
1621 | | - |
1622 | | - // Multi-Selects return an array |
1623 | | - values.push( value ); |
1624 | | - } |
1625 | | - } |
1626 | | - |
1627 | | - return values; |
| 2069 | + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { |
| 2070 | + return ret; |
1628 | 2071 | } |
1629 | 2072 | |
1630 | | - // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified |
1631 | | - if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) { |
1632 | | - return elem.getAttribute("value") === null ? "on" : elem.value; |
1633 | | - } |
1634 | | - |
| 2073 | + ret = elem.value; |
1635 | 2074 | |
1636 | | - // Everything else, we just grab the value |
1637 | | - return (elem.value || "").replace(rreturn, ""); |
1638 | | - |
| 2075 | + return typeof ret === "string" ? |
| 2076 | + // handle most common string cases |
| 2077 | + ret.replace(rreturn, "") : |
| 2078 | + // handle cases where value is null/undef or number |
| 2079 | + ret == null ? "" : ret; |
1639 | 2080 | } |
1640 | 2081 | |
1641 | 2082 | return undefined; |
1642 | 2083 | } |
1643 | 2084 | |
1644 | | - var isFunction = jQuery.isFunction(value); |
| 2085 | + var isFunction = jQuery.isFunction( value ); |
1645 | 2086 | |
1646 | | - return this.each(function(i) { |
1647 | | - var self = jQuery(this), val = value; |
| 2087 | + return this.each(function( i ) { |
| 2088 | + var self = jQuery(this), val; |
1648 | 2089 | |
1649 | 2090 | if ( this.nodeType !== 1 ) { |
1650 | 2091 | return; |
1651 | 2092 | } |
1652 | 2093 | |
1653 | 2094 | if ( isFunction ) { |
1654 | | - val = value.call(this, i, self.val()); |
| 2095 | + val = value.call( this, i, self.val() ); |
| 2096 | + } else { |
| 2097 | + val = value; |
1655 | 2098 | } |
1656 | 2099 | |
1657 | 2100 | // Treat null/undefined as ""; convert numbers to string |
— | — | @@ -1658,34 +2101,89 @@ |
1659 | 2102 | val = ""; |
1660 | 2103 | } else if ( typeof val === "number" ) { |
1661 | 2104 | val += ""; |
1662 | | - } else if ( jQuery.isArray(val) ) { |
1663 | | - val = jQuery.map(val, function (value) { |
| 2105 | + } else if ( jQuery.isArray( val ) ) { |
| 2106 | + val = jQuery.map(val, function ( value ) { |
1664 | 2107 | return value == null ? "" : value + ""; |
1665 | 2108 | }); |
1666 | 2109 | } |
1667 | 2110 | |
1668 | | - if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) { |
1669 | | - this.checked = jQuery.inArray( self.val(), val ) >= 0; |
| 2111 | + hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; |
1670 | 2112 | |
1671 | | - } else if ( jQuery.nodeName( this, "select" ) ) { |
1672 | | - var values = jQuery.makeArray(val); |
| 2113 | + // If set returns undefined, fall back to normal setting |
| 2114 | + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { |
| 2115 | + this.value = val; |
| 2116 | + } |
| 2117 | + }); |
| 2118 | + } |
| 2119 | +}); |
1673 | 2120 | |
1674 | | - jQuery( "option", this ).each(function() { |
| 2121 | +jQuery.extend({ |
| 2122 | + valHooks: { |
| 2123 | + option: { |
| 2124 | + get: function( elem ) { |
| 2125 | + // attributes.value is undefined in Blackberry 4.7 but |
| 2126 | + // uses .value. See #6932 |
| 2127 | + var val = elem.attributes.value; |
| 2128 | + return !val || val.specified ? elem.value : elem.text; |
| 2129 | + } |
| 2130 | + }, |
| 2131 | + select: { |
| 2132 | + get: function( elem ) { |
| 2133 | + var value, |
| 2134 | + index = elem.selectedIndex, |
| 2135 | + values = [], |
| 2136 | + options = elem.options, |
| 2137 | + one = elem.type === "select-one"; |
| 2138 | + |
| 2139 | + // Nothing was selected |
| 2140 | + if ( index < 0 ) { |
| 2141 | + return null; |
| 2142 | + } |
| 2143 | + |
| 2144 | + // Loop through all the selected options |
| 2145 | + for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
| 2146 | + var option = options[ i ]; |
| 2147 | + |
| 2148 | + // Don't return options that are disabled or in a disabled optgroup |
| 2149 | + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && |
| 2150 | + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { |
| 2151 | + |
| 2152 | + // Get the specific value for the option |
| 2153 | + value = jQuery( option ).val(); |
| 2154 | + |
| 2155 | + // We don't need an array for one selects |
| 2156 | + if ( one ) { |
| 2157 | + return value; |
| 2158 | + } |
| 2159 | + |
| 2160 | + // Multi-Selects return an array |
| 2161 | + values.push( value ); |
| 2162 | + } |
| 2163 | + } |
| 2164 | + |
| 2165 | + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() |
| 2166 | + if ( one && !values.length && options.length ) { |
| 2167 | + return jQuery( options[ index ] ).val(); |
| 2168 | + } |
| 2169 | + |
| 2170 | + return values; |
| 2171 | + }, |
| 2172 | + |
| 2173 | + set: function( elem, value ) { |
| 2174 | + var values = jQuery.makeArray( value ); |
| 2175 | + |
| 2176 | + jQuery(elem).find("option").each(function() { |
1675 | 2177 | this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; |
1676 | 2178 | }); |
1677 | 2179 | |
1678 | 2180 | if ( !values.length ) { |
1679 | | - this.selectedIndex = -1; |
| 2181 | + elem.selectedIndex = -1; |
1680 | 2182 | } |
1681 | | - |
1682 | | - } else { |
1683 | | - this.value = val; |
| 2183 | + return values; |
1684 | 2184 | } |
1685 | | - }); |
1686 | | - } |
1687 | | -}); |
| 2185 | + } |
| 2186 | + }, |
1688 | 2187 | |
1689 | | -jQuery.extend({ |
1690 | 2188 | attrFn: { |
1691 | 2189 | val: true, |
1692 | 2190 | css: true, |
— | — | @@ -1696,107 +2194,340 @@ |
1697 | 2195 | height: true, |
1698 | 2196 | offset: true |
1699 | 2197 | }, |
| 2198 | + |
| 2199 | + attrFix: { |
| 2200 | + // Always normalize to ensure hook usage |
| 2201 | + tabindex: "tabIndex" |
| 2202 | + }, |
| 2203 | + |
| 2204 | + attr: function( elem, name, value, pass ) { |
| 2205 | + var nType = elem.nodeType; |
1700 | 2206 | |
1701 | | - attr: function( elem, name, value, pass ) { |
1702 | | - // don't set attributes on text and comment nodes |
1703 | | - if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
| 2207 | + // don't get/set attributes on text, comment and attribute nodes |
| 2208 | + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
1704 | 2209 | return undefined; |
1705 | 2210 | } |
1706 | 2211 | |
1707 | 2212 | if ( pass && name in jQuery.attrFn ) { |
1708 | | - return jQuery(elem)[name](value); |
| 2213 | + return jQuery( elem )[ name ]( value ); |
1709 | 2214 | } |
1710 | 2215 | |
1711 | | - var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), |
1712 | | - // Whether we are setting (or getting) |
1713 | | - set = value !== undefined; |
| 2216 | + // Fallback to prop when attributes are not supported |
| 2217 | + if ( !("getAttribute" in elem) ) { |
| 2218 | + return jQuery.prop( elem, name, value ); |
| 2219 | + } |
1714 | 2220 | |
1715 | | - // Try to normalize/fix the name |
1716 | | - name = notxml && jQuery.props[ name ] || name; |
| 2221 | + var ret, hooks, |
| 2222 | + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); |
1717 | 2223 | |
1718 | | - // These attributes require special treatment |
1719 | | - var special = rspecialurl.test( name ); |
| 2224 | + // Normalize the name if needed |
| 2225 | + if ( notxml ) { |
| 2226 | + name = jQuery.attrFix[ name ] || name; |
1720 | 2227 | |
1721 | | - // Safari mis-reports the default selected property of an option |
1722 | | - // Accessing the parent's selectedIndex property fixes it |
1723 | | - if ( name === "selected" && !jQuery.support.optSelected ) { |
1724 | | - var parent = elem.parentNode; |
1725 | | - if ( parent ) { |
1726 | | - parent.selectedIndex; |
| 2228 | + hooks = jQuery.attrHooks[ name ]; |
1727 | 2229 | |
1728 | | - // Make sure that it also works with optgroups, see #5701 |
1729 | | - if ( parent.parentNode ) { |
1730 | | - parent.parentNode.selectedIndex; |
| 2230 | + if ( !hooks ) { |
| 2231 | + // Use boolHook for boolean attributes |
| 2232 | + if ( rboolean.test( name ) ) { |
| 2233 | + |
| 2234 | + hooks = boolHook; |
| 2235 | + |
| 2236 | + // Use formHook for forms and if the name contains certain characters |
| 2237 | + } else if ( formHook && name !== "className" && |
| 2238 | + (jQuery.nodeName( elem, "form" ) || rinvalidChar.test( name )) ) { |
| 2239 | + |
| 2240 | + hooks = formHook; |
1731 | 2241 | } |
1732 | 2242 | } |
1733 | 2243 | } |
1734 | 2244 | |
1735 | | - // If applicable, access the attribute via the DOM 0 way |
1736 | | - // 'in' checks fail in Blackberry 4.7 #6931 |
1737 | | - if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) { |
1738 | | - if ( set ) { |
1739 | | - // We can't allow the type property to be changed (since it causes problems in IE) |
1740 | | - if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) { |
1741 | | - jQuery.error( "type property can't be changed" ); |
1742 | | - } |
| 2245 | + if ( value !== undefined ) { |
1743 | 2246 | |
1744 | | - if ( value === null ) { |
1745 | | - if ( elem.nodeType === 1 ) { |
1746 | | - elem.removeAttribute( name ); |
1747 | | - } |
| 2247 | + if ( value === null ) { |
| 2248 | + jQuery.removeAttr( elem, name ); |
| 2249 | + return undefined; |
1748 | 2250 | |
1749 | | - } else { |
1750 | | - elem[ name ] = value; |
1751 | | - } |
| 2251 | + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { |
| 2252 | + return ret; |
| 2253 | + |
| 2254 | + } else { |
| 2255 | + elem.setAttribute( name, "" + value ); |
| 2256 | + return value; |
1752 | 2257 | } |
1753 | 2258 | |
1754 | | - // browsers index elements by id/name on forms, give priority to attributes. |
1755 | | - if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) { |
1756 | | - return elem.getAttributeNode( name ).nodeValue; |
| 2259 | + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { |
| 2260 | + return ret; |
| 2261 | + |
| 2262 | + } else { |
| 2263 | + |
| 2264 | + ret = elem.getAttribute( name ); |
| 2265 | + |
| 2266 | + // Non-existent attributes return null, we normalize to undefined |
| 2267 | + return ret === null ? |
| 2268 | + undefined : |
| 2269 | + ret; |
| 2270 | + } |
| 2271 | + }, |
| 2272 | + |
| 2273 | + removeAttr: function( elem, name ) { |
| 2274 | + var propName; |
| 2275 | + if ( elem.nodeType === 1 ) { |
| 2276 | + name = jQuery.attrFix[ name ] || name; |
| 2277 | + |
| 2278 | + if ( jQuery.support.getSetAttribute ) { |
| 2279 | + // Use removeAttribute in browsers that support it |
| 2280 | + elem.removeAttribute( name ); |
| 2281 | + } else { |
| 2282 | + jQuery.attr( elem, name, "" ); |
| 2283 | + elem.removeAttributeNode( elem.getAttributeNode( name ) ); |
1757 | 2284 | } |
1758 | 2285 | |
1759 | | - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set |
1760 | | - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
1761 | | - if ( name === "tabIndex" ) { |
1762 | | - var attributeNode = elem.getAttributeNode( "tabIndex" ); |
| 2286 | + // Set corresponding property to false for boolean attributes |
| 2287 | + if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) { |
| 2288 | + elem[ propName ] = false; |
| 2289 | + } |
| 2290 | + } |
| 2291 | + }, |
1763 | 2292 | |
| 2293 | + attrHooks: { |
| 2294 | + type: { |
| 2295 | + set: function( elem, value ) { |
| 2296 | + // We can't allow the type property to be changed (since it causes problems in IE) |
| 2297 | + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { |
| 2298 | + jQuery.error( "type property can't be changed" ); |
| 2299 | + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { |
| 2300 | + // Setting the type on a radio button after the value resets the value in IE6-9 |
| 2301 | + // Reset value to it's default in case type is set after value |
| 2302 | + // This is for element creation |
| 2303 | + var val = elem.value; |
| 2304 | + elem.setAttribute( "type", value ); |
| 2305 | + if ( val ) { |
| 2306 | + elem.value = val; |
| 2307 | + } |
| 2308 | + return value; |
| 2309 | + } |
| 2310 | + } |
| 2311 | + }, |
| 2312 | + tabIndex: { |
| 2313 | + get: function( elem ) { |
| 2314 | + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set |
| 2315 | + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
| 2316 | + var attributeNode = elem.getAttributeNode("tabIndex"); |
| 2317 | + |
1764 | 2318 | return attributeNode && attributeNode.specified ? |
1765 | | - attributeNode.value : |
| 2319 | + parseInt( attributeNode.value, 10 ) : |
1766 | 2320 | rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? |
1767 | 2321 | 0 : |
1768 | 2322 | undefined; |
1769 | 2323 | } |
| 2324 | + }, |
| 2325 | + // Use the value property for back compat |
| 2326 | + // Use the formHook for button elements in IE6/7 (#1954) |
| 2327 | + value: { |
| 2328 | + get: function( elem, name ) { |
| 2329 | + if ( formHook && jQuery.nodeName( elem, "button" ) ) { |
| 2330 | + return formHook.get( elem, name ); |
| 2331 | + } |
| 2332 | + return name in elem ? |
| 2333 | + elem.value : |
| 2334 | + null; |
| 2335 | + }, |
| 2336 | + set: function( elem, value, name ) { |
| 2337 | + if ( formHook && jQuery.nodeName( elem, "button" ) ) { |
| 2338 | + return formHook.set( elem, value, name ); |
| 2339 | + } |
| 2340 | + // Does not return so that setAttribute is also used |
| 2341 | + elem.value = value; |
| 2342 | + } |
| 2343 | + } |
| 2344 | + }, |
1770 | 2345 | |
1771 | | - return elem[ name ]; |
| 2346 | + propFix: { |
| 2347 | + tabindex: "tabIndex", |
| 2348 | + readonly: "readOnly", |
| 2349 | + "for": "htmlFor", |
| 2350 | + "class": "className", |
| 2351 | + maxlength: "maxLength", |
| 2352 | + cellspacing: "cellSpacing", |
| 2353 | + cellpadding: "cellPadding", |
| 2354 | + rowspan: "rowSpan", |
| 2355 | + colspan: "colSpan", |
| 2356 | + usemap: "useMap", |
| 2357 | + frameborder: "frameBorder", |
| 2358 | + contenteditable: "contentEditable" |
| 2359 | + }, |
| 2360 | + |
| 2361 | + prop: function( elem, name, value ) { |
| 2362 | + var nType = elem.nodeType; |
| 2363 | + |
| 2364 | + // don't get/set properties on text, comment and attribute nodes |
| 2365 | + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { |
| 2366 | + return undefined; |
1772 | 2367 | } |
1773 | 2368 | |
1774 | | - if ( !jQuery.support.style && notxml && name === "style" ) { |
1775 | | - if ( set ) { |
1776 | | - elem.style.cssText = "" + value; |
| 2369 | + var ret, hooks, |
| 2370 | + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); |
| 2371 | + |
| 2372 | + if ( notxml ) { |
| 2373 | + // Fix name and attach hooks |
| 2374 | + name = jQuery.propFix[ name ] || name; |
| 2375 | + hooks = jQuery.propHooks[ name ]; |
| 2376 | + } |
| 2377 | + |
| 2378 | + if ( value !== undefined ) { |
| 2379 | + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { |
| 2380 | + return ret; |
| 2381 | + |
| 2382 | + } else { |
| 2383 | + return (elem[ name ] = value); |
1777 | 2384 | } |
1778 | 2385 | |
1779 | | - return elem.style.cssText; |
| 2386 | + } else { |
| 2387 | + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== undefined ) { |
| 2388 | + return ret; |
| 2389 | + |
| 2390 | + } else { |
| 2391 | + return elem[ name ]; |
| 2392 | + } |
1780 | 2393 | } |
| 2394 | + }, |
| 2395 | + |
| 2396 | + propHooks: {} |
| 2397 | +}); |
1781 | 2398 | |
1782 | | - if ( set ) { |
1783 | | - // convert the value to a string (all browsers do this but IE) see #1070 |
1784 | | - elem.setAttribute( name, "" + value ); |
| 2399 | +// Hook for boolean attributes |
| 2400 | +boolHook = { |
| 2401 | + get: function( elem, name ) { |
| 2402 | + // Align boolean attributes with corresponding properties |
| 2403 | + return jQuery.prop( elem, name ) ? |
| 2404 | + name.toLowerCase() : |
| 2405 | + undefined; |
| 2406 | + }, |
| 2407 | + set: function( elem, value, name ) { |
| 2408 | + var propName; |
| 2409 | + if ( value === false ) { |
| 2410 | + // Remove boolean attributes when set to false |
| 2411 | + jQuery.removeAttr( elem, name ); |
| 2412 | + } else { |
| 2413 | + // value is true since we know at this point it's type boolean and not false |
| 2414 | + // Set boolean attributes to the same name and set the DOM property |
| 2415 | + propName = jQuery.propFix[ name ] || name; |
| 2416 | + if ( propName in elem ) { |
| 2417 | + // Only set the IDL specifically if it already exists on the element |
| 2418 | + elem[ propName ] = true; |
| 2419 | + } |
| 2420 | + |
| 2421 | + elem.setAttribute( name, name.toLowerCase() ); |
1785 | 2422 | } |
| 2423 | + return name; |
| 2424 | + } |
| 2425 | +}; |
1786 | 2426 | |
1787 | | - // Ensure that missing attributes return undefined |
1788 | | - // Blackberry 4.7 returns "" from getAttribute #6938 |
1789 | | - if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) { |
1790 | | - return undefined; |
| 2427 | +// IE6/7 do not support getting/setting some attributes with get/setAttribute |
| 2428 | +if ( !jQuery.support.getSetAttribute ) { |
| 2429 | + |
| 2430 | + // propFix is more comprehensive and contains all fixes |
| 2431 | + jQuery.attrFix = jQuery.propFix; |
| 2432 | + |
| 2433 | + // Use this for any attribute on a form in IE6/7 |
| 2434 | + formHook = jQuery.attrHooks.name = jQuery.attrHooks.title = jQuery.valHooks.button = { |
| 2435 | + get: function( elem, name ) { |
| 2436 | + var ret; |
| 2437 | + ret = elem.getAttributeNode( name ); |
| 2438 | + // Return undefined if nodeValue is empty string |
| 2439 | + return ret && ret.nodeValue !== "" ? |
| 2440 | + ret.nodeValue : |
| 2441 | + undefined; |
| 2442 | + }, |
| 2443 | + set: function( elem, value, name ) { |
| 2444 | + // Check form objects in IE (multiple bugs related) |
| 2445 | + // Only use nodeValue if the attribute node exists on the form |
| 2446 | + var ret = elem.getAttributeNode( name ); |
| 2447 | + if ( ret ) { |
| 2448 | + ret.nodeValue = value; |
| 2449 | + return value; |
| 2450 | + } |
1791 | 2451 | } |
| 2452 | + }; |
1792 | 2453 | |
1793 | | - var attr = !jQuery.support.hrefNormalized && notxml && special ? |
1794 | | - // Some attributes require a special call on IE |
1795 | | - elem.getAttribute( name, 2 ) : |
1796 | | - elem.getAttribute( name ); |
| 2454 | + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) |
| 2455 | + // This is for removals |
| 2456 | + jQuery.each([ "width", "height" ], function( i, name ) { |
| 2457 | + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { |
| 2458 | + set: function( elem, value ) { |
| 2459 | + if ( value === "" ) { |
| 2460 | + elem.setAttribute( name, "auto" ); |
| 2461 | + return value; |
| 2462 | + } |
| 2463 | + } |
| 2464 | + }); |
| 2465 | + }); |
| 2466 | +} |
1797 | 2467 | |
1798 | | - // Non-existent attributes return null, we normalize to undefined |
1799 | | - return attr === null ? undefined : attr; |
1800 | | - } |
| 2468 | + |
| 2469 | +// Some attributes require a special call on IE |
| 2470 | +if ( !jQuery.support.hrefNormalized ) { |
| 2471 | + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { |
| 2472 | + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { |
| 2473 | + get: function( elem ) { |
| 2474 | + var ret = elem.getAttribute( name, 2 ); |
| 2475 | + return ret === null ? undefined : ret; |
| 2476 | + } |
| 2477 | + }); |
| 2478 | + }); |
| 2479 | +} |
| 2480 | + |
| 2481 | +if ( !jQuery.support.style ) { |
| 2482 | + jQuery.attrHooks.style = { |
| 2483 | + get: function( elem ) { |
| 2484 | + // Return undefined in the case of empty string |
| 2485 | + // Normalize to lowercase since IE uppercases css property names |
| 2486 | + return elem.style.cssText.toLowerCase() || undefined; |
| 2487 | + }, |
| 2488 | + set: function( elem, value ) { |
| 2489 | + return (elem.style.cssText = "" + value); |
| 2490 | + } |
| 2491 | + }; |
| 2492 | +} |
| 2493 | + |
| 2494 | +// Safari mis-reports the default selected property of an option |
| 2495 | +// Accessing the parent's selectedIndex property fixes it |
| 2496 | +if ( !jQuery.support.optSelected ) { |
| 2497 | + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { |
| 2498 | + get: function( elem ) { |
| 2499 | + var parent = elem.parentNode; |
| 2500 | + |
| 2501 | + if ( parent ) { |
| 2502 | + parent.selectedIndex; |
| 2503 | + |
| 2504 | + // Make sure that it also works with optgroups, see #5701 |
| 2505 | + if ( parent.parentNode ) { |
| 2506 | + parent.parentNode.selectedIndex; |
| 2507 | + } |
| 2508 | + } |
| 2509 | + } |
| 2510 | + }); |
| 2511 | +} |
| 2512 | + |
| 2513 | +// Radios and checkboxes getter/setter |
| 2514 | +if ( !jQuery.support.checkOn ) { |
| 2515 | + jQuery.each([ "radio", "checkbox" ], function() { |
| 2516 | + jQuery.valHooks[ this ] = { |
| 2517 | + get: function( elem ) { |
| 2518 | + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified |
| 2519 | + return elem.getAttribute("value") === null ? "on" : elem.value; |
| 2520 | + } |
| 2521 | + }; |
| 2522 | + }); |
| 2523 | +} |
| 2524 | +jQuery.each([ "radio", "checkbox" ], function() { |
| 2525 | + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { |
| 2526 | + set: function( elem, value ) { |
| 2527 | + if ( jQuery.isArray( value ) ) { |
| 2528 | + return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0); |
| 2529 | + } |
| 2530 | + } |
| 2531 | + }); |
1801 | 2532 | }); |
1802 | 2533 | |
1803 | 2534 | |
— | — | @@ -1805,12 +2536,11 @@ |
1806 | 2537 | var rnamespaces = /\.(.*)$/, |
1807 | 2538 | rformElems = /^(?:textarea|input|select)$/i, |
1808 | 2539 | rperiod = /\./g, |
1809 | | - rspace = / /g, |
| 2540 | + rspaces = / /g, |
1810 | 2541 | rescape = /[^\w\s.|`]/g, |
1811 | 2542 | fcleanup = function( nm ) { |
1812 | 2543 | return nm.replace(rescape, "\\$&"); |
1813 | | - }, |
1814 | | - focusCounts = { focusin: 0, focusout: 0 }; |
| 2544 | + }; |
1815 | 2545 | |
1816 | 2546 | /* |
1817 | 2547 | * A number of helper functions used for managing events. |
— | — | @@ -1826,17 +2556,11 @@ |
1827 | 2557 | return; |
1828 | 2558 | } |
1829 | 2559 | |
1830 | | - // For whatever reason, IE has trouble passing the window object |
1831 | | - // around, causing it to be cloned in the process |
1832 | | - if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) { |
1833 | | - elem = window; |
1834 | | - } |
1835 | | - |
1836 | 2560 | if ( handler === false ) { |
1837 | 2561 | handler = returnFalse; |
1838 | 2562 | } else if ( !handler ) { |
1839 | 2563 | // Fixes bug #7229. Fix recommended by jdalton |
1840 | | - return; |
| 2564 | + return; |
1841 | 2565 | } |
1842 | 2566 | |
1843 | 2567 | var handleObjIn, handleObj; |
— | — | @@ -1852,7 +2576,7 @@ |
1853 | 2577 | } |
1854 | 2578 | |
1855 | 2579 | // Init the element's event structure |
1856 | | - var elemData = jQuery.data( elem ); |
| 2580 | + var elemData = jQuery._data( elem ); |
1857 | 2581 | |
1858 | 2582 | // If no elemData is found then we must be trying to bind to one of the |
1859 | 2583 | // banned noData elements |
— | — | @@ -1860,34 +2584,18 @@ |
1861 | 2585 | return; |
1862 | 2586 | } |
1863 | 2587 | |
1864 | | - // Use a key less likely to result in collisions for plain JS objects. |
1865 | | - // Fixes bug #7150. |
1866 | | - var eventKey = elem.nodeType ? "events" : "__events__", |
1867 | | - events = elemData[ eventKey ], |
| 2588 | + var events = elemData.events, |
1868 | 2589 | eventHandle = elemData.handle; |
1869 | | - |
1870 | | - if ( typeof events === "function" ) { |
1871 | | - // On plain objects events is a fn that holds the the data |
1872 | | - // which prevents this data from being JSON serialized |
1873 | | - // the function does not need to be called, it just contains the data |
1874 | | - eventHandle = events.handle; |
1875 | | - events = events.events; |
1876 | 2590 | |
1877 | | - } else if ( !events ) { |
1878 | | - if ( !elem.nodeType ) { |
1879 | | - // On plain objects, create a fn that acts as the holder |
1880 | | - // of the values to avoid JSON serialization of event data |
1881 | | - elemData[ eventKey ] = elemData = function(){}; |
1882 | | - } |
1883 | | - |
| 2591 | + if ( !events ) { |
1884 | 2592 | elemData.events = events = {}; |
1885 | 2593 | } |
1886 | 2594 | |
1887 | 2595 | if ( !eventHandle ) { |
1888 | | - elemData.handle = eventHandle = function() { |
1889 | | - // Handle the second event of a trigger and when |
1890 | | - // an event is called after a page has unloaded |
1891 | | - return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
| 2596 | + elemData.handle = eventHandle = function( e ) { |
| 2597 | + // Discard the second event of a jQuery.event.trigger() and |
| 2598 | + // when an event is called after a page has unloaded |
| 2599 | + return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? |
1892 | 2600 | jQuery.event.handle.apply( eventHandle.elem, arguments ) : |
1893 | 2601 | undefined; |
1894 | 2602 | }; |
— | — | @@ -1945,10 +2653,10 @@ |
1946 | 2654 | } |
1947 | 2655 | } |
1948 | 2656 | } |
1949 | | - |
1950 | | - if ( special.add ) { |
1951 | | - special.add.call( elem, handleObj ); |
1952 | 2657 | |
| 2658 | + if ( special.add ) { |
| 2659 | + special.add.call( elem, handleObj ); |
| 2660 | + |
1953 | 2661 | if ( !handleObj.handler.guid ) { |
1954 | 2662 | handleObj.handler.guid = handler.guid; |
1955 | 2663 | } |
— | — | @@ -1957,7 +2665,7 @@ |
1958 | 2666 | // Add the function to the element's handler list |
1959 | 2667 | handlers.push( handleObj ); |
1960 | 2668 | |
1961 | | - // Keep track of which events have been used, for global triggering |
| 2669 | + // Keep track of which events have been used, for event optimization |
1962 | 2670 | jQuery.event.global[ type ] = true; |
1963 | 2671 | } |
1964 | 2672 | |
— | — | @@ -1979,18 +2687,12 @@ |
1980 | 2688 | } |
1981 | 2689 | |
1982 | 2690 | var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, |
1983 | | - eventKey = elem.nodeType ? "events" : "__events__", |
1984 | | - elemData = jQuery.data( elem ), |
1985 | | - events = elemData && elemData[ eventKey ]; |
| 2691 | + elemData = jQuery.hasData( elem ) && jQuery._data( elem ), |
| 2692 | + events = elemData && elemData.events; |
1986 | 2693 | |
1987 | 2694 | if ( !elemData || !events ) { |
1988 | 2695 | return; |
1989 | 2696 | } |
1990 | | - |
1991 | | - if ( typeof events === "function" ) { |
1992 | | - elemData = events; |
1993 | | - events = events.events; |
1994 | | - } |
1995 | 2697 | |
1996 | 2698 | // types is actually an event object here |
1997 | 2699 | if ( types && types.type ) { |
— | — | @@ -2024,7 +2726,7 @@ |
2025 | 2727 | namespaces = type.split("."); |
2026 | 2728 | type = namespaces.shift(); |
2027 | 2729 | |
2028 | | - namespace = new RegExp("(^|\\.)" + |
| 2730 | + namespace = new RegExp("(^|\\.)" + |
2029 | 2731 | jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)"); |
2030 | 2732 | } |
2031 | 2733 | |
— | — | @@ -2091,189 +2793,190 @@ |
2092 | 2794 | delete elemData.events; |
2093 | 2795 | delete elemData.handle; |
2094 | 2796 | |
2095 | | - if ( typeof elemData === "function" ) { |
2096 | | - jQuery.removeData( elem, eventKey ); |
2097 | | - |
2098 | | - } else if ( jQuery.isEmptyObject( elemData ) ) { |
2099 | | - jQuery.removeData( elem ); |
| 2797 | + if ( jQuery.isEmptyObject( elemData ) ) { |
| 2798 | + jQuery.removeData( elem, undefined, true ); |
2100 | 2799 | } |
2101 | 2800 | } |
2102 | 2801 | }, |
| 2802 | + |
| 2803 | + // Events that are safe to short-circuit if no handlers are attached. |
| 2804 | + // Native DOM events should not be added, they may have inline handlers. |
| 2805 | + customEvent: { |
| 2806 | + "getData": true, |
| 2807 | + "setData": true, |
| 2808 | + "changeData": true |
| 2809 | + }, |
2103 | 2810 | |
2104 | | - // bubbling is internal |
2105 | | - trigger: function( event, data, elem /*, bubbling */ ) { |
| 2811 | + trigger: function( event, data, elem, onlyHandlers ) { |
2106 | 2812 | // Event object or event type |
2107 | 2813 | var type = event.type || event, |
2108 | | - bubbling = arguments[3]; |
| 2814 | + namespaces = [], |
| 2815 | + exclusive; |
2109 | 2816 | |
2110 | | - if ( !bubbling ) { |
2111 | | - event = typeof event === "object" ? |
2112 | | - // jQuery.Event object |
2113 | | - event[ jQuery.expando ] ? event : |
2114 | | - // Object literal |
2115 | | - jQuery.extend( jQuery.Event(type), event ) : |
2116 | | - // Just the event type (string) |
2117 | | - jQuery.Event(type); |
| 2817 | + if ( type.indexOf("!") >= 0 ) { |
| 2818 | + // Exclusive events trigger only for the exact event (no namespaces) |
| 2819 | + type = type.slice(0, -1); |
| 2820 | + exclusive = true; |
| 2821 | + } |
2118 | 2822 | |
2119 | | - if ( type.indexOf("!") >= 0 ) { |
2120 | | - event.type = type = type.slice(0, -1); |
2121 | | - event.exclusive = true; |
2122 | | - } |
| 2823 | + if ( type.indexOf(".") >= 0 ) { |
| 2824 | + // Namespaced trigger; create a regexp to match event type in handle() |
| 2825 | + namespaces = type.split("."); |
| 2826 | + type = namespaces.shift(); |
| 2827 | + namespaces.sort(); |
| 2828 | + } |
2123 | 2829 | |
2124 | | - // Handle a global trigger |
2125 | | - if ( !elem ) { |
2126 | | - // Don't bubble custom events when global (to avoid too much overhead) |
2127 | | - event.stopPropagation(); |
| 2830 | + if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { |
| 2831 | + // No jQuery handlers for this event type, and it can't have inline handlers |
| 2832 | + return; |
| 2833 | + } |
2128 | 2834 | |
2129 | | - // Only trigger if we've ever bound an event for it |
2130 | | - if ( jQuery.event.global[ type ] ) { |
2131 | | - jQuery.each( jQuery.cache, function() { |
2132 | | - if ( this.events && this.events[type] ) { |
2133 | | - jQuery.event.trigger( event, data, this.handle.elem ); |
2134 | | - } |
2135 | | - }); |
2136 | | - } |
2137 | | - } |
| 2835 | + // Caller can pass in an Event, Object, or just an event type string |
| 2836 | + event = typeof event === "object" ? |
| 2837 | + // jQuery.Event object |
| 2838 | + event[ jQuery.expando ] ? event : |
| 2839 | + // Object literal |
| 2840 | + new jQuery.Event( type, event ) : |
| 2841 | + // Just the event type (string) |
| 2842 | + new jQuery.Event( type ); |
2138 | 2843 | |
2139 | | - // Handle triggering a single element |
| 2844 | + event.type = type; |
| 2845 | + event.exclusive = exclusive; |
| 2846 | + event.namespace = namespaces.join("."); |
| 2847 | + event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); |
| 2848 | + |
| 2849 | + // triggerHandler() and global events don't bubble or run the default action |
| 2850 | + if ( onlyHandlers || !elem ) { |
| 2851 | + event.preventDefault(); |
| 2852 | + event.stopPropagation(); |
| 2853 | + } |
2140 | 2854 | |
2141 | | - // don't do events on text and comment nodes |
2142 | | - if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
2143 | | - return undefined; |
2144 | | - } |
| 2855 | + // Handle a global trigger |
| 2856 | + if ( !elem ) { |
| 2857 | + // TODO: Stop taunting the data cache; remove global events and always attach to document |
| 2858 | + jQuery.each( jQuery.cache, function() { |
| 2859 | + // internalKey variable is just used to make it easier to find |
| 2860 | + // and potentially change this stuff later; currently it just |
| 2861 | + // points to jQuery.expando |
| 2862 | + var internalKey = jQuery.expando, |
| 2863 | + internalCache = this[ internalKey ]; |
| 2864 | + if ( internalCache && internalCache.events && internalCache.events[ type ] ) { |
| 2865 | + jQuery.event.trigger( event, data, internalCache.handle.elem ); |
| 2866 | + } |
| 2867 | + }); |
| 2868 | + return; |
| 2869 | + } |
2145 | 2870 | |
2146 | | - // Clean up in case it is reused |
2147 | | - event.result = undefined; |
2148 | | - event.target = elem; |
2149 | | - |
2150 | | - // Clone the incoming data, if any |
2151 | | - data = jQuery.makeArray( data ); |
2152 | | - data.unshift( event ); |
| 2871 | + // Don't do events on text and comment nodes |
| 2872 | + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
| 2873 | + return; |
2153 | 2874 | } |
2154 | 2875 | |
2155 | | - event.currentTarget = elem; |
| 2876 | + // Clean up the event in case it is being reused |
| 2877 | + event.result = undefined; |
| 2878 | + event.target = elem; |
2156 | 2879 | |
2157 | | - // Trigger the event, it is assumed that "handle" is a function |
2158 | | - var handle = elem.nodeType ? |
2159 | | - jQuery.data( elem, "handle" ) : |
2160 | | - (jQuery.data( elem, "__events__" ) || {}).handle; |
| 2880 | + // Clone any incoming data and prepend the event, creating the handler arg list |
| 2881 | + data = data != null ? jQuery.makeArray( data ) : []; |
| 2882 | + data.unshift( event ); |
2161 | 2883 | |
2162 | | - if ( handle ) { |
2163 | | - handle.apply( elem, data ); |
2164 | | - } |
| 2884 | + var cur = elem, |
| 2885 | + // IE doesn't like method names with a colon (#3533, #8272) |
| 2886 | + ontype = type.indexOf(":") < 0 ? "on" + type : ""; |
2165 | 2887 | |
2166 | | - var parent = elem.parentNode || elem.ownerDocument; |
| 2888 | + // Fire event on the current element, then bubble up the DOM tree |
| 2889 | + do { |
| 2890 | + var handle = jQuery._data( cur, "handle" ); |
2167 | 2891 | |
2168 | | - // Trigger an inline bound script |
2169 | | - try { |
2170 | | - if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) { |
2171 | | - if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) { |
2172 | | - event.result = false; |
2173 | | - event.preventDefault(); |
2174 | | - } |
| 2892 | + event.currentTarget = cur; |
| 2893 | + if ( handle ) { |
| 2894 | + handle.apply( cur, data ); |
2175 | 2895 | } |
2176 | 2896 | |
2177 | | - // prevent IE from throwing an error for some elements with some event types, see #3533 |
2178 | | - } catch (inlineError) {} |
| 2897 | + // Trigger an inline bound script |
| 2898 | + if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) { |
| 2899 | + event.result = false; |
| 2900 | + event.preventDefault(); |
| 2901 | + } |
2179 | 2902 | |
2180 | | - if ( !event.isPropagationStopped() && parent ) { |
2181 | | - jQuery.event.trigger( event, data, parent, true ); |
| 2903 | + // Bubble up to document, then to window |
| 2904 | + cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window; |
| 2905 | + } while ( cur && !event.isPropagationStopped() ); |
2182 | 2906 | |
2183 | | - } else if ( !event.isDefaultPrevented() ) { |
| 2907 | + // If nobody prevented the default action, do it now |
| 2908 | + if ( !event.isDefaultPrevented() ) { |
2184 | 2909 | var old, |
2185 | | - target = event.target, |
2186 | | - targetType = type.replace( rnamespaces, "" ), |
2187 | | - isClick = jQuery.nodeName( target, "a" ) && targetType === "click", |
2188 | | - special = jQuery.event.special[ targetType ] || {}; |
| 2910 | + special = jQuery.event.special[ type ] || {}; |
2189 | 2911 | |
2190 | | - if ( (!special._default || special._default.call( elem, event ) === false) && |
2191 | | - !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) { |
| 2912 | + if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) && |
| 2913 | + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { |
2192 | 2914 | |
| 2915 | + // Call a native DOM method on the target with the same name name as the event. |
| 2916 | + // Can't use an .isFunction)() check here because IE6/7 fails that test. |
| 2917 | + // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch. |
2193 | 2918 | try { |
2194 | | - if ( target[ targetType ] ) { |
2195 | | - // Make sure that we don't accidentally re-trigger the onFOO events |
2196 | | - old = target[ "on" + targetType ]; |
| 2919 | + if ( ontype && elem[ type ] ) { |
| 2920 | + // Don't re-trigger an onFOO event when we call its FOO() method |
| 2921 | + old = elem[ ontype ]; |
2197 | 2922 | |
2198 | 2923 | if ( old ) { |
2199 | | - target[ "on" + targetType ] = null; |
| 2924 | + elem[ ontype ] = null; |
2200 | 2925 | } |
2201 | 2926 | |
2202 | | - jQuery.event.triggered = true; |
2203 | | - target[ targetType ](); |
| 2927 | + jQuery.event.triggered = type; |
| 2928 | + elem[ type ](); |
2204 | 2929 | } |
| 2930 | + } catch ( ieError ) {} |
2205 | 2931 | |
2206 | | - // prevent IE from throwing an error for some elements with some event types, see #3533 |
2207 | | - } catch (triggerError) {} |
2208 | | - |
2209 | 2932 | if ( old ) { |
2210 | | - target[ "on" + targetType ] = old; |
| 2933 | + elem[ ontype ] = old; |
2211 | 2934 | } |
2212 | 2935 | |
2213 | | - jQuery.event.triggered = false; |
| 2936 | + jQuery.event.triggered = undefined; |
2214 | 2937 | } |
2215 | 2938 | } |
| 2939 | + |
| 2940 | + return event.result; |
2216 | 2941 | }, |
2217 | 2942 | |
2218 | 2943 | handle: function( event ) { |
2219 | | - var all, handlers, namespaces, namespace_re, events, |
2220 | | - namespace_sort = [], |
2221 | | - args = jQuery.makeArray( arguments ); |
| 2944 | + event = jQuery.event.fix( event || window.event ); |
| 2945 | + // Snapshot the handlers list since a called handler may add/remove events. |
| 2946 | + var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0), |
| 2947 | + run_all = !event.exclusive && !event.namespace, |
| 2948 | + args = Array.prototype.slice.call( arguments, 0 ); |
2222 | 2949 | |
2223 | | - event = args[0] = jQuery.event.fix( event || window.event ); |
| 2950 | + // Use the fix-ed Event rather than the (read-only) native event |
| 2951 | + args[0] = event; |
2224 | 2952 | event.currentTarget = this; |
2225 | 2953 | |
2226 | | - // Namespaced event handlers |
2227 | | - all = event.type.indexOf(".") < 0 && !event.exclusive; |
| 2954 | + for ( var j = 0, l = handlers.length; j < l; j++ ) { |
| 2955 | + var handleObj = handlers[ j ]; |
2228 | 2956 | |
2229 | | - if ( !all ) { |
2230 | | - namespaces = event.type.split("."); |
2231 | | - event.type = namespaces.shift(); |
2232 | | - namespace_sort = namespaces.slice(0).sort(); |
2233 | | - namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)"); |
2234 | | - } |
| 2957 | + // Triggered event must 1) be non-exclusive and have no namespace, or |
| 2958 | + // 2) have namespace(s) a subset or equal to those in the bound event. |
| 2959 | + if ( run_all || event.namespace_re.test( handleObj.namespace ) ) { |
| 2960 | + // Pass in a reference to the handler function itself |
| 2961 | + // So that we can later remove it |
| 2962 | + event.handler = handleObj.handler; |
| 2963 | + event.data = handleObj.data; |
| 2964 | + event.handleObj = handleObj; |
2235 | 2965 | |
2236 | | - event.namespace = event.namespace || namespace_sort.join("."); |
| 2966 | + var ret = handleObj.handler.apply( this, args ); |
2237 | 2967 | |
2238 | | - events = jQuery.data(this, this.nodeType ? "events" : "__events__"); |
2239 | | - |
2240 | | - if ( typeof events === "function" ) { |
2241 | | - events = events.events; |
2242 | | - } |
2243 | | - |
2244 | | - handlers = (events || {})[ event.type ]; |
2245 | | - |
2246 | | - if ( events && handlers ) { |
2247 | | - // Clone the handlers to prevent manipulation |
2248 | | - handlers = handlers.slice(0); |
2249 | | - |
2250 | | - for ( var j = 0, l = handlers.length; j < l; j++ ) { |
2251 | | - var handleObj = handlers[ j ]; |
2252 | | - |
2253 | | - // Filter the functions by class |
2254 | | - if ( all || namespace_re.test( handleObj.namespace ) ) { |
2255 | | - // Pass in a reference to the handler function itself |
2256 | | - // So that we can later remove it |
2257 | | - event.handler = handleObj.handler; |
2258 | | - event.data = handleObj.data; |
2259 | | - event.handleObj = handleObj; |
2260 | | - |
2261 | | - var ret = handleObj.handler.apply( this, args ); |
2262 | | - |
2263 | | - if ( ret !== undefined ) { |
2264 | | - event.result = ret; |
2265 | | - if ( ret === false ) { |
2266 | | - event.preventDefault(); |
2267 | | - event.stopPropagation(); |
2268 | | - } |
| 2968 | + if ( ret !== undefined ) { |
| 2969 | + event.result = ret; |
| 2970 | + if ( ret === false ) { |
| 2971 | + event.preventDefault(); |
| 2972 | + event.stopPropagation(); |
2269 | 2973 | } |
| 2974 | + } |
2270 | 2975 | |
2271 | | - if ( event.isImmediatePropagationStopped() ) { |
2272 | | - break; |
2273 | | - } |
| 2976 | + if ( event.isImmediatePropagationStopped() ) { |
| 2977 | + break; |
2274 | 2978 | } |
2275 | 2979 | } |
2276 | 2980 | } |
2277 | | - |
2278 | 2981 | return event.result; |
2279 | 2982 | }, |
2280 | 2983 | |
— | — | @@ -2312,8 +3015,9 @@ |
2313 | 3016 | |
2314 | 3017 | // Calculate pageX/Y if missing and clientX/Y available |
2315 | 3018 | if ( event.pageX == null && event.clientX != null ) { |
2316 | | - var doc = document.documentElement, |
2317 | | - body = document.body; |
| 3019 | + var eventDocument = event.target.ownerDocument || document, |
| 3020 | + doc = eventDocument.documentElement, |
| 3021 | + body = eventDocument.body; |
2318 | 3022 | |
2319 | 3023 | event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); |
2320 | 3024 | event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); |
— | — | @@ -2355,7 +3059,7 @@ |
2356 | 3060 | add: function( handleObj ) { |
2357 | 3061 | jQuery.event.add( this, |
2358 | 3062 | liveConvert( handleObj.origType, handleObj.selector ), |
2359 | | - jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); |
| 3063 | + jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); |
2360 | 3064 | }, |
2361 | 3065 | |
2362 | 3066 | remove: function( handleObj ) { |
— | — | @@ -2385,28 +3089,39 @@ |
2386 | 3090 | if ( elem.removeEventListener ) { |
2387 | 3091 | elem.removeEventListener( type, handle, false ); |
2388 | 3092 | } |
2389 | | - } : |
| 3093 | + } : |
2390 | 3094 | function( elem, type, handle ) { |
2391 | 3095 | if ( elem.detachEvent ) { |
2392 | 3096 | elem.detachEvent( "on" + type, handle ); |
2393 | 3097 | } |
2394 | 3098 | }; |
2395 | 3099 | |
2396 | | -jQuery.Event = function( src ) { |
| 3100 | +jQuery.Event = function( src, props ) { |
2397 | 3101 | // Allow instantiation without the 'new' keyword |
2398 | 3102 | if ( !this.preventDefault ) { |
2399 | | - return new jQuery.Event( src ); |
| 3103 | + return new jQuery.Event( src, props ); |
2400 | 3104 | } |
2401 | 3105 | |
2402 | 3106 | // Event object |
2403 | 3107 | if ( src && src.type ) { |
2404 | 3108 | this.originalEvent = src; |
2405 | 3109 | this.type = src.type; |
| 3110 | + |
| 3111 | + // Events bubbling up the document may have been marked as prevented |
| 3112 | + // by a handler lower down the tree; reflect the correct value. |
| 3113 | + this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || |
| 3114 | + src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse; |
| 3115 | + |
2406 | 3116 | // Event type |
2407 | 3117 | } else { |
2408 | 3118 | this.type = src; |
2409 | 3119 | } |
2410 | 3120 | |
| 3121 | + // Put explicitly provided properties onto the event object |
| 3122 | + if ( props ) { |
| 3123 | + jQuery.extend( this, props ); |
| 3124 | + } |
| 3125 | + |
2411 | 3126 | // timeStamp is buggy for some events on Firefox(#3843) |
2412 | 3127 | // So we won't rely on the native value |
2413 | 3128 | this.timeStamp = jQuery.now(); |
— | — | @@ -2432,7 +3147,7 @@ |
2433 | 3148 | if ( !e ) { |
2434 | 3149 | return; |
2435 | 3150 | } |
2436 | | - |
| 3151 | + |
2437 | 3152 | // if preventDefault exists run it on the original event |
2438 | 3153 | if ( e.preventDefault ) { |
2439 | 3154 | e.preventDefault(); |
— | — | @@ -2468,27 +3183,27 @@ |
2469 | 3184 | // Checks if an event happened on an element within another element |
2470 | 3185 | // Used in jQuery.event.special.mouseenter and mouseleave handlers |
2471 | 3186 | var withinElement = function( event ) { |
| 3187 | + |
2472 | 3188 | // Check if mouse(over|out) are still within the same parent element |
2473 | | - var parent = event.relatedTarget; |
| 3189 | + var related = event.relatedTarget, |
| 3190 | + inside = false, |
| 3191 | + eventType = event.type; |
2474 | 3192 | |
2475 | | - // Firefox sometimes assigns relatedTarget a XUL element |
2476 | | - // which we cannot access the parentNode property of |
2477 | | - try { |
2478 | | - // Traverse up the tree |
2479 | | - while ( parent && parent !== this ) { |
2480 | | - parent = parent.parentNode; |
| 3193 | + event.type = event.data; |
| 3194 | + |
| 3195 | + if ( related !== this ) { |
| 3196 | + |
| 3197 | + if ( related ) { |
| 3198 | + inside = jQuery.contains( this, related ); |
2481 | 3199 | } |
2482 | 3200 | |
2483 | | - if ( parent !== this ) { |
2484 | | - // set the correct event type |
2485 | | - event.type = event.data; |
| 3201 | + if ( !inside ) { |
2486 | 3202 | |
2487 | | - // handle event if we actually just moused on to a non sub-element |
2488 | 3203 | jQuery.event.handle.apply( this, arguments ); |
| 3204 | + |
| 3205 | + event.type = eventType; |
2489 | 3206 | } |
2490 | | - |
2491 | | - // assuming we've left the element since we most likely mousedover a xul element |
2492 | | - } catch(e) { } |
| 3207 | + } |
2493 | 3208 | }, |
2494 | 3209 | |
2495 | 3210 | // In case of event delegation, we only need to rename the event.type, |
— | — | @@ -2518,24 +3233,22 @@ |
2519 | 3234 | |
2520 | 3235 | jQuery.event.special.submit = { |
2521 | 3236 | setup: function( data, namespaces ) { |
2522 | | - if ( this.nodeName.toLowerCase() !== "form" ) { |
| 3237 | + if ( !jQuery.nodeName( this, "form" ) ) { |
2523 | 3238 | jQuery.event.add(this, "click.specialSubmit", function( e ) { |
2524 | 3239 | var elem = e.target, |
2525 | 3240 | type = elem.type; |
2526 | 3241 | |
2527 | 3242 | if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { |
2528 | | - e.liveFired = undefined; |
2529 | | - return trigger( "submit", this, arguments ); |
| 3243 | + trigger( "submit", this, arguments ); |
2530 | 3244 | } |
2531 | 3245 | }); |
2532 | | - |
| 3246 | + |
2533 | 3247 | jQuery.event.add(this, "keypress.specialSubmit", function( e ) { |
2534 | 3248 | var elem = e.target, |
2535 | 3249 | type = elem.type; |
2536 | 3250 | |
2537 | 3251 | if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { |
2538 | | - e.liveFired = undefined; |
2539 | | - return trigger( "submit", this, arguments ); |
| 3252 | + trigger( "submit", this, arguments ); |
2540 | 3253 | } |
2541 | 3254 | }); |
2542 | 3255 | |
— | — | @@ -2569,7 +3282,7 @@ |
2570 | 3283 | }).join("-") : |
2571 | 3284 | ""; |
2572 | 3285 | |
2573 | | - } else if ( elem.nodeName.toLowerCase() === "select" ) { |
| 3286 | + } else if ( jQuery.nodeName( elem, "select" ) ) { |
2574 | 3287 | val = elem.selectedIndex; |
2575 | 3288 | } |
2576 | 3289 | |
— | — | @@ -2583,14 +3296,14 @@ |
2584 | 3297 | return; |
2585 | 3298 | } |
2586 | 3299 | |
2587 | | - data = jQuery.data( elem, "_change_data" ); |
| 3300 | + data = jQuery._data( elem, "_change_data" ); |
2588 | 3301 | val = getVal(elem); |
2589 | 3302 | |
2590 | 3303 | // the current data will be also retrieved by beforeactivate |
2591 | 3304 | if ( e.type !== "focusout" || elem.type !== "radio" ) { |
2592 | | - jQuery.data( elem, "_change_data", val ); |
| 3305 | + jQuery._data( elem, "_change_data", val ); |
2593 | 3306 | } |
2594 | | - |
| 3307 | + |
2595 | 3308 | if ( data === undefined || val === data ) { |
2596 | 3309 | return; |
2597 | 3310 | } |
— | — | @@ -2598,33 +3311,33 @@ |
2599 | 3312 | if ( data != null || val ) { |
2600 | 3313 | e.type = "change"; |
2601 | 3314 | e.liveFired = undefined; |
2602 | | - return jQuery.event.trigger( e, arguments[1], elem ); |
| 3315 | + jQuery.event.trigger( e, arguments[1], elem ); |
2603 | 3316 | } |
2604 | 3317 | }; |
2605 | 3318 | |
2606 | 3319 | jQuery.event.special.change = { |
2607 | 3320 | filters: { |
2608 | | - focusout: testChange, |
| 3321 | + focusout: testChange, |
2609 | 3322 | |
2610 | 3323 | beforedeactivate: testChange, |
2611 | 3324 | |
2612 | 3325 | click: function( e ) { |
2613 | | - var elem = e.target, type = elem.type; |
| 3326 | + var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; |
2614 | 3327 | |
2615 | | - if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) { |
2616 | | - return testChange.call( this, e ); |
| 3328 | + if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) { |
| 3329 | + testChange.call( this, e ); |
2617 | 3330 | } |
2618 | 3331 | }, |
2619 | 3332 | |
2620 | 3333 | // Change has to be called before submit |
2621 | 3334 | // Keydown will be called before keypress, which is used in submit-event delegation |
2622 | 3335 | keydown: function( e ) { |
2623 | | - var elem = e.target, type = elem.type; |
| 3336 | + var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; |
2624 | 3337 | |
2625 | | - if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") || |
| 3338 | + if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) || |
2626 | 3339 | (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || |
2627 | 3340 | type === "select-multiple" ) { |
2628 | | - return testChange.call( this, e ); |
| 3341 | + testChange.call( this, e ); |
2629 | 3342 | } |
2630 | 3343 | }, |
2631 | 3344 | |
— | — | @@ -2633,7 +3346,7 @@ |
2634 | 3347 | // information |
2635 | 3348 | beforeactivate: function( e ) { |
2636 | 3349 | var elem = e.target; |
2637 | | - jQuery.data( elem, "_change_data", getVal(elem) ); |
| 3350 | + jQuery._data( elem, "_change_data", getVal(elem) ); |
2638 | 3351 | } |
2639 | 3352 | }, |
2640 | 3353 | |
— | — | @@ -2663,36 +3376,58 @@ |
2664 | 3377 | } |
2665 | 3378 | |
2666 | 3379 | function trigger( type, elem, args ) { |
2667 | | - args[0].type = type; |
2668 | | - return jQuery.event.handle.apply( elem, args ); |
| 3380 | + // Piggyback on a donor event to simulate a different one. |
| 3381 | + // Fake originalEvent to avoid donor's stopPropagation, but if the |
| 3382 | + // simulated event prevents default then we do the same on the donor. |
| 3383 | + // Don't pass args or remember liveFired; they apply to the donor event. |
| 3384 | + var event = jQuery.extend( {}, args[ 0 ] ); |
| 3385 | + event.type = type; |
| 3386 | + event.originalEvent = {}; |
| 3387 | + event.liveFired = undefined; |
| 3388 | + jQuery.event.handle.call( elem, event ); |
| 3389 | + if ( event.isDefaultPrevented() ) { |
| 3390 | + args[ 0 ].preventDefault(); |
| 3391 | + } |
2669 | 3392 | } |
2670 | 3393 | |
2671 | 3394 | // Create "bubbling" focus and blur events |
2672 | | -if ( document.addEventListener ) { |
| 3395 | +if ( !jQuery.support.focusinBubbles ) { |
2673 | 3396 | jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { |
| 3397 | + |
| 3398 | + // Attach a single capturing handler while someone wants focusin/focusout |
| 3399 | + var attaches = 0; |
| 3400 | + |
2674 | 3401 | jQuery.event.special[ fix ] = { |
2675 | 3402 | setup: function() { |
2676 | | - if ( focusCounts[fix]++ === 0 ) { |
| 3403 | + if ( attaches++ === 0 ) { |
2677 | 3404 | document.addEventListener( orig, handler, true ); |
2678 | 3405 | } |
2679 | | - }, |
2680 | | - teardown: function() { |
2681 | | - if ( --focusCounts[fix] === 0 ) { |
| 3406 | + }, |
| 3407 | + teardown: function() { |
| 3408 | + if ( --attaches === 0 ) { |
2682 | 3409 | document.removeEventListener( orig, handler, true ); |
2683 | 3410 | } |
2684 | 3411 | } |
2685 | 3412 | }; |
2686 | 3413 | |
2687 | | - function handler( e ) { |
2688 | | - e = jQuery.event.fix( e ); |
| 3414 | + function handler( donor ) { |
| 3415 | + // Donor event is always a native one; fix it and switch its type. |
| 3416 | + // Let focusin/out handler cancel the donor focus/blur event. |
| 3417 | + var e = jQuery.event.fix( donor ); |
2689 | 3418 | e.type = fix; |
2690 | | - return jQuery.event.trigger( e, null, e.target ); |
| 3419 | + e.originalEvent = {}; |
| 3420 | + jQuery.event.trigger( e, null, e.target ); |
| 3421 | + if ( e.isDefaultPrevented() ) { |
| 3422 | + donor.preventDefault(); |
| 3423 | + } |
2691 | 3424 | } |
2692 | 3425 | }); |
2693 | 3426 | } |
2694 | 3427 | |
2695 | 3428 | jQuery.each(["bind", "one"], function( i, name ) { |
2696 | 3429 | jQuery.fn[ name ] = function( type, data, fn ) { |
| 3430 | + var handler; |
| 3431 | + |
2697 | 3432 | // Handle object literals |
2698 | 3433 | if ( typeof type === "object" ) { |
2699 | 3434 | for ( var key in type ) { |
— | — | @@ -2700,16 +3435,21 @@ |
2701 | 3436 | } |
2702 | 3437 | return this; |
2703 | 3438 | } |
2704 | | - |
2705 | | - if ( jQuery.isFunction( data ) || data === false ) { |
| 3439 | + |
| 3440 | + if ( arguments.length === 2 || data === false ) { |
2706 | 3441 | fn = data; |
2707 | 3442 | data = undefined; |
2708 | 3443 | } |
2709 | 3444 | |
2710 | | - var handler = name === "one" ? jQuery.proxy( fn, function( event ) { |
2711 | | - jQuery( this ).unbind( event, handler ); |
2712 | | - return fn.apply( this, arguments ); |
2713 | | - }) : fn; |
| 3445 | + if ( name === "one" ) { |
| 3446 | + handler = function( event ) { |
| 3447 | + jQuery( this ).unbind( event, handler ); |
| 3448 | + return fn.apply( this, arguments ); |
| 3449 | + }; |
| 3450 | + handler.guid = fn.guid || jQuery.guid++; |
| 3451 | + } else { |
| 3452 | + handler = fn; |
| 3453 | + } |
2714 | 3454 | |
2715 | 3455 | if ( type === "unload" && name !== "one" ) { |
2716 | 3456 | this.one( type, data, fn ); |
— | — | @@ -2740,20 +3480,20 @@ |
2741 | 3481 | |
2742 | 3482 | return this; |
2743 | 3483 | }, |
2744 | | - |
| 3484 | + |
2745 | 3485 | delegate: function( selector, types, data, fn ) { |
2746 | 3486 | return this.live( types, data, fn, selector ); |
2747 | 3487 | }, |
2748 | | - |
| 3488 | + |
2749 | 3489 | undelegate: function( selector, types, fn ) { |
2750 | 3490 | if ( arguments.length === 0 ) { |
2751 | | - return this.unbind( "live" ); |
2752 | | - |
| 3491 | + return this.unbind( "live" ); |
| 3492 | + |
2753 | 3493 | } else { |
2754 | 3494 | return this.die( types, null, fn, selector ); |
2755 | 3495 | } |
2756 | 3496 | }, |
2757 | | - |
| 3497 | + |
2758 | 3498 | trigger: function( type, data ) { |
2759 | 3499 | return this.each(function() { |
2760 | 3500 | jQuery.event.trigger( type, data, this ); |
— | — | @@ -2762,35 +3502,34 @@ |
2763 | 3503 | |
2764 | 3504 | triggerHandler: function( type, data ) { |
2765 | 3505 | if ( this[0] ) { |
2766 | | - var event = jQuery.Event( type ); |
2767 | | - event.preventDefault(); |
2768 | | - event.stopPropagation(); |
2769 | | - jQuery.event.trigger( event, data, this[0] ); |
2770 | | - return event.result; |
| 3506 | + return jQuery.event.trigger( type, data, this[0], true ); |
2771 | 3507 | } |
2772 | 3508 | }, |
2773 | 3509 | |
2774 | 3510 | toggle: function( fn ) { |
2775 | 3511 | // Save reference to arguments for access in closure |
2776 | 3512 | var args = arguments, |
2777 | | - i = 1; |
| 3513 | + guid = fn.guid || jQuery.guid++, |
| 3514 | + i = 0, |
| 3515 | + toggler = function( event ) { |
| 3516 | + // Figure out which function to execute |
| 3517 | + var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i; |
| 3518 | + jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 ); |
2778 | 3519 | |
| 3520 | + // Make sure that clicks stop |
| 3521 | + event.preventDefault(); |
| 3522 | + |
| 3523 | + // and execute the function |
| 3524 | + return args[ lastToggle ].apply( this, arguments ) || false; |
| 3525 | + }; |
| 3526 | + |
2779 | 3527 | // link all the functions, so any of them can unbind this click handler |
| 3528 | + toggler.guid = guid; |
2780 | 3529 | while ( i < args.length ) { |
2781 | | - jQuery.proxy( fn, args[ i++ ] ); |
| 3530 | + args[ i++ ].guid = guid; |
2782 | 3531 | } |
2783 | 3532 | |
2784 | | - return this.click( jQuery.proxy( fn, function( event ) { |
2785 | | - // Figure out which function to execute |
2786 | | - var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i; |
2787 | | - jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 ); |
2788 | | - |
2789 | | - // Make sure that clicks stop |
2790 | | - event.preventDefault(); |
2791 | | - |
2792 | | - // and execute the function |
2793 | | - return args[ lastToggle ].apply( this, arguments ) || false; |
2794 | | - })); |
| 3533 | + return this.click( toggler ); |
2795 | 3534 | }, |
2796 | 3535 | |
2797 | 3536 | hover: function( fnOver, fnOut ) { |
— | — | @@ -2810,17 +3549,25 @@ |
2811 | 3550 | var type, i = 0, match, namespaces, preType, |
2812 | 3551 | selector = origSelector || this.selector, |
2813 | 3552 | context = origSelector ? this : jQuery( this.context ); |
2814 | | - |
| 3553 | + |
2815 | 3554 | if ( typeof types === "object" && !types.preventDefault ) { |
2816 | 3555 | for ( var key in types ) { |
2817 | 3556 | context[ name ]( key, data, types[key], selector ); |
2818 | 3557 | } |
2819 | | - |
| 3558 | + |
2820 | 3559 | return this; |
2821 | 3560 | } |
2822 | 3561 | |
2823 | | - if ( jQuery.isFunction( data ) ) { |
2824 | | - fn = data; |
| 3562 | + if ( name === "die" && !types && |
| 3563 | + origSelector && origSelector.charAt(0) === "." ) { |
| 3564 | + |
| 3565 | + context.unbind( origSelector ); |
| 3566 | + |
| 3567 | + return this; |
| 3568 | + } |
| 3569 | + |
| 3570 | + if ( data === false || jQuery.isFunction( data ) ) { |
| 3571 | + fn = data || returnFalse; |
2825 | 3572 | data = undefined; |
2826 | 3573 | } |
2827 | 3574 | |
— | — | @@ -2842,7 +3589,7 @@ |
2843 | 3590 | |
2844 | 3591 | preType = type; |
2845 | 3592 | |
2846 | | - if ( type === "focus" || type === "blur" ) { |
| 3593 | + if ( liveMap[ type ] ) { |
2847 | 3594 | types.push( liveMap[ type ] + namespaces ); |
2848 | 3595 | type = type + namespaces; |
2849 | 3596 | |
— | — | @@ -2862,7 +3609,7 @@ |
2863 | 3610 | context.unbind( "live." + liveConvert( type, selector ), fn ); |
2864 | 3611 | } |
2865 | 3612 | } |
2866 | | - |
| 3613 | + |
2867 | 3614 | return this; |
2868 | 3615 | }; |
2869 | 3616 | }); |
— | — | @@ -2871,17 +3618,13 @@ |
2872 | 3619 | var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret, |
2873 | 3620 | elems = [], |
2874 | 3621 | selectors = [], |
2875 | | - events = jQuery.data( this, this.nodeType ? "events" : "__events__" ); |
| 3622 | + events = jQuery._data( this, "events" ); |
2876 | 3623 | |
2877 | | - if ( typeof events === "function" ) { |
2878 | | - events = events.events; |
| 3624 | + // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911) |
| 3625 | + if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) { |
| 3626 | + return; |
2879 | 3627 | } |
2880 | 3628 | |
2881 | | - // Make sure we avoid non-left-click bubbling in Firefox (#3861) |
2882 | | - if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) { |
2883 | | - return; |
2884 | | - } |
2885 | | - |
2886 | 3629 | if ( event.namespace ) { |
2887 | 3630 | namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)"); |
2888 | 3631 | } |
— | — | @@ -2909,7 +3652,7 @@ |
2910 | 3653 | for ( j = 0; j < live.length; j++ ) { |
2911 | 3654 | handleObj = live[j]; |
2912 | 3655 | |
2913 | | - if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) { |
| 3656 | + if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) { |
2914 | 3657 | elem = close.elem; |
2915 | 3658 | related = null; |
2916 | 3659 | |
— | — | @@ -2917,6 +3660,11 @@ |
2918 | 3661 | if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) { |
2919 | 3662 | event.type = handleObj.preType; |
2920 | 3663 | related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0]; |
| 3664 | + |
| 3665 | + // Make sure not to accidentally match a child element with the same selector |
| 3666 | + if ( related && jQuery.contains( elem, related ) ) { |
| 3667 | + related = elem; |
| 3668 | + } |
2921 | 3669 | } |
2922 | 3670 | |
2923 | 3671 | if ( !related || related !== elem ) { |
— | — | @@ -2955,7 +3703,7 @@ |
2956 | 3704 | } |
2957 | 3705 | |
2958 | 3706 | function liveConvert( type, selector ) { |
2959 | | - return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&"); |
| 3707 | + return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&"); |
2960 | 3708 | } |
2961 | 3709 | |
2962 | 3710 | jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + |
— | — | @@ -2979,27 +3727,11 @@ |
2980 | 3728 | } |
2981 | 3729 | }); |
2982 | 3730 | |
2983 | | -// Prevent memory leaks in IE |
2984 | | -// Window isn't included so as not to unbind existing unload events |
2985 | | -// More info: |
2986 | | -// - http://isaacschlueter.com/2006/10/msie-memory-leaks/ |
2987 | | -if ( window.attachEvent && !window.addEventListener ) { |
2988 | | - jQuery(window).bind("unload", function() { |
2989 | | - for ( var id in jQuery.cache ) { |
2990 | | - if ( jQuery.cache[ id ].handle ) { |
2991 | | - // Try/Catch is to handle iframes being unloaded, see #4280 |
2992 | | - try { |
2993 | | - jQuery.event.remove( jQuery.cache[ id ].handle.elem ); |
2994 | | - } catch(e) {} |
2995 | | - } |
2996 | | - } |
2997 | | - }); |
2998 | | -} |
2999 | 3731 | |
3000 | 3732 | |
3001 | 3733 | /*! |
3002 | | - * Sizzle CSS Selector Engine - v1.0 |
3003 | | - * Copyright 2009, The Dojo Foundation |
| 3734 | + * Sizzle CSS Selector Engine |
| 3735 | + * Copyright 2011, The Dojo Foundation |
3004 | 3736 | * Released under the MIT, BSD, and GPL Licenses. |
3005 | 3737 | * More information: http://sizzlejs.com/ |
3006 | 3738 | */ |
— | — | @@ -3009,7 +3741,9 @@ |
3010 | 3742 | done = 0, |
3011 | 3743 | toString = Object.prototype.toString, |
3012 | 3744 | hasDuplicate = false, |
3013 | | - baseHasDuplicate = true; |
| 3745 | + baseHasDuplicate = true, |
| 3746 | + rBackslash = /\\/g, |
| 3747 | + rNonWord = /\W/; |
3014 | 3748 | |
3015 | 3749 | // Here we check if the JavaScript engine is using some sort of |
3016 | 3750 | // optimization where it does not always call our comparision |
— | — | @@ -3208,7 +3942,7 @@ |
3209 | 3943 | match.splice( 1, 1 ); |
3210 | 3944 | |
3211 | 3945 | if ( left.substr( left.length - 1 ) !== "\\" ) { |
3212 | | - match[1] = (match[1] || "").replace(/\\/g, ""); |
| 3946 | + match[1] = (match[1] || "").replace( rBackslash, "" ); |
3213 | 3947 | set = Expr.find[ type ]( match, context, isXML ); |
3214 | 3948 | |
3215 | 3949 | if ( set != null ) { |
— | — | @@ -3220,7 +3954,9 @@ |
3221 | 3955 | } |
3222 | 3956 | |
3223 | 3957 | if ( !set ) { |
3224 | | - set = context.getElementsByTagName( "*" ); |
| 3958 | + set = typeof context.getElementsByTagName !== "undefined" ? |
| 3959 | + context.getElementsByTagName( "*" ) : |
| 3960 | + []; |
3225 | 3961 | } |
3226 | 3962 | |
3227 | 3963 | return { set: set, expr: expr }; |
— | — | @@ -3328,9 +4064,9 @@ |
3329 | 4065 | ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, |
3330 | 4066 | CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, |
3331 | 4067 | NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, |
3332 | | - ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, |
| 4068 | + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, |
3333 | 4069 | TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, |
3334 | | - CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/, |
| 4070 | + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, |
3335 | 4071 | POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, |
3336 | 4072 | PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ |
3337 | 4073 | }, |
— | — | @@ -3345,13 +4081,16 @@ |
3346 | 4082 | attrHandle: { |
3347 | 4083 | href: function( elem ) { |
3348 | 4084 | return elem.getAttribute( "href" ); |
| 4085 | + }, |
| 4086 | + type: function( elem ) { |
| 4087 | + return elem.getAttribute( "type" ); |
3349 | 4088 | } |
3350 | 4089 | }, |
3351 | 4090 | |
3352 | 4091 | relative: { |
3353 | 4092 | "+": function(checkSet, part){ |
3354 | 4093 | var isPartStr = typeof part === "string", |
3355 | | - isTag = isPartStr && !/\W/.test( part ), |
| 4094 | + isTag = isPartStr && !rNonWord.test( part ), |
3356 | 4095 | isPartStrNotTag = isPartStr && !isTag; |
3357 | 4096 | |
3358 | 4097 | if ( isTag ) { |
— | — | @@ -3379,7 +4118,7 @@ |
3380 | 4119 | i = 0, |
3381 | 4120 | l = checkSet.length; |
3382 | 4121 | |
3383 | | - if ( isPartStr && !/\W/.test( part ) ) { |
| 4122 | + if ( isPartStr && !rNonWord.test( part ) ) { |
3384 | 4123 | part = part.toLowerCase(); |
3385 | 4124 | |
3386 | 4125 | for ( ; i < l; i++ ) { |
— | — | @@ -3413,7 +4152,7 @@ |
3414 | 4153 | doneName = done++, |
3415 | 4154 | checkFn = dirCheck; |
3416 | 4155 | |
3417 | | - if ( typeof part === "string" && !/\W/.test(part) ) { |
| 4156 | + if ( typeof part === "string" && !rNonWord.test( part ) ) { |
3418 | 4157 | part = part.toLowerCase(); |
3419 | 4158 | nodeCheck = part; |
3420 | 4159 | checkFn = dirNodeCheck; |
— | — | @@ -3427,7 +4166,7 @@ |
3428 | 4167 | doneName = done++, |
3429 | 4168 | checkFn = dirCheck; |
3430 | 4169 | |
3431 | | - if ( typeof part === "string" && !/\W/.test( part ) ) { |
| 4170 | + if ( typeof part === "string" && !rNonWord.test( part ) ) { |
3432 | 4171 | part = part.toLowerCase(); |
3433 | 4172 | nodeCheck = part; |
3434 | 4173 | checkFn = dirNodeCheck; |
— | — | @@ -3463,12 +4202,14 @@ |
3464 | 4203 | }, |
3465 | 4204 | |
3466 | 4205 | TAG: function( match, context ) { |
3467 | | - return context.getElementsByTagName( match[1] ); |
| 4206 | + if ( typeof context.getElementsByTagName !== "undefined" ) { |
| 4207 | + return context.getElementsByTagName( match[1] ); |
| 4208 | + } |
3468 | 4209 | } |
3469 | 4210 | }, |
3470 | 4211 | preFilter: { |
3471 | 4212 | CLASS: function( match, curLoop, inplace, result, not, isXML ) { |
3472 | | - match = " " + match[1].replace(/\\/g, "") + " "; |
| 4213 | + match = " " + match[1].replace( rBackslash, "" ) + " "; |
3473 | 4214 | |
3474 | 4215 | if ( isXML ) { |
3475 | 4216 | return match; |
— | — | @@ -3476,7 +4217,7 @@ |
3477 | 4218 | |
3478 | 4219 | for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { |
3479 | 4220 | if ( elem ) { |
3480 | | - if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) { |
| 4221 | + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { |
3481 | 4222 | if ( !inplace ) { |
3482 | 4223 | result.push( elem ); |
3483 | 4224 | } |
— | — | @@ -3491,17 +4232,23 @@ |
3492 | 4233 | }, |
3493 | 4234 | |
3494 | 4235 | ID: function( match ) { |
3495 | | - return match[1].replace(/\\/g, ""); |
| 4236 | + return match[1].replace( rBackslash, "" ); |
3496 | 4237 | }, |
3497 | 4238 | |
3498 | 4239 | TAG: function( match, curLoop ) { |
3499 | | - return match[1].toLowerCase(); |
| 4240 | + return match[1].replace( rBackslash, "" ).toLowerCase(); |
3500 | 4241 | }, |
3501 | 4242 | |
3502 | 4243 | CHILD: function( match ) { |
3503 | 4244 | if ( match[1] === "nth" ) { |
| 4245 | + if ( !match[2] ) { |
| 4246 | + Sizzle.error( match[0] ); |
| 4247 | + } |
| 4248 | + |
| 4249 | + match[2] = match[2].replace(/^\+|\s*/g, ''); |
| 4250 | + |
3504 | 4251 | // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' |
3505 | | - var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( |
| 4252 | + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( |
3506 | 4253 | match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || |
3507 | 4254 | !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); |
3508 | 4255 | |
— | — | @@ -3509,6 +4256,9 @@ |
3510 | 4257 | match[2] = (test[1] + (test[2] || 1)) - 0; |
3511 | 4258 | match[3] = test[3] - 0; |
3512 | 4259 | } |
| 4260 | + else if ( match[2] ) { |
| 4261 | + Sizzle.error( match[0] ); |
| 4262 | + } |
3513 | 4263 | |
3514 | 4264 | // TODO: Move to normal caching system |
3515 | 4265 | match[0] = done++; |
— | — | @@ -3517,12 +4267,15 @@ |
3518 | 4268 | }, |
3519 | 4269 | |
3520 | 4270 | ATTR: function( match, curLoop, inplace, result, not, isXML ) { |
3521 | | - var name = match[1].replace(/\\/g, ""); |
| 4271 | + var name = match[1] = match[1].replace( rBackslash, "" ); |
3522 | 4272 | |
3523 | 4273 | if ( !isXML && Expr.attrMap[name] ) { |
3524 | 4274 | match[1] = Expr.attrMap[name]; |
3525 | 4275 | } |
3526 | 4276 | |
| 4277 | + // Handle if an un-quoted value was used |
| 4278 | + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); |
| 4279 | + |
3527 | 4280 | if ( match[2] === "~=" ) { |
3528 | 4281 | match[4] = " " + match[4] + " "; |
3529 | 4282 | } |
— | — | @@ -3576,7 +4329,9 @@ |
3577 | 4330 | selected: function( elem ) { |
3578 | 4331 | // Accessing this property makes selected-by-default |
3579 | 4332 | // options in Safari work properly |
3580 | | - elem.parentNode.selectedIndex; |
| 4333 | + if ( elem.parentNode ) { |
| 4334 | + elem.parentNode.selectedIndex; |
| 4335 | + } |
3581 | 4336 | |
3582 | 4337 | return elem.selected === true; |
3583 | 4338 | }, |
— | — | @@ -3598,41 +4353,53 @@ |
3599 | 4354 | }, |
3600 | 4355 | |
3601 | 4356 | text: function( elem ) { |
3602 | | - return "text" === elem.type; |
| 4357 | + var attr = elem.getAttribute( "type" ), type = elem.type; |
| 4358 | + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) |
| 4359 | + // use getAttribute instead to test this case |
| 4360 | + return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); |
3603 | 4361 | }, |
| 4362 | + |
3604 | 4363 | radio: function( elem ) { |
3605 | | - return "radio" === elem.type; |
| 4364 | + return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; |
3606 | 4365 | }, |
3607 | 4366 | |
3608 | 4367 | checkbox: function( elem ) { |
3609 | | - return "checkbox" === elem.type; |
| 4368 | + return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; |
3610 | 4369 | }, |
3611 | 4370 | |
3612 | 4371 | file: function( elem ) { |
3613 | | - return "file" === elem.type; |
| 4372 | + return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; |
3614 | 4373 | }, |
| 4374 | + |
3615 | 4375 | password: function( elem ) { |
3616 | | - return "password" === elem.type; |
| 4376 | + return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; |
3617 | 4377 | }, |
3618 | 4378 | |
3619 | 4379 | submit: function( elem ) { |
3620 | | - return "submit" === elem.type; |
| 4380 | + var name = elem.nodeName.toLowerCase(); |
| 4381 | + return (name === "input" || name === "button") && "submit" === elem.type; |
3621 | 4382 | }, |
3622 | 4383 | |
3623 | 4384 | image: function( elem ) { |
3624 | | - return "image" === elem.type; |
| 4385 | + return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; |
3625 | 4386 | }, |
3626 | 4387 | |
3627 | 4388 | reset: function( elem ) { |
3628 | | - return "reset" === elem.type; |
| 4389 | + var name = elem.nodeName.toLowerCase(); |
| 4390 | + return (name === "input" || name === "button") && "reset" === elem.type; |
3629 | 4391 | }, |
3630 | 4392 | |
3631 | 4393 | button: function( elem ) { |
3632 | | - return "button" === elem.type || elem.nodeName.toLowerCase() === "button"; |
| 4394 | + var name = elem.nodeName.toLowerCase(); |
| 4395 | + return name === "input" && "button" === elem.type || name === "button"; |
3633 | 4396 | }, |
3634 | 4397 | |
3635 | 4398 | input: function( elem ) { |
3636 | 4399 | return (/input|select|textarea|button/i).test( elem.nodeName ); |
| 4400 | + }, |
| 4401 | + |
| 4402 | + focus: function( elem ) { |
| 4403 | + return elem === elem.ownerDocument.activeElement; |
3637 | 4404 | } |
3638 | 4405 | }, |
3639 | 4406 | setFilters: { |
— | — | @@ -3691,7 +4458,7 @@ |
3692 | 4459 | return true; |
3693 | 4460 | |
3694 | 4461 | } else { |
3695 | | - Sizzle.error( "Syntax error, unrecognized expression: " + name ); |
| 4462 | + Sizzle.error( name ); |
3696 | 4463 | } |
3697 | 4464 | }, |
3698 | 4465 | |
— | — | @@ -3885,6 +4652,16 @@ |
3886 | 4653 | |
3887 | 4654 | } else { |
3888 | 4655 | sortOrder = function( a, b ) { |
| 4656 | + // The nodes are identical, we can exit early |
| 4657 | + if ( a === b ) { |
| 4658 | + hasDuplicate = true; |
| 4659 | + return 0; |
| 4660 | + |
| 4661 | + // Fallback to using sourceIndex (in IE) if it's available on both nodes |
| 4662 | + } else if ( a.sourceIndex && b.sourceIndex ) { |
| 4663 | + return a.sourceIndex - b.sourceIndex; |
| 4664 | + } |
| 4665 | + |
3889 | 4666 | var al, bl, |
3890 | 4667 | ap = [], |
3891 | 4668 | bp = [], |
— | — | @@ -3892,13 +4669,8 @@ |
3893 | 4670 | bup = b.parentNode, |
3894 | 4671 | cur = aup; |
3895 | 4672 | |
3896 | | - // The nodes are identical, we can exit early |
3897 | | - if ( a === b ) { |
3898 | | - hasDuplicate = true; |
3899 | | - return 0; |
3900 | | - |
3901 | 4673 | // If the nodes are siblings (or identical) we can do a quick check |
3902 | | - } else if ( aup === bup ) { |
| 4674 | + if ( aup === bup ) { |
3903 | 4675 | return siblingCheck( a, b ); |
3904 | 4676 | |
3905 | 4677 | // If no parents were found then the nodes are disconnected |
— | — | @@ -4081,13 +4853,47 @@ |
4082 | 4854 | Sizzle = function( query, context, extra, seed ) { |
4083 | 4855 | context = context || document; |
4084 | 4856 | |
4085 | | - // Make sure that attribute selectors are quoted |
4086 | | - query = query.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); |
4087 | | - |
4088 | 4857 | // Only use querySelectorAll on non-XML documents |
4089 | 4858 | // (ID selectors don't work in non-HTML documents) |
4090 | 4859 | if ( !seed && !Sizzle.isXML(context) ) { |
| 4860 | + // See if we find a selector to speed up |
| 4861 | + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); |
| 4862 | + |
| 4863 | + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { |
| 4864 | + // Speed-up: Sizzle("TAG") |
| 4865 | + if ( match[1] ) { |
| 4866 | + return makeArray( context.getElementsByTagName( query ), extra ); |
| 4867 | + |
| 4868 | + // Speed-up: Sizzle(".CLASS") |
| 4869 | + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { |
| 4870 | + return makeArray( context.getElementsByClassName( match[2] ), extra ); |
| 4871 | + } |
| 4872 | + } |
| 4873 | + |
4091 | 4874 | if ( context.nodeType === 9 ) { |
| 4875 | + // Speed-up: Sizzle("body") |
| 4876 | + // The body element only exists once, optimize finding it |
| 4877 | + if ( query === "body" && context.body ) { |
| 4878 | + return makeArray( [ context.body ], extra ); |
| 4879 | + |
| 4880 | + // Speed-up: Sizzle("#ID") |
| 4881 | + } else if ( match && match[3] ) { |
| 4882 | + var elem = context.getElementById( match[3] ); |
| 4883 | + |
| 4884 | + // Check parentNode to catch when Blackberry 4.6 returns |
| 4885 | + // nodes that are no longer in the document #6963 |
| 4886 | + if ( elem && elem.parentNode ) { |
| 4887 | + // Handle the case where IE and Opera return items |
| 4888 | + // by name instead of ID |
| 4889 | + if ( elem.id === match[3] ) { |
| 4890 | + return makeArray( [ elem ], extra ); |
| 4891 | + } |
| 4892 | + |
| 4893 | + } else { |
| 4894 | + return makeArray( [], extra ); |
| 4895 | + } |
| 4896 | + } |
| 4897 | + |
4092 | 4898 | try { |
4093 | 4899 | return makeArray( context.querySelectorAll(query), extra ); |
4094 | 4900 | } catch(qsaError) {} |
— | — | @@ -4097,20 +4903,30 @@ |
4098 | 4904 | // and working up from there (Thanks to Andrew Dupont for the technique) |
4099 | 4905 | // IE 8 doesn't work on object elements |
4100 | 4906 | } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { |
4101 | | - var old = context.getAttribute( "id" ), |
4102 | | - nid = old || id; |
| 4907 | + var oldContext = context, |
| 4908 | + old = context.getAttribute( "id" ), |
| 4909 | + nid = old || id, |
| 4910 | + hasParent = context.parentNode, |
| 4911 | + relativeHierarchySelector = /^\s*[+~]/.test( query ); |
4103 | 4912 | |
4104 | 4913 | if ( !old ) { |
4105 | 4914 | context.setAttribute( "id", nid ); |
| 4915 | + } else { |
| 4916 | + nid = nid.replace( /'/g, "\\$&" ); |
4106 | 4917 | } |
| 4918 | + if ( relativeHierarchySelector && hasParent ) { |
| 4919 | + context = context.parentNode; |
| 4920 | + } |
4107 | 4921 | |
4108 | 4922 | try { |
4109 | | - return makeArray( context.querySelectorAll( "#" + nid + " " + query ), extra ); |
| 4923 | + if ( !relativeHierarchySelector || hasParent ) { |
| 4924 | + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); |
| 4925 | + } |
4110 | 4926 | |
4111 | 4927 | } catch(pseudoError) { |
4112 | 4928 | } finally { |
4113 | 4929 | if ( !old ) { |
4114 | | - context.removeAttribute( "id" ); |
| 4930 | + oldContext.removeAttribute( "id" ); |
4115 | 4931 | } |
4116 | 4932 | } |
4117 | 4933 | } |
— | — | @@ -4130,19 +4946,23 @@ |
4131 | 4947 | |
4132 | 4948 | (function(){ |
4133 | 4949 | var html = document.documentElement, |
4134 | | - matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector, |
4135 | | - pseudoWorks = false; |
| 4950 | + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; |
4136 | 4951 | |
4137 | | - try { |
4138 | | - // This should fail with an exception |
4139 | | - // Gecko does not error, returns false instead |
4140 | | - matches.call( document.documentElement, "[test!='']:sizzle" ); |
| 4952 | + if ( matches ) { |
| 4953 | + // Check to see if it's possible to do matchesSelector |
| 4954 | + // on a disconnected node (IE 9 fails this) |
| 4955 | + var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), |
| 4956 | + pseudoWorks = false; |
| 4957 | + |
| 4958 | + try { |
| 4959 | + // This should fail with an exception |
| 4960 | + // Gecko does not error, returns false instead |
| 4961 | + matches.call( document.documentElement, "[test!='']:sizzle" ); |
4141 | 4962 | |
4142 | | - } catch( pseudoError ) { |
4143 | | - pseudoWorks = true; |
4144 | | - } |
| 4963 | + } catch( pseudoError ) { |
| 4964 | + pseudoWorks = true; |
| 4965 | + } |
4145 | 4966 | |
4146 | | - if ( matches ) { |
4147 | 4967 | Sizzle.matchesSelector = function( node, expr ) { |
4148 | 4968 | // Make sure that attribute selectors are quoted |
4149 | 4969 | expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); |
— | — | @@ -4150,7 +4970,15 @@ |
4151 | 4971 | if ( !Sizzle.isXML( node ) ) { |
4152 | 4972 | try { |
4153 | 4973 | if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { |
4154 | | - return matches.call( node, expr ); |
| 4974 | + var ret = matches.call( node, expr ); |
| 4975 | + |
| 4976 | + // IE 9's matchesSelector returns false on disconnected nodes |
| 4977 | + if ( ret || !disconnectedMatch || |
| 4978 | + // As well, disconnected nodes are said to be in a document |
| 4979 | + // fragment in IE 9, so check for that |
| 4980 | + node.document && node.document.nodeType !== 11 ) { |
| 4981 | + return ret; |
| 4982 | + } |
4155 | 4983 | } |
4156 | 4984 | } catch(e) {} |
4157 | 4985 | } |
— | — | @@ -4328,21 +5156,41 @@ |
4329 | 5157 | rmultiselector = /,/, |
4330 | 5158 | isSimple = /^.[^:#\[\.,]*$/, |
4331 | 5159 | slice = Array.prototype.slice, |
4332 | | - POS = jQuery.expr.match.POS; |
| 5160 | + POS = jQuery.expr.match.POS, |
| 5161 | + // methods guaranteed to produce a unique set when starting from a unique set |
| 5162 | + guaranteedUnique = { |
| 5163 | + children: true, |
| 5164 | + contents: true, |
| 5165 | + next: true, |
| 5166 | + prev: true |
| 5167 | + }; |
4333 | 5168 | |
4334 | 5169 | jQuery.fn.extend({ |
4335 | 5170 | find: function( selector ) { |
| 5171 | + var self = this, |
| 5172 | + i, l; |
| 5173 | + |
| 5174 | + if ( typeof selector !== "string" ) { |
| 5175 | + return jQuery( selector ).filter(function() { |
| 5176 | + for ( i = 0, l = self.length; i < l; i++ ) { |
| 5177 | + if ( jQuery.contains( self[ i ], this ) ) { |
| 5178 | + return true; |
| 5179 | + } |
| 5180 | + } |
| 5181 | + }); |
| 5182 | + } |
| 5183 | + |
4336 | 5184 | var ret = this.pushStack( "", "find", selector ), |
4337 | | - length = 0; |
| 5185 | + length, n, r; |
4338 | 5186 | |
4339 | | - for ( var i = 0, l = this.length; i < l; i++ ) { |
| 5187 | + for ( i = 0, l = this.length; i < l; i++ ) { |
4340 | 5188 | length = ret.length; |
4341 | 5189 | jQuery.find( selector, this[i], ret ); |
4342 | 5190 | |
4343 | 5191 | if ( i > 0 ) { |
4344 | 5192 | // Make sure that the results are unique |
4345 | | - for ( var n = length; n < ret.length; n++ ) { |
4346 | | - for ( var r = 0; r < length; r++ ) { |
| 5193 | + for ( n = length; n < ret.length; n++ ) { |
| 5194 | + for ( r = 0; r < length; r++ ) { |
4347 | 5195 | if ( ret[r] === ret[n] ) { |
4348 | 5196 | ret.splice(n--, 1); |
4349 | 5197 | break; |
— | — | @@ -4373,14 +5221,17 @@ |
4374 | 5222 | filter: function( selector ) { |
4375 | 5223 | return this.pushStack( winnow(this, selector, true), "filter", selector ); |
4376 | 5224 | }, |
4377 | | - |
| 5225 | + |
4378 | 5226 | is: function( selector ) { |
4379 | | - return !!selector && jQuery.filter( selector, this ).length > 0; |
| 5227 | + return !!selector && ( typeof selector === "string" ? |
| 5228 | + jQuery.filter( selector, this ).length > 0 : |
| 5229 | + this.filter( selector ).length > 0 ); |
4380 | 5230 | }, |
4381 | 5231 | |
4382 | 5232 | closest: function( selectors, context ) { |
4383 | 5233 | var ret = [], i, l, cur = this[0]; |
4384 | | - |
| 5234 | + |
| 5235 | + // Array |
4385 | 5236 | if ( jQuery.isArray( selectors ) ) { |
4386 | 5237 | var match, selector, |
4387 | 5238 | matches = {}, |
— | — | @@ -4390,8 +5241,8 @@ |
4391 | 5242 | for ( i = 0, l = selectors.length; i < l; i++ ) { |
4392 | 5243 | selector = selectors[i]; |
4393 | 5244 | |
4394 | | - if ( !matches[selector] ) { |
4395 | | - matches[selector] = jQuery.expr.match.POS.test( selector ) ? |
| 5245 | + if ( !matches[ selector ] ) { |
| 5246 | + matches[ selector ] = POS.test( selector ) ? |
4396 | 5247 | jQuery( selector, context || this.context ) : |
4397 | 5248 | selector; |
4398 | 5249 | } |
— | — | @@ -4399,9 +5250,9 @@ |
4400 | 5251 | |
4401 | 5252 | while ( cur && cur.ownerDocument && cur !== context ) { |
4402 | 5253 | for ( selector in matches ) { |
4403 | | - match = matches[selector]; |
| 5254 | + match = matches[ selector ]; |
4404 | 5255 | |
4405 | | - if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) { |
| 5256 | + if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) { |
4406 | 5257 | ret.push({ selector: selector, elem: cur, level: level }); |
4407 | 5258 | } |
4408 | 5259 | } |
— | — | @@ -4414,8 +5265,10 @@ |
4415 | 5266 | return ret; |
4416 | 5267 | } |
4417 | 5268 | |
4418 | | - var pos = POS.test( selectors ) ? |
4419 | | - jQuery( selectors, context || this.context ) : null; |
| 5269 | + // String |
| 5270 | + var pos = POS.test( selectors ) || typeof selectors !== "string" ? |
| 5271 | + jQuery( selectors, context || this.context ) : |
| 5272 | + 0; |
4420 | 5273 | |
4421 | 5274 | for ( i = 0, l = this.length; i < l; i++ ) { |
4422 | 5275 | cur = this[i]; |
— | — | @@ -4427,18 +5280,18 @@ |
4428 | 5281 | |
4429 | 5282 | } else { |
4430 | 5283 | cur = cur.parentNode; |
4431 | | - if ( !cur || !cur.ownerDocument || cur === context ) { |
| 5284 | + if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { |
4432 | 5285 | break; |
4433 | 5286 | } |
4434 | 5287 | } |
4435 | 5288 | } |
4436 | 5289 | } |
4437 | 5290 | |
4438 | | - ret = ret.length > 1 ? jQuery.unique(ret) : ret; |
4439 | | - |
| 5291 | + ret = ret.length > 1 ? jQuery.unique( ret ) : ret; |
| 5292 | + |
4440 | 5293 | return this.pushStack( ret, "closest", selectors ); |
4441 | 5294 | }, |
4442 | | - |
| 5295 | + |
4443 | 5296 | // Determine the position of an element within |
4444 | 5297 | // the matched set of elements |
4445 | 5298 | index: function( elem ) { |
— | — | @@ -4456,8 +5309,8 @@ |
4457 | 5310 | |
4458 | 5311 | add: function( selector, context ) { |
4459 | 5312 | var set = typeof selector === "string" ? |
4460 | | - jQuery( selector, context || this.context ) : |
4461 | | - jQuery.makeArray( selector ), |
| 5313 | + jQuery( selector, context ) : |
| 5314 | + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), |
4462 | 5315 | all = jQuery.merge( this.get(), set ); |
4463 | 5316 | |
4464 | 5317 | return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? |
— | — | @@ -4518,8 +5371,13 @@ |
4519 | 5372 | } |
4520 | 5373 | }, function( name, fn ) { |
4521 | 5374 | jQuery.fn[ name ] = function( until, selector ) { |
4522 | | - var ret = jQuery.map( this, fn, until ); |
4523 | | - |
| 5375 | + var ret = jQuery.map( this, fn, until ), |
| 5376 | + // The variable 'args' was introduced in |
| 5377 | + // https://github.com/jquery/jquery/commit/52a0238 |
| 5378 | + // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. |
| 5379 | + // http://code.google.com/p/v8/issues/detail?id=1050 |
| 5380 | + args = slice.call(arguments); |
| 5381 | + |
4524 | 5382 | if ( !runtil.test( name ) ) { |
4525 | 5383 | selector = until; |
4526 | 5384 | } |
— | — | @@ -4528,13 +5386,13 @@ |
4529 | 5387 | ret = jQuery.filter( selector, ret ); |
4530 | 5388 | } |
4531 | 5389 | |
4532 | | - ret = this.length > 1 ? jQuery.unique( ret ) : ret; |
| 5390 | + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; |
4533 | 5391 | |
4534 | 5392 | if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { |
4535 | 5393 | ret = ret.reverse(); |
4536 | 5394 | } |
4537 | 5395 | |
4538 | | - return this.pushStack( ret, name, slice.call(arguments).join(",") ); |
| 5396 | + return this.pushStack( ret, name, args.join(",") ); |
4539 | 5397 | }; |
4540 | 5398 | }); |
4541 | 5399 | |
— | — | @@ -4548,7 +5406,7 @@ |
4549 | 5407 | jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : |
4550 | 5408 | jQuery.find.matches(expr, elems); |
4551 | 5409 | }, |
4552 | | - |
| 5410 | + |
4553 | 5411 | dir: function( elem, dir, until ) { |
4554 | 5412 | var matched = [], |
4555 | 5413 | cur = elem[ dir ]; |
— | — | @@ -4590,6 +5448,11 @@ |
4591 | 5449 | |
4592 | 5450 | // Implement the identical functionality for filter and not |
4593 | 5451 | function winnow( elements, qualifier, keep ) { |
| 5452 | + |
| 5453 | + // Can't pass null or undefined to indexOf in Firefox 4 |
| 5454 | + // Set to 0 to skip string check |
| 5455 | + qualifier = qualifier || 0; |
| 5456 | + |
4594 | 5457 | if ( jQuery.isFunction( qualifier ) ) { |
4595 | 5458 | return jQuery.grep(elements, function( elem, i ) { |
4596 | 5459 | var retVal = !!qualifier.call( elem, i, elem ); |
— | — | @@ -4628,9 +5491,10 @@ |
4629 | 5492 | rtbody = /<tbody/i, |
4630 | 5493 | rhtml = /<|&#?\w+;/, |
4631 | 5494 | rnocache = /<(?:script|object|embed|option|style)/i, |
4632 | | - // checked="checked" or checked (html5) |
| 5495 | + // checked="checked" or checked |
4633 | 5496 | rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, |
4634 | | - raction = /\=([^="'>\s]+\/)>/g, |
| 5497 | + rscriptType = /\/(java|ecma)script/i, |
| 5498 | + rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/, |
4635 | 5499 | wrapMap = { |
4636 | 5500 | option: [ 1, "<select multiple='multiple'>", "</select>" ], |
4637 | 5501 | legend: [ 1, "<fieldset>", "</fieldset>" ], |
— | — | @@ -4691,7 +5555,7 @@ |
4692 | 5556 | } |
4693 | 5557 | |
4694 | 5558 | return elem; |
4695 | | - }).append(this); |
| 5559 | + }).append( this ); |
4696 | 5560 | } |
4697 | 5561 | |
4698 | 5562 | return this; |
— | — | @@ -4770,7 +5634,7 @@ |
4771 | 5635 | return set; |
4772 | 5636 | } |
4773 | 5637 | }, |
4774 | | - |
| 5638 | + |
4775 | 5639 | // keepData is for internal use only--do not document |
4776 | 5640 | remove: function( selector, keepData ) { |
4777 | 5641 | for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { |
— | — | @@ -4781,11 +5645,11 @@ |
4782 | 5646 | } |
4783 | 5647 | |
4784 | 5648 | if ( elem.parentNode ) { |
4785 | | - elem.parentNode.removeChild( elem ); |
| 5649 | + elem.parentNode.removeChild( elem ); |
4786 | 5650 | } |
4787 | 5651 | } |
4788 | 5652 | } |
4789 | | - |
| 5653 | + |
4790 | 5654 | return this; |
4791 | 5655 | }, |
4792 | 5656 | |
— | — | @@ -4801,48 +5665,17 @@ |
4802 | 5666 | elem.removeChild( elem.firstChild ); |
4803 | 5667 | } |
4804 | 5668 | } |
4805 | | - |
| 5669 | + |
4806 | 5670 | return this; |
4807 | 5671 | }, |
4808 | 5672 | |
4809 | | - clone: function( events ) { |
4810 | | - // Do the clone |
4811 | | - var ret = this.map(function() { |
4812 | | - if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) { |
4813 | | - // IE copies events bound via attachEvent when |
4814 | | - // using cloneNode. Calling detachEvent on the |
4815 | | - // clone will also remove the events from the orignal |
4816 | | - // In order to get around this, we use innerHTML. |
4817 | | - // Unfortunately, this means some modifications to |
4818 | | - // attributes in IE that are actually only stored |
4819 | | - // as properties will not be copied (such as the |
4820 | | - // the name attribute on an input). |
4821 | | - var html = this.outerHTML, |
4822 | | - ownerDocument = this.ownerDocument; |
| 5673 | + clone: function( dataAndEvents, deepDataAndEvents ) { |
| 5674 | + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; |
| 5675 | + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; |
4823 | 5676 | |
4824 | | - if ( !html ) { |
4825 | | - var div = ownerDocument.createElement("div"); |
4826 | | - div.appendChild( this.cloneNode(true) ); |
4827 | | - html = div.innerHTML; |
4828 | | - } |
4829 | | - |
4830 | | - return jQuery.clean([html.replace(rinlinejQuery, "") |
4831 | | - // Handle the case in IE 8 where action=/test/> self-closes a tag |
4832 | | - .replace(raction, '="$1">') |
4833 | | - .replace(rleadingWhitespace, "")], ownerDocument)[0]; |
4834 | | - } else { |
4835 | | - return this.cloneNode(true); |
4836 | | - } |
| 5677 | + return this.map( function () { |
| 5678 | + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); |
4837 | 5679 | }); |
4838 | | - |
4839 | | - // Copy the events from the original to the clone |
4840 | | - if ( events === true ) { |
4841 | | - cloneCopyEvent( this, ret ); |
4842 | | - cloneCopyEvent( this.find("*"), ret.find("*") ); |
4843 | | - } |
4844 | | - |
4845 | | - // Return the cloned set |
4846 | | - return ret; |
4847 | 5680 | }, |
4848 | 5681 | |
4849 | 5682 | html: function( value ) { |
— | — | @@ -4914,7 +5747,9 @@ |
4915 | 5748 | } |
4916 | 5749 | }); |
4917 | 5750 | } else { |
4918 | | - return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ); |
| 5751 | + return this.length ? |
| 5752 | + this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) : |
| 5753 | + this; |
4919 | 5754 | } |
4920 | 5755 | }, |
4921 | 5756 | |
— | — | @@ -4952,9 +5787,9 @@ |
4953 | 5788 | } else { |
4954 | 5789 | results = jQuery.buildFragment( args, this, scripts ); |
4955 | 5790 | } |
4956 | | - |
| 5791 | + |
4957 | 5792 | fragment = results.fragment; |
4958 | | - |
| 5793 | + |
4959 | 5794 | if ( fragment.childNodes.length === 1 ) { |
4960 | 5795 | first = fragment = fragment.firstChild; |
4961 | 5796 | } else { |
— | — | @@ -4964,13 +5799,20 @@ |
4965 | 5800 | if ( first ) { |
4966 | 5801 | table = table && jQuery.nodeName( first, "tr" ); |
4967 | 5802 | |
4968 | | - for ( var i = 0, l = this.length; i < l; i++ ) { |
| 5803 | + for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) { |
4969 | 5804 | callback.call( |
4970 | 5805 | table ? |
4971 | 5806 | root(this[i], first) : |
4972 | 5807 | this[i], |
4973 | | - i > 0 || results.cacheable || this.length > 1 ? |
4974 | | - fragment.cloneNode(true) : |
| 5808 | + // Make sure that we do not leak memory by inadvertently discarding |
| 5809 | + // the original fragment (which might have attached data) instead of |
| 5810 | + // using it; in addition, use the original fragment object for the last |
| 5811 | + // item instead of first because it can end up being emptied incorrectly |
| 5812 | + // in certain situations (Bug #8070). |
| 5813 | + // Fragments from the fragment cache must always be cloned and never used |
| 5814 | + // in place. |
| 5815 | + results.cacheable || (l > 1 && i < lastIndex) ? |
| 5816 | + jQuery.clone( fragment, true, true ) : |
4975 | 5817 | fragment |
4976 | 5818 | ); |
4977 | 5819 | } |
— | — | @@ -4992,48 +5834,122 @@ |
4993 | 5835 | elem; |
4994 | 5836 | } |
4995 | 5837 | |
4996 | | -function cloneCopyEvent(orig, ret) { |
4997 | | - var i = 0; |
| 5838 | +function cloneCopyEvent( src, dest ) { |
4998 | 5839 | |
4999 | | - ret.each(function() { |
5000 | | - if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) { |
5001 | | - return; |
5002 | | - } |
| 5840 | + if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { |
| 5841 | + return; |
| 5842 | + } |
5003 | 5843 | |
5004 | | - var oldData = jQuery.data( orig[i++] ), |
5005 | | - curData = jQuery.data( this, oldData ), |
5006 | | - events = oldData && oldData.events; |
| 5844 | + var internalKey = jQuery.expando, |
| 5845 | + oldData = jQuery.data( src ), |
| 5846 | + curData = jQuery.data( dest, oldData ); |
5007 | 5847 | |
| 5848 | + // Switch to use the internal data object, if it exists, for the next |
| 5849 | + // stage of data copying |
| 5850 | + if ( (oldData = oldData[ internalKey ]) ) { |
| 5851 | + var events = oldData.events; |
| 5852 | + curData = curData[ internalKey ] = jQuery.extend({}, oldData); |
| 5853 | + |
5008 | 5854 | if ( events ) { |
5009 | 5855 | delete curData.handle; |
5010 | 5856 | curData.events = {}; |
5011 | 5857 | |
5012 | 5858 | for ( var type in events ) { |
5013 | | - for ( var handler in events[ type ] ) { |
5014 | | - jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); |
| 5859 | + for ( var i = 0, l = events[ type ].length; i < l; i++ ) { |
| 5860 | + jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data ); |
5015 | 5861 | } |
5016 | 5862 | } |
5017 | 5863 | } |
5018 | | - }); |
| 5864 | + } |
5019 | 5865 | } |
5020 | 5866 | |
| 5867 | +function cloneFixAttributes( src, dest ) { |
| 5868 | + var nodeName; |
| 5869 | + |
| 5870 | + // We do not need to do anything for non-Elements |
| 5871 | + if ( dest.nodeType !== 1 ) { |
| 5872 | + return; |
| 5873 | + } |
| 5874 | + |
| 5875 | + // clearAttributes removes the attributes, which we don't want, |
| 5876 | + // but also removes the attachEvent events, which we *do* want |
| 5877 | + if ( dest.clearAttributes ) { |
| 5878 | + dest.clearAttributes(); |
| 5879 | + } |
| 5880 | + |
| 5881 | + // mergeAttributes, in contrast, only merges back on the |
| 5882 | + // original attributes, not the events |
| 5883 | + if ( dest.mergeAttributes ) { |
| 5884 | + dest.mergeAttributes( src ); |
| 5885 | + } |
| 5886 | + |
| 5887 | + nodeName = dest.nodeName.toLowerCase(); |
| 5888 | + |
| 5889 | + // IE6-8 fail to clone children inside object elements that use |
| 5890 | + // the proprietary classid attribute value (rather than the type |
| 5891 | + // attribute) to identify the type of content to display |
| 5892 | + if ( nodeName === "object" ) { |
| 5893 | + dest.outerHTML = src.outerHTML; |
| 5894 | + |
| 5895 | + } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) { |
| 5896 | + // IE6-8 fails to persist the checked state of a cloned checkbox |
| 5897 | + // or radio button. Worse, IE6-7 fail to give the cloned element |
| 5898 | + // a checked appearance if the defaultChecked value isn't also set |
| 5899 | + if ( src.checked ) { |
| 5900 | + dest.defaultChecked = dest.checked = src.checked; |
| 5901 | + } |
| 5902 | + |
| 5903 | + // IE6-7 get confused and end up setting the value of a cloned |
| 5904 | + // checkbox/radio button to an empty string instead of "on" |
| 5905 | + if ( dest.value !== src.value ) { |
| 5906 | + dest.value = src.value; |
| 5907 | + } |
| 5908 | + |
| 5909 | + // IE6-8 fails to return the selected option to the default selected |
| 5910 | + // state when cloning options |
| 5911 | + } else if ( nodeName === "option" ) { |
| 5912 | + dest.selected = src.defaultSelected; |
| 5913 | + |
| 5914 | + // IE6-8 fails to set the defaultValue to the correct value when |
| 5915 | + // cloning other types of input fields |
| 5916 | + } else if ( nodeName === "input" || nodeName === "textarea" ) { |
| 5917 | + dest.defaultValue = src.defaultValue; |
| 5918 | + } |
| 5919 | + |
| 5920 | + // Event data gets referenced instead of copied if the expando |
| 5921 | + // gets copied too |
| 5922 | + dest.removeAttribute( jQuery.expando ); |
| 5923 | +} |
| 5924 | + |
5021 | 5925 | jQuery.buildFragment = function( args, nodes, scripts ) { |
5022 | | - var fragment, cacheable, cacheresults, |
5023 | | - doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document); |
| 5926 | + var fragment, cacheable, cacheresults, doc; |
5024 | 5927 | |
5025 | | - // Only cache "small" (1/2 KB) strings that are associated with the main document |
| 5928 | + // nodes may contain either an explicit document object, |
| 5929 | + // a jQuery collection or context object. |
| 5930 | + // If nodes[0] contains a valid object to assign to doc |
| 5931 | + if ( nodes && nodes[0] ) { |
| 5932 | + doc = nodes[0].ownerDocument || nodes[0]; |
| 5933 | + } |
| 5934 | + |
| 5935 | + // Ensure that an attr object doesn't incorrectly stand in as a document object |
| 5936 | + // Chrome and Firefox seem to allow this to occur and will throw exception |
| 5937 | + // Fixes #8950 |
| 5938 | + if ( !doc.createDocumentFragment ) { |
| 5939 | + doc = document; |
| 5940 | + } |
| 5941 | + |
| 5942 | + // Only cache "small" (1/2 KB) HTML strings that are associated with the main document |
5026 | 5943 | // Cloning options loses the selected state, so don't cache them |
5027 | 5944 | // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment |
5028 | 5945 | // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache |
5029 | 5946 | if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document && |
5030 | | - !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) { |
| 5947 | + args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) { |
5031 | 5948 | |
5032 | 5949 | cacheable = true; |
| 5950 | + |
5033 | 5951 | cacheresults = jQuery.fragments[ args[0] ]; |
5034 | | - if ( cacheresults ) { |
5035 | | - if ( cacheresults !== 1 ) { |
5036 | | - fragment = cacheresults; |
5037 | | - } |
| 5952 | + if ( cacheresults && cacheresults !== 1 ) { |
| 5953 | + fragment = cacheresults; |
5038 | 5954 | } |
5039 | 5955 | } |
5040 | 5956 | |
— | — | @@ -5062,25 +5978,103 @@ |
5063 | 5979 | var ret = [], |
5064 | 5980 | insert = jQuery( selector ), |
5065 | 5981 | parent = this.length === 1 && this[0].parentNode; |
5066 | | - |
| 5982 | + |
5067 | 5983 | if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) { |
5068 | 5984 | insert[ original ]( this[0] ); |
5069 | 5985 | return this; |
5070 | | - |
| 5986 | + |
5071 | 5987 | } else { |
5072 | 5988 | for ( var i = 0, l = insert.length; i < l; i++ ) { |
5073 | 5989 | var elems = (i > 0 ? this.clone(true) : this).get(); |
5074 | 5990 | jQuery( insert[i] )[ original ]( elems ); |
5075 | 5991 | ret = ret.concat( elems ); |
5076 | 5992 | } |
5077 | | - |
| 5993 | + |
5078 | 5994 | return this.pushStack( ret, name, insert.selector ); |
5079 | 5995 | } |
5080 | 5996 | }; |
5081 | 5997 | }); |
5082 | 5998 | |
| 5999 | +function getAll( elem ) { |
| 6000 | + if ( "getElementsByTagName" in elem ) { |
| 6001 | + return elem.getElementsByTagName( "*" ); |
| 6002 | + |
| 6003 | + } else if ( "querySelectorAll" in elem ) { |
| 6004 | + return elem.querySelectorAll( "*" ); |
| 6005 | + |
| 6006 | + } else { |
| 6007 | + return []; |
| 6008 | + } |
| 6009 | +} |
| 6010 | + |
| 6011 | +// Used in clean, fixes the defaultChecked property |
| 6012 | +function fixDefaultChecked( elem ) { |
| 6013 | + if ( elem.type === "checkbox" || elem.type === "radio" ) { |
| 6014 | + elem.defaultChecked = elem.checked; |
| 6015 | + } |
| 6016 | +} |
| 6017 | +// Finds all inputs and passes them to fixDefaultChecked |
| 6018 | +function findInputs( elem ) { |
| 6019 | + if ( jQuery.nodeName( elem, "input" ) ) { |
| 6020 | + fixDefaultChecked( elem ); |
| 6021 | + } else if ( "getElementsByTagName" in elem ) { |
| 6022 | + jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked ); |
| 6023 | + } |
| 6024 | +} |
| 6025 | + |
5083 | 6026 | jQuery.extend({ |
| 6027 | + clone: function( elem, dataAndEvents, deepDataAndEvents ) { |
| 6028 | + var clone = elem.cloneNode(true), |
| 6029 | + srcElements, |
| 6030 | + destElements, |
| 6031 | + i; |
| 6032 | + |
| 6033 | + if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && |
| 6034 | + (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { |
| 6035 | + // IE copies events bound via attachEvent when using cloneNode. |
| 6036 | + // Calling detachEvent on the clone will also remove the events |
| 6037 | + // from the original. In order to get around this, we use some |
| 6038 | + // proprietary methods to clear the events. Thanks to MooTools |
| 6039 | + // guys for this hotness. |
| 6040 | + |
| 6041 | + cloneFixAttributes( elem, clone ); |
| 6042 | + |
| 6043 | + // Using Sizzle here is crazy slow, so we use getElementsByTagName |
| 6044 | + // instead |
| 6045 | + srcElements = getAll( elem ); |
| 6046 | + destElements = getAll( clone ); |
| 6047 | + |
| 6048 | + // Weird iteration because IE will replace the length property |
| 6049 | + // with an element if you are cloning the body and one of the |
| 6050 | + // elements on the page has a name or id of "length" |
| 6051 | + for ( i = 0; srcElements[i]; ++i ) { |
| 6052 | + cloneFixAttributes( srcElements[i], destElements[i] ); |
| 6053 | + } |
| 6054 | + } |
| 6055 | + |
| 6056 | + // Copy the events from the original to the clone |
| 6057 | + if ( dataAndEvents ) { |
| 6058 | + cloneCopyEvent( elem, clone ); |
| 6059 | + |
| 6060 | + if ( deepDataAndEvents ) { |
| 6061 | + srcElements = getAll( elem ); |
| 6062 | + destElements = getAll( clone ); |
| 6063 | + |
| 6064 | + for ( i = 0; srcElements[i]; ++i ) { |
| 6065 | + cloneCopyEvent( srcElements[i], destElements[i] ); |
| 6066 | + } |
| 6067 | + } |
| 6068 | + } |
| 6069 | + |
| 6070 | + srcElements = destElements = null; |
| 6071 | + |
| 6072 | + // Return the cloned set |
| 6073 | + return clone; |
| 6074 | + }, |
| 6075 | + |
5084 | 6076 | clean: function( elems, context, fragment, scripts ) { |
| 6077 | + var checkScriptType; |
| 6078 | + |
5085 | 6079 | context = context || document; |
5086 | 6080 | |
5087 | 6081 | // !context.createElement fails in IE with an error but returns typeof 'object' |
— | — | @@ -5088,7 +6082,7 @@ |
5089 | 6083 | context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
5090 | 6084 | } |
5091 | 6085 | |
5092 | | - var ret = []; |
| 6086 | + var ret = [], j; |
5093 | 6087 | |
5094 | 6088 | for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
5095 | 6089 | if ( typeof elem === "number" ) { |
— | — | @@ -5100,54 +6094,67 @@ |
5101 | 6095 | } |
5102 | 6096 | |
5103 | 6097 | // Convert html string into DOM nodes |
5104 | | - if ( typeof elem === "string" && !rhtml.test( elem ) ) { |
5105 | | - elem = context.createTextNode( elem ); |
| 6098 | + if ( typeof elem === "string" ) { |
| 6099 | + if ( !rhtml.test( elem ) ) { |
| 6100 | + elem = context.createTextNode( elem ); |
| 6101 | + } else { |
| 6102 | + // Fix "XHTML"-style tags in all browsers |
| 6103 | + elem = elem.replace(rxhtmlTag, "<$1></$2>"); |
5106 | 6104 | |
5107 | | - } else if ( typeof elem === "string" ) { |
5108 | | - // Fix "XHTML"-style tags in all browsers |
5109 | | - elem = elem.replace(rxhtmlTag, "<$1></$2>"); |
| 6105 | + // Trim whitespace, otherwise indexOf won't work as expected |
| 6106 | + var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), |
| 6107 | + wrap = wrapMap[ tag ] || wrapMap._default, |
| 6108 | + depth = wrap[0], |
| 6109 | + div = context.createElement("div"); |
5110 | 6110 | |
5111 | | - // Trim whitespace, otherwise indexOf won't work as expected |
5112 | | - var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), |
5113 | | - wrap = wrapMap[ tag ] || wrapMap._default, |
5114 | | - depth = wrap[0], |
5115 | | - div = context.createElement("div"); |
| 6111 | + // Go to html and back, then peel off extra wrappers |
| 6112 | + div.innerHTML = wrap[1] + elem + wrap[2]; |
5116 | 6113 | |
5117 | | - // Go to html and back, then peel off extra wrappers |
5118 | | - div.innerHTML = wrap[1] + elem + wrap[2]; |
| 6114 | + // Move to the right depth |
| 6115 | + while ( depth-- ) { |
| 6116 | + div = div.lastChild; |
| 6117 | + } |
5119 | 6118 | |
5120 | | - // Move to the right depth |
5121 | | - while ( depth-- ) { |
5122 | | - div = div.lastChild; |
5123 | | - } |
| 6119 | + // Remove IE's autoinserted <tbody> from table fragments |
| 6120 | + if ( !jQuery.support.tbody ) { |
5124 | 6121 | |
5125 | | - // Remove IE's autoinserted <tbody> from table fragments |
5126 | | - if ( !jQuery.support.tbody ) { |
| 6122 | + // String was a <table>, *may* have spurious <tbody> |
| 6123 | + var hasBody = rtbody.test(elem), |
| 6124 | + tbody = tag === "table" && !hasBody ? |
| 6125 | + div.firstChild && div.firstChild.childNodes : |
5127 | 6126 | |
5128 | | - // String was a <table>, *may* have spurious <tbody> |
5129 | | - var hasBody = rtbody.test(elem), |
5130 | | - tbody = tag === "table" && !hasBody ? |
5131 | | - div.firstChild && div.firstChild.childNodes : |
| 6127 | + // String was a bare <thead> or <tfoot> |
| 6128 | + wrap[1] === "<table>" && !hasBody ? |
| 6129 | + div.childNodes : |
| 6130 | + []; |
5132 | 6131 | |
5133 | | - // String was a bare <thead> or <tfoot> |
5134 | | - wrap[1] === "<table>" && !hasBody ? |
5135 | | - div.childNodes : |
5136 | | - []; |
5137 | | - |
5138 | | - for ( var j = tbody.length - 1; j >= 0 ; --j ) { |
5139 | | - if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
5140 | | - tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
| 6132 | + for ( j = tbody.length - 1; j >= 0 ; --j ) { |
| 6133 | + if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { |
| 6134 | + tbody[ j ].parentNode.removeChild( tbody[ j ] ); |
| 6135 | + } |
5141 | 6136 | } |
5142 | 6137 | } |
5143 | 6138 | |
| 6139 | + // IE completely kills leading whitespace when innerHTML is used |
| 6140 | + if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
| 6141 | + div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
| 6142 | + } |
| 6143 | + |
| 6144 | + elem = div.childNodes; |
5144 | 6145 | } |
| 6146 | + } |
5145 | 6147 | |
5146 | | - // IE completely kills leading whitespace when innerHTML is used |
5147 | | - if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { |
5148 | | - div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); |
| 6148 | + // Resets defaultChecked for any radios and checkboxes |
| 6149 | + // about to be appended to the DOM in IE 6/7 (#8060) |
| 6150 | + var len; |
| 6151 | + if ( !jQuery.support.appendChecked ) { |
| 6152 | + if ( elem[0] && typeof (len = elem.length) === "number" ) { |
| 6153 | + for ( j = 0; j < len; j++ ) { |
| 6154 | + findInputs( elem[j] ); |
| 6155 | + } |
| 6156 | + } else { |
| 6157 | + findInputs( elem ); |
5149 | 6158 | } |
5150 | | - |
5151 | | - elem = div.childNodes; |
5152 | 6159 | } |
5153 | 6160 | |
5154 | 6161 | if ( elem.nodeType ) { |
— | — | @@ -5158,13 +6165,18 @@ |
5159 | 6166 | } |
5160 | 6167 | |
5161 | 6168 | if ( fragment ) { |
| 6169 | + checkScriptType = function( elem ) { |
| 6170 | + return !elem.type || rscriptType.test( elem.type ); |
| 6171 | + }; |
5162 | 6172 | for ( i = 0; ret[i]; i++ ) { |
5163 | 6173 | if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
5164 | 6174 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
5165 | | - |
| 6175 | + |
5166 | 6176 | } else { |
5167 | 6177 | if ( ret[i].nodeType === 1 ) { |
5168 | | - ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
| 6178 | + var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType ); |
| 6179 | + |
| 6180 | + ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); |
5169 | 6181 | } |
5170 | 6182 | fragment.appendChild( ret[i] ); |
5171 | 6183 | } |
— | — | @@ -5173,40 +6185,45 @@ |
5174 | 6186 | |
5175 | 6187 | return ret; |
5176 | 6188 | }, |
5177 | | - |
| 6189 | + |
5178 | 6190 | cleanData: function( elems ) { |
5179 | | - var data, id, cache = jQuery.cache, |
5180 | | - special = jQuery.event.special, |
| 6191 | + var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special, |
5181 | 6192 | deleteExpando = jQuery.support.deleteExpando; |
5182 | | - |
| 6193 | + |
5183 | 6194 | for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
5184 | 6195 | if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { |
5185 | 6196 | continue; |
5186 | 6197 | } |
5187 | 6198 | |
5188 | 6199 | id = elem[ jQuery.expando ]; |
5189 | | - |
| 6200 | + |
5190 | 6201 | if ( id ) { |
5191 | | - data = cache[ id ]; |
5192 | | - |
| 6202 | + data = cache[ id ] && cache[ id ][ internalKey ]; |
| 6203 | + |
5193 | 6204 | if ( data && data.events ) { |
5194 | 6205 | for ( var type in data.events ) { |
5195 | 6206 | if ( special[ type ] ) { |
5196 | 6207 | jQuery.event.remove( elem, type ); |
5197 | 6208 | |
| 6209 | + // This is a shortcut to avoid jQuery.event.remove's overhead |
5198 | 6210 | } else { |
5199 | 6211 | jQuery.removeEvent( elem, type, data.handle ); |
5200 | 6212 | } |
5201 | 6213 | } |
| 6214 | + |
| 6215 | + // Null the DOM reference to avoid IE6/7/8 leak (#7054) |
| 6216 | + if ( data.handle ) { |
| 6217 | + data.handle.elem = null; |
| 6218 | + } |
5202 | 6219 | } |
5203 | | - |
| 6220 | + |
5204 | 6221 | if ( deleteExpando ) { |
5205 | 6222 | delete elem[ jQuery.expando ]; |
5206 | 6223 | |
5207 | 6224 | } else if ( elem.removeAttribute ) { |
5208 | 6225 | elem.removeAttribute( jQuery.expando ); |
5209 | 6226 | } |
5210 | | - |
| 6227 | + |
5211 | 6228 | delete cache[ id ]; |
5212 | 6229 | } |
5213 | 6230 | } |
— | — | @@ -5221,7 +6238,7 @@ |
5222 | 6239 | dataType: "script" |
5223 | 6240 | }); |
5224 | 6241 | } else { |
5225 | | - jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
| 6242 | + jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) ); |
5226 | 6243 | } |
5227 | 6244 | |
5228 | 6245 | if ( elem.parentNode ) { |
— | — | @@ -5231,13 +6248,14 @@ |
5232 | 6249 | |
5233 | 6250 | |
5234 | 6251 | |
5235 | | - |
5236 | 6252 | var ralpha = /alpha\([^)]*\)/i, |
5237 | 6253 | ropacity = /opacity=([^)]*)/, |
5238 | | - rdashAlpha = /-([a-z])/ig, |
5239 | | - rupper = /([A-Z])/g, |
| 6254 | + // fixed for IE9, see #8346 |
| 6255 | + rupper = /([A-Z]|^ms)/g, |
5240 | 6256 | rnumpx = /^-?\d+(?:px)?$/i, |
5241 | 6257 | rnum = /^-?\d/, |
| 6258 | + rrelNum = /^[+\-]=/, |
| 6259 | + rrelNumFilter = /[^+\-\.\de]+/g, |
5242 | 6260 | |
5243 | 6261 | cssShow = { position: "absolute", visibility: "hidden", display: "block" }, |
5244 | 6262 | cssWidth = [ "Left", "Right" ], |
— | — | @@ -5245,12 +6263,8 @@ |
5246 | 6264 | curCSS, |
5247 | 6265 | |
5248 | 6266 | getComputedStyle, |
5249 | | - currentStyle, |
| 6267 | + currentStyle; |
5250 | 6268 | |
5251 | | - fcamelCase = function( all, letter ) { |
5252 | | - return letter.toUpperCase(); |
5253 | | - }; |
5254 | | - |
5255 | 6269 | jQuery.fn.css = function( name, value ) { |
5256 | 6270 | // Setting 'undefined' is a no-op |
5257 | 6271 | if ( arguments.length === 2 && value === undefined ) { |
— | — | @@ -5284,11 +6298,14 @@ |
5285 | 6299 | |
5286 | 6300 | // Exclude the following css properties to add px |
5287 | 6301 | cssNumber: { |
5288 | | - "zIndex": true, |
| 6302 | + "fillOpacity": true, |
5289 | 6303 | "fontWeight": true, |
| 6304 | + "lineHeight": true, |
5290 | 6305 | "opacity": true, |
5291 | | - "zoom": true, |
5292 | | - "lineHeight": true |
| 6306 | + "orphans": true, |
| 6307 | + "widows": true, |
| 6308 | + "zIndex": true, |
| 6309 | + "zoom": true |
5293 | 6310 | }, |
5294 | 6311 | |
5295 | 6312 | // Add in properties whose names you wish to fix before |
— | — | @@ -5306,20 +6323,29 @@ |
5307 | 6324 | } |
5308 | 6325 | |
5309 | 6326 | // Make sure that we're working with the right name |
5310 | | - var ret, origName = jQuery.camelCase( name ), |
| 6327 | + var ret, type, origName = jQuery.camelCase( name ), |
5311 | 6328 | style = elem.style, hooks = jQuery.cssHooks[ origName ]; |
5312 | 6329 | |
5313 | 6330 | name = jQuery.cssProps[ origName ] || origName; |
5314 | 6331 | |
5315 | 6332 | // Check if we're setting a value |
5316 | 6333 | if ( value !== undefined ) { |
| 6334 | + type = typeof value; |
| 6335 | + |
5317 | 6336 | // Make sure that NaN and null values aren't set. See: #7116 |
5318 | | - if ( typeof value === "number" && isNaN( value ) || value == null ) { |
| 6337 | + if ( type === "number" && isNaN( value ) || value == null ) { |
5319 | 6338 | return; |
5320 | 6339 | } |
5321 | 6340 | |
| 6341 | + // convert relative number strings (+= or -=) to relative numbers. #7345 |
| 6342 | + if ( type === "string" && rrelNum.test( value ) ) { |
| 6343 | + value = +value.replace( rrelNumFilter, "" ) + parseFloat( jQuery.css( elem, name ) ); |
| 6344 | + // Fixes bug #9237 |
| 6345 | + type = "number"; |
| 6346 | + } |
| 6347 | + |
5322 | 6348 | // If a number was passed in, add 'px' to the (except for certain CSS properties) |
5323 | | - if ( typeof value === "number" && !jQuery.cssNumber[ origName ] ) { |
| 6349 | + if ( type === "number" && !jQuery.cssNumber[ origName ] ) { |
5324 | 6350 | value += "px"; |
5325 | 6351 | } |
5326 | 6352 | |
— | — | @@ -5344,11 +6370,17 @@ |
5345 | 6371 | }, |
5346 | 6372 | |
5347 | 6373 | css: function( elem, name, extra ) { |
| 6374 | + var ret, hooks; |
| 6375 | + |
5348 | 6376 | // Make sure that we're working with the right name |
5349 | | - var ret, origName = jQuery.camelCase( name ), |
5350 | | - hooks = jQuery.cssHooks[ origName ]; |
| 6377 | + name = jQuery.camelCase( name ); |
| 6378 | + hooks = jQuery.cssHooks[ name ]; |
| 6379 | + name = jQuery.cssProps[ name ] || name; |
5351 | 6380 | |
5352 | | - name = jQuery.cssProps[ origName ] || origName; |
| 6381 | + // cssFloat needs a special treatment |
| 6382 | + if ( name === "cssFloat" ) { |
| 6383 | + name = "float"; |
| 6384 | + } |
5353 | 6385 | |
5354 | 6386 | // If a hook was provided get the computed value from there |
5355 | 6387 | if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) { |
— | — | @@ -5356,7 +6388,7 @@ |
5357 | 6389 | |
5358 | 6390 | // Otherwise, if a way to get the computed value exists, use that |
5359 | 6391 | } else if ( curCSS ) { |
5360 | | - return curCSS( elem, name, origName ); |
| 6392 | + return curCSS( elem, name ); |
5361 | 6393 | } |
5362 | 6394 | }, |
5363 | 6395 | |
— | — | @@ -5376,10 +6408,6 @@ |
5377 | 6409 | for ( name in options ) { |
5378 | 6410 | elem.style[ name ] = old[ name ]; |
5379 | 6411 | } |
5380 | | - }, |
5381 | | - |
5382 | | - camelCase: function( string ) { |
5383 | | - return string.replace( rdashAlpha, fcamelCase ); |
5384 | 6412 | } |
5385 | 6413 | }); |
5386 | 6414 | |
— | — | @@ -5393,44 +6421,21 @@ |
5394 | 6422 | |
5395 | 6423 | if ( computed ) { |
5396 | 6424 | if ( elem.offsetWidth !== 0 ) { |
5397 | | - val = getWH( elem, name, extra ); |
5398 | | - |
| 6425 | + return getWH( elem, name, extra ); |
5399 | 6426 | } else { |
5400 | 6427 | jQuery.swap( elem, cssShow, function() { |
5401 | 6428 | val = getWH( elem, name, extra ); |
5402 | 6429 | }); |
5403 | 6430 | } |
5404 | 6431 | |
5405 | | - if ( val <= 0 ) { |
5406 | | - val = curCSS( elem, name, name ); |
5407 | | - |
5408 | | - if ( val === "0px" && currentStyle ) { |
5409 | | - val = currentStyle( elem, name, name ); |
5410 | | - } |
5411 | | - |
5412 | | - if ( val != null ) { |
5413 | | - // Should return "auto" instead of 0, use 0 for |
5414 | | - // temporary backwards-compat |
5415 | | - return val === "" || val === "auto" ? "0px" : val; |
5416 | | - } |
5417 | | - } |
5418 | | - |
5419 | | - if ( val < 0 || val == null ) { |
5420 | | - val = elem.style[ name ]; |
5421 | | - |
5422 | | - // Should return "auto" instead of 0, use 0 for |
5423 | | - // temporary backwards-compat |
5424 | | - return val === "" || val === "auto" ? "0px" : val; |
5425 | | - } |
5426 | | - |
5427 | | - return typeof val === "string" ? val : val + "px"; |
| 6432 | + return val; |
5428 | 6433 | } |
5429 | 6434 | }, |
5430 | 6435 | |
5431 | 6436 | set: function( elem, value ) { |
5432 | 6437 | if ( rnumpx.test( value ) ) { |
5433 | 6438 | // ignore negative width and height values #1599 |
5434 | | - value = parseFloat(value); |
| 6439 | + value = parseFloat( value ); |
5435 | 6440 | |
5436 | 6441 | if ( value >= 0 ) { |
5437 | 6442 | return value + "px"; |
— | — | @@ -5447,33 +6452,56 @@ |
5448 | 6453 | jQuery.cssHooks.opacity = { |
5449 | 6454 | get: function( elem, computed ) { |
5450 | 6455 | // IE uses filters for opacity |
5451 | | - return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ? |
5452 | | - (parseFloat(RegExp.$1) / 100) + "" : |
| 6456 | + return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? |
| 6457 | + ( parseFloat( RegExp.$1 ) / 100 ) + "" : |
5453 | 6458 | computed ? "1" : ""; |
5454 | 6459 | }, |
5455 | 6460 | |
5456 | 6461 | set: function( elem, value ) { |
5457 | | - var style = elem.style; |
| 6462 | + var style = elem.style, |
| 6463 | + currentStyle = elem.currentStyle; |
5458 | 6464 | |
5459 | 6465 | // IE has trouble with opacity if it does not have layout |
5460 | 6466 | // Force it by setting the zoom level |
5461 | 6467 | style.zoom = 1; |
5462 | 6468 | |
5463 | 6469 | // Set the alpha filter to set the opacity |
5464 | | - var opacity = jQuery.isNaN(value) ? |
| 6470 | + var opacity = jQuery.isNaN( value ) ? |
5465 | 6471 | "" : |
5466 | 6472 | "alpha(opacity=" + value * 100 + ")", |
5467 | | - filter = style.filter || ""; |
| 6473 | + filter = currentStyle && currentStyle.filter || style.filter || ""; |
5468 | 6474 | |
5469 | | - style.filter = ralpha.test(filter) ? |
5470 | | - filter.replace(ralpha, opacity) : |
5471 | | - style.filter + ' ' + opacity; |
| 6475 | + style.filter = ralpha.test( filter ) ? |
| 6476 | + filter.replace( ralpha, opacity ) : |
| 6477 | + filter + " " + opacity; |
5472 | 6478 | } |
5473 | 6479 | }; |
5474 | 6480 | } |
5475 | 6481 | |
| 6482 | +jQuery(function() { |
| 6483 | + // This hook cannot be added until DOM ready because the support test |
| 6484 | + // for it is not run until after DOM ready |
| 6485 | + if ( !jQuery.support.reliableMarginRight ) { |
| 6486 | + jQuery.cssHooks.marginRight = { |
| 6487 | + get: function( elem, computed ) { |
| 6488 | + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
| 6489 | + // Work around by temporarily setting element display to inline-block |
| 6490 | + var ret; |
| 6491 | + jQuery.swap( elem, { "display": "inline-block" }, function() { |
| 6492 | + if ( computed ) { |
| 6493 | + ret = curCSS( elem, "margin-right", "marginRight" ); |
| 6494 | + } else { |
| 6495 | + ret = elem.style.marginRight; |
| 6496 | + } |
| 6497 | + }); |
| 6498 | + return ret; |
| 6499 | + } |
| 6500 | + }; |
| 6501 | + } |
| 6502 | +}); |
| 6503 | + |
5476 | 6504 | if ( document.defaultView && document.defaultView.getComputedStyle ) { |
5477 | | - getComputedStyle = function( elem, newName, name ) { |
| 6505 | + getComputedStyle = function( elem, name ) { |
5478 | 6506 | var ret, defaultView, computedStyle; |
5479 | 6507 | |
5480 | 6508 | name = name.replace( rupper, "-$1" ).toLowerCase(); |
— | — | @@ -5495,8 +6523,9 @@ |
5496 | 6524 | |
5497 | 6525 | if ( document.documentElement.currentStyle ) { |
5498 | 6526 | currentStyle = function( elem, name ) { |
5499 | | - var left, rsLeft, |
| 6527 | + var left, |
5500 | 6528 | ret = elem.currentStyle && elem.currentStyle[ name ], |
| 6529 | + rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ], |
5501 | 6530 | style = elem.style; |
5502 | 6531 | |
5503 | 6532 | // From the awesome hack by Dean Edwards |
— | — | @@ -5507,16 +6536,19 @@ |
5508 | 6537 | if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { |
5509 | 6538 | // Remember the original values |
5510 | 6539 | left = style.left; |
5511 | | - rsLeft = elem.runtimeStyle.left; |
5512 | 6540 | |
5513 | 6541 | // Put in the new values to get a computed value out |
5514 | | - elem.runtimeStyle.left = elem.currentStyle.left; |
| 6542 | + if ( rsLeft ) { |
| 6543 | + elem.runtimeStyle.left = elem.currentStyle.left; |
| 6544 | + } |
5515 | 6545 | style.left = name === "fontSize" ? "1em" : (ret || 0); |
5516 | 6546 | ret = style.pixelLeft + "px"; |
5517 | 6547 | |
5518 | 6548 | // Revert the changed values |
5519 | 6549 | style.left = left; |
5520 | | - elem.runtimeStyle.left = rsLeft; |
| 6550 | + if ( rsLeft ) { |
| 6551 | + elem.runtimeStyle.left = rsLeft; |
| 6552 | + } |
5521 | 6553 | } |
5522 | 6554 | |
5523 | 6555 | return ret === "" ? "auto" : ret; |
— | — | @@ -5526,27 +6558,50 @@ |
5527 | 6559 | curCSS = getComputedStyle || currentStyle; |
5528 | 6560 | |
5529 | 6561 | function getWH( elem, name, extra ) { |
5530 | | - var which = name === "width" ? cssWidth : cssHeight, |
5531 | | - val = name === "width" ? elem.offsetWidth : elem.offsetHeight; |
5532 | 6562 | |
5533 | | - if ( extra === "border" ) { |
5534 | | - return val; |
5535 | | - } |
| 6563 | + // Start with offset property |
| 6564 | + var val = name === "width" ? elem.offsetWidth : elem.offsetHeight, |
| 6565 | + which = name === "width" ? cssWidth : cssHeight; |
5536 | 6566 | |
5537 | | - jQuery.each( which, function() { |
5538 | | - if ( !extra ) { |
5539 | | - val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0; |
| 6567 | + if ( val > 0 ) { |
| 6568 | + if ( extra !== "border" ) { |
| 6569 | + jQuery.each( which, function() { |
| 6570 | + if ( !extra ) { |
| 6571 | + val -= parseFloat( jQuery.css( elem, "padding" + this ) ) || 0; |
| 6572 | + } |
| 6573 | + if ( extra === "margin" ) { |
| 6574 | + val += parseFloat( jQuery.css( elem, extra + this ) ) || 0; |
| 6575 | + } else { |
| 6576 | + val -= parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0; |
| 6577 | + } |
| 6578 | + }); |
5540 | 6579 | } |
5541 | 6580 | |
5542 | | - if ( extra === "margin" ) { |
5543 | | - val += parseFloat(jQuery.css( elem, "margin" + this )) || 0; |
| 6581 | + return val + "px"; |
| 6582 | + } |
5544 | 6583 | |
5545 | | - } else { |
5546 | | - val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0; |
5547 | | - } |
5548 | | - }); |
| 6584 | + // Fall back to computed then uncomputed css if necessary |
| 6585 | + val = curCSS( elem, name, name ); |
| 6586 | + if ( val < 0 || val == null ) { |
| 6587 | + val = elem.style[ name ] || 0; |
| 6588 | + } |
| 6589 | + // Normalize "", auto, and prepare for extra |
| 6590 | + val = parseFloat( val ) || 0; |
5549 | 6591 | |
5550 | | - return val; |
| 6592 | + // Add padding, border, margin |
| 6593 | + if ( extra ) { |
| 6594 | + jQuery.each( which, function() { |
| 6595 | + val += parseFloat( jQuery.css( elem, "padding" + this ) ) || 0; |
| 6596 | + if ( extra !== "padding" ) { |
| 6597 | + val += parseFloat( jQuery.css( elem, "border" + this + "Width" ) ) || 0; |
| 6598 | + } |
| 6599 | + if ( extra === "margin" ) { |
| 6600 | + val += parseFloat( jQuery.css( elem, extra + this ) ) || 0; |
| 6601 | + } |
| 6602 | + }); |
| 6603 | + } |
| 6604 | + |
| 6605 | + return val + "px"; |
5551 | 6606 | } |
5552 | 6607 | |
5553 | 6608 | if ( jQuery.expr && jQuery.expr.filters ) { |
— | — | @@ -5565,22 +6620,141 @@ |
5566 | 6621 | |
5567 | 6622 | |
5568 | 6623 | |
5569 | | -var jsc = jQuery.now(), |
5570 | | - rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, |
5571 | | - rselectTextarea = /^(?:select|textarea)/i, |
| 6624 | +var r20 = /%20/g, |
| 6625 | + rbracket = /\[\]$/, |
| 6626 | + rCRLF = /\r?\n/g, |
| 6627 | + rhash = /#.*$/, |
| 6628 | + rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL |
5572 | 6629 | rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, |
| 6630 | + // #7653, #8125, #8152: local protocol detection |
| 6631 | + rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|widget):$/, |
5573 | 6632 | rnoContent = /^(?:GET|HEAD)$/, |
5574 | | - rbracket = /\[\]$/, |
5575 | | - jsre = /\=\?(&|$)/, |
| 6633 | + rprotocol = /^\/\//, |
5576 | 6634 | rquery = /\?/, |
| 6635 | + rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, |
| 6636 | + rselectTextarea = /^(?:select|textarea)/i, |
| 6637 | + rspacesAjax = /\s+/, |
5577 | 6638 | rts = /([?&])_=[^&]*/, |
5578 | | - rurl = /^(\w+:)?\/\/([^\/?#]+)/, |
5579 | | - r20 = /%20/g, |
5580 | | - rhash = /#.*$/, |
| 6639 | + rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/, |
5581 | 6640 | |
5582 | 6641 | // Keep a copy of the old load method |
5583 | | - _load = jQuery.fn.load; |
| 6642 | + _load = jQuery.fn.load, |
5584 | 6643 | |
| 6644 | + /* Prefilters |
| 6645 | + * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) |
| 6646 | + * 2) These are called: |
| 6647 | + * - BEFORE asking for a transport |
| 6648 | + * - AFTER param serialization (s.data is a string if s.processData is true) |
| 6649 | + * 3) key is the dataType |
| 6650 | + * 4) the catchall symbol "*" can be used |
| 6651 | + * 5) execution will start with transport dataType and THEN continue down to "*" if needed |
| 6652 | + */ |
| 6653 | + prefilters = {}, |
| 6654 | + |
| 6655 | + /* Transports bindings |
| 6656 | + * 1) key is the dataType |
| 6657 | + * 2) the catchall symbol "*" can be used |
| 6658 | + * 3) selection will start with transport dataType and THEN go to "*" if needed |
| 6659 | + */ |
| 6660 | + transports = {}, |
| 6661 | + |
| 6662 | + // Document location |
| 6663 | + ajaxLocation, |
| 6664 | + |
| 6665 | + // Document location segments |
| 6666 | + ajaxLocParts; |
| 6667 | + |
| 6668 | +// #8138, IE may throw an exception when accessing |
| 6669 | +// a field from window.location if document.domain has been set |
| 6670 | +try { |
| 6671 | + ajaxLocation = location.href; |
| 6672 | +} catch( e ) { |
| 6673 | + // Use the href attribute of an A element |
| 6674 | + // since IE will modify it given document.location |
| 6675 | + ajaxLocation = document.createElement( "a" ); |
| 6676 | + ajaxLocation.href = ""; |
| 6677 | + ajaxLocation = ajaxLocation.href; |
| 6678 | +} |
| 6679 | + |
| 6680 | +// Segment location into parts |
| 6681 | +ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; |
| 6682 | + |
| 6683 | +// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport |
| 6684 | +function addToPrefiltersOrTransports( structure ) { |
| 6685 | + |
| 6686 | + // dataTypeExpression is optional and defaults to "*" |
| 6687 | + return function( dataTypeExpression, func ) { |
| 6688 | + |
| 6689 | + if ( typeof dataTypeExpression !== "string" ) { |
| 6690 | + func = dataTypeExpression; |
| 6691 | + dataTypeExpression = "*"; |
| 6692 | + } |
| 6693 | + |
| 6694 | + if ( jQuery.isFunction( func ) ) { |
| 6695 | + var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ), |
| 6696 | + i = 0, |
| 6697 | + length = dataTypes.length, |
| 6698 | + dataType, |
| 6699 | + list, |
| 6700 | + placeBefore; |
| 6701 | + |
| 6702 | + // For each dataType in the dataTypeExpression |
| 6703 | + for(; i < length; i++ ) { |
| 6704 | + dataType = dataTypes[ i ]; |
| 6705 | + // We control if we're asked to add before |
| 6706 | + // any existing element |
| 6707 | + placeBefore = /^\+/.test( dataType ); |
| 6708 | + if ( placeBefore ) { |
| 6709 | + dataType = dataType.substr( 1 ) || "*"; |
| 6710 | + } |
| 6711 | + list = structure[ dataType ] = structure[ dataType ] || []; |
| 6712 | + // then we add to the structure accordingly |
| 6713 | + list[ placeBefore ? "unshift" : "push" ]( func ); |
| 6714 | + } |
| 6715 | + } |
| 6716 | + }; |
| 6717 | +} |
| 6718 | + |
| 6719 | +// Base inspection function for prefilters and transports |
| 6720 | +function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR, |
| 6721 | + dataType /* internal */, inspected /* internal */ ) { |
| 6722 | + |
| 6723 | + dataType = dataType || options.dataTypes[ 0 ]; |
| 6724 | + inspected = inspected || {}; |
| 6725 | + |
| 6726 | + inspected[ dataType ] = true; |
| 6727 | + |
| 6728 | + var list = structure[ dataType ], |
| 6729 | + i = 0, |
| 6730 | + length = list ? list.length : 0, |
| 6731 | + executeOnly = ( structure === prefilters ), |
| 6732 | + selection; |
| 6733 | + |
| 6734 | + for(; i < length && ( executeOnly || !selection ); i++ ) { |
| 6735 | + selection = list[ i ]( options, originalOptions, jqXHR ); |
| 6736 | + // If we got redirected to another dataType |
| 6737 | + // we try there if executing only and not done already |
| 6738 | + if ( typeof selection === "string" ) { |
| 6739 | + if ( !executeOnly || inspected[ selection ] ) { |
| 6740 | + selection = undefined; |
| 6741 | + } else { |
| 6742 | + options.dataTypes.unshift( selection ); |
| 6743 | + selection = inspectPrefiltersOrTransports( |
| 6744 | + structure, options, originalOptions, jqXHR, selection, inspected ); |
| 6745 | + } |
| 6746 | + } |
| 6747 | + } |
| 6748 | + // If we're only executing or nothing was selected |
| 6749 | + // we try the catchall dataType if not done already |
| 6750 | + if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) { |
| 6751 | + selection = inspectPrefiltersOrTransports( |
| 6752 | + structure, options, originalOptions, jqXHR, "*", inspected ); |
| 6753 | + } |
| 6754 | + // unnecessary when only executing (prefilters) |
| 6755 | + // but it'll be ignored by the caller in that case |
| 6756 | + return selection; |
| 6757 | +} |
| 6758 | + |
5585 | 6759 | jQuery.fn.extend({ |
5586 | 6760 | load: function( url, params, callback ) { |
5587 | 6761 | if ( typeof url !== "string" && _load ) { |
— | — | @@ -5591,10 +6765,10 @@ |
5592 | 6766 | return this; |
5593 | 6767 | } |
5594 | 6768 | |
5595 | | - var off = url.indexOf(" "); |
| 6769 | + var off = url.indexOf( " " ); |
5596 | 6770 | if ( off >= 0 ) { |
5597 | | - var selector = url.slice(off, url.length); |
5598 | | - url = url.slice(0, off); |
| 6771 | + var selector = url.slice( off, url.length ); |
| 6772 | + url = url.slice( 0, off ); |
5599 | 6773 | } |
5600 | 6774 | |
5601 | 6775 | // Default to a GET request |
— | — | @@ -5606,7 +6780,7 @@ |
5607 | 6781 | if ( jQuery.isFunction( params ) ) { |
5608 | 6782 | // We assume that it's the callback |
5609 | 6783 | callback = params; |
5610 | | - params = null; |
| 6784 | + params = undefined; |
5611 | 6785 | |
5612 | 6786 | // Otherwise, build a param string |
5613 | 6787 | } else if ( typeof params === "object" ) { |
— | — | @@ -5623,26 +6797,34 @@ |
5624 | 6798 | type: type, |
5625 | 6799 | dataType: "html", |
5626 | 6800 | data: params, |
5627 | | - complete: function( res, status ) { |
| 6801 | + // Complete callback (responseText is used internally) |
| 6802 | + complete: function( jqXHR, status, responseText ) { |
| 6803 | + // Store the response as specified by the jqXHR object |
| 6804 | + responseText = jqXHR.responseText; |
5628 | 6805 | // If successful, inject the HTML into all the matched elements |
5629 | | - if ( status === "success" || status === "notmodified" ) { |
| 6806 | + if ( jqXHR.isResolved() ) { |
| 6807 | + // #4825: Get the actual response in case |
| 6808 | + // a dataFilter is present in ajaxSettings |
| 6809 | + jqXHR.done(function( r ) { |
| 6810 | + responseText = r; |
| 6811 | + }); |
5630 | 6812 | // See if a selector was specified |
5631 | 6813 | self.html( selector ? |
5632 | 6814 | // Create a dummy div to hold the results |
5633 | 6815 | jQuery("<div>") |
5634 | 6816 | // inject the contents of the document in, removing the scripts |
5635 | 6817 | // to avoid any 'Permission Denied' errors in IE |
5636 | | - .append(res.responseText.replace(rscript, "")) |
| 6818 | + .append(responseText.replace(rscript, "")) |
5637 | 6819 | |
5638 | 6820 | // Locate the specified elements |
5639 | 6821 | .find(selector) : |
5640 | 6822 | |
5641 | 6823 | // If not, just inject the full result |
5642 | | - res.responseText ); |
| 6824 | + responseText ); |
5643 | 6825 | } |
5644 | 6826 | |
5645 | 6827 | if ( callback ) { |
5646 | | - self.each( callback, [res.responseText, status, res] ); |
| 6828 | + self.each( callback, [ responseText, status, jqXHR ] ); |
5647 | 6829 | } |
5648 | 6830 | } |
5649 | 6831 | }); |
— | — | @@ -5651,88 +6833,94 @@ |
5652 | 6834 | }, |
5653 | 6835 | |
5654 | 6836 | serialize: function() { |
5655 | | - return jQuery.param(this.serializeArray()); |
| 6837 | + return jQuery.param( this.serializeArray() ); |
5656 | 6838 | }, |
5657 | 6839 | |
5658 | 6840 | serializeArray: function() { |
5659 | | - return this.map(function() { |
5660 | | - return this.elements ? jQuery.makeArray(this.elements) : this; |
| 6841 | + return this.map(function(){ |
| 6842 | + return this.elements ? jQuery.makeArray( this.elements ) : this; |
5661 | 6843 | }) |
5662 | | - .filter(function() { |
| 6844 | + .filter(function(){ |
5663 | 6845 | return this.name && !this.disabled && |
5664 | | - (this.checked || rselectTextarea.test(this.nodeName) || |
5665 | | - rinput.test(this.type)); |
| 6846 | + ( this.checked || rselectTextarea.test( this.nodeName ) || |
| 6847 | + rinput.test( this.type ) ); |
5666 | 6848 | }) |
5667 | | - .map(function( i, elem ) { |
5668 | | - var val = jQuery(this).val(); |
| 6849 | + .map(function( i, elem ){ |
| 6850 | + var val = jQuery( this ).val(); |
5669 | 6851 | |
5670 | 6852 | return val == null ? |
5671 | 6853 | null : |
5672 | | - jQuery.isArray(val) ? |
5673 | | - jQuery.map( val, function( val, i ) { |
5674 | | - return { name: elem.name, value: val }; |
| 6854 | + jQuery.isArray( val ) ? |
| 6855 | + jQuery.map( val, function( val, i ){ |
| 6856 | + return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
5675 | 6857 | }) : |
5676 | | - { name: elem.name, value: val }; |
| 6858 | + { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
5677 | 6859 | }).get(); |
5678 | 6860 | } |
5679 | 6861 | }); |
5680 | 6862 | |
5681 | 6863 | // Attach a bunch of functions for handling common AJAX events |
5682 | | -jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) { |
5683 | | - jQuery.fn[o] = function( f ) { |
5684 | | - return this.bind(o, f); |
| 6864 | +jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){ |
| 6865 | + jQuery.fn[ o ] = function( f ){ |
| 6866 | + return this.bind( o, f ); |
5685 | 6867 | }; |
5686 | 6868 | }); |
5687 | 6869 | |
5688 | | -jQuery.extend({ |
5689 | | - get: function( url, data, callback, type ) { |
5690 | | - // shift arguments if data argument was omited |
| 6870 | +jQuery.each( [ "get", "post" ], function( i, method ) { |
| 6871 | + jQuery[ method ] = function( url, data, callback, type ) { |
| 6872 | + // shift arguments if data argument was omitted |
5691 | 6873 | if ( jQuery.isFunction( data ) ) { |
5692 | 6874 | type = type || callback; |
5693 | 6875 | callback = data; |
5694 | | - data = null; |
| 6876 | + data = undefined; |
5695 | 6877 | } |
5696 | 6878 | |
5697 | 6879 | return jQuery.ajax({ |
5698 | | - type: "GET", |
| 6880 | + type: method, |
5699 | 6881 | url: url, |
5700 | 6882 | data: data, |
5701 | 6883 | success: callback, |
5702 | 6884 | dataType: type |
5703 | 6885 | }); |
5704 | | - }, |
| 6886 | + }; |
| 6887 | +}); |
5705 | 6888 | |
| 6889 | +jQuery.extend({ |
| 6890 | + |
5706 | 6891 | getScript: function( url, callback ) { |
5707 | | - return jQuery.get(url, null, callback, "script"); |
| 6892 | + return jQuery.get( url, undefined, callback, "script" ); |
5708 | 6893 | }, |
5709 | 6894 | |
5710 | 6895 | getJSON: function( url, data, callback ) { |
5711 | | - return jQuery.get(url, data, callback, "json"); |
| 6896 | + return jQuery.get( url, data, callback, "json" ); |
5712 | 6897 | }, |
5713 | 6898 | |
5714 | | - post: function( url, data, callback, type ) { |
5715 | | - // shift arguments if data argument was omited |
5716 | | - if ( jQuery.isFunction( data ) ) { |
5717 | | - type = type || callback; |
5718 | | - callback = data; |
5719 | | - data = {}; |
| 6899 | + // Creates a full fledged settings object into target |
| 6900 | + // with both ajaxSettings and settings fields. |
| 6901 | + // If target is omitted, writes into ajaxSettings. |
| 6902 | + ajaxSetup: function ( target, settings ) { |
| 6903 | + if ( !settings ) { |
| 6904 | + // Only one parameter, we extend ajaxSettings |
| 6905 | + settings = target; |
| 6906 | + target = jQuery.extend( true, jQuery.ajaxSettings, settings ); |
| 6907 | + } else { |
| 6908 | + // target was provided, we extend into it |
| 6909 | + jQuery.extend( true, target, jQuery.ajaxSettings, settings ); |
5720 | 6910 | } |
5721 | | - |
5722 | | - return jQuery.ajax({ |
5723 | | - type: "POST", |
5724 | | - url: url, |
5725 | | - data: data, |
5726 | | - success: callback, |
5727 | | - dataType: type |
5728 | | - }); |
| 6911 | + // Flatten fields we don't want deep extended |
| 6912 | + for( var field in { context: 1, url: 1 } ) { |
| 6913 | + if ( field in settings ) { |
| 6914 | + target[ field ] = settings[ field ]; |
| 6915 | + } else if( field in jQuery.ajaxSettings ) { |
| 6916 | + target[ field ] = jQuery.ajaxSettings[ field ]; |
| 6917 | + } |
| 6918 | + } |
| 6919 | + return target; |
5729 | 6920 | }, |
5730 | 6921 | |
5731 | | - ajaxSetup: function( settings ) { |
5732 | | - jQuery.extend( jQuery.ajaxSettings, settings ); |
5733 | | - }, |
5734 | | - |
5735 | 6922 | ajaxSettings: { |
5736 | | - url: location.href, |
| 6923 | + url: ajaxLocation, |
| 6924 | + isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), |
5737 | 6925 | global: true, |
5738 | 6926 | type: "GET", |
5739 | 6927 | contentType: "application/x-www-form-urlencoded", |
— | — | @@ -5741,332 +6929,434 @@ |
5742 | 6930 | /* |
5743 | 6931 | timeout: 0, |
5744 | 6932 | data: null, |
| 6933 | + dataType: null, |
5745 | 6934 | username: null, |
5746 | 6935 | password: null, |
| 6936 | + cache: null, |
5747 | 6937 | traditional: false, |
| 6938 | + headers: {}, |
5748 | 6939 | */ |
5749 | | - // This function can be overriden by calling jQuery.ajaxSetup |
5750 | | - xhr: function() { |
5751 | | - return new window.XMLHttpRequest(); |
5752 | | - }, |
| 6940 | + |
5753 | 6941 | accepts: { |
5754 | 6942 | xml: "application/xml, text/xml", |
5755 | 6943 | html: "text/html", |
5756 | | - script: "text/javascript, application/javascript", |
| 6944 | + text: "text/plain", |
5757 | 6945 | json: "application/json, text/javascript", |
5758 | | - text: "text/plain", |
5759 | | - _default: "*/*" |
5760 | | - } |
5761 | | - }, |
| 6946 | + "*": "*/*" |
| 6947 | + }, |
5762 | 6948 | |
5763 | | - ajax: function( origSettings ) { |
5764 | | - var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings), |
5765 | | - jsonp, status, data, type = s.type.toUpperCase(), noContent = rnoContent.test(type); |
| 6949 | + contents: { |
| 6950 | + xml: /xml/, |
| 6951 | + html: /html/, |
| 6952 | + json: /json/ |
| 6953 | + }, |
5766 | 6954 | |
5767 | | - s.url = s.url.replace( rhash, "" ); |
| 6955 | + responseFields: { |
| 6956 | + xml: "responseXML", |
| 6957 | + text: "responseText" |
| 6958 | + }, |
5768 | 6959 | |
5769 | | - // Use original (not extended) context object if it was provided |
5770 | | - s.context = origSettings && origSettings.context != null ? origSettings.context : s; |
| 6960 | + // List of data converters |
| 6961 | + // 1) key format is "source_type destination_type" (a single space in-between) |
| 6962 | + // 2) the catchall symbol "*" can be used for source_type |
| 6963 | + converters: { |
5771 | 6964 | |
5772 | | - // convert data if not already a string |
5773 | | - if ( s.data && s.processData && typeof s.data !== "string" ) { |
5774 | | - s.data = jQuery.param( s.data, s.traditional ); |
| 6965 | + // Convert anything to text |
| 6966 | + "* text": window.String, |
| 6967 | + |
| 6968 | + // Text to html (true = no transformation) |
| 6969 | + "text html": true, |
| 6970 | + |
| 6971 | + // Evaluate text as a json expression |
| 6972 | + "text json": jQuery.parseJSON, |
| 6973 | + |
| 6974 | + // Parse text as xml |
| 6975 | + "text xml": jQuery.parseXML |
5775 | 6976 | } |
| 6977 | + }, |
5776 | 6978 | |
5777 | | - // Handle JSONP Parameter Callbacks |
5778 | | - if ( s.dataType === "jsonp" ) { |
5779 | | - if ( type === "GET" ) { |
5780 | | - if ( !jsre.test( s.url ) ) { |
5781 | | - s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?"; |
5782 | | - } |
5783 | | - } else if ( !s.data || !jsre.test(s.data) ) { |
5784 | | - s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?"; |
5785 | | - } |
5786 | | - s.dataType = "json"; |
| 6979 | + ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), |
| 6980 | + ajaxTransport: addToPrefiltersOrTransports( transports ), |
| 6981 | + |
| 6982 | + // Main method |
| 6983 | + ajax: function( url, options ) { |
| 6984 | + |
| 6985 | + // If url is an object, simulate pre-1.5 signature |
| 6986 | + if ( typeof url === "object" ) { |
| 6987 | + options = url; |
| 6988 | + url = undefined; |
5787 | 6989 | } |
5788 | 6990 | |
5789 | | - // Build temporary JSONP function |
5790 | | - if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) { |
5791 | | - jsonp = s.jsonpCallback || ("jsonp" + jsc++); |
| 6991 | + // Force options to be an object |
| 6992 | + options = options || {}; |
5792 | 6993 | |
5793 | | - // Replace the =? sequence both in the query string and the data |
5794 | | - if ( s.data ) { |
5795 | | - s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1"); |
5796 | | - } |
| 6994 | + var // Create the final options object |
| 6995 | + s = jQuery.ajaxSetup( {}, options ), |
| 6996 | + // Callbacks context |
| 6997 | + callbackContext = s.context || s, |
| 6998 | + // Context for global events |
| 6999 | + // It's the callbackContext if one was provided in the options |
| 7000 | + // and if it's a DOM node or a jQuery collection |
| 7001 | + globalEventContext = callbackContext !== s && |
| 7002 | + ( callbackContext.nodeType || callbackContext instanceof jQuery ) ? |
| 7003 | + jQuery( callbackContext ) : jQuery.event, |
| 7004 | + // Deferreds |
| 7005 | + deferred = jQuery.Deferred(), |
| 7006 | + completeDeferred = jQuery._Deferred(), |
| 7007 | + // Status-dependent callbacks |
| 7008 | + statusCode = s.statusCode || {}, |
| 7009 | + // ifModified key |
| 7010 | + ifModifiedKey, |
| 7011 | + // Headers (they are sent all at once) |
| 7012 | + requestHeaders = {}, |
| 7013 | + requestHeadersNames = {}, |
| 7014 | + // Response headers |
| 7015 | + responseHeadersString, |
| 7016 | + responseHeaders, |
| 7017 | + // transport |
| 7018 | + transport, |
| 7019 | + // timeout handle |
| 7020 | + timeoutTimer, |
| 7021 | + // Cross-domain detection vars |
| 7022 | + parts, |
| 7023 | + // The jqXHR state |
| 7024 | + state = 0, |
| 7025 | + // To know if global events are to be dispatched |
| 7026 | + fireGlobals, |
| 7027 | + // Loop variable |
| 7028 | + i, |
| 7029 | + // Fake xhr |
| 7030 | + jqXHR = { |
5797 | 7031 | |
5798 | | - s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
| 7032 | + readyState: 0, |
5799 | 7033 | |
5800 | | - // We need to make sure |
5801 | | - // that a JSONP style response is executed properly |
5802 | | - s.dataType = "script"; |
| 7034 | + // Caches the header |
| 7035 | + setRequestHeader: function( name, value ) { |
| 7036 | + if ( !state ) { |
| 7037 | + var lname = name.toLowerCase(); |
| 7038 | + name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; |
| 7039 | + requestHeaders[ name ] = value; |
| 7040 | + } |
| 7041 | + return this; |
| 7042 | + }, |
5803 | 7043 | |
5804 | | - // Handle JSONP-style loading |
5805 | | - var customJsonp = window[ jsonp ]; |
| 7044 | + // Raw string |
| 7045 | + getAllResponseHeaders: function() { |
| 7046 | + return state === 2 ? responseHeadersString : null; |
| 7047 | + }, |
5806 | 7048 | |
5807 | | - window[ jsonp ] = function( tmp ) { |
5808 | | - if ( jQuery.isFunction( customJsonp ) ) { |
5809 | | - customJsonp( tmp ); |
| 7049 | + // Builds headers hashtable if needed |
| 7050 | + getResponseHeader: function( key ) { |
| 7051 | + var match; |
| 7052 | + if ( state === 2 ) { |
| 7053 | + if ( !responseHeaders ) { |
| 7054 | + responseHeaders = {}; |
| 7055 | + while( ( match = rheaders.exec( responseHeadersString ) ) ) { |
| 7056 | + responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; |
| 7057 | + } |
| 7058 | + } |
| 7059 | + match = responseHeaders[ key.toLowerCase() ]; |
| 7060 | + } |
| 7061 | + return match === undefined ? null : match; |
| 7062 | + }, |
5810 | 7063 | |
5811 | | - } else { |
5812 | | - // Garbage collect |
5813 | | - window[ jsonp ] = undefined; |
| 7064 | + // Overrides response content-type header |
| 7065 | + overrideMimeType: function( type ) { |
| 7066 | + if ( !state ) { |
| 7067 | + s.mimeType = type; |
| 7068 | + } |
| 7069 | + return this; |
| 7070 | + }, |
5814 | 7071 | |
5815 | | - try { |
5816 | | - delete window[ jsonp ]; |
5817 | | - } catch( jsonpError ) {} |
| 7072 | + // Cancel the request |
| 7073 | + abort: function( statusText ) { |
| 7074 | + statusText = statusText || "abort"; |
| 7075 | + if ( transport ) { |
| 7076 | + transport.abort( statusText ); |
| 7077 | + } |
| 7078 | + done( 0, statusText ); |
| 7079 | + return this; |
5818 | 7080 | } |
5819 | | - |
5820 | | - data = tmp; |
5821 | | - jQuery.handleSuccess( s, xhr, status, data ); |
5822 | | - jQuery.handleComplete( s, xhr, status, data ); |
5823 | | - |
5824 | | - if ( head ) { |
5825 | | - head.removeChild( script ); |
5826 | | - } |
5827 | 7081 | }; |
5828 | | - } |
5829 | 7082 | |
5830 | | - if ( s.dataType === "script" && s.cache === null ) { |
5831 | | - s.cache = false; |
5832 | | - } |
| 7083 | + // Callback for when everything is done |
| 7084 | + // It is defined here because jslint complains if it is declared |
| 7085 | + // at the end of the function (which would be more logical and readable) |
| 7086 | + function done( status, statusText, responses, headers ) { |
5833 | 7087 | |
5834 | | - if ( s.cache === false && noContent ) { |
5835 | | - var ts = jQuery.now(); |
| 7088 | + // Called once |
| 7089 | + if ( state === 2 ) { |
| 7090 | + return; |
| 7091 | + } |
5836 | 7092 | |
5837 | | - // try replacing _= if it is there |
5838 | | - var ret = s.url.replace(rts, "$1_=" + ts); |
| 7093 | + // State is "done" now |
| 7094 | + state = 2; |
5839 | 7095 | |
5840 | | - // if nothing was replaced, add timestamp to the end |
5841 | | - s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : ""); |
5842 | | - } |
| 7096 | + // Clear timeout if it exists |
| 7097 | + if ( timeoutTimer ) { |
| 7098 | + clearTimeout( timeoutTimer ); |
| 7099 | + } |
5843 | 7100 | |
5844 | | - // If data is available, append data to url for GET/HEAD requests |
5845 | | - if ( s.data && noContent ) { |
5846 | | - s.url += (rquery.test(s.url) ? "&" : "?") + s.data; |
5847 | | - } |
| 7101 | + // Dereference transport for early garbage collection |
| 7102 | + // (no matter how long the jqXHR object will be used) |
| 7103 | + transport = undefined; |
5848 | 7104 | |
5849 | | - // Watch for a new set of requests |
5850 | | - if ( s.global && jQuery.active++ === 0 ) { |
5851 | | - jQuery.event.trigger( "ajaxStart" ); |
5852 | | - } |
| 7105 | + // Cache response headers |
| 7106 | + responseHeadersString = headers || ""; |
5853 | 7107 | |
5854 | | - // Matches an absolute URL, and saves the domain |
5855 | | - var parts = rurl.exec( s.url ), |
5856 | | - remote = parts && (parts[1] && parts[1].toLowerCase() !== location.protocol || parts[2].toLowerCase() !== location.host); |
| 7108 | + // Set readyState |
| 7109 | + jqXHR.readyState = status ? 4 : 0; |
5857 | 7110 | |
5858 | | - // If we're requesting a remote document |
5859 | | - // and trying to load JSON or Script with a GET |
5860 | | - if ( s.dataType === "script" && type === "GET" && remote ) { |
5861 | | - var head = document.getElementsByTagName("head")[0] || document.documentElement; |
5862 | | - var script = document.createElement("script"); |
5863 | | - if ( s.scriptCharset ) { |
5864 | | - script.charset = s.scriptCharset; |
5865 | | - } |
5866 | | - script.src = s.url; |
| 7111 | + var isSuccess, |
| 7112 | + success, |
| 7113 | + error, |
| 7114 | + response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined, |
| 7115 | + lastModified, |
| 7116 | + etag; |
5867 | 7117 | |
5868 | | - // Handle Script loading |
5869 | | - if ( !jsonp ) { |
5870 | | - var done = false; |
| 7118 | + // If successful, handle type chaining |
| 7119 | + if ( status >= 200 && status < 300 || status === 304 ) { |
5871 | 7120 | |
5872 | | - // Attach handlers for all browsers |
5873 | | - script.onload = script.onreadystatechange = function() { |
5874 | | - if ( !done && (!this.readyState || |
5875 | | - this.readyState === "loaded" || this.readyState === "complete") ) { |
5876 | | - done = true; |
5877 | | - jQuery.handleSuccess( s, xhr, status, data ); |
5878 | | - jQuery.handleComplete( s, xhr, status, data ); |
| 7121 | + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 7122 | + if ( s.ifModified ) { |
5879 | 7123 | |
5880 | | - // Handle memory leak in IE |
5881 | | - script.onload = script.onreadystatechange = null; |
5882 | | - if ( head && script.parentNode ) { |
5883 | | - head.removeChild( script ); |
5884 | | - } |
| 7124 | + if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) { |
| 7125 | + jQuery.lastModified[ ifModifiedKey ] = lastModified; |
5885 | 7126 | } |
5886 | | - }; |
5887 | | - } |
| 7127 | + if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) { |
| 7128 | + jQuery.etag[ ifModifiedKey ] = etag; |
| 7129 | + } |
| 7130 | + } |
5888 | 7131 | |
5889 | | - // Use insertBefore instead of appendChild to circumvent an IE6 bug. |
5890 | | - // This arises when a base node is used (#2709 and #4378). |
5891 | | - head.insertBefore( script, head.firstChild ); |
| 7132 | + // If not modified |
| 7133 | + if ( status === 304 ) { |
5892 | 7134 | |
5893 | | - // We handle everything using the script element injection |
5894 | | - return undefined; |
5895 | | - } |
| 7135 | + statusText = "notmodified"; |
| 7136 | + isSuccess = true; |
5896 | 7137 | |
5897 | | - var requestDone = false; |
| 7138 | + // If we have data |
| 7139 | + } else { |
5898 | 7140 | |
5899 | | - // Create the request object |
5900 | | - var xhr = s.xhr(); |
| 7141 | + try { |
| 7142 | + success = ajaxConvert( s, response ); |
| 7143 | + statusText = "success"; |
| 7144 | + isSuccess = true; |
| 7145 | + } catch(e) { |
| 7146 | + // We have a parsererror |
| 7147 | + statusText = "parsererror"; |
| 7148 | + error = e; |
| 7149 | + } |
| 7150 | + } |
| 7151 | + } else { |
| 7152 | + // We extract error from statusText |
| 7153 | + // then normalize statusText and status for non-aborts |
| 7154 | + error = statusText; |
| 7155 | + if( !statusText || status ) { |
| 7156 | + statusText = "error"; |
| 7157 | + if ( status < 0 ) { |
| 7158 | + status = 0; |
| 7159 | + } |
| 7160 | + } |
| 7161 | + } |
5901 | 7162 | |
5902 | | - if ( !xhr ) { |
5903 | | - return; |
5904 | | - } |
| 7163 | + // Set data for the fake xhr object |
| 7164 | + jqXHR.status = status; |
| 7165 | + jqXHR.statusText = statusText; |
5905 | 7166 | |
5906 | | - // Open the socket |
5907 | | - // Passing null username, generates a login popup on Opera (#2865) |
5908 | | - if ( s.username ) { |
5909 | | - xhr.open(type, s.url, s.async, s.username, s.password); |
5910 | | - } else { |
5911 | | - xhr.open(type, s.url, s.async); |
5912 | | - } |
| 7167 | + // Success/Error |
| 7168 | + if ( isSuccess ) { |
| 7169 | + deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); |
| 7170 | + } else { |
| 7171 | + deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); |
| 7172 | + } |
5913 | 7173 | |
5914 | | - // Need an extra try/catch for cross domain requests in Firefox 3 |
5915 | | - try { |
5916 | | - // Set content-type if data specified and content-body is valid for this type |
5917 | | - if ( (s.data != null && !noContent) || (origSettings && origSettings.contentType) ) { |
5918 | | - xhr.setRequestHeader("Content-Type", s.contentType); |
| 7174 | + // Status-dependent callbacks |
| 7175 | + jqXHR.statusCode( statusCode ); |
| 7176 | + statusCode = undefined; |
| 7177 | + |
| 7178 | + if ( fireGlobals ) { |
| 7179 | + globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ), |
| 7180 | + [ jqXHR, s, isSuccess ? success : error ] ); |
5919 | 7181 | } |
5920 | 7182 | |
5921 | | - // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
5922 | | - if ( s.ifModified ) { |
5923 | | - if ( jQuery.lastModified[s.url] ) { |
5924 | | - xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]); |
5925 | | - } |
| 7183 | + // Complete |
| 7184 | + completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] ); |
5926 | 7185 | |
5927 | | - if ( jQuery.etag[s.url] ) { |
5928 | | - xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]); |
| 7186 | + if ( fireGlobals ) { |
| 7187 | + globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] ); |
| 7188 | + // Handle the global AJAX counter |
| 7189 | + if ( !( --jQuery.active ) ) { |
| 7190 | + jQuery.event.trigger( "ajaxStop" ); |
5929 | 7191 | } |
5930 | 7192 | } |
| 7193 | + } |
5931 | 7194 | |
5932 | | - // Set header so the called script knows that it's an XMLHttpRequest |
5933 | | - // Only send the header if it's not a remote XHR |
5934 | | - if ( !remote ) { |
5935 | | - xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"); |
| 7195 | + // Attach deferreds |
| 7196 | + deferred.promise( jqXHR ); |
| 7197 | + jqXHR.success = jqXHR.done; |
| 7198 | + jqXHR.error = jqXHR.fail; |
| 7199 | + jqXHR.complete = completeDeferred.done; |
| 7200 | + |
| 7201 | + // Status-dependent callbacks |
| 7202 | + jqXHR.statusCode = function( map ) { |
| 7203 | + if ( map ) { |
| 7204 | + var tmp; |
| 7205 | + if ( state < 2 ) { |
| 7206 | + for( tmp in map ) { |
| 7207 | + statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ]; |
| 7208 | + } |
| 7209 | + } else { |
| 7210 | + tmp = map[ jqXHR.status ]; |
| 7211 | + jqXHR.then( tmp, tmp ); |
| 7212 | + } |
5936 | 7213 | } |
| 7214 | + return this; |
| 7215 | + }; |
5937 | 7216 | |
5938 | | - // Set the Accepts header for the server, depending on the dataType |
5939 | | - xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ? |
5940 | | - s.accepts[ s.dataType ] + ", */*; q=0.01" : |
5941 | | - s.accepts._default ); |
5942 | | - } catch( headerError ) {} |
| 7217 | + // Remove hash character (#7531: and string promotion) |
| 7218 | + // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) |
| 7219 | + // We also use the url parameter if available |
| 7220 | + s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); |
5943 | 7221 | |
5944 | | - // Allow custom headers/mimetypes and early abort |
5945 | | - if ( s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false ) { |
5946 | | - // Handle the global AJAX counter |
5947 | | - if ( s.global && jQuery.active-- === 1 ) { |
5948 | | - jQuery.event.trigger( "ajaxStop" ); |
5949 | | - } |
| 7222 | + // Extract dataTypes list |
| 7223 | + s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax ); |
5950 | 7224 | |
5951 | | - // close opended socket |
5952 | | - xhr.abort(); |
5953 | | - return false; |
| 7225 | + // Determine if a cross-domain request is in order |
| 7226 | + if ( s.crossDomain == null ) { |
| 7227 | + parts = rurl.exec( s.url.toLowerCase() ); |
| 7228 | + s.crossDomain = !!( parts && |
| 7229 | + ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] || |
| 7230 | + ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) != |
| 7231 | + ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) ) |
| 7232 | + ); |
5954 | 7233 | } |
5955 | 7234 | |
5956 | | - if ( s.global ) { |
5957 | | - jQuery.triggerGlobal( s, "ajaxSend", [xhr, s] ); |
| 7235 | + // Convert data if not already a string |
| 7236 | + if ( s.data && s.processData && typeof s.data !== "string" ) { |
| 7237 | + s.data = jQuery.param( s.data, s.traditional ); |
5958 | 7238 | } |
5959 | 7239 | |
5960 | | - // Wait for a response to come back |
5961 | | - var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) { |
5962 | | - // The request was aborted |
5963 | | - if ( !xhr || xhr.readyState === 0 || isTimeout === "abort" ) { |
5964 | | - // Opera doesn't call onreadystatechange before this point |
5965 | | - // so we simulate the call |
5966 | | - if ( !requestDone ) { |
5967 | | - jQuery.handleComplete( s, xhr, status, data ); |
5968 | | - } |
| 7240 | + // Apply prefilters |
| 7241 | + inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); |
5969 | 7242 | |
5970 | | - requestDone = true; |
5971 | | - if ( xhr ) { |
5972 | | - xhr.onreadystatechange = jQuery.noop; |
5973 | | - } |
| 7243 | + // If request was aborted inside a prefiler, stop there |
| 7244 | + if ( state === 2 ) { |
| 7245 | + return false; |
| 7246 | + } |
5974 | 7247 | |
5975 | | - // The transfer is complete and the data is available, or the request timed out |
5976 | | - } else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) { |
5977 | | - requestDone = true; |
5978 | | - xhr.onreadystatechange = jQuery.noop; |
| 7248 | + // We can fire global events as of now if asked to |
| 7249 | + fireGlobals = s.global; |
5979 | 7250 | |
5980 | | - status = isTimeout === "timeout" ? |
5981 | | - "timeout" : |
5982 | | - !jQuery.httpSuccess( xhr ) ? |
5983 | | - "error" : |
5984 | | - s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? |
5985 | | - "notmodified" : |
5986 | | - "success"; |
| 7251 | + // Uppercase the type |
| 7252 | + s.type = s.type.toUpperCase(); |
5987 | 7253 | |
5988 | | - var errMsg; |
| 7254 | + // Determine if request has content |
| 7255 | + s.hasContent = !rnoContent.test( s.type ); |
5989 | 7256 | |
5990 | | - if ( status === "success" ) { |
5991 | | - // Watch for, and catch, XML document parse errors |
5992 | | - try { |
5993 | | - // process the data (runs the xml through httpData regardless of callback) |
5994 | | - data = jQuery.httpData( xhr, s.dataType, s ); |
5995 | | - } catch( parserError ) { |
5996 | | - status = "parsererror"; |
5997 | | - errMsg = parserError; |
5998 | | - } |
5999 | | - } |
| 7257 | + // Watch for a new set of requests |
| 7258 | + if ( fireGlobals && jQuery.active++ === 0 ) { |
| 7259 | + jQuery.event.trigger( "ajaxStart" ); |
| 7260 | + } |
6000 | 7261 | |
6001 | | - // Make sure that the request was successful or notmodified |
6002 | | - if ( status === "success" || status === "notmodified" ) { |
6003 | | - // JSONP handles its own success callback |
6004 | | - if ( !jsonp ) { |
6005 | | - jQuery.handleSuccess( s, xhr, status, data ); |
6006 | | - } |
6007 | | - } else { |
6008 | | - jQuery.handleError( s, xhr, status, errMsg ); |
6009 | | - } |
| 7262 | + // More options handling for requests with no content |
| 7263 | + if ( !s.hasContent ) { |
6010 | 7264 | |
6011 | | - // Fire the complete handlers |
6012 | | - if ( !jsonp ) { |
6013 | | - jQuery.handleComplete( s, xhr, status, data ); |
6014 | | - } |
| 7265 | + // If data is available, append data to url |
| 7266 | + if ( s.data ) { |
| 7267 | + s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; |
| 7268 | + } |
6015 | 7269 | |
6016 | | - if ( isTimeout === "timeout" ) { |
6017 | | - xhr.abort(); |
6018 | | - } |
| 7270 | + // Get ifModifiedKey before adding the anti-cache parameter |
| 7271 | + ifModifiedKey = s.url; |
6019 | 7272 | |
6020 | | - // Stop memory leaks |
6021 | | - if ( s.async ) { |
6022 | | - xhr = null; |
6023 | | - } |
| 7273 | + // Add anti-cache in url if needed |
| 7274 | + if ( s.cache === false ) { |
| 7275 | + |
| 7276 | + var ts = jQuery.now(), |
| 7277 | + // try replacing _= if it is there |
| 7278 | + ret = s.url.replace( rts, "$1_=" + ts ); |
| 7279 | + |
| 7280 | + // if nothing was replaced, add timestamp to the end |
| 7281 | + s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); |
6024 | 7282 | } |
6025 | | - }; |
| 7283 | + } |
6026 | 7284 | |
6027 | | - // Override the abort handler, if we can (IE 6 doesn't allow it, but that's OK) |
6028 | | - // Opera doesn't fire onreadystatechange at all on abort |
6029 | | - try { |
6030 | | - var oldAbort = xhr.abort; |
6031 | | - xhr.abort = function() { |
6032 | | - if ( xhr ) { |
6033 | | - // oldAbort has no call property in IE7 so |
6034 | | - // just do it this way, which works in all |
6035 | | - // browsers |
6036 | | - Function.prototype.call.call( oldAbort, xhr ); |
6037 | | - } |
| 7285 | + // Set the correct header, if data is being sent |
| 7286 | + if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { |
| 7287 | + jqXHR.setRequestHeader( "Content-Type", s.contentType ); |
| 7288 | + } |
6038 | 7289 | |
6039 | | - onreadystatechange( "abort" ); |
6040 | | - }; |
6041 | | - } catch( abortError ) {} |
| 7290 | + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 7291 | + if ( s.ifModified ) { |
| 7292 | + ifModifiedKey = ifModifiedKey || s.url; |
| 7293 | + if ( jQuery.lastModified[ ifModifiedKey ] ) { |
| 7294 | + jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] ); |
| 7295 | + } |
| 7296 | + if ( jQuery.etag[ ifModifiedKey ] ) { |
| 7297 | + jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] ); |
| 7298 | + } |
| 7299 | + } |
6042 | 7300 | |
6043 | | - // Timeout checker |
6044 | | - if ( s.async && s.timeout > 0 ) { |
6045 | | - setTimeout(function() { |
6046 | | - // Check to see if the request is still happening |
6047 | | - if ( xhr && !requestDone ) { |
6048 | | - onreadystatechange( "timeout" ); |
6049 | | - } |
6050 | | - }, s.timeout); |
| 7301 | + // Set the Accepts header for the server, depending on the dataType |
| 7302 | + jqXHR.setRequestHeader( |
| 7303 | + "Accept", |
| 7304 | + s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? |
| 7305 | + s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) : |
| 7306 | + s.accepts[ "*" ] |
| 7307 | + ); |
| 7308 | + |
| 7309 | + // Check for headers option |
| 7310 | + for ( i in s.headers ) { |
| 7311 | + jqXHR.setRequestHeader( i, s.headers[ i ] ); |
6051 | 7312 | } |
6052 | 7313 | |
6053 | | - // Send the data |
6054 | | - try { |
6055 | | - xhr.send( noContent || s.data == null ? null : s.data ); |
| 7314 | + // Allow custom headers/mimetypes and early abort |
| 7315 | + if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { |
| 7316 | + // Abort if not done already |
| 7317 | + jqXHR.abort(); |
| 7318 | + return false; |
6056 | 7319 | |
6057 | | - } catch( sendError ) { |
6058 | | - jQuery.handleError( s, xhr, null, sendError ); |
| 7320 | + } |
6059 | 7321 | |
6060 | | - // Fire the complete handlers |
6061 | | - jQuery.handleComplete( s, xhr, status, data ); |
| 7322 | + // Install callbacks on deferreds |
| 7323 | + for ( i in { success: 1, error: 1, complete: 1 } ) { |
| 7324 | + jqXHR[ i ]( s[ i ] ); |
6062 | 7325 | } |
6063 | 7326 | |
6064 | | - // firefox 1.5 doesn't fire statechange for sync requests |
6065 | | - if ( !s.async ) { |
6066 | | - onreadystatechange(); |
| 7327 | + // Get transport |
| 7328 | + transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); |
| 7329 | + |
| 7330 | + // If no transport, we auto-abort |
| 7331 | + if ( !transport ) { |
| 7332 | + done( -1, "No Transport" ); |
| 7333 | + } else { |
| 7334 | + jqXHR.readyState = 1; |
| 7335 | + // Send global event |
| 7336 | + if ( fireGlobals ) { |
| 7337 | + globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); |
| 7338 | + } |
| 7339 | + // Timeout |
| 7340 | + if ( s.async && s.timeout > 0 ) { |
| 7341 | + timeoutTimer = setTimeout( function(){ |
| 7342 | + jqXHR.abort( "timeout" ); |
| 7343 | + }, s.timeout ); |
| 7344 | + } |
| 7345 | + |
| 7346 | + try { |
| 7347 | + state = 1; |
| 7348 | + transport.send( requestHeaders, done ); |
| 7349 | + } catch (e) { |
| 7350 | + // Propagate exception as error if not done |
| 7351 | + if ( status < 2 ) { |
| 7352 | + done( -1, e ); |
| 7353 | + // Simply rethrow otherwise |
| 7354 | + } else { |
| 7355 | + jQuery.error( e ); |
| 7356 | + } |
| 7357 | + } |
6067 | 7358 | } |
6068 | 7359 | |
6069 | | - // return XMLHttpRequest to allow aborting the request etc. |
6070 | | - return xhr; |
| 7360 | + return jqXHR; |
6071 | 7361 | }, |
6072 | 7362 | |
6073 | 7363 | // Serialize an array of form elements or a set of |
— | — | @@ -6075,37 +7365,37 @@ |
6076 | 7366 | var s = [], |
6077 | 7367 | add = function( key, value ) { |
6078 | 7368 | // If value is a function, invoke it and return its value |
6079 | | - value = jQuery.isFunction(value) ? value() : value; |
6080 | | - s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value); |
| 7369 | + value = jQuery.isFunction( value ) ? value() : value; |
| 7370 | + s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); |
6081 | 7371 | }; |
6082 | | - |
| 7372 | + |
6083 | 7373 | // Set traditional to true for jQuery <= 1.3.2 behavior. |
6084 | 7374 | if ( traditional === undefined ) { |
6085 | 7375 | traditional = jQuery.ajaxSettings.traditional; |
6086 | 7376 | } |
6087 | | - |
| 7377 | + |
6088 | 7378 | // If an array was passed in, assume that it is an array of form elements. |
6089 | | - if ( jQuery.isArray(a) || a.jquery ) { |
| 7379 | + if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
6090 | 7380 | // Serialize the form elements |
6091 | 7381 | jQuery.each( a, function() { |
6092 | 7382 | add( this.name, this.value ); |
6093 | 7383 | }); |
6094 | | - |
| 7384 | + |
6095 | 7385 | } else { |
6096 | 7386 | // If traditional, encode the "old" way (the way 1.3.2 or older |
6097 | 7387 | // did it), otherwise encode params recursively. |
6098 | 7388 | for ( var prefix in a ) { |
6099 | | - buildParams( prefix, a[prefix], traditional, add ); |
| 7389 | + buildParams( prefix, a[ prefix ], traditional, add ); |
6100 | 7390 | } |
6101 | 7391 | } |
6102 | 7392 | |
6103 | 7393 | // Return the resulting serialization |
6104 | | - return s.join("&").replace(r20, "+"); |
| 7394 | + return s.join( "&" ).replace( r20, "+" ); |
6105 | 7395 | } |
6106 | 7396 | }); |
6107 | 7397 | |
6108 | 7398 | function buildParams( prefix, obj, traditional, add ) { |
6109 | | - if ( jQuery.isArray(obj) && obj.length ) { |
| 7399 | + if ( jQuery.isArray( obj ) ) { |
6110 | 7400 | // Serialize array item. |
6111 | 7401 | jQuery.each( obj, function( i, v ) { |
6112 | 7402 | if ( traditional || rbracket.test( prefix ) ) { |
— | — | @@ -6123,18 +7413,13 @@ |
6124 | 7414 | buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add ); |
6125 | 7415 | } |
6126 | 7416 | }); |
6127 | | - |
| 7417 | + |
6128 | 7418 | } else if ( !traditional && obj != null && typeof obj === "object" ) { |
6129 | | - if ( jQuery.isEmptyObject( obj ) ) { |
6130 | | - add( prefix, "" ); |
6131 | | - |
6132 | 7419 | // Serialize object item. |
6133 | | - } else { |
6134 | | - jQuery.each( obj, function( k, v ) { |
6135 | | - buildParams( prefix + "[" + k + "]", v, traditional, add ); |
6136 | | - }); |
| 7420 | + for ( var name in obj ) { |
| 7421 | + buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); |
6137 | 7422 | } |
6138 | | - |
| 7423 | + |
6139 | 7424 | } else { |
6140 | 7425 | // Serialize scalar item. |
6141 | 7426 | add( prefix, obj ); |
— | — | @@ -6150,143 +7435,557 @@ |
6151 | 7436 | |
6152 | 7437 | // Last-Modified header cache for next request |
6153 | 7438 | lastModified: {}, |
6154 | | - etag: {}, |
| 7439 | + etag: {} |
6155 | 7440 | |
6156 | | - handleError: function( s, xhr, status, e ) { |
6157 | | - // If a local callback was specified, fire it |
6158 | | - if ( s.error ) { |
6159 | | - s.error.call( s.context, xhr, status, e ); |
6160 | | - } |
| 7441 | +}); |
6161 | 7442 | |
6162 | | - // Fire the global callback |
6163 | | - if ( s.global ) { |
6164 | | - jQuery.triggerGlobal( s, "ajaxError", [xhr, s, e] ); |
6165 | | - } |
6166 | | - }, |
| 7443 | +/* Handles responses to an ajax request: |
| 7444 | + * - sets all responseXXX fields accordingly |
| 7445 | + * - finds the right dataType (mediates between content-type and expected dataType) |
| 7446 | + * - returns the corresponding response |
| 7447 | + */ |
| 7448 | +function ajaxHandleResponses( s, jqXHR, responses ) { |
6167 | 7449 | |
6168 | | - handleSuccess: function( s, xhr, status, data ) { |
6169 | | - // If a local callback was specified, fire it and pass it the data |
6170 | | - if ( s.success ) { |
6171 | | - s.success.call( s.context, data, status, xhr ); |
| 7450 | + var contents = s.contents, |
| 7451 | + dataTypes = s.dataTypes, |
| 7452 | + responseFields = s.responseFields, |
| 7453 | + ct, |
| 7454 | + type, |
| 7455 | + finalDataType, |
| 7456 | + firstDataType; |
| 7457 | + |
| 7458 | + // Fill responseXXX fields |
| 7459 | + for( type in responseFields ) { |
| 7460 | + if ( type in responses ) { |
| 7461 | + jqXHR[ responseFields[type] ] = responses[ type ]; |
6172 | 7462 | } |
| 7463 | + } |
6173 | 7464 | |
6174 | | - // Fire the global callback |
6175 | | - if ( s.global ) { |
6176 | | - jQuery.triggerGlobal( s, "ajaxSuccess", [xhr, s] ); |
| 7465 | + // Remove auto dataType and get content-type in the process |
| 7466 | + while( dataTypes[ 0 ] === "*" ) { |
| 7467 | + dataTypes.shift(); |
| 7468 | + if ( ct === undefined ) { |
| 7469 | + ct = s.mimeType || jqXHR.getResponseHeader( "content-type" ); |
6177 | 7470 | } |
6178 | | - }, |
| 7471 | + } |
6179 | 7472 | |
6180 | | - handleComplete: function( s, xhr, status ) { |
6181 | | - // Process result |
6182 | | - if ( s.complete ) { |
6183 | | - s.complete.call( s.context, xhr, status ); |
| 7473 | + // Check if we're dealing with a known content-type |
| 7474 | + if ( ct ) { |
| 7475 | + for ( type in contents ) { |
| 7476 | + if ( contents[ type ] && contents[ type ].test( ct ) ) { |
| 7477 | + dataTypes.unshift( type ); |
| 7478 | + break; |
| 7479 | + } |
6184 | 7480 | } |
| 7481 | + } |
6185 | 7482 | |
6186 | | - // The request was completed |
6187 | | - if ( s.global ) { |
6188 | | - jQuery.triggerGlobal( s, "ajaxComplete", [xhr, s] ); |
| 7483 | + // Check to see if we have a response for the expected dataType |
| 7484 | + if ( dataTypes[ 0 ] in responses ) { |
| 7485 | + finalDataType = dataTypes[ 0 ]; |
| 7486 | + } else { |
| 7487 | + // Try convertible dataTypes |
| 7488 | + for ( type in responses ) { |
| 7489 | + if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { |
| 7490 | + finalDataType = type; |
| 7491 | + break; |
| 7492 | + } |
| 7493 | + if ( !firstDataType ) { |
| 7494 | + firstDataType = type; |
| 7495 | + } |
6189 | 7496 | } |
| 7497 | + // Or just use first one |
| 7498 | + finalDataType = finalDataType || firstDataType; |
| 7499 | + } |
6190 | 7500 | |
6191 | | - // Handle the global AJAX counter |
6192 | | - if ( s.global && jQuery.active-- === 1 ) { |
6193 | | - jQuery.event.trigger( "ajaxStop" ); |
| 7501 | + // If we found a dataType |
| 7502 | + // We add the dataType to the list if needed |
| 7503 | + // and return the corresponding response |
| 7504 | + if ( finalDataType ) { |
| 7505 | + if ( finalDataType !== dataTypes[ 0 ] ) { |
| 7506 | + dataTypes.unshift( finalDataType ); |
6194 | 7507 | } |
6195 | | - }, |
6196 | | - |
6197 | | - triggerGlobal: function( s, type, args ) { |
6198 | | - (s.context && s.context.url == null ? jQuery(s.context) : jQuery.event).trigger(type, args); |
6199 | | - }, |
| 7508 | + return responses[ finalDataType ]; |
| 7509 | + } |
| 7510 | +} |
6200 | 7511 | |
6201 | | - // Determines if an XMLHttpRequest was successful or not |
6202 | | - httpSuccess: function( xhr ) { |
6203 | | - try { |
6204 | | - // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450 |
6205 | | - return !xhr.status && location.protocol === "file:" || |
6206 | | - xhr.status >= 200 && xhr.status < 300 || |
6207 | | - xhr.status === 304 || xhr.status === 1223; |
6208 | | - } catch(e) {} |
| 7512 | +// Chain conversions given the request and the original response |
| 7513 | +function ajaxConvert( s, response ) { |
6209 | 7514 | |
6210 | | - return false; |
6211 | | - }, |
| 7515 | + // Apply the dataFilter if provided |
| 7516 | + if ( s.dataFilter ) { |
| 7517 | + response = s.dataFilter( response, s.dataType ); |
| 7518 | + } |
6212 | 7519 | |
6213 | | - // Determines if an XMLHttpRequest returns NotModified |
6214 | | - httpNotModified: function( xhr, url ) { |
6215 | | - var lastModified = xhr.getResponseHeader("Last-Modified"), |
6216 | | - etag = xhr.getResponseHeader("Etag"); |
| 7520 | + var dataTypes = s.dataTypes, |
| 7521 | + converters = {}, |
| 7522 | + i, |
| 7523 | + key, |
| 7524 | + length = dataTypes.length, |
| 7525 | + tmp, |
| 7526 | + // Current and previous dataTypes |
| 7527 | + current = dataTypes[ 0 ], |
| 7528 | + prev, |
| 7529 | + // Conversion expression |
| 7530 | + conversion, |
| 7531 | + // Conversion function |
| 7532 | + conv, |
| 7533 | + // Conversion functions (transitive conversion) |
| 7534 | + conv1, |
| 7535 | + conv2; |
6217 | 7536 | |
6218 | | - if ( lastModified ) { |
6219 | | - jQuery.lastModified[url] = lastModified; |
6220 | | - } |
| 7537 | + // For each dataType in the chain |
| 7538 | + for( i = 1; i < length; i++ ) { |
6221 | 7539 | |
6222 | | - if ( etag ) { |
6223 | | - jQuery.etag[url] = etag; |
| 7540 | + // Create converters map |
| 7541 | + // with lowercased keys |
| 7542 | + if ( i === 1 ) { |
| 7543 | + for( key in s.converters ) { |
| 7544 | + if( typeof key === "string" ) { |
| 7545 | + converters[ key.toLowerCase() ] = s.converters[ key ]; |
| 7546 | + } |
| 7547 | + } |
6224 | 7548 | } |
6225 | 7549 | |
6226 | | - return xhr.status === 304; |
6227 | | - }, |
| 7550 | + // Get the dataTypes |
| 7551 | + prev = current; |
| 7552 | + current = dataTypes[ i ]; |
6228 | 7553 | |
6229 | | - httpData: function( xhr, type, s ) { |
6230 | | - var ct = xhr.getResponseHeader("content-type") || "", |
6231 | | - xml = type === "xml" || !type && ct.indexOf("xml") >= 0, |
6232 | | - data = xml ? xhr.responseXML : xhr.responseText; |
| 7554 | + // If current is auto dataType, update it to prev |
| 7555 | + if( current === "*" ) { |
| 7556 | + current = prev; |
| 7557 | + // If no auto and dataTypes are actually different |
| 7558 | + } else if ( prev !== "*" && prev !== current ) { |
6233 | 7559 | |
6234 | | - if ( xml && data.documentElement.nodeName === "parsererror" ) { |
6235 | | - jQuery.error( "parsererror" ); |
| 7560 | + // Get the converter |
| 7561 | + conversion = prev + " " + current; |
| 7562 | + conv = converters[ conversion ] || converters[ "* " + current ]; |
| 7563 | + |
| 7564 | + // If there is no direct converter, search transitively |
| 7565 | + if ( !conv ) { |
| 7566 | + conv2 = undefined; |
| 7567 | + for( conv1 in converters ) { |
| 7568 | + tmp = conv1.split( " " ); |
| 7569 | + if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) { |
| 7570 | + conv2 = converters[ tmp[1] + " " + current ]; |
| 7571 | + if ( conv2 ) { |
| 7572 | + conv1 = converters[ conv1 ]; |
| 7573 | + if ( conv1 === true ) { |
| 7574 | + conv = conv2; |
| 7575 | + } else if ( conv2 === true ) { |
| 7576 | + conv = conv1; |
| 7577 | + } |
| 7578 | + break; |
| 7579 | + } |
| 7580 | + } |
| 7581 | + } |
| 7582 | + } |
| 7583 | + // If we found no converter, dispatch an error |
| 7584 | + if ( !( conv || conv2 ) ) { |
| 7585 | + jQuery.error( "No conversion from " + conversion.replace(" "," to ") ); |
| 7586 | + } |
| 7587 | + // If found converter is not an equivalence |
| 7588 | + if ( conv !== true ) { |
| 7589 | + // Convert with 1 or 2 converters accordingly |
| 7590 | + response = conv ? conv( response ) : conv2( conv1(response) ); |
| 7591 | + } |
6236 | 7592 | } |
| 7593 | + } |
| 7594 | + return response; |
| 7595 | +} |
6237 | 7596 | |
6238 | | - // Allow a pre-filtering function to sanitize the response |
6239 | | - // s is checked to keep backwards compatibility |
6240 | | - if ( s && s.dataFilter ) { |
6241 | | - data = s.dataFilter( data, type ); |
| 7597 | + |
| 7598 | + |
| 7599 | + |
| 7600 | +var jsc = jQuery.now(), |
| 7601 | + jsre = /(\=)\?(&|$)|\?\?/i; |
| 7602 | + |
| 7603 | +// Default jsonp settings |
| 7604 | +jQuery.ajaxSetup({ |
| 7605 | + jsonp: "callback", |
| 7606 | + jsonpCallback: function() { |
| 7607 | + return jQuery.expando + "_" + ( jsc++ ); |
| 7608 | + } |
| 7609 | +}); |
| 7610 | + |
| 7611 | +// Detect, normalize options and install callbacks for jsonp requests |
| 7612 | +jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { |
| 7613 | + |
| 7614 | + var inspectData = s.contentType === "application/x-www-form-urlencoded" && |
| 7615 | + ( typeof s.data === "string" ); |
| 7616 | + |
| 7617 | + if ( s.dataTypes[ 0 ] === "jsonp" || |
| 7618 | + s.jsonp !== false && ( jsre.test( s.url ) || |
| 7619 | + inspectData && jsre.test( s.data ) ) ) { |
| 7620 | + |
| 7621 | + var responseContainer, |
| 7622 | + jsonpCallback = s.jsonpCallback = |
| 7623 | + jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback, |
| 7624 | + previous = window[ jsonpCallback ], |
| 7625 | + url = s.url, |
| 7626 | + data = s.data, |
| 7627 | + replace = "$1" + jsonpCallback + "$2"; |
| 7628 | + |
| 7629 | + if ( s.jsonp !== false ) { |
| 7630 | + url = url.replace( jsre, replace ); |
| 7631 | + if ( s.url === url ) { |
| 7632 | + if ( inspectData ) { |
| 7633 | + data = data.replace( jsre, replace ); |
| 7634 | + } |
| 7635 | + if ( s.data === data ) { |
| 7636 | + // Add callback manually |
| 7637 | + url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback; |
| 7638 | + } |
| 7639 | + } |
6242 | 7640 | } |
6243 | 7641 | |
6244 | | - // The filter can actually parse the response |
6245 | | - if ( typeof data === "string" ) { |
6246 | | - // Get the JavaScript object, if JSON is used. |
6247 | | - if ( type === "json" || !type && ct.indexOf("json") >= 0 ) { |
6248 | | - data = jQuery.parseJSON( data ); |
| 7642 | + s.url = url; |
| 7643 | + s.data = data; |
6249 | 7644 | |
6250 | | - // If the type is "script", eval it in global context |
6251 | | - } else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) { |
6252 | | - jQuery.globalEval( data ); |
| 7645 | + // Install callback |
| 7646 | + window[ jsonpCallback ] = function( response ) { |
| 7647 | + responseContainer = [ response ]; |
| 7648 | + }; |
| 7649 | + |
| 7650 | + // Clean-up function |
| 7651 | + jqXHR.always(function() { |
| 7652 | + // Set callback back to previous value |
| 7653 | + window[ jsonpCallback ] = previous; |
| 7654 | + // Call if it was a function and we have a response |
| 7655 | + if ( responseContainer && jQuery.isFunction( previous ) ) { |
| 7656 | + window[ jsonpCallback ]( responseContainer[ 0 ] ); |
6253 | 7657 | } |
| 7658 | + }); |
| 7659 | + |
| 7660 | + // Use data converter to retrieve json after script execution |
| 7661 | + s.converters["script json"] = function() { |
| 7662 | + if ( !responseContainer ) { |
| 7663 | + jQuery.error( jsonpCallback + " was not called" ); |
| 7664 | + } |
| 7665 | + return responseContainer[ 0 ]; |
| 7666 | + }; |
| 7667 | + |
| 7668 | + // force json dataType |
| 7669 | + s.dataTypes[ 0 ] = "json"; |
| 7670 | + |
| 7671 | + // Delegate to script |
| 7672 | + return "script"; |
| 7673 | + } |
| 7674 | +}); |
| 7675 | + |
| 7676 | + |
| 7677 | + |
| 7678 | + |
| 7679 | +// Install script dataType |
| 7680 | +jQuery.ajaxSetup({ |
| 7681 | + accepts: { |
| 7682 | + script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" |
| 7683 | + }, |
| 7684 | + contents: { |
| 7685 | + script: /javascript|ecmascript/ |
| 7686 | + }, |
| 7687 | + converters: { |
| 7688 | + "text script": function( text ) { |
| 7689 | + jQuery.globalEval( text ); |
| 7690 | + return text; |
6254 | 7691 | } |
| 7692 | + } |
| 7693 | +}); |
6255 | 7694 | |
6256 | | - return data; |
| 7695 | +// Handle cache's special case and global |
| 7696 | +jQuery.ajaxPrefilter( "script", function( s ) { |
| 7697 | + if ( s.cache === undefined ) { |
| 7698 | + s.cache = false; |
6257 | 7699 | } |
| 7700 | + if ( s.crossDomain ) { |
| 7701 | + s.type = "GET"; |
| 7702 | + s.global = false; |
| 7703 | + } |
| 7704 | +}); |
6258 | 7705 | |
| 7706 | +// Bind script tag hack transport |
| 7707 | +jQuery.ajaxTransport( "script", function(s) { |
| 7708 | + |
| 7709 | + // This transport only deals with cross domain requests |
| 7710 | + if ( s.crossDomain ) { |
| 7711 | + |
| 7712 | + var script, |
| 7713 | + head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; |
| 7714 | + |
| 7715 | + return { |
| 7716 | + |
| 7717 | + send: function( _, callback ) { |
| 7718 | + |
| 7719 | + script = document.createElement( "script" ); |
| 7720 | + |
| 7721 | + script.async = "async"; |
| 7722 | + |
| 7723 | + if ( s.scriptCharset ) { |
| 7724 | + script.charset = s.scriptCharset; |
| 7725 | + } |
| 7726 | + |
| 7727 | + script.src = s.url; |
| 7728 | + |
| 7729 | + // Attach handlers for all browsers |
| 7730 | + script.onload = script.onreadystatechange = function( _, isAbort ) { |
| 7731 | + |
| 7732 | + if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { |
| 7733 | + |
| 7734 | + // Handle memory leak in IE |
| 7735 | + script.onload = script.onreadystatechange = null; |
| 7736 | + |
| 7737 | + // Remove the script |
| 7738 | + if ( head && script.parentNode ) { |
| 7739 | + head.removeChild( script ); |
| 7740 | + } |
| 7741 | + |
| 7742 | + // Dereference the script |
| 7743 | + script = undefined; |
| 7744 | + |
| 7745 | + // Callback if not abort |
| 7746 | + if ( !isAbort ) { |
| 7747 | + callback( 200, "success" ); |
| 7748 | + } |
| 7749 | + } |
| 7750 | + }; |
| 7751 | + // Use insertBefore instead of appendChild to circumvent an IE6 bug. |
| 7752 | + // This arises when a base node is used (#2709 and #4378). |
| 7753 | + head.insertBefore( script, head.firstChild ); |
| 7754 | + }, |
| 7755 | + |
| 7756 | + abort: function() { |
| 7757 | + if ( script ) { |
| 7758 | + script.onload( 0, 1 ); |
| 7759 | + } |
| 7760 | + } |
| 7761 | + }; |
| 7762 | + } |
6259 | 7763 | }); |
6260 | 7764 | |
6261 | | -/* |
6262 | | - * Create the request object; Microsoft failed to properly |
6263 | | - * implement the XMLHttpRequest in IE7 (can't request local files), |
6264 | | - * so we use the ActiveXObject when it is available |
6265 | | - * Additionally XMLHttpRequest can be disabled in IE7/IE8 so |
6266 | | - * we need a fallback. |
6267 | | - */ |
6268 | | -if ( window.ActiveXObject ) { |
6269 | | - jQuery.ajaxSettings.xhr = function() { |
6270 | | - if ( window.location.protocol !== "file:" ) { |
6271 | | - try { |
6272 | | - return new window.XMLHttpRequest(); |
6273 | | - } catch(xhrError) {} |
| 7765 | + |
| 7766 | + |
| 7767 | + |
| 7768 | +var // #5280: Internet Explorer will keep connections alive if we don't abort on unload |
| 7769 | + xhrOnUnloadAbort = window.ActiveXObject ? function() { |
| 7770 | + // Abort all pending requests |
| 7771 | + for ( var key in xhrCallbacks ) { |
| 7772 | + xhrCallbacks[ key ]( 0, 1 ); |
6274 | 7773 | } |
| 7774 | + } : false, |
| 7775 | + xhrId = 0, |
| 7776 | + xhrCallbacks; |
6275 | 7777 | |
6276 | | - try { |
6277 | | - return new window.ActiveXObject("Microsoft.XMLHTTP"); |
6278 | | - } catch(activeError) {} |
6279 | | - }; |
| 7778 | +// Functions to create xhrs |
| 7779 | +function createStandardXHR() { |
| 7780 | + try { |
| 7781 | + return new window.XMLHttpRequest(); |
| 7782 | + } catch( e ) {} |
6280 | 7783 | } |
6281 | 7784 | |
6282 | | -// Does this browser support XHR requests? |
6283 | | -jQuery.support.ajax = !!jQuery.ajaxSettings.xhr(); |
| 7785 | +function createActiveXHR() { |
| 7786 | + try { |
| 7787 | + return new window.ActiveXObject( "Microsoft.XMLHTTP" ); |
| 7788 | + } catch( e ) {} |
| 7789 | +} |
6284 | 7790 | |
| 7791 | +// Create the request object |
| 7792 | +// (This is still attached to ajaxSettings for backward compatibility) |
| 7793 | +jQuery.ajaxSettings.xhr = window.ActiveXObject ? |
| 7794 | + /* Microsoft failed to properly |
| 7795 | + * implement the XMLHttpRequest in IE7 (can't request local files), |
| 7796 | + * so we use the ActiveXObject when it is available |
| 7797 | + * Additionally XMLHttpRequest can be disabled in IE7/IE8 so |
| 7798 | + * we need a fallback. |
| 7799 | + */ |
| 7800 | + function() { |
| 7801 | + return !this.isLocal && createStandardXHR() || createActiveXHR(); |
| 7802 | + } : |
| 7803 | + // For all other browsers, use the standard XMLHttpRequest object |
| 7804 | + createStandardXHR; |
6285 | 7805 | |
| 7806 | +// Determine support properties |
| 7807 | +(function( xhr ) { |
| 7808 | + jQuery.extend( jQuery.support, { |
| 7809 | + ajax: !!xhr, |
| 7810 | + cors: !!xhr && ( "withCredentials" in xhr ) |
| 7811 | + }); |
| 7812 | +})( jQuery.ajaxSettings.xhr() ); |
6286 | 7813 | |
| 7814 | +// Create transport if the browser can provide an xhr |
| 7815 | +if ( jQuery.support.ajax ) { |
6287 | 7816 | |
| 7817 | + jQuery.ajaxTransport(function( s ) { |
| 7818 | + // Cross domain only allowed if supported through XMLHttpRequest |
| 7819 | + if ( !s.crossDomain || jQuery.support.cors ) { |
| 7820 | + |
| 7821 | + var callback; |
| 7822 | + |
| 7823 | + return { |
| 7824 | + send: function( headers, complete ) { |
| 7825 | + |
| 7826 | + // Get a new xhr |
| 7827 | + var xhr = s.xhr(), |
| 7828 | + handle, |
| 7829 | + i; |
| 7830 | + |
| 7831 | + // Open the socket |
| 7832 | + // Passing null username, generates a login popup on Opera (#2865) |
| 7833 | + if ( s.username ) { |
| 7834 | + xhr.open( s.type, s.url, s.async, s.username, s.password ); |
| 7835 | + } else { |
| 7836 | + xhr.open( s.type, s.url, s.async ); |
| 7837 | + } |
| 7838 | + |
| 7839 | + // Apply custom fields if provided |
| 7840 | + if ( s.xhrFields ) { |
| 7841 | + for ( i in s.xhrFields ) { |
| 7842 | + xhr[ i ] = s.xhrFields[ i ]; |
| 7843 | + } |
| 7844 | + } |
| 7845 | + |
| 7846 | + // Override mime type if needed |
| 7847 | + if ( s.mimeType && xhr.overrideMimeType ) { |
| 7848 | + xhr.overrideMimeType( s.mimeType ); |
| 7849 | + } |
| 7850 | + |
| 7851 | + // X-Requested-With header |
| 7852 | + // For cross-domain requests, seeing as conditions for a preflight are |
| 7853 | + // akin to a jigsaw puzzle, we simply never set it to be sure. |
| 7854 | + // (it can always be set on a per-request basis or even using ajaxSetup) |
| 7855 | + // For same-domain requests, won't change header if already provided. |
| 7856 | + if ( !s.crossDomain && !headers["X-Requested-With"] ) { |
| 7857 | + headers[ "X-Requested-With" ] = "XMLHttpRequest"; |
| 7858 | + } |
| 7859 | + |
| 7860 | + // Need an extra try/catch for cross domain requests in Firefox 3 |
| 7861 | + try { |
| 7862 | + for ( i in headers ) { |
| 7863 | + xhr.setRequestHeader( i, headers[ i ] ); |
| 7864 | + } |
| 7865 | + } catch( _ ) {} |
| 7866 | + |
| 7867 | + // Do send the request |
| 7868 | + // This may raise an exception which is actually |
| 7869 | + // handled in jQuery.ajax (so no try/catch here) |
| 7870 | + xhr.send( ( s.hasContent && s.data ) || null ); |
| 7871 | + |
| 7872 | + // Listener |
| 7873 | + callback = function( _, isAbort ) { |
| 7874 | + |
| 7875 | + var status, |
| 7876 | + statusText, |
| 7877 | + responseHeaders, |
| 7878 | + responses, |
| 7879 | + xml; |
| 7880 | + |
| 7881 | + // Firefox throws exceptions when accessing properties |
| 7882 | + // of an xhr when a network error occured |
| 7883 | + // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) |
| 7884 | + try { |
| 7885 | + |
| 7886 | + // Was never called and is aborted or complete |
| 7887 | + if ( callback && ( isAbort || xhr.readyState === 4 ) ) { |
| 7888 | + |
| 7889 | + // Only called once |
| 7890 | + callback = undefined; |
| 7891 | + |
| 7892 | + // Do not keep as active anymore |
| 7893 | + if ( handle ) { |
| 7894 | + xhr.onreadystatechange = jQuery.noop; |
| 7895 | + if ( xhrOnUnloadAbort ) { |
| 7896 | + delete xhrCallbacks[ handle ]; |
| 7897 | + } |
| 7898 | + } |
| 7899 | + |
| 7900 | + // If it's an abort |
| 7901 | + if ( isAbort ) { |
| 7902 | + // Abort it manually if needed |
| 7903 | + if ( xhr.readyState !== 4 ) { |
| 7904 | + xhr.abort(); |
| 7905 | + } |
| 7906 | + } else { |
| 7907 | + status = xhr.status; |
| 7908 | + responseHeaders = xhr.getAllResponseHeaders(); |
| 7909 | + responses = {}; |
| 7910 | + xml = xhr.responseXML; |
| 7911 | + |
| 7912 | + // Construct response list |
| 7913 | + if ( xml && xml.documentElement /* #4958 */ ) { |
| 7914 | + responses.xml = xml; |
| 7915 | + } |
| 7916 | + responses.text = xhr.responseText; |
| 7917 | + |
| 7918 | + // Firefox throws an exception when accessing |
| 7919 | + // statusText for faulty cross-domain requests |
| 7920 | + try { |
| 7921 | + statusText = xhr.statusText; |
| 7922 | + } catch( e ) { |
| 7923 | + // We normalize with Webkit giving an empty statusText |
| 7924 | + statusText = ""; |
| 7925 | + } |
| 7926 | + |
| 7927 | + // Filter status for non standard behaviors |
| 7928 | + |
| 7929 | + // If the request is local and we have data: assume a success |
| 7930 | + // (success with no data won't get notified, that's the best we |
| 7931 | + // can do given current implementations) |
| 7932 | + if ( !status && s.isLocal && !s.crossDomain ) { |
| 7933 | + status = responses.text ? 200 : 404; |
| 7934 | + // IE - #1450: sometimes returns 1223 when it should be 204 |
| 7935 | + } else if ( status === 1223 ) { |
| 7936 | + status = 204; |
| 7937 | + } |
| 7938 | + } |
| 7939 | + } |
| 7940 | + } catch( firefoxAccessException ) { |
| 7941 | + if ( !isAbort ) { |
| 7942 | + complete( -1, firefoxAccessException ); |
| 7943 | + } |
| 7944 | + } |
| 7945 | + |
| 7946 | + // Call complete if needed |
| 7947 | + if ( responses ) { |
| 7948 | + complete( status, statusText, responses, responseHeaders ); |
| 7949 | + } |
| 7950 | + }; |
| 7951 | + |
| 7952 | + // if we're in sync mode or it's in cache |
| 7953 | + // and has been retrieved directly (IE6 & IE7) |
| 7954 | + // we need to manually fire the callback |
| 7955 | + if ( !s.async || xhr.readyState === 4 ) { |
| 7956 | + callback(); |
| 7957 | + } else { |
| 7958 | + handle = ++xhrId; |
| 7959 | + if ( xhrOnUnloadAbort ) { |
| 7960 | + // Create the active xhrs callbacks list if needed |
| 7961 | + // and attach the unload handler |
| 7962 | + if ( !xhrCallbacks ) { |
| 7963 | + xhrCallbacks = {}; |
| 7964 | + jQuery( window ).unload( xhrOnUnloadAbort ); |
| 7965 | + } |
| 7966 | + // Add to list of active xhrs callbacks |
| 7967 | + xhrCallbacks[ handle ] = callback; |
| 7968 | + } |
| 7969 | + xhr.onreadystatechange = callback; |
| 7970 | + } |
| 7971 | + }, |
| 7972 | + |
| 7973 | + abort: function() { |
| 7974 | + if ( callback ) { |
| 7975 | + callback(0,1); |
| 7976 | + } |
| 7977 | + } |
| 7978 | + }; |
| 7979 | + } |
| 7980 | + }); |
| 7981 | +} |
| 7982 | + |
| 7983 | + |
| 7984 | + |
| 7985 | + |
6288 | 7986 | var elemdisplay = {}, |
| 7987 | + iframe, iframeDoc, |
6289 | 7988 | rfxtypes = /^(?:toggle|show|hide)$/, |
6290 | | - rfxnum = /^([+\-]=)?([\d+.\-]+)(.*)$/, |
| 7989 | + rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i, |
6291 | 7990 | timerId, |
6292 | 7991 | fxAttrs = [ |
6293 | 7992 | // height animations |
— | — | @@ -6295,7 +7994,11 @@ |
6296 | 7995 | [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ], |
6297 | 7996 | // opacity animations |
6298 | 7997 | [ "opacity" ] |
6299 | | - ]; |
| 7998 | + ], |
| 7999 | + fxNow, |
| 8000 | + requestAnimationFrame = window.webkitRequestAnimationFrame || |
| 8001 | + window.mozRequestAnimationFrame || |
| 8002 | + window.oRequestAnimationFrame; |
6300 | 8003 | |
6301 | 8004 | jQuery.fn.extend({ |
6302 | 8005 | show: function( speed, easing, callback ) { |
— | — | @@ -6307,19 +8010,22 @@ |
6308 | 8011 | } else { |
6309 | 8012 | for ( var i = 0, j = this.length; i < j; i++ ) { |
6310 | 8013 | elem = this[i]; |
6311 | | - display = elem.style.display; |
6312 | 8014 | |
6313 | | - // Reset the inline display of this element to learn if it is |
6314 | | - // being hidden by cascaded rules or not |
6315 | | - if ( !jQuery.data(elem, "olddisplay") && display === "none" ) { |
6316 | | - display = elem.style.display = ""; |
6317 | | - } |
| 8015 | + if ( elem.style ) { |
| 8016 | + display = elem.style.display; |
6318 | 8017 | |
6319 | | - // Set elements which have been overridden with display: none |
6320 | | - // in a stylesheet to whatever the default browser style is |
6321 | | - // for such an element |
6322 | | - if ( display === "" && jQuery.css( elem, "display" ) === "none" ) { |
6323 | | - jQuery.data(elem, "olddisplay", defaultDisplay(elem.nodeName)); |
| 8018 | + // Reset the inline display of this element to learn if it is |
| 8019 | + // being hidden by cascaded rules or not |
| 8020 | + if ( !jQuery._data(elem, "olddisplay") && display === "none" ) { |
| 8021 | + display = elem.style.display = ""; |
| 8022 | + } |
| 8023 | + |
| 8024 | + // Set elements which have been overridden with display: none |
| 8025 | + // in a stylesheet to whatever the default browser style is |
| 8026 | + // for such an element |
| 8027 | + if ( display === "" && jQuery.css( elem, "display" ) === "none" ) { |
| 8028 | + jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName)); |
| 8029 | + } |
6324 | 8030 | } |
6325 | 8031 | } |
6326 | 8032 | |
— | — | @@ -6327,10 +8033,13 @@ |
6328 | 8034 | // to avoid the constant reflow |
6329 | 8035 | for ( i = 0; i < j; i++ ) { |
6330 | 8036 | elem = this[i]; |
6331 | | - display = elem.style.display; |
6332 | 8037 | |
6333 | | - if ( display === "" || display === "none" ) { |
6334 | | - elem.style.display = jQuery.data(elem, "olddisplay") || ""; |
| 8038 | + if ( elem.style ) { |
| 8039 | + display = elem.style.display; |
| 8040 | + |
| 8041 | + if ( display === "" || display === "none" ) { |
| 8042 | + elem.style.display = jQuery._data(elem, "olddisplay") || ""; |
| 8043 | + } |
6335 | 8044 | } |
6336 | 8045 | } |
6337 | 8046 | |
— | — | @@ -6344,17 +8053,21 @@ |
6345 | 8054 | |
6346 | 8055 | } else { |
6347 | 8056 | for ( var i = 0, j = this.length; i < j; i++ ) { |
6348 | | - var display = jQuery.css( this[i], "display" ); |
| 8057 | + if ( this[i].style ) { |
| 8058 | + var display = jQuery.css( this[i], "display" ); |
6349 | 8059 | |
6350 | | - if ( display !== "none" ) { |
6351 | | - jQuery.data( this[i], "olddisplay", display ); |
| 8060 | + if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) { |
| 8061 | + jQuery._data( this[i], "olddisplay", display ); |
| 8062 | + } |
6352 | 8063 | } |
6353 | 8064 | } |
6354 | 8065 | |
6355 | 8066 | // Set the display of the elements in a second loop |
6356 | 8067 | // to avoid the constant reflow |
6357 | 8068 | for ( i = 0; i < j; i++ ) { |
6358 | | - this[i].style.display = "none"; |
| 8069 | + if ( this[i].style ) { |
| 8070 | + this[i].style.display = "none"; |
| 8071 | + } |
6359 | 8072 | } |
6360 | 8073 | |
6361 | 8074 | return this; |
— | — | @@ -6392,32 +8105,54 @@ |
6393 | 8106 | var optall = jQuery.speed(speed, easing, callback); |
6394 | 8107 | |
6395 | 8108 | if ( jQuery.isEmptyObject( prop ) ) { |
6396 | | - return this.each( optall.complete ); |
| 8109 | + return this.each( optall.complete, [ false ] ); |
6397 | 8110 | } |
6398 | 8111 | |
| 8112 | + // Do not change referenced properties as per-property easing will be lost |
| 8113 | + prop = jQuery.extend( {}, prop ); |
| 8114 | + |
6399 | 8115 | return this[ optall.queue === false ? "each" : "queue" ](function() { |
6400 | 8116 | // XXX 'this' does not always have a nodeName when running the |
6401 | 8117 | // test suite |
6402 | 8118 | |
6403 | | - var opt = jQuery.extend({}, optall), p, |
| 8119 | + if ( optall.queue === false ) { |
| 8120 | + jQuery._mark( this ); |
| 8121 | + } |
| 8122 | + |
| 8123 | + var opt = jQuery.extend( {}, optall ), |
6404 | 8124 | isElement = this.nodeType === 1, |
6405 | 8125 | hidden = isElement && jQuery(this).is(":hidden"), |
6406 | | - self = this; |
| 8126 | + name, val, p, |
| 8127 | + display, e, |
| 8128 | + parts, start, end, unit; |
6407 | 8129 | |
| 8130 | + // will store per property easing and be used to determine when an animation is complete |
| 8131 | + opt.animatedProperties = {}; |
| 8132 | + |
6408 | 8133 | for ( p in prop ) { |
6409 | | - var name = jQuery.camelCase( p ); |
6410 | 8134 | |
| 8135 | + // property name normalization |
| 8136 | + name = jQuery.camelCase( p ); |
6411 | 8137 | if ( p !== name ) { |
6412 | 8138 | prop[ name ] = prop[ p ]; |
6413 | 8139 | delete prop[ p ]; |
6414 | | - p = name; |
6415 | 8140 | } |
6416 | 8141 | |
6417 | | - if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) { |
6418 | | - return opt.complete.call(this); |
| 8142 | + val = prop[ name ]; |
| 8143 | + |
| 8144 | + // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default) |
| 8145 | + if ( jQuery.isArray( val ) ) { |
| 8146 | + opt.animatedProperties[ name ] = val[ 1 ]; |
| 8147 | + val = prop[ name ] = val[ 0 ]; |
| 8148 | + } else { |
| 8149 | + opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing'; |
6419 | 8150 | } |
6420 | 8151 | |
6421 | | - if ( isElement && ( p === "height" || p === "width" ) ) { |
| 8152 | + if ( val === "hide" && hidden || val === "show" && !hidden ) { |
| 8153 | + return opt.complete.call( this ); |
| 8154 | + } |
| 8155 | + |
| 8156 | + if ( isElement && ( name === "height" || name === "width" ) ) { |
6422 | 8157 | // Make sure that nothing sneaks out |
6423 | 8158 | // Record all 3 overflow attributes because IE does not |
6424 | 8159 | // change the overflow attribute when overflowX and |
— | — | @@ -6433,7 +8168,7 @@ |
6434 | 8169 | this.style.display = "inline-block"; |
6435 | 8170 | |
6436 | 8171 | } else { |
6437 | | - var display = defaultDisplay(this.nodeName); |
| 8172 | + display = defaultDisplay( this.nodeName ); |
6438 | 8173 | |
6439 | 8174 | // inline-level elements accept inline-block; |
6440 | 8175 | // block-level elements need to be inline with layout |
— | — | @@ -6447,44 +8182,37 @@ |
6448 | 8183 | } |
6449 | 8184 | } |
6450 | 8185 | } |
6451 | | - |
6452 | | - if ( jQuery.isArray( prop[p] ) ) { |
6453 | | - // Create (if needed) and add to specialEasing |
6454 | | - (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1]; |
6455 | | - prop[p] = prop[p][0]; |
6456 | | - } |
6457 | 8186 | } |
6458 | 8187 | |
6459 | 8188 | if ( opt.overflow != null ) { |
6460 | 8189 | this.style.overflow = "hidden"; |
6461 | 8190 | } |
6462 | 8191 | |
6463 | | - opt.curAnim = jQuery.extend({}, prop); |
| 8192 | + for ( p in prop ) { |
| 8193 | + e = new jQuery.fx( this, opt, p ); |
| 8194 | + val = prop[ p ]; |
6464 | 8195 | |
6465 | | - jQuery.each( prop, function( name, val ) { |
6466 | | - var e = new jQuery.fx( self, opt, name ); |
6467 | | - |
6468 | 8196 | if ( rfxtypes.test(val) ) { |
6469 | | - e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop ); |
| 8197 | + e[ val === "toggle" ? hidden ? "show" : "hide" : val ](); |
6470 | 8198 | |
6471 | 8199 | } else { |
6472 | | - var parts = rfxnum.exec(val), |
6473 | | - start = e.cur() || 0; |
| 8200 | + parts = rfxnum.exec( val ); |
| 8201 | + start = e.cur(); |
6474 | 8202 | |
6475 | 8203 | if ( parts ) { |
6476 | | - var end = parseFloat( parts[2] ), |
6477 | | - unit = parts[3] || "px"; |
| 8204 | + end = parseFloat( parts[2] ); |
| 8205 | + unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" ); |
6478 | 8206 | |
6479 | 8207 | // We need to compute starting value |
6480 | 8208 | if ( unit !== "px" ) { |
6481 | | - jQuery.style( self, name, (end || 1) + unit); |
| 8209 | + jQuery.style( this, p, (end || 1) + unit); |
6482 | 8210 | start = ((end || 1) / e.cur()) * start; |
6483 | | - jQuery.style( self, name, start + unit); |
| 8211 | + jQuery.style( this, p, start + unit); |
6484 | 8212 | } |
6485 | 8213 | |
6486 | 8214 | // If a +=/-= token was provided, we're doing a relative animation |
6487 | 8215 | if ( parts[1] ) { |
6488 | | - end = ((parts[1] === "-=" ? -1 : 1) * end) + start; |
| 8216 | + end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start; |
6489 | 8217 | } |
6490 | 8218 | |
6491 | 8219 | e.custom( start, end, unit ); |
— | — | @@ -6493,7 +8221,7 @@ |
6494 | 8222 | e.custom( start, val, "" ); |
6495 | 8223 | } |
6496 | 8224 | } |
6497 | | - }); |
| 8225 | + } |
6498 | 8226 | |
6499 | 8227 | // For JS strict compliance |
6500 | 8228 | return true; |
— | — | @@ -6501,15 +8229,18 @@ |
6502 | 8230 | }, |
6503 | 8231 | |
6504 | 8232 | stop: function( clearQueue, gotoEnd ) { |
6505 | | - var timers = jQuery.timers; |
6506 | | - |
6507 | 8233 | if ( clearQueue ) { |
6508 | 8234 | this.queue([]); |
6509 | 8235 | } |
6510 | 8236 | |
6511 | 8237 | this.each(function() { |
6512 | | - // go in reverse order so anything added to the queue during the loop is ignored |
6513 | | - for ( var i = timers.length - 1; i >= 0; i-- ) { |
| 8238 | + var timers = jQuery.timers, |
| 8239 | + i = timers.length; |
| 8240 | + // clear marker counters if we know they won't be |
| 8241 | + if ( !gotoEnd ) { |
| 8242 | + jQuery._unmark( true, this ); |
| 8243 | + } |
| 8244 | + while ( i-- ) { |
6514 | 8245 | if ( timers[i].elem === this ) { |
6515 | 8246 | if (gotoEnd) { |
6516 | 8247 | // force the next step to be the last |
— | — | @@ -6531,6 +8262,17 @@ |
6532 | 8263 | |
6533 | 8264 | }); |
6534 | 8265 | |
| 8266 | +// Animations created synchronously will run synchronously |
| 8267 | +function createFxNow() { |
| 8268 | + setTimeout( clearFxNow, 0 ); |
| 8269 | + return ( fxNow = jQuery.now() ); |
| 8270 | +} |
| 8271 | + |
| 8272 | +function clearFxNow() { |
| 8273 | + fxNow = undefined; |
| 8274 | +} |
| 8275 | + |
| 8276 | +// Generate parameters to create a standard animation |
6535 | 8277 | function genFx( type, num ) { |
6536 | 8278 | var obj = {}; |
6537 | 8279 | |
— | — | @@ -6569,13 +8311,16 @@ |
6570 | 8312 | |
6571 | 8313 | // Queueing |
6572 | 8314 | opt.old = opt.complete; |
6573 | | - opt.complete = function() { |
6574 | | - if ( opt.queue !== false ) { |
6575 | | - jQuery(this).dequeue(); |
6576 | | - } |
| 8315 | + opt.complete = function( noUnmark ) { |
6577 | 8316 | if ( jQuery.isFunction( opt.old ) ) { |
6578 | 8317 | opt.old.call( this ); |
6579 | 8318 | } |
| 8319 | + |
| 8320 | + if ( opt.queue !== false ) { |
| 8321 | + jQuery.dequeue( this ); |
| 8322 | + } else if ( noUnmark !== false ) { |
| 8323 | + jQuery._unmark( this ); |
| 8324 | + } |
6580 | 8325 | }; |
6581 | 8326 | |
6582 | 8327 | return opt; |
— | — | @@ -6597,9 +8342,7 @@ |
6598 | 8343 | this.elem = elem; |
6599 | 8344 | this.prop = prop; |
6600 | 8345 | |
6601 | | - if ( !options.orig ) { |
6602 | | - options.orig = {}; |
6603 | | - } |
| 8346 | + options.orig = options.orig || {}; |
6604 | 8347 | } |
6605 | 8348 | |
6606 | 8349 | }); |
— | — | @@ -6620,19 +8363,24 @@ |
6621 | 8364 | return this.elem[ this.prop ]; |
6622 | 8365 | } |
6623 | 8366 | |
6624 | | - var r = parseFloat( jQuery.css( this.elem, this.prop ) ); |
6625 | | - return r && r > -10000 ? r : 0; |
| 8367 | + var parsed, |
| 8368 | + r = jQuery.css( this.elem, this.prop ); |
| 8369 | + // Empty strings, null, undefined and "auto" are converted to 0, |
| 8370 | + // complex values such as "rotate(1rad)" are returned as is, |
| 8371 | + // simple values such as "10px" are parsed to Float. |
| 8372 | + return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed; |
6626 | 8373 | }, |
6627 | 8374 | |
6628 | 8375 | // Start an animation from one number to another |
6629 | 8376 | custom: function( from, to, unit ) { |
6630 | 8377 | var self = this, |
6631 | | - fx = jQuery.fx; |
| 8378 | + fx = jQuery.fx, |
| 8379 | + raf; |
6632 | 8380 | |
6633 | | - this.startTime = jQuery.now(); |
| 8381 | + this.startTime = fxNow || createFxNow(); |
6634 | 8382 | this.start = from; |
6635 | 8383 | this.end = to; |
6636 | | - this.unit = unit || this.unit || "px"; |
| 8384 | + this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" ); |
6637 | 8385 | this.now = this.start; |
6638 | 8386 | this.pos = this.state = 0; |
6639 | 8387 | |
— | — | @@ -6643,7 +8391,20 @@ |
6644 | 8392 | t.elem = this.elem; |
6645 | 8393 | |
6646 | 8394 | if ( t() && jQuery.timers.push(t) && !timerId ) { |
6647 | | - timerId = setInterval(fx.tick, fx.interval); |
| 8395 | + // Use requestAnimationFrame instead of setInterval if available |
| 8396 | + if ( requestAnimationFrame ) { |
| 8397 | + timerId = true; |
| 8398 | + raf = function() { |
| 8399 | + // When timerId gets set to null at any point, this stops |
| 8400 | + if ( timerId ) { |
| 8401 | + requestAnimationFrame( raf ); |
| 8402 | + fx.tick(); |
| 8403 | + } |
| 8404 | + }; |
| 8405 | + requestAnimationFrame( raf ); |
| 8406 | + } else { |
| 8407 | + timerId = setInterval( fx.tick, fx.interval ); |
| 8408 | + } |
6648 | 8409 | } |
6649 | 8410 | }, |
6650 | 8411 | |
— | — | @@ -6674,60 +8435,64 @@ |
6675 | 8436 | |
6676 | 8437 | // Each step of an animation |
6677 | 8438 | step: function( gotoEnd ) { |
6678 | | - var t = jQuery.now(), done = true; |
| 8439 | + var t = fxNow || createFxNow(), |
| 8440 | + done = true, |
| 8441 | + elem = this.elem, |
| 8442 | + options = this.options, |
| 8443 | + i, n; |
6679 | 8444 | |
6680 | | - if ( gotoEnd || t >= this.options.duration + this.startTime ) { |
| 8445 | + if ( gotoEnd || t >= options.duration + this.startTime ) { |
6681 | 8446 | this.now = this.end; |
6682 | 8447 | this.pos = this.state = 1; |
6683 | 8448 | this.update(); |
6684 | 8449 | |
6685 | | - this.options.curAnim[ this.prop ] = true; |
| 8450 | + options.animatedProperties[ this.prop ] = true; |
6686 | 8451 | |
6687 | | - for ( var i in this.options.curAnim ) { |
6688 | | - if ( this.options.curAnim[i] !== true ) { |
| 8452 | + for ( i in options.animatedProperties ) { |
| 8453 | + if ( options.animatedProperties[i] !== true ) { |
6689 | 8454 | done = false; |
6690 | 8455 | } |
6691 | 8456 | } |
6692 | 8457 | |
6693 | 8458 | if ( done ) { |
6694 | 8459 | // Reset the overflow |
6695 | | - if ( this.options.overflow != null && !jQuery.support.shrinkWrapBlocks ) { |
6696 | | - var elem = this.elem, |
6697 | | - options = this.options; |
| 8460 | + if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) { |
6698 | 8461 | |
6699 | 8462 | jQuery.each( [ "", "X", "Y" ], function (index, value) { |
6700 | 8463 | elem.style[ "overflow" + value ] = options.overflow[index]; |
6701 | | - } ); |
| 8464 | + }); |
6702 | 8465 | } |
6703 | 8466 | |
6704 | 8467 | // Hide the element if the "hide" operation was done |
6705 | | - if ( this.options.hide ) { |
6706 | | - jQuery(this.elem).hide(); |
| 8468 | + if ( options.hide ) { |
| 8469 | + jQuery(elem).hide(); |
6707 | 8470 | } |
6708 | 8471 | |
6709 | 8472 | // Reset the properties, if the item has been hidden or shown |
6710 | | - if ( this.options.hide || this.options.show ) { |
6711 | | - for ( var p in this.options.curAnim ) { |
6712 | | - jQuery.style( this.elem, p, this.options.orig[p] ); |
| 8473 | + if ( options.hide || options.show ) { |
| 8474 | + for ( var p in options.animatedProperties ) { |
| 8475 | + jQuery.style( elem, p, options.orig[p] ); |
6713 | 8476 | } |
6714 | 8477 | } |
6715 | 8478 | |
6716 | 8479 | // Execute the complete function |
6717 | | - this.options.complete.call( this.elem ); |
| 8480 | + options.complete.call( elem ); |
6718 | 8481 | } |
6719 | 8482 | |
6720 | 8483 | return false; |
6721 | 8484 | |
6722 | 8485 | } else { |
6723 | | - var n = t - this.startTime; |
6724 | | - this.state = n / this.options.duration; |
| 8486 | + // classical easing cannot be used with an Infinity duration |
| 8487 | + if ( options.duration == Infinity ) { |
| 8488 | + this.now = t; |
| 8489 | + } else { |
| 8490 | + n = t - this.startTime; |
| 8491 | + this.state = n / options.duration; |
6725 | 8492 | |
6726 | | - // Perform the easing function, defaults to swing |
6727 | | - var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop]; |
6728 | | - var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear"); |
6729 | | - this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration); |
6730 | | - this.now = this.start + ((this.end - this.start) * this.pos); |
6731 | | - |
| 8493 | + // Perform the easing function, defaults to swing |
| 8494 | + this.pos = jQuery.easing[ options.animatedProperties[ this.prop ] ]( this.state, n, 0, 1, options.duration ); |
| 8495 | + this.now = this.start + ((this.end - this.start) * this.pos); |
| 8496 | + } |
6732 | 8497 | // Perform the next step of the animation |
6733 | 8498 | this.update(); |
6734 | 8499 | } |
— | — | @@ -6738,9 +8503,7 @@ |
6739 | 8504 | |
6740 | 8505 | jQuery.extend( jQuery.fx, { |
6741 | 8506 | tick: function() { |
6742 | | - var timers = jQuery.timers; |
6743 | | - |
6744 | | - for ( var i = 0; i < timers.length; i++ ) { |
| 8507 | + for ( var timers = jQuery.timers, i = 0 ; i < timers.length ; ++i ) { |
6745 | 8508 | if ( !timers[i]() ) { |
6746 | 8509 | timers.splice(i--, 1); |
6747 | 8510 | } |
— | — | @@ -6788,17 +8551,47 @@ |
6789 | 8552 | }; |
6790 | 8553 | } |
6791 | 8554 | |
| 8555 | +// Try to restore the default display value of an element |
6792 | 8556 | function defaultDisplay( nodeName ) { |
| 8557 | + |
6793 | 8558 | if ( !elemdisplay[ nodeName ] ) { |
6794 | | - var elem = jQuery("<" + nodeName + ">").appendTo("body"), |
6795 | | - display = elem.css("display"); |
6796 | 8559 | |
| 8560 | + var body = document.body, |
| 8561 | + elem = jQuery( "<" + nodeName + ">" ).appendTo( body ), |
| 8562 | + display = elem.css( "display" ); |
| 8563 | + |
6797 | 8564 | elem.remove(); |
6798 | 8565 | |
| 8566 | + // If the simple way fails, |
| 8567 | + // get element's real default display by attaching it to a temp iframe |
6799 | 8568 | if ( display === "none" || display === "" ) { |
6800 | | - display = "block"; |
| 8569 | + // No iframe to use yet, so create it |
| 8570 | + if ( !iframe ) { |
| 8571 | + iframe = document.createElement( "iframe" ); |
| 8572 | + iframe.frameBorder = iframe.width = iframe.height = 0; |
| 8573 | + } |
| 8574 | + |
| 8575 | + body.appendChild( iframe ); |
| 8576 | + |
| 8577 | + // Create a cacheable copy of the iframe document on first call. |
| 8578 | + // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML |
| 8579 | + // document to it; WebKit & Firefox won't allow reusing the iframe document. |
| 8580 | + if ( !iframeDoc || !iframe.createElement ) { |
| 8581 | + iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document; |
| 8582 | + iframeDoc.write( ( document.compatMode === "CSS1Compat" ? "<!doctype html>" : "" ) + "<html><body>" ); |
| 8583 | + iframeDoc.close(); |
| 8584 | + } |
| 8585 | + |
| 8586 | + elem = iframeDoc.createElement( nodeName ); |
| 8587 | + |
| 8588 | + iframeDoc.body.appendChild( elem ); |
| 8589 | + |
| 8590 | + display = jQuery.css( elem, "display" ); |
| 8591 | + |
| 8592 | + body.removeChild( iframe ); |
6801 | 8593 | } |
6802 | 8594 | |
| 8595 | + // Store the correct default display |
6803 | 8596 | elemdisplay[ nodeName ] = display; |
6804 | 8597 | } |
6805 | 8598 | |
— | — | @@ -6815,7 +8608,7 @@ |
6816 | 8609 | jQuery.fn.offset = function( options ) { |
6817 | 8610 | var elem = this[0], box; |
6818 | 8611 | |
6819 | | - if ( options ) { |
| 8612 | + if ( options ) { |
6820 | 8613 | return this.each(function( i ) { |
6821 | 8614 | jQuery.offset.setOffset( this, options, i ); |
6822 | 8615 | }); |
— | — | @@ -6838,15 +8631,15 @@ |
6839 | 8632 | |
6840 | 8633 | // Make sure we're not dealing with a disconnected DOM node |
6841 | 8634 | if ( !box || !jQuery.contains( docElem, elem ) ) { |
6842 | | - return box || { top: 0, left: 0 }; |
| 8635 | + return box ? { top: box.top, left: box.left } : { top: 0, left: 0 }; |
6843 | 8636 | } |
6844 | 8637 | |
6845 | 8638 | var body = doc.body, |
6846 | 8639 | win = getWindow(doc), |
6847 | 8640 | clientTop = docElem.clientTop || body.clientTop || 0, |
6848 | 8641 | clientLeft = docElem.clientLeft || body.clientLeft || 0, |
6849 | | - scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ), |
6850 | | - scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft), |
| 8642 | + scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop, |
| 8643 | + scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft, |
6851 | 8644 | top = box.top + scrollTop - clientTop, |
6852 | 8645 | left = box.left + scrollLeft - clientLeft; |
6853 | 8646 | |
— | — | @@ -6857,7 +8650,7 @@ |
6858 | 8651 | jQuery.fn.offset = function( options ) { |
6859 | 8652 | var elem = this[0]; |
6860 | 8653 | |
6861 | | - if ( options ) { |
| 8654 | + if ( options ) { |
6862 | 8655 | return this.each(function( i ) { |
6863 | 8656 | jQuery.offset.setOffset( this, options, i ); |
6864 | 8657 | }); |
— | — | @@ -6959,7 +8752,6 @@ |
6960 | 8753 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
6961 | 8754 | |
6962 | 8755 | body.removeChild( container ); |
6963 | | - body = container = innerDiv = checkDiv = table = td = null; |
6964 | 8756 | jQuery.offset.initialize = jQuery.noop; |
6965 | 8757 | }, |
6966 | 8758 | |
— | — | @@ -6976,7 +8768,7 @@ |
6977 | 8769 | |
6978 | 8770 | return { top: top, left: left }; |
6979 | 8771 | }, |
6980 | | - |
| 8772 | + |
6981 | 8773 | setOffset: function( elem, options, i ) { |
6982 | 8774 | var position = jQuery.css( elem, "position" ); |
6983 | 8775 | |
— | — | @@ -6989,17 +8781,19 @@ |
6990 | 8782 | curOffset = curElem.offset(), |
6991 | 8783 | curCSSTop = jQuery.css( elem, "top" ), |
6992 | 8784 | curCSSLeft = jQuery.css( elem, "left" ), |
6993 | | - calculatePosition = (position === "absolute" && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1), |
| 8785 | + calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1, |
6994 | 8786 | props = {}, curPosition = {}, curTop, curLeft; |
6995 | 8787 | |
6996 | | - // need to be able to calculate position if either top or left is auto and position is absolute |
| 8788 | + // need to be able to calculate position if either top or left is auto and position is either absolute or fixed |
6997 | 8789 | if ( calculatePosition ) { |
6998 | 8790 | curPosition = curElem.position(); |
| 8791 | + curTop = curPosition.top; |
| 8792 | + curLeft = curPosition.left; |
| 8793 | + } else { |
| 8794 | + curTop = parseFloat( curCSSTop ) || 0; |
| 8795 | + curLeft = parseFloat( curCSSLeft ) || 0; |
6999 | 8796 | } |
7000 | 8797 | |
7001 | | - curTop = calculatePosition ? curPosition.top : parseInt( curCSSTop, 10 ) || 0; |
7002 | | - curLeft = calculatePosition ? curPosition.left : parseInt( curCSSLeft, 10 ) || 0; |
7003 | | - |
7004 | 8798 | if ( jQuery.isFunction( options ) ) { |
7005 | 8799 | options = options.call( elem, i, curOffset ); |
7006 | 8800 | } |
— | — | @@ -7010,7 +8804,7 @@ |
7011 | 8805 | if (options.left != null) { |
7012 | 8806 | props.left = (options.left - curOffset.left) + curLeft; |
7013 | 8807 | } |
7014 | | - |
| 8808 | + |
7015 | 8809 | if ( "using" in options ) { |
7016 | 8810 | options.using.call( elem, props ); |
7017 | 8811 | } else { |
— | — | @@ -7068,29 +8862,16 @@ |
7069 | 8863 | jQuery.each( ["Left", "Top"], function( i, name ) { |
7070 | 8864 | var method = "scroll" + name; |
7071 | 8865 | |
7072 | | - jQuery.fn[ method ] = function(val) { |
7073 | | - var elem = this[0], win; |
7074 | | - |
7075 | | - if ( !elem ) { |
7076 | | - return null; |
7077 | | - } |
| 8866 | + jQuery.fn[ method ] = function( val ) { |
| 8867 | + var elem, win; |
7078 | 8868 | |
7079 | | - if ( val !== undefined ) { |
7080 | | - // Set the scroll offset |
7081 | | - return this.each(function() { |
7082 | | - win = getWindow( this ); |
| 8869 | + if ( val === undefined ) { |
| 8870 | + elem = this[ 0 ]; |
7083 | 8871 | |
7084 | | - if ( win ) { |
7085 | | - win.scrollTo( |
7086 | | - !i ? val : jQuery(win).scrollLeft(), |
7087 | | - i ? val : jQuery(win).scrollTop() |
7088 | | - ); |
| 8872 | + if ( !elem ) { |
| 8873 | + return null; |
| 8874 | + } |
7089 | 8875 | |
7090 | | - } else { |
7091 | | - this[ method ] = val; |
7092 | | - } |
7093 | | - }); |
7094 | | - } else { |
7095 | 8876 | win = getWindow( elem ); |
7096 | 8877 | |
7097 | 8878 | // Return the scroll offset |
— | — | @@ -7099,6 +8880,21 @@ |
7100 | 8881 | win.document.body[ method ] : |
7101 | 8882 | elem[ method ]; |
7102 | 8883 | } |
| 8884 | + |
| 8885 | + // Set the scroll offset |
| 8886 | + return this.each(function() { |
| 8887 | + win = getWindow( this ); |
| 8888 | + |
| 8889 | + if ( win ) { |
| 8890 | + win.scrollTo( |
| 8891 | + !i ? val : jQuery( win ).scrollLeft(), |
| 8892 | + i ? val : jQuery( win ).scrollTop() |
| 8893 | + ); |
| 8894 | + |
| 8895 | + } else { |
| 8896 | + this[ method ] = val; |
| 8897 | + } |
| 8898 | + }); |
7103 | 8899 | }; |
7104 | 8900 | }); |
7105 | 8901 | |
— | — | @@ -7113,22 +8909,24 @@ |
7114 | 8910 | |
7115 | 8911 | |
7116 | 8912 | |
7117 | | -// Create innerHeight, innerWidth, outerHeight and outerWidth methods |
| 8913 | +// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods |
7118 | 8914 | jQuery.each([ "Height", "Width" ], function( i, name ) { |
7119 | 8915 | |
7120 | 8916 | var type = name.toLowerCase(); |
7121 | 8917 | |
7122 | 8918 | // innerHeight and innerWidth |
7123 | | - jQuery.fn["inner" + name] = function() { |
7124 | | - return this[0] ? |
7125 | | - parseFloat( jQuery.css( this[0], type, "padding" ) ) : |
| 8919 | + jQuery.fn[ "inner" + name ] = function() { |
| 8920 | + var elem = this[0]; |
| 8921 | + return elem && elem.style ? |
| 8922 | + parseFloat( jQuery.css( elem, type, "padding" ) ) : |
7126 | 8923 | null; |
7127 | 8924 | }; |
7128 | 8925 | |
7129 | 8926 | // outerHeight and outerWidth |
7130 | | - jQuery.fn["outer" + name] = function( margin ) { |
7131 | | - return this[0] ? |
7132 | | - parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) : |
| 8927 | + jQuery.fn[ "outer" + name ] = function( margin ) { |
| 8928 | + var elem = this[0]; |
| 8929 | + return elem && elem.style ? |
| 8930 | + parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) : |
7133 | 8931 | null; |
7134 | 8932 | }; |
7135 | 8933 | |
— | — | @@ -7138,7 +8936,7 @@ |
7139 | 8937 | if ( !elem ) { |
7140 | 8938 | return size == null ? null : this; |
7141 | 8939 | } |
7142 | | - |
| 8940 | + |
7143 | 8941 | if ( jQuery.isFunction( size ) ) { |
7144 | 8942 | return this.each(function( i ) { |
7145 | 8943 | var self = jQuery( this ); |
— | — | @@ -7148,8 +8946,10 @@ |
7149 | 8947 | |
7150 | 8948 | if ( jQuery.isWindow( elem ) ) { |
7151 | 8949 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode |
7152 | | - return elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || |
7153 | | - elem.document.body[ "client" + name ]; |
| 8950 | + // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat |
| 8951 | + var docElemProp = elem.document.documentElement[ "client" + name ]; |
| 8952 | + return elem.document.compatMode === "CSS1Compat" && docElemProp || |
| 8953 | + elem.document.body[ "client" + name ] || docElemProp; |
7154 | 8954 | |
7155 | 8955 | // Get document width or height |
7156 | 8956 | } else if ( elem.nodeType === 9 ) { |
— | — | @@ -7176,4 +8976,6 @@ |
7177 | 8977 | }); |
7178 | 8978 | |
7179 | 8979 | |
| 8980 | +// Expose jQuery to the global object |
| 8981 | +window.jQuery = window.$ = jQuery; |
7180 | 8982 | })(window); |
Property changes on: branches/REL1_18/phase3/resources/jquery/jquery.js |
___________________________________________________________________ |
Added: svn:mergeinfo |
7181 | 8983 | Merged /branches/REL1_15/phase3/resources/jquery/jquery.js:r51646 |
7182 | 8984 | Merged /branches/REL1_17/phase3/resources/jquery/jquery.js:r81445,81448 |
7183 | 8985 | Merged /branches/sqlite/resources/jquery/jquery.js:r58211-58321 |
7184 | 8986 | Merged /trunk/phase3/resources/jquery/jquery.js:r87586,87627-87628,87630,87632,87636,87640,87644,87840,87998,88085,88118,88124,88134,88231-88232,88250,88492,88498,88513,88750,89099,89108,89853,90602,90612,90618,90626,90630-90631,90637,90655,90657,90666,90812,91845 |
7185 | 8987 | Merged /branches/new-installer/phase3/resources/jquery/jquery.js:r43664-66004 |