Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -37,6 +37,7 @@ |
38 | 38 | * (bug 29036) For cascade-protected pages, the mw-textarea-cprotected class is |
39 | 39 | added to the textarea on the edit form. |
40 | 40 | * mw.util.getScript has been implemented (like wfScript in GlobalFunctions.php) |
| 41 | +* (bug 28904) Update jQuery version from 1.4.4 to 1.5.2 (the latest update to 1.5) |
41 | 42 | |
42 | 43 | === Bug fixes in 1.19 === |
43 | 44 | * (bug 10154) Don't allow user to specify days beyond $wgRCMaxAge. |
Index: trunk/phase3/resources/jquery/jquery.js |
— | — | @@ -1,17 +1,17 @@ |
2 | 2 | /*! |
3 | | - * jQuery JavaScript Library v1.4.4 |
| 3 | + * jQuery JavaScript Library v1.5.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 Mar 31 15:28:23 2011 -0400 |
16 | 16 | */ |
17 | 17 | (function( window, undefined ) { |
18 | 18 | |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | // Define a local copy of jQuery |
24 | 24 | var jQuery = function( selector, context ) { |
25 | 25 | // The jQuery object is actually just the init constructor 'enhanced' |
26 | | - return new jQuery.fn.init( selector, context ); |
| 26 | + return new jQuery.fn.init( selector, context, rootjQuery ); |
27 | 27 | }, |
28 | 28 | |
29 | 29 | // Map over jQuery in case of overwrite |
— | — | @@ -38,20 +38,13 @@ |
39 | 39 | // (both of which we optimize for) |
40 | 40 | quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/, |
41 | 41 | |
42 | | - // Is it a simple selector |
43 | | - isSimple = /^.[^:#\[\.,]*$/, |
44 | | - |
45 | 42 | // Check if a string has a non-whitespace character in it |
46 | 43 | rnotwhite = /\S/, |
47 | | - rwhite = /\s/, |
48 | 44 | |
49 | 45 | // Used for trimming whitespace |
50 | 46 | trimLeft = /^\s+/, |
51 | 47 | trimRight = /\s+$/, |
52 | 48 | |
53 | | - // Check for non-word characters |
54 | | - rnonword = /\W/, |
55 | | - |
56 | 49 | // Check for digits |
57 | 50 | rdigit = /\d/, |
58 | 51 | |
— | — | @@ -75,13 +68,10 @@ |
76 | 69 | |
77 | 70 | // For matching the engine and version of the browser |
78 | 71 | 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 | 72 | |
| 73 | + // The deferred used on DOM ready |
| 74 | + readyList, |
| 75 | + |
86 | 76 | // The ready event handler |
87 | 77 | DOMContentLoaded, |
88 | 78 | |
— | — | @@ -92,12 +82,13 @@ |
93 | 83 | slice = Array.prototype.slice, |
94 | 84 | trim = String.prototype.trim, |
95 | 85 | indexOf = Array.prototype.indexOf, |
96 | | - |
| 86 | + |
97 | 87 | // [[Class]] -> type pairs |
98 | 88 | class2type = {}; |
99 | 89 | |
100 | 90 | jQuery.fn = jQuery.prototype = { |
101 | | - init: function( selector, context ) { |
| 91 | + constructor: jQuery, |
| 92 | + init: function( selector, context, rootjQuery ) { |
102 | 93 | var match, elem, ret, doc; |
103 | 94 | |
104 | 95 | // Handle $(""), $(null), or $(undefined) |
— | — | @@ -111,7 +102,7 @@ |
112 | 103 | this.length = 1; |
113 | 104 | return this; |
114 | 105 | } |
115 | | - |
| 106 | + |
116 | 107 | // The body element only exists once, optimize finding it |
117 | 108 | if ( selector === "body" && !context && document.body ) { |
118 | 109 | this.context = document; |
— | — | @@ -131,6 +122,7 @@ |
132 | 123 | |
133 | 124 | // HANDLE: $(html) -> $(array) |
134 | 125 | if ( match[1] ) { |
| 126 | + context = context instanceof jQuery ? context[0] : context; |
135 | 127 | doc = (context ? context.ownerDocument || context : document); |
136 | 128 | |
137 | 129 | // If a single string is passed in and it's a single tag |
— | — | @@ -148,11 +140,11 @@ |
149 | 141 | |
150 | 142 | } else { |
151 | 143 | ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); |
152 | | - selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; |
| 144 | + selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes; |
153 | 145 | } |
154 | | - |
| 146 | + |
155 | 147 | return jQuery.merge( this, selector ); |
156 | | - |
| 148 | + |
157 | 149 | // HANDLE: $("#id") |
158 | 150 | } else { |
159 | 151 | elem = document.getElementById( match[2] ); |
— | — | @@ -176,13 +168,6 @@ |
177 | 169 | return this; |
178 | 170 | } |
179 | 171 | |
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 | 172 | // HANDLE: $(expr, $(...)) |
188 | 173 | } else if ( !context || context.jquery ) { |
189 | 174 | return (context || rootjQuery).find( selector ); |
— | — | @@ -190,7 +175,7 @@ |
191 | 176 | // HANDLE: $(expr, context) |
192 | 177 | // (which is just equivalent to: $(context).find(expr) |
193 | 178 | } else { |
194 | | - return jQuery( context ).find( selector ); |
| 179 | + return this.constructor( context ).find( selector ); |
195 | 180 | } |
196 | 181 | |
197 | 182 | // HANDLE: $(function) |
— | — | @@ -211,7 +196,7 @@ |
212 | 197 | selector: "", |
213 | 198 | |
214 | 199 | // The current version of jQuery being used |
215 | | - jquery: "1.4.4", |
| 200 | + jquery: "1.5.2", |
216 | 201 | |
217 | 202 | // The default length of a jQuery object is 0 |
218 | 203 | length: 0, |
— | — | @@ -234,18 +219,18 @@ |
235 | 220 | this.toArray() : |
236 | 221 | |
237 | 222 | // Return just the object |
238 | | - ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] ); |
| 223 | + ( num < 0 ? this[ this.length + num ] : this[ num ] ); |
239 | 224 | }, |
240 | 225 | |
241 | 226 | // Take an array of elements and push it onto the stack |
242 | 227 | // (returning the new matched element set) |
243 | 228 | pushStack: function( elems, name, selector ) { |
244 | 229 | // Build a new jQuery matched element set |
245 | | - var ret = jQuery(); |
| 230 | + var ret = this.constructor(); |
246 | 231 | |
247 | 232 | if ( jQuery.isArray( elems ) ) { |
248 | 233 | push.apply( ret, elems ); |
249 | | - |
| 234 | + |
250 | 235 | } else { |
251 | 236 | jQuery.merge( ret, elems ); |
252 | 237 | } |
— | — | @@ -271,25 +256,17 @@ |
272 | 257 | each: function( callback, args ) { |
273 | 258 | return jQuery.each( this, callback, args ); |
274 | 259 | }, |
275 | | - |
| 260 | + |
276 | 261 | ready: function( fn ) { |
277 | 262 | // Attach the listeners |
278 | 263 | jQuery.bindReady(); |
279 | 264 | |
280 | | - // If the DOM is already ready |
281 | | - if ( jQuery.isReady ) { |
282 | | - // Execute the function immediately |
283 | | - fn.call( document, jQuery ); |
| 265 | + // Add the callback |
| 266 | + readyList.done( fn ); |
284 | 267 | |
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 | 268 | return this; |
292 | 269 | }, |
293 | | - |
| 270 | + |
294 | 271 | eq: function( i ) { |
295 | 272 | return i === -1 ? |
296 | 273 | this.slice( i ) : |
— | — | @@ -314,9 +291,9 @@ |
315 | 292 | return callback.call( elem, i, elem ); |
316 | 293 | })); |
317 | 294 | }, |
318 | | - |
| 295 | + |
319 | 296 | end: function() { |
320 | | - return this.prevObject || jQuery(null); |
| 297 | + return this.prevObject || this.constructor(null); |
321 | 298 | }, |
322 | 299 | |
323 | 300 | // For internal use only. |
— | — | @@ -330,7 +307,7 @@ |
331 | 308 | jQuery.fn.init.prototype = jQuery.fn; |
332 | 309 | |
333 | 310 | jQuery.extend = jQuery.fn.extend = function() { |
334 | | - var options, name, src, copy, copyIsArray, clone, |
| 311 | + var options, name, src, copy, copyIsArray, clone, |
335 | 312 | target = arguments[0] || {}, |
336 | 313 | i = 1, |
337 | 314 | length = arguments.length, |
— | — | @@ -403,14 +380,14 @@ |
404 | 381 | |
405 | 382 | return jQuery; |
406 | 383 | }, |
407 | | - |
| 384 | + |
408 | 385 | // Is the DOM ready to be used? Set to true once it occurs. |
409 | 386 | isReady: false, |
410 | 387 | |
411 | 388 | // A counter to track how many items to wait for before |
412 | 389 | // the ready event fires. See #6781 |
413 | 390 | readyWait: 1, |
414 | | - |
| 391 | + |
415 | 392 | // Handle when the DOM is ready |
416 | 393 | ready: function( wait ) { |
417 | 394 | // A third-party is pushing the ready event forwards |
— | — | @@ -434,33 +411,21 @@ |
435 | 412 | } |
436 | 413 | |
437 | 414 | // If there are functions bound, to execute |
438 | | - if ( readyList ) { |
439 | | - // Execute all of them |
440 | | - var fn, |
441 | | - i = 0, |
442 | | - ready = readyList; |
| 415 | + readyList.resolveWith( document, [ jQuery ] ); |
443 | 416 | |
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 | | - } |
| 417 | + // Trigger any bound ready events |
| 418 | + if ( jQuery.fn.trigger ) { |
| 419 | + jQuery( document ).trigger( "ready" ).unbind( "ready" ); |
455 | 420 | } |
456 | 421 | } |
457 | 422 | }, |
458 | | - |
| 423 | + |
459 | 424 | bindReady: function() { |
460 | | - if ( readyBound ) { |
| 425 | + if ( readyList ) { |
461 | 426 | return; |
462 | 427 | } |
463 | 428 | |
464 | | - readyBound = true; |
| 429 | + readyList = jQuery._Deferred(); |
465 | 430 | |
466 | 431 | // Catch cases where $(document).ready() is called after the |
467 | 432 | // browser event has already occurred. |
— | — | @@ -473,7 +438,7 @@ |
474 | 439 | if ( document.addEventListener ) { |
475 | 440 | // Use the handy event callback |
476 | 441 | document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
477 | | - |
| 442 | + |
478 | 443 | // A fallback to window.onload, that will always work |
479 | 444 | window.addEventListener( "load", jQuery.ready, false ); |
480 | 445 | |
— | — | @@ -482,7 +447,7 @@ |
483 | 448 | // ensure firing before onload, |
484 | 449 | // maybe late but safe also for iframes |
485 | 450 | document.attachEvent("onreadystatechange", DOMContentLoaded); |
486 | | - |
| 451 | + |
487 | 452 | // A fallback to window.onload, that will always work |
488 | 453 | window.attachEvent( "onload", jQuery.ready ); |
489 | 454 | |
— | — | @@ -533,20 +498,20 @@ |
534 | 499 | if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { |
535 | 500 | return false; |
536 | 501 | } |
537 | | - |
| 502 | + |
538 | 503 | // Not own constructor property must be Object |
539 | 504 | if ( obj.constructor && |
540 | 505 | !hasOwn.call(obj, "constructor") && |
541 | 506 | !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { |
542 | 507 | return false; |
543 | 508 | } |
544 | | - |
| 509 | + |
545 | 510 | // Own properties are enumerated firstly, so to speed up, |
546 | 511 | // if last one is own, then all properties are own. |
547 | | - |
| 512 | + |
548 | 513 | var key; |
549 | 514 | for ( key in obj ) {} |
550 | | - |
| 515 | + |
551 | 516 | return key === undefined || hasOwn.call( obj, key ); |
552 | 517 | }, |
553 | 518 | |
— | — | @@ -556,11 +521,11 @@ |
557 | 522 | } |
558 | 523 | return true; |
559 | 524 | }, |
560 | | - |
| 525 | + |
561 | 526 | error: function( msg ) { |
562 | 527 | throw msg; |
563 | 528 | }, |
564 | | - |
| 529 | + |
565 | 530 | parseJSON: function( data ) { |
566 | 531 | if ( typeof data !== "string" || !data ) { |
567 | 532 | return null; |
— | — | @@ -568,7 +533,7 @@ |
569 | 534 | |
570 | 535 | // Make sure leading/trailing whitespace is removed (IE can't handle it) |
571 | 536 | data = jQuery.trim( data ); |
572 | | - |
| 537 | + |
573 | 538 | // Make sure the incoming data is actual JSON |
574 | 539 | // Logic borrowed from http://json.org/json2.js |
575 | 540 | if ( rvalidchars.test(data.replace(rvalidescape, "@") |
— | — | @@ -585,6 +550,28 @@ |
586 | 551 | } |
587 | 552 | }, |
588 | 553 | |
| 554 | + // Cross-browser xml parsing |
| 555 | + // (xml & tmp used internally) |
| 556 | + parseXML: function( data , xml , tmp ) { |
| 557 | + |
| 558 | + if ( window.DOMParser ) { // Standard |
| 559 | + tmp = new DOMParser(); |
| 560 | + xml = tmp.parseFromString( data , "text/xml" ); |
| 561 | + } else { // IE |
| 562 | + xml = new ActiveXObject( "Microsoft.XMLDOM" ); |
| 563 | + xml.async = "false"; |
| 564 | + xml.loadXML( data ); |
| 565 | + } |
| 566 | + |
| 567 | + tmp = xml.documentElement; |
| 568 | + |
| 569 | + if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) { |
| 570 | + jQuery.error( "Invalid XML: " + data ); |
| 571 | + } |
| 572 | + |
| 573 | + return xml; |
| 574 | + }, |
| 575 | + |
589 | 576 | noop: function() {}, |
590 | 577 | |
591 | 578 | // Evalulates a script in a global context |
— | — | @@ -592,12 +579,10 @@ |
593 | 580 | if ( data && rnotwhite.test(data) ) { |
594 | 581 | // Inspired by code by Andrea Giammarchi |
595 | 582 | // 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"); |
| 583 | + var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement, |
| 584 | + script = document.createElement( "script" ); |
598 | 585 | |
599 | | - script.type = "text/javascript"; |
600 | | - |
601 | | - if ( jQuery.support.scriptEval ) { |
| 586 | + if ( jQuery.support.scriptEval() ) { |
602 | 587 | script.appendChild( document.createTextNode( data ) ); |
603 | 588 | } else { |
604 | 589 | script.text = data; |
— | — | @@ -710,7 +695,7 @@ |
711 | 696 | for ( var l = second.length; j < l; j++ ) { |
712 | 697 | first[ i++ ] = second[ j ]; |
713 | 698 | } |
714 | | - |
| 699 | + |
715 | 700 | } else { |
716 | 701 | while ( second[j] !== undefined ) { |
717 | 702 | first[ i++ ] = second[ j++ ]; |
— | — | @@ -752,6 +737,7 @@ |
753 | 738 | } |
754 | 739 | } |
755 | 740 | |
| 741 | + // Flatten any nested arrays |
756 | 742 | return ret.concat.apply( [], ret ); |
757 | 743 | }, |
758 | 744 | |
— | — | @@ -790,7 +776,7 @@ |
791 | 777 | // The value/s can be optionally by executed if its a function |
792 | 778 | access: function( elems, key, value, exec, fn, pass ) { |
793 | 779 | var length = elems.length; |
794 | | - |
| 780 | + |
795 | 781 | // Setting many attributes |
796 | 782 | if ( typeof key === "object" ) { |
797 | 783 | for ( var k in key ) { |
— | — | @@ -798,19 +784,19 @@ |
799 | 785 | } |
800 | 786 | return elems; |
801 | 787 | } |
802 | | - |
| 788 | + |
803 | 789 | // Setting one attribute |
804 | 790 | if ( value !== undefined ) { |
805 | 791 | // Optionally, function values get executed if exec is true |
806 | 792 | exec = !pass && exec && jQuery.isFunction(value); |
807 | | - |
| 793 | + |
808 | 794 | for ( var i = 0; i < length; i++ ) { |
809 | 795 | fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); |
810 | 796 | } |
811 | | - |
| 797 | + |
812 | 798 | return elems; |
813 | 799 | } |
814 | | - |
| 800 | + |
815 | 801 | // Getting an attribute |
816 | 802 | return length ? fn( elems[0], key ) : undefined; |
817 | 803 | }, |
— | — | @@ -833,6 +819,27 @@ |
834 | 820 | return { browser: match[1] || "", version: match[2] || "0" }; |
835 | 821 | }, |
836 | 822 | |
| 823 | + sub: function() { |
| 824 | + function jQuerySubclass( selector, context ) { |
| 825 | + return new jQuerySubclass.fn.init( selector, context ); |
| 826 | + } |
| 827 | + jQuery.extend( true, jQuerySubclass, this ); |
| 828 | + jQuerySubclass.superclass = this; |
| 829 | + jQuerySubclass.fn = jQuerySubclass.prototype = this(); |
| 830 | + jQuerySubclass.fn.constructor = jQuerySubclass; |
| 831 | + jQuerySubclass.subclass = this.subclass; |
| 832 | + jQuerySubclass.fn.init = function init( selector, context ) { |
| 833 | + if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) { |
| 834 | + context = jQuerySubclass(context); |
| 835 | + } |
| 836 | + |
| 837 | + return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass ); |
| 838 | + }; |
| 839 | + jQuerySubclass.fn.init.prototype = jQuerySubclass.fn; |
| 840 | + var rootjQuerySubclass = jQuerySubclass(document); |
| 841 | + return jQuerySubclass; |
| 842 | + }, |
| 843 | + |
837 | 844 | browser: {} |
838 | 845 | }); |
839 | 846 | |
— | — | @@ -858,9 +865,8 @@ |
859 | 866 | }; |
860 | 867 | } |
861 | 868 | |
862 | | -// Verify that \s matches non-breaking spaces |
863 | | -// (IE fails on this test) |
864 | | -if ( !rwhite.test( "\xA0" ) ) { |
| 869 | +// IE doesn't match non-breaking spaces with \s |
| 870 | +if ( rnotwhite.test( "\xA0" ) ) { |
865 | 871 | trimLeft = /^[\s\xA0]+/; |
866 | 872 | trimRight = /[\s\xA0]+$/; |
867 | 873 | } |
— | — | @@ -905,19 +911,188 @@ |
906 | 912 | } |
907 | 913 | |
908 | 914 | // Expose jQuery to the global object |
909 | | -return (window.jQuery = window.$ = jQuery); |
| 915 | +return jQuery; |
910 | 916 | |
911 | 917 | })(); |
912 | 918 | |
913 | 919 | |
| 920 | +var // Promise methods |
| 921 | + promiseMethods = "then done fail isResolved isRejected promise".split( " " ), |
| 922 | + // Static reference to slice |
| 923 | + sliceDeferred = [].slice; |
| 924 | + |
| 925 | +jQuery.extend({ |
| 926 | + // Create a simple deferred (one callbacks list) |
| 927 | + _Deferred: function() { |
| 928 | + var // callbacks list |
| 929 | + callbacks = [], |
| 930 | + // stored [ context , args ] |
| 931 | + fired, |
| 932 | + // to avoid firing when already doing so |
| 933 | + firing, |
| 934 | + // flag to know if the deferred has been cancelled |
| 935 | + cancelled, |
| 936 | + // the deferred itself |
| 937 | + deferred = { |
| 938 | + |
| 939 | + // done( f1, f2, ...) |
| 940 | + done: function() { |
| 941 | + if ( !cancelled ) { |
| 942 | + var args = arguments, |
| 943 | + i, |
| 944 | + length, |
| 945 | + elem, |
| 946 | + type, |
| 947 | + _fired; |
| 948 | + if ( fired ) { |
| 949 | + _fired = fired; |
| 950 | + fired = 0; |
| 951 | + } |
| 952 | + for ( i = 0, length = args.length; i < length; i++ ) { |
| 953 | + elem = args[ i ]; |
| 954 | + type = jQuery.type( elem ); |
| 955 | + if ( type === "array" ) { |
| 956 | + deferred.done.apply( deferred, elem ); |
| 957 | + } else if ( type === "function" ) { |
| 958 | + callbacks.push( elem ); |
| 959 | + } |
| 960 | + } |
| 961 | + if ( _fired ) { |
| 962 | + deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] ); |
| 963 | + } |
| 964 | + } |
| 965 | + return this; |
| 966 | + }, |
| 967 | + |
| 968 | + // resolve with given context and args |
| 969 | + resolveWith: function( context, args ) { |
| 970 | + if ( !cancelled && !fired && !firing ) { |
| 971 | + // make sure args are available (#8421) |
| 972 | + args = args || []; |
| 973 | + firing = 1; |
| 974 | + try { |
| 975 | + while( callbacks[ 0 ] ) { |
| 976 | + callbacks.shift().apply( context, args ); |
| 977 | + } |
| 978 | + } |
| 979 | + finally { |
| 980 | + fired = [ context, args ]; |
| 981 | + firing = 0; |
| 982 | + } |
| 983 | + } |
| 984 | + return this; |
| 985 | + }, |
| 986 | + |
| 987 | + // resolve with this as context and given arguments |
| 988 | + resolve: function() { |
| 989 | + deferred.resolveWith( this, arguments ); |
| 990 | + return this; |
| 991 | + }, |
| 992 | + |
| 993 | + // Has this deferred been resolved? |
| 994 | + isResolved: function() { |
| 995 | + return !!( firing || fired ); |
| 996 | + }, |
| 997 | + |
| 998 | + // Cancel |
| 999 | + cancel: function() { |
| 1000 | + cancelled = 1; |
| 1001 | + callbacks = []; |
| 1002 | + return this; |
| 1003 | + } |
| 1004 | + }; |
| 1005 | + |
| 1006 | + return deferred; |
| 1007 | + }, |
| 1008 | + |
| 1009 | + // Full fledged deferred (two callbacks list) |
| 1010 | + Deferred: function( func ) { |
| 1011 | + var deferred = jQuery._Deferred(), |
| 1012 | + failDeferred = jQuery._Deferred(), |
| 1013 | + promise; |
| 1014 | + // Add errorDeferred methods, then and promise |
| 1015 | + jQuery.extend( deferred, { |
| 1016 | + then: function( doneCallbacks, failCallbacks ) { |
| 1017 | + deferred.done( doneCallbacks ).fail( failCallbacks ); |
| 1018 | + return this; |
| 1019 | + }, |
| 1020 | + fail: failDeferred.done, |
| 1021 | + rejectWith: failDeferred.resolveWith, |
| 1022 | + reject: failDeferred.resolve, |
| 1023 | + isRejected: failDeferred.isResolved, |
| 1024 | + // Get a promise for this deferred |
| 1025 | + // If obj is provided, the promise aspect is added to the object |
| 1026 | + promise: function( obj ) { |
| 1027 | + if ( obj == null ) { |
| 1028 | + if ( promise ) { |
| 1029 | + return promise; |
| 1030 | + } |
| 1031 | + promise = obj = {}; |
| 1032 | + } |
| 1033 | + var i = promiseMethods.length; |
| 1034 | + while( i-- ) { |
| 1035 | + obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ]; |
| 1036 | + } |
| 1037 | + return obj; |
| 1038 | + } |
| 1039 | + } ); |
| 1040 | + // Make sure only one callback list will be used |
| 1041 | + deferred.done( failDeferred.cancel ).fail( deferred.cancel ); |
| 1042 | + // Unexpose cancel |
| 1043 | + delete deferred.cancel; |
| 1044 | + // Call given func if any |
| 1045 | + if ( func ) { |
| 1046 | + func.call( deferred, deferred ); |
| 1047 | + } |
| 1048 | + return deferred; |
| 1049 | + }, |
| 1050 | + |
| 1051 | + // Deferred helper |
| 1052 | + when: function( firstParam ) { |
| 1053 | + var args = arguments, |
| 1054 | + i = 0, |
| 1055 | + length = args.length, |
| 1056 | + count = length, |
| 1057 | + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? |
| 1058 | + firstParam : |
| 1059 | + jQuery.Deferred(); |
| 1060 | + function resolveFunc( i ) { |
| 1061 | + return function( value ) { |
| 1062 | + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; |
| 1063 | + if ( !( --count ) ) { |
| 1064 | + // Strange bug in FF4: |
| 1065 | + // Values changed onto the arguments object sometimes end up as undefined values |
| 1066 | + // outside the $.when method. Cloning the object into a fresh array solves the issue |
| 1067 | + deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) ); |
| 1068 | + } |
| 1069 | + }; |
| 1070 | + } |
| 1071 | + if ( length > 1 ) { |
| 1072 | + for( ; i < length; i++ ) { |
| 1073 | + if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) { |
| 1074 | + args[ i ].promise().then( resolveFunc(i), deferred.reject ); |
| 1075 | + } else { |
| 1076 | + --count; |
| 1077 | + } |
| 1078 | + } |
| 1079 | + if ( !count ) { |
| 1080 | + deferred.resolveWith( deferred, args ); |
| 1081 | + } |
| 1082 | + } else if ( deferred !== firstParam ) { |
| 1083 | + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); |
| 1084 | + } |
| 1085 | + return deferred.promise(); |
| 1086 | + } |
| 1087 | +}); |
| 1088 | + |
| 1089 | + |
| 1090 | + |
| 1091 | + |
914 | 1092 | (function() { |
915 | 1093 | |
916 | 1094 | jQuery.support = {}; |
917 | 1095 | |
918 | | - var root = document.documentElement, |
919 | | - script = document.createElement("script"), |
920 | | - div = document.createElement("div"), |
921 | | - id = "script" + jQuery.now(); |
| 1096 | + var div = document.createElement("div"); |
922 | 1097 | |
923 | 1098 | div.style.display = "none"; |
924 | 1099 | div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>"; |
— | — | @@ -925,7 +1100,8 @@ |
926 | 1101 | var all = div.getElementsByTagName("*"), |
927 | 1102 | a = div.getElementsByTagName("a")[0], |
928 | 1103 | select = document.createElement("select"), |
929 | | - opt = select.appendChild( document.createElement("option") ); |
| 1104 | + opt = select.appendChild( document.createElement("option") ), |
| 1105 | + input = div.getElementsByTagName("input")[0]; |
930 | 1106 | |
931 | 1107 | // Can't get basic test support |
932 | 1108 | if ( !all || !all.length || !a ) { |
— | — | @@ -964,7 +1140,7 @@ |
965 | 1141 | // Make sure that if no value is specified for a checkbox |
966 | 1142 | // that it defaults to "on". |
967 | 1143 | // (WebKit defaults to "" instead) |
968 | | - checkOn: div.getElementsByTagName("input")[0].value === "on", |
| 1144 | + checkOn: input.value === "on", |
969 | 1145 | |
970 | 1146 | // Make sure that a selected-by-default option has a working selected property. |
971 | 1147 | // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) |
— | — | @@ -974,46 +1150,62 @@ |
975 | 1151 | deleteExpando: true, |
976 | 1152 | optDisabled: false, |
977 | 1153 | checkClone: false, |
978 | | - scriptEval: false, |
979 | 1154 | noCloneEvent: true, |
| 1155 | + noCloneChecked: true, |
980 | 1156 | boxModel: null, |
981 | 1157 | inlineBlockNeedsLayout: false, |
982 | 1158 | shrinkWrapBlocks: false, |
983 | | - reliableHiddenOffsets: true |
| 1159 | + reliableHiddenOffsets: true, |
| 1160 | + reliableMarginRight: true |
984 | 1161 | }; |
985 | 1162 | |
| 1163 | + input.checked = true; |
| 1164 | + jQuery.support.noCloneChecked = input.cloneNode( true ).checked; |
| 1165 | + |
986 | 1166 | // Make sure that the options inside disabled selects aren't marked as disabled |
987 | 1167 | // (WebKit marks them as diabled) |
988 | 1168 | select.disabled = true; |
989 | 1169 | jQuery.support.optDisabled = !opt.disabled; |
990 | 1170 | |
991 | | - script.type = "text/javascript"; |
992 | | - try { |
993 | | - script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
994 | | - } catch(e) {} |
| 1171 | + var _scriptEval = null; |
| 1172 | + jQuery.support.scriptEval = function() { |
| 1173 | + if ( _scriptEval === null ) { |
| 1174 | + var root = document.documentElement, |
| 1175 | + script = document.createElement("script"), |
| 1176 | + id = "script" + jQuery.now(); |
995 | 1177 | |
996 | | - root.insertBefore( script, root.firstChild ); |
| 1178 | + // Make sure that the execution of code works by injecting a script |
| 1179 | + // tag with appendChild/createTextNode |
| 1180 | + // (IE doesn't support this, fails, and uses .text instead) |
| 1181 | + try { |
| 1182 | + script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
| 1183 | + } catch(e) {} |
997 | 1184 | |
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 | | - } |
| 1185 | + root.insertBefore( script, root.firstChild ); |
1005 | 1186 | |
| 1187 | + if ( window[ id ] ) { |
| 1188 | + _scriptEval = true; |
| 1189 | + delete window[ id ]; |
| 1190 | + } else { |
| 1191 | + _scriptEval = false; |
| 1192 | + } |
| 1193 | + |
| 1194 | + root.removeChild( script ); |
| 1195 | + } |
| 1196 | + |
| 1197 | + return _scriptEval; |
| 1198 | + }; |
| 1199 | + |
1006 | 1200 | // Test to see if it's possible to delete an expando from an element |
1007 | 1201 | // Fails in Internet Explorer |
1008 | 1202 | try { |
1009 | | - delete script.test; |
| 1203 | + delete div.test; |
1010 | 1204 | |
1011 | 1205 | } catch(e) { |
1012 | 1206 | jQuery.support.deleteExpando = false; |
1013 | 1207 | } |
1014 | 1208 | |
1015 | | - root.removeChild( script ); |
1016 | | - |
1017 | | - if ( div.attachEvent && div.fireEvent ) { |
| 1209 | + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { |
1018 | 1210 | div.attachEvent("onclick", function click() { |
1019 | 1211 | // Cloning a node shouldn't copy over any |
1020 | 1212 | // bound event handlers (IE does this) |
— | — | @@ -1035,10 +1227,16 @@ |
1036 | 1228 | // Figure out if the W3C box model works as expected |
1037 | 1229 | // document.body must exist before we can do this |
1038 | 1230 | jQuery(function() { |
1039 | | - var div = document.createElement("div"); |
| 1231 | + var div = document.createElement("div"), |
| 1232 | + body = document.getElementsByTagName("body")[0]; |
| 1233 | + |
| 1234 | + // Frameset documents with no body should not run this code |
| 1235 | + if ( !body ) { |
| 1236 | + return; |
| 1237 | + } |
| 1238 | + |
1040 | 1239 | div.style.width = div.style.paddingLeft = "1px"; |
1041 | | - |
1042 | | - document.body.appendChild( div ); |
| 1240 | + body.appendChild( div ); |
1043 | 1241 | jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
1044 | 1242 | |
1045 | 1243 | if ( "zoom" in div.style ) { |
— | — | @@ -1057,7 +1255,7 @@ |
1058 | 1256 | jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2; |
1059 | 1257 | } |
1060 | 1258 | |
1061 | | - div.innerHTML = "<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>"; |
| 1259 | + div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>"; |
1062 | 1260 | var tds = div.getElementsByTagName("td"); |
1063 | 1261 | |
1064 | 1262 | // Check if table cells still have offsetWidth/Height when they are set |
— | — | @@ -1077,7 +1275,18 @@ |
1078 | 1276 | jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0; |
1079 | 1277 | div.innerHTML = ""; |
1080 | 1278 | |
1081 | | - document.body.removeChild( div ).style.display = "none"; |
| 1279 | + // Check if div with explicit width and no margin-right incorrectly |
| 1280 | + // gets computed margin-right based on width of container. For more |
| 1281 | + // info see bug #3333 |
| 1282 | + // Fails in WebKit before Feb 2011 nightlies |
| 1283 | + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
| 1284 | + if ( document.defaultView && document.defaultView.getComputedStyle ) { |
| 1285 | + div.style.width = "1px"; |
| 1286 | + div.style.marginRight = "0"; |
| 1287 | + jQuery.support.reliableMarginRight = ( parseInt(document.defaultView.getComputedStyle(div, null).marginRight, 10) || 0 ) === 0; |
| 1288 | + } |
| 1289 | + |
| 1290 | + body.removeChild( div ).style.display = "none"; |
1082 | 1291 | div = tds = null; |
1083 | 1292 | }); |
1084 | 1293 | |
— | — | @@ -1087,13 +1296,19 @@ |
1088 | 1297 | var el = document.createElement("div"); |
1089 | 1298 | eventName = "on" + eventName; |
1090 | 1299 | |
| 1300 | + // We only care about the case where non-standard event systems |
| 1301 | + // are used, namely in IE. Short-circuiting here helps us to |
| 1302 | + // avoid an eval call (in setAttribute) which can cause CSP |
| 1303 | + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP |
| 1304 | + if ( !el.attachEvent ) { |
| 1305 | + return true; |
| 1306 | + } |
| 1307 | + |
1091 | 1308 | var isSupported = (eventName in el); |
1092 | 1309 | if ( !isSupported ) { |
1093 | 1310 | el.setAttribute(eventName, "return;"); |
1094 | 1311 | isSupported = typeof el[eventName] === "function"; |
1095 | 1312 | } |
1096 | | - el = null; |
1097 | | - |
1098 | 1313 | return isSupported; |
1099 | 1314 | }; |
1100 | 1315 | |
— | — | @@ -1101,13 +1316,12 @@ |
1102 | 1317 | jQuery.support.changeBubbles = eventSupported("change"); |
1103 | 1318 | |
1104 | 1319 | // release memory in IE |
1105 | | - root = script = div = all = a = null; |
| 1320 | + div = all = a = null; |
1106 | 1321 | })(); |
1107 | 1322 | |
1108 | 1323 | |
1109 | 1324 | |
1110 | | -var windowData = {}, |
1111 | | - rbrace = /^(?:\{.*\}|\[.*\])$/; |
| 1325 | +var rbrace = /^(?:\{.*\}|\[.*\])$/; |
1112 | 1326 | |
1113 | 1327 | jQuery.extend({ |
1114 | 1328 | cache: {}, |
— | — | @@ -1115,8 +1329,9 @@ |
1116 | 1330 | // Please use with caution |
1117 | 1331 | uuid: 0, |
1118 | 1332 | |
1119 | | - // Unique for each copy of jQuery on the page |
1120 | | - expando: "jQuery" + jQuery.now(), |
| 1333 | + // Unique for each copy of jQuery on the page |
| 1334 | + // Non-digits removed to match rinlinejQuery |
| 1335 | + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), |
1121 | 1336 | |
1122 | 1337 | // The following elements throw uncatchable exceptions if you |
1123 | 1338 | // attempt to add expando properties to them. |
— | — | @@ -1127,103 +1342,185 @@ |
1128 | 1343 | "applet": true |
1129 | 1344 | }, |
1130 | 1345 | |
1131 | | - data: function( elem, name, data ) { |
| 1346 | + hasData: function( elem ) { |
| 1347 | + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; |
| 1348 | + |
| 1349 | + return !!elem && !isEmptyDataObject( elem ); |
| 1350 | + }, |
| 1351 | + |
| 1352 | + data: function( elem, name, data, pvt /* Internal Use Only */ ) { |
1132 | 1353 | if ( !jQuery.acceptData( elem ) ) { |
1133 | 1354 | return; |
1134 | 1355 | } |
1135 | 1356 | |
1136 | | - elem = elem == window ? |
1137 | | - windowData : |
1138 | | - elem; |
| 1357 | + var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache, |
1139 | 1358 | |
1140 | | - var isNode = elem.nodeType, |
1141 | | - id = isNode ? elem[ jQuery.expando ] : null, |
1142 | | - cache = jQuery.cache, thisCache; |
| 1359 | + // We have to handle DOM nodes and JS objects differently because IE6-7 |
| 1360 | + // can't GC object references properly across the DOM-JS boundary |
| 1361 | + isNode = elem.nodeType, |
1143 | 1362 | |
1144 | | - if ( isNode && !id && typeof name === "string" && data === undefined ) { |
| 1363 | + // Only DOM nodes need the global jQuery cache; JS object data is |
| 1364 | + // attached directly to the object so GC can occur automatically |
| 1365 | + cache = isNode ? jQuery.cache : elem, |
| 1366 | + |
| 1367 | + // Only defining an ID for JS objects if its cache already exists allows |
| 1368 | + // the code to shortcut on the same path as a DOM node with no cache |
| 1369 | + id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando; |
| 1370 | + |
| 1371 | + // Avoid doing any more work than we need to when trying to get data on an |
| 1372 | + // object that has no data at all |
| 1373 | + if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) { |
1145 | 1374 | return; |
1146 | 1375 | } |
1147 | 1376 | |
1148 | | - // Get the data from the object directly |
1149 | | - if ( !isNode ) { |
1150 | | - cache = elem; |
| 1377 | + if ( !id ) { |
| 1378 | + // Only DOM nodes need a new unique ID for each element since their data |
| 1379 | + // ends up in the global cache |
| 1380 | + if ( isNode ) { |
| 1381 | + elem[ jQuery.expando ] = id = ++jQuery.uuid; |
| 1382 | + } else { |
| 1383 | + id = jQuery.expando; |
| 1384 | + } |
| 1385 | + } |
1151 | 1386 | |
1152 | | - // Compute a unique ID for the element |
1153 | | - } else if ( !id ) { |
1154 | | - elem[ jQuery.expando ] = id = ++jQuery.uuid; |
| 1387 | + if ( !cache[ id ] ) { |
| 1388 | + cache[ id ] = {}; |
| 1389 | + |
| 1390 | + // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery |
| 1391 | + // metadata on plain JS objects when the object is serialized using |
| 1392 | + // JSON.stringify |
| 1393 | + if ( !isNode ) { |
| 1394 | + cache[ id ].toJSON = jQuery.noop; |
| 1395 | + } |
1155 | 1396 | } |
1156 | 1397 | |
1157 | | - // Avoid generating a new cache unless none exists and we |
1158 | | - // want to manipulate it. |
1159 | | - if ( typeof name === "object" ) { |
1160 | | - if ( isNode ) { |
| 1398 | + // An object can be passed to jQuery.data instead of a key/value pair; this gets |
| 1399 | + // shallow copied over onto the existing cache |
| 1400 | + if ( typeof name === "object" || typeof name === "function" ) { |
| 1401 | + if ( pvt ) { |
| 1402 | + cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name); |
| 1403 | + } else { |
1161 | 1404 | cache[ id ] = jQuery.extend(cache[ id ], name); |
| 1405 | + } |
| 1406 | + } |
1162 | 1407 | |
1163 | | - } else { |
1164 | | - jQuery.extend( cache, name ); |
| 1408 | + thisCache = cache[ id ]; |
| 1409 | + |
| 1410 | + // Internal jQuery data is stored in a separate object inside the object's data |
| 1411 | + // cache in order to avoid key collisions between internal data and user-defined |
| 1412 | + // data |
| 1413 | + if ( pvt ) { |
| 1414 | + if ( !thisCache[ internalKey ] ) { |
| 1415 | + thisCache[ internalKey ] = {}; |
1165 | 1416 | } |
1166 | 1417 | |
1167 | | - } else if ( isNode && !cache[ id ] ) { |
1168 | | - cache[ id ] = {}; |
| 1418 | + thisCache = thisCache[ internalKey ]; |
1169 | 1419 | } |
1170 | 1420 | |
1171 | | - thisCache = isNode ? cache[ id ] : cache; |
1172 | | - |
1173 | | - // Prevent overriding the named cache with undefined values |
1174 | 1421 | if ( data !== undefined ) { |
1175 | 1422 | thisCache[ name ] = data; |
1176 | 1423 | } |
1177 | 1424 | |
1178 | | - return typeof name === "string" ? thisCache[ name ] : thisCache; |
| 1425 | + // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should |
| 1426 | + // not attempt to inspect the internal events object using jQuery.data, as this |
| 1427 | + // internal data object is undocumented and subject to change. |
| 1428 | + if ( name === "events" && !thisCache[name] ) { |
| 1429 | + return thisCache[ internalKey ] && thisCache[ internalKey ].events; |
| 1430 | + } |
| 1431 | + |
| 1432 | + return getByName ? thisCache[ name ] : thisCache; |
1179 | 1433 | }, |
1180 | 1434 | |
1181 | | - removeData: function( elem, name ) { |
| 1435 | + removeData: function( elem, name, pvt /* Internal Use Only */ ) { |
1182 | 1436 | if ( !jQuery.acceptData( elem ) ) { |
1183 | 1437 | return; |
1184 | 1438 | } |
1185 | 1439 | |
1186 | | - elem = elem == window ? |
1187 | | - windowData : |
1188 | | - elem; |
| 1440 | + var internalKey = jQuery.expando, isNode = elem.nodeType, |
1189 | 1441 | |
1190 | | - var isNode = elem.nodeType, |
1191 | | - id = isNode ? elem[ jQuery.expando ] : elem, |
1192 | | - cache = jQuery.cache, |
1193 | | - thisCache = isNode ? cache[ id ] : id; |
| 1442 | + // See jQuery.data for more information |
| 1443 | + cache = isNode ? jQuery.cache : elem, |
1194 | 1444 | |
1195 | | - // If we want to remove a specific section of the element's data |
| 1445 | + // See jQuery.data for more information |
| 1446 | + id = isNode ? elem[ jQuery.expando ] : jQuery.expando; |
| 1447 | + |
| 1448 | + // If there is already no cache entry for this object, there is no |
| 1449 | + // purpose in continuing |
| 1450 | + if ( !cache[ id ] ) { |
| 1451 | + return; |
| 1452 | + } |
| 1453 | + |
1196 | 1454 | if ( name ) { |
| 1455 | + var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ]; |
| 1456 | + |
1197 | 1457 | if ( thisCache ) { |
1198 | | - // Remove the section of cache data |
1199 | 1458 | delete thisCache[ name ]; |
1200 | 1459 | |
1201 | | - // If we've removed all the data, remove the element's cache |
1202 | | - if ( isNode && jQuery.isEmptyObject(thisCache) ) { |
1203 | | - jQuery.removeData( elem ); |
| 1460 | + // If there is no data left in the cache, we want to continue |
| 1461 | + // and let the cache object itself get destroyed |
| 1462 | + if ( !isEmptyDataObject(thisCache) ) { |
| 1463 | + return; |
1204 | 1464 | } |
1205 | 1465 | } |
| 1466 | + } |
1206 | 1467 | |
1207 | | - // Otherwise, we want to remove all of the element's data |
| 1468 | + // See jQuery.data for more information |
| 1469 | + if ( pvt ) { |
| 1470 | + delete cache[ id ][ internalKey ]; |
| 1471 | + |
| 1472 | + // Don't destroy the parent cache unless the internal data object |
| 1473 | + // had been the only thing left in it |
| 1474 | + if ( !isEmptyDataObject(cache[ id ]) ) { |
| 1475 | + return; |
| 1476 | + } |
| 1477 | + } |
| 1478 | + |
| 1479 | + var internalCache = cache[ id ][ internalKey ]; |
| 1480 | + |
| 1481 | + // Browsers that fail expando deletion also refuse to delete expandos on |
| 1482 | + // the window, but it will allow it on all other JS objects; other browsers |
| 1483 | + // don't care |
| 1484 | + if ( jQuery.support.deleteExpando || cache != window ) { |
| 1485 | + delete cache[ id ]; |
1208 | 1486 | } else { |
1209 | | - if ( isNode && jQuery.support.deleteExpando ) { |
| 1487 | + cache[ id ] = null; |
| 1488 | + } |
| 1489 | + |
| 1490 | + // We destroyed the entire user cache at once because it's faster than |
| 1491 | + // iterating through each key, but we need to continue to persist internal |
| 1492 | + // data if it existed |
| 1493 | + if ( internalCache ) { |
| 1494 | + cache[ id ] = {}; |
| 1495 | + // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery |
| 1496 | + // metadata on plain JS objects when the object is serialized using |
| 1497 | + // JSON.stringify |
| 1498 | + if ( !isNode ) { |
| 1499 | + cache[ id ].toJSON = jQuery.noop; |
| 1500 | + } |
| 1501 | + |
| 1502 | + cache[ id ][ internalKey ] = internalCache; |
| 1503 | + |
| 1504 | + // Otherwise, we need to eliminate the expando on the node to avoid |
| 1505 | + // false lookups in the cache for entries that no longer exist |
| 1506 | + } else if ( isNode ) { |
| 1507 | + // IE does not allow us to delete expando properties from nodes, |
| 1508 | + // nor does it have a removeAttribute function on Document nodes; |
| 1509 | + // we must handle all of these cases |
| 1510 | + if ( jQuery.support.deleteExpando ) { |
1210 | 1511 | delete elem[ jQuery.expando ]; |
1211 | | - |
1212 | 1512 | } else if ( elem.removeAttribute ) { |
1213 | 1513 | 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 | 1514 | } else { |
1221 | | - for ( var n in elem ) { |
1222 | | - delete elem[ n ]; |
1223 | | - } |
| 1515 | + elem[ jQuery.expando ] = null; |
1224 | 1516 | } |
1225 | 1517 | } |
1226 | 1518 | }, |
1227 | 1519 | |
| 1520 | + // For internal use only. |
| 1521 | + _data: function( elem, name, data ) { |
| 1522 | + return jQuery.data( elem, name, data, true ); |
| 1523 | + }, |
| 1524 | + |
1228 | 1525 | // A method for determining if a DOM node can handle the data expando |
1229 | 1526 | acceptData: function( elem ) { |
1230 | 1527 | if ( elem.nodeName ) { |
— | — | @@ -1244,15 +1541,17 @@ |
1245 | 1542 | |
1246 | 1543 | if ( typeof key === "undefined" ) { |
1247 | 1544 | if ( this.length ) { |
1248 | | - var attr = this[0].attributes, name; |
1249 | 1545 | data = jQuery.data( this[0] ); |
1250 | 1546 | |
1251 | | - for ( var i = 0, l = attr.length; i < l; i++ ) { |
1252 | | - name = attr[i].name; |
| 1547 | + if ( this[0].nodeType === 1 ) { |
| 1548 | + var attr = this[0].attributes, name; |
| 1549 | + for ( var i = 0, l = attr.length; i < l; i++ ) { |
| 1550 | + name = attr[i].name; |
1253 | 1551 | |
1254 | | - if ( name.indexOf( "data-" ) === 0 ) { |
1255 | | - name = name.substr( 5 ); |
1256 | | - dataAttr( this[0], name, data[ name ] ); |
| 1552 | + if ( name.indexOf( "data-" ) === 0 ) { |
| 1553 | + name = name.substr( 5 ); |
| 1554 | + dataAttr( this[0], name, data[ name ] ); |
| 1555 | + } |
1257 | 1556 | } |
1258 | 1557 | } |
1259 | 1558 | } |
— | — | @@ -1327,9 +1626,22 @@ |
1328 | 1627 | return data; |
1329 | 1628 | } |
1330 | 1629 | |
| 1630 | +// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON |
| 1631 | +// property to be considered empty objects; this property always exists in |
| 1632 | +// order to make sure JSON.stringify does not expose internal metadata |
| 1633 | +function isEmptyDataObject( obj ) { |
| 1634 | + for ( var name in obj ) { |
| 1635 | + if ( name !== "toJSON" ) { |
| 1636 | + return false; |
| 1637 | + } |
| 1638 | + } |
1331 | 1639 | |
| 1640 | + return true; |
| 1641 | +} |
1332 | 1642 | |
1333 | 1643 | |
| 1644 | + |
| 1645 | + |
1334 | 1646 | jQuery.extend({ |
1335 | 1647 | queue: function( elem, type, data ) { |
1336 | 1648 | if ( !elem ) { |
— | — | @@ -1337,7 +1649,7 @@ |
1338 | 1650 | } |
1339 | 1651 | |
1340 | 1652 | type = (type || "fx") + "queue"; |
1341 | | - var q = jQuery.data( elem, type ); |
| 1653 | + var q = jQuery._data( elem, type ); |
1342 | 1654 | |
1343 | 1655 | // Speed up dequeue by getting out quickly if this is just a lookup |
1344 | 1656 | if ( !data ) { |
— | — | @@ -1345,7 +1657,7 @@ |
1346 | 1658 | } |
1347 | 1659 | |
1348 | 1660 | if ( !q || jQuery.isArray(data) ) { |
1349 | | - q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
| 1661 | + q = jQuery._data( elem, type, jQuery.makeArray(data) ); |
1350 | 1662 | |
1351 | 1663 | } else { |
1352 | 1664 | q.push( data ); |
— | — | @@ -1376,6 +1688,10 @@ |
1377 | 1689 | jQuery.dequeue(elem, type); |
1378 | 1690 | }); |
1379 | 1691 | } |
| 1692 | + |
| 1693 | + if ( !queue.length ) { |
| 1694 | + jQuery.removeData( elem, type + "queue", true ); |
| 1695 | + } |
1380 | 1696 | } |
1381 | 1697 | }); |
1382 | 1698 | |
— | — | @@ -1425,7 +1741,7 @@ |
1426 | 1742 | |
1427 | 1743 | |
1428 | 1744 | |
1429 | | -var rclass = /[\n\t]/g, |
| 1745 | +var rclass = /[\n\t\r]/g, |
1430 | 1746 | rspaces = /\s+/, |
1431 | 1747 | rreturn = /\r/g, |
1432 | 1748 | rspecialurl = /^(?:href|src|style)$/, |
— | — | @@ -1558,11 +1874,11 @@ |
1559 | 1875 | } else if ( type === "undefined" || type === "boolean" ) { |
1560 | 1876 | if ( this.className ) { |
1561 | 1877 | // store className if set |
1562 | | - jQuery.data( this, "__className__", this.className ); |
| 1878 | + jQuery._data( this, "__className__", this.className ); |
1563 | 1879 | } |
1564 | 1880 | |
1565 | 1881 | // toggle whole className |
1566 | | - this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || ""; |
| 1882 | + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; |
1567 | 1883 | } |
1568 | 1884 | }); |
1569 | 1885 | }, |
— | — | @@ -1607,7 +1923,7 @@ |
1608 | 1924 | var option = options[ i ]; |
1609 | 1925 | |
1610 | 1926 | // 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) && |
| 1927 | + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && |
1612 | 1928 | (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { |
1613 | 1929 | |
1614 | 1930 | // Get the specific value for the option |
— | — | @@ -1623,6 +1939,11 @@ |
1624 | 1940 | } |
1625 | 1941 | } |
1626 | 1942 | |
| 1943 | + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() |
| 1944 | + if ( one && !values.length && options.length ) { |
| 1945 | + return jQuery( options[ index ] ).val(); |
| 1946 | + } |
| 1947 | + |
1627 | 1948 | return values; |
1628 | 1949 | } |
1629 | 1950 | |
— | — | @@ -1630,7 +1951,6 @@ |
1631 | 1952 | if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) { |
1632 | 1953 | return elem.getAttribute("value") === null ? "on" : elem.value; |
1633 | 1954 | } |
1634 | | - |
1635 | 1955 | |
1636 | 1956 | // Everything else, we just grab the value |
1637 | 1957 | return (elem.value || "").replace(rreturn, ""); |
— | — | @@ -1696,10 +2016,10 @@ |
1697 | 2017 | height: true, |
1698 | 2018 | offset: true |
1699 | 2019 | }, |
1700 | | - |
| 2020 | + |
1701 | 2021 | 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 ) { |
| 2022 | + // don't get/set attributes on text, comment and attribute nodes |
| 2023 | + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) { |
1704 | 2024 | return undefined; |
1705 | 2025 | } |
1706 | 2026 | |
— | — | @@ -1714,88 +2034,96 @@ |
1715 | 2035 | // Try to normalize/fix the name |
1716 | 2036 | name = notxml && jQuery.props[ name ] || name; |
1717 | 2037 | |
1718 | | - // These attributes require special treatment |
1719 | | - var special = rspecialurl.test( name ); |
| 2038 | + // Only do all the following if this is a node (faster for style) |
| 2039 | + if ( elem.nodeType === 1 ) { |
| 2040 | + // These attributes require special treatment |
| 2041 | + var special = rspecialurl.test( name ); |
1720 | 2042 | |
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; |
| 2043 | + // Safari mis-reports the default selected property of an option |
| 2044 | + // Accessing the parent's selectedIndex property fixes it |
| 2045 | + if ( name === "selected" && !jQuery.support.optSelected ) { |
| 2046 | + var parent = elem.parentNode; |
| 2047 | + if ( parent ) { |
| 2048 | + parent.selectedIndex; |
1727 | 2049 | |
1728 | | - // Make sure that it also works with optgroups, see #5701 |
1729 | | - if ( parent.parentNode ) { |
1730 | | - parent.parentNode.selectedIndex; |
| 2050 | + // Make sure that it also works with optgroups, see #5701 |
| 2051 | + if ( parent.parentNode ) { |
| 2052 | + parent.parentNode.selectedIndex; |
| 2053 | + } |
1731 | 2054 | } |
1732 | 2055 | } |
1733 | | - } |
1734 | 2056 | |
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 | | - } |
| 2057 | + // If applicable, access the attribute via the DOM 0 way |
| 2058 | + // 'in' checks fail in Blackberry 4.7 #6931 |
| 2059 | + if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) { |
| 2060 | + if ( set ) { |
| 2061 | + // We can't allow the type property to be changed (since it causes problems in IE) |
| 2062 | + if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) { |
| 2063 | + jQuery.error( "type property can't be changed" ); |
| 2064 | + } |
1743 | 2065 | |
1744 | | - if ( value === null ) { |
1745 | | - if ( elem.nodeType === 1 ) { |
1746 | | - elem.removeAttribute( name ); |
| 2066 | + if ( value === null ) { |
| 2067 | + if ( elem.nodeType === 1 ) { |
| 2068 | + elem.removeAttribute( name ); |
| 2069 | + } |
| 2070 | + |
| 2071 | + } else { |
| 2072 | + elem[ name ] = value; |
1747 | 2073 | } |
| 2074 | + } |
1748 | 2075 | |
1749 | | - } else { |
1750 | | - elem[ name ] = value; |
| 2076 | + // browsers index elements by id/name on forms, give priority to attributes. |
| 2077 | + if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) { |
| 2078 | + return elem.getAttributeNode( name ).nodeValue; |
1751 | 2079 | } |
1752 | | - } |
1753 | 2080 | |
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; |
| 2081 | + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set |
| 2082 | + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
| 2083 | + if ( name === "tabIndex" ) { |
| 2084 | + var attributeNode = elem.getAttributeNode( "tabIndex" ); |
| 2085 | + |
| 2086 | + return attributeNode && attributeNode.specified ? |
| 2087 | + attributeNode.value : |
| 2088 | + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? |
| 2089 | + 0 : |
| 2090 | + undefined; |
| 2091 | + } |
| 2092 | + |
| 2093 | + return elem[ name ]; |
1757 | 2094 | } |
1758 | 2095 | |
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" ); |
| 2096 | + if ( !jQuery.support.style && notxml && name === "style" ) { |
| 2097 | + if ( set ) { |
| 2098 | + elem.style.cssText = "" + value; |
| 2099 | + } |
1763 | 2100 | |
1764 | | - return attributeNode && attributeNode.specified ? |
1765 | | - attributeNode.value : |
1766 | | - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? |
1767 | | - 0 : |
1768 | | - undefined; |
| 2101 | + return elem.style.cssText; |
1769 | 2102 | } |
1770 | 2103 | |
1771 | | - return elem[ name ]; |
1772 | | - } |
1773 | | - |
1774 | | - if ( !jQuery.support.style && notxml && name === "style" ) { |
1775 | 2104 | if ( set ) { |
1776 | | - elem.style.cssText = "" + value; |
| 2105 | + // convert the value to a string (all browsers do this but IE) see #1070 |
| 2106 | + elem.setAttribute( name, "" + value ); |
1777 | 2107 | } |
1778 | 2108 | |
1779 | | - return elem.style.cssText; |
| 2109 | + // Ensure that missing attributes return undefined |
| 2110 | + // Blackberry 4.7 returns "" from getAttribute #6938 |
| 2111 | + if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) { |
| 2112 | + return undefined; |
| 2113 | + } |
| 2114 | + |
| 2115 | + var attr = !jQuery.support.hrefNormalized && notxml && special ? |
| 2116 | + // Some attributes require a special call on IE |
| 2117 | + elem.getAttribute( name, 2 ) : |
| 2118 | + elem.getAttribute( name ); |
| 2119 | + |
| 2120 | + // Non-existent attributes return null, we normalize to undefined |
| 2121 | + return attr === null ? undefined : attr; |
1780 | 2122 | } |
1781 | | - |
| 2123 | + // Handle everything which isn't a DOM element node |
1782 | 2124 | if ( set ) { |
1783 | | - // convert the value to a string (all browsers do this but IE) see #1070 |
1784 | | - elem.setAttribute( name, "" + value ); |
| 2125 | + elem[ name ] = value; |
1785 | 2126 | } |
1786 | | - |
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; |
1791 | | - } |
1792 | | - |
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 ); |
1797 | | - |
1798 | | - // Non-existent attributes return null, we normalize to undefined |
1799 | | - return attr === null ? undefined : attr; |
| 2127 | + return elem[ name ]; |
1800 | 2128 | } |
1801 | 2129 | }); |
1802 | 2130 | |
— | — | @@ -1809,8 +2137,7 @@ |
1810 | 2138 | rescape = /[^\w\s.|`]/g, |
1811 | 2139 | fcleanup = function( nm ) { |
1812 | 2140 | return nm.replace(rescape, "\\$&"); |
1813 | | - }, |
1814 | | - focusCounts = { focusin: 0, focusout: 0 }; |
| 2141 | + }; |
1815 | 2142 | |
1816 | 2143 | /* |
1817 | 2144 | * A number of helper functions used for managing events. |
— | — | @@ -1826,17 +2153,22 @@ |
1827 | 2154 | return; |
1828 | 2155 | } |
1829 | 2156 | |
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; |
| 2157 | + // TODO :: Use a try/catch until it's safe to pull this out (likely 1.6) |
| 2158 | + // Minor release fix for bug #8018 |
| 2159 | + try { |
| 2160 | + // For whatever reason, IE has trouble passing the window object |
| 2161 | + // around, causing it to be cloned in the process |
| 2162 | + if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) { |
| 2163 | + elem = window; |
| 2164 | + } |
1834 | 2165 | } |
| 2166 | + catch ( e ) {} |
1835 | 2167 | |
1836 | 2168 | if ( handler === false ) { |
1837 | 2169 | handler = returnFalse; |
1838 | 2170 | } else if ( !handler ) { |
1839 | 2171 | // Fixes bug #7229. Fix recommended by jdalton |
1840 | | - return; |
| 2172 | + return; |
1841 | 2173 | } |
1842 | 2174 | |
1843 | 2175 | var handleObjIn, handleObj; |
— | — | @@ -1852,7 +2184,7 @@ |
1853 | 2185 | } |
1854 | 2186 | |
1855 | 2187 | // Init the element's event structure |
1856 | | - var elemData = jQuery.data( elem ); |
| 2188 | + var elemData = jQuery._data( elem ); |
1857 | 2189 | |
1858 | 2190 | // If no elemData is found then we must be trying to bind to one of the |
1859 | 2191 | // banned noData elements |
— | — | @@ -1860,34 +2192,18 @@ |
1861 | 2193 | return; |
1862 | 2194 | } |
1863 | 2195 | |
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 ], |
| 2196 | + var events = elemData.events, |
1868 | 2197 | 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 | 2198 | |
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 | | - |
| 2199 | + if ( !events ) { |
1884 | 2200 | elemData.events = events = {}; |
1885 | 2201 | } |
1886 | 2202 | |
1887 | 2203 | if ( !eventHandle ) { |
1888 | | - elemData.handle = eventHandle = function() { |
| 2204 | + elemData.handle = eventHandle = function( e ) { |
1889 | 2205 | // Handle the second event of a trigger and when |
1890 | 2206 | // an event is called after a page has unloaded |
1891 | | - return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
| 2207 | + return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? |
1892 | 2208 | jQuery.event.handle.apply( eventHandle.elem, arguments ) : |
1893 | 2209 | undefined; |
1894 | 2210 | }; |
— | — | @@ -1945,10 +2261,10 @@ |
1946 | 2262 | } |
1947 | 2263 | } |
1948 | 2264 | } |
1949 | | - |
1950 | | - if ( special.add ) { |
1951 | | - special.add.call( elem, handleObj ); |
1952 | 2265 | |
| 2266 | + if ( special.add ) { |
| 2267 | + special.add.call( elem, handleObj ); |
| 2268 | + |
1953 | 2269 | if ( !handleObj.handler.guid ) { |
1954 | 2270 | handleObj.handler.guid = handler.guid; |
1955 | 2271 | } |
— | — | @@ -1979,18 +2295,12 @@ |
1980 | 2296 | } |
1981 | 2297 | |
1982 | 2298 | 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 ]; |
| 2299 | + elemData = jQuery.hasData( elem ) && jQuery._data( elem ), |
| 2300 | + events = elemData && elemData.events; |
1986 | 2301 | |
1987 | 2302 | if ( !elemData || !events ) { |
1988 | 2303 | return; |
1989 | 2304 | } |
1990 | | - |
1991 | | - if ( typeof events === "function" ) { |
1992 | | - elemData = events; |
1993 | | - events = events.events; |
1994 | | - } |
1995 | 2305 | |
1996 | 2306 | // types is actually an event object here |
1997 | 2307 | if ( types && types.type ) { |
— | — | @@ -2024,7 +2334,7 @@ |
2025 | 2335 | namespaces = type.split("."); |
2026 | 2336 | type = namespaces.shift(); |
2027 | 2337 | |
2028 | | - namespace = new RegExp("(^|\\.)" + |
| 2338 | + namespace = new RegExp("(^|\\.)" + |
2029 | 2339 | jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)"); |
2030 | 2340 | } |
2031 | 2341 | |
— | — | @@ -2091,11 +2401,8 @@ |
2092 | 2402 | delete elemData.events; |
2093 | 2403 | delete elemData.handle; |
2094 | 2404 | |
2095 | | - if ( typeof elemData === "function" ) { |
2096 | | - jQuery.removeData( elem, eventKey ); |
2097 | | - |
2098 | | - } else if ( jQuery.isEmptyObject( elemData ) ) { |
2099 | | - jQuery.removeData( elem ); |
| 2405 | + if ( jQuery.isEmptyObject( elemData ) ) { |
| 2406 | + jQuery.removeData( elem, undefined, true ); |
2100 | 2407 | } |
2101 | 2408 | } |
2102 | 2409 | }, |
— | — | @@ -2127,9 +2434,16 @@ |
2128 | 2435 | |
2129 | 2436 | // Only trigger if we've ever bound an event for it |
2130 | 2437 | if ( jQuery.event.global[ type ] ) { |
| 2438 | + // XXX This code smells terrible. event.js should not be directly |
| 2439 | + // inspecting the data cache |
2131 | 2440 | jQuery.each( jQuery.cache, function() { |
2132 | | - if ( this.events && this.events[type] ) { |
2133 | | - jQuery.event.trigger( event, data, this.handle.elem ); |
| 2441 | + // internalKey variable is just used to make it easier to find |
| 2442 | + // and potentially change this stuff later; currently it just |
| 2443 | + // points to jQuery.expando |
| 2444 | + var internalKey = jQuery.expando, |
| 2445 | + internalCache = this[ internalKey ]; |
| 2446 | + if ( internalCache && internalCache.events && internalCache.events[ type ] ) { |
| 2447 | + jQuery.event.trigger( event, data, internalCache.handle.elem ); |
2134 | 2448 | } |
2135 | 2449 | }); |
2136 | 2450 | } |
— | — | @@ -2154,9 +2468,7 @@ |
2155 | 2469 | event.currentTarget = elem; |
2156 | 2470 | |
2157 | 2471 | // 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; |
| 2472 | + var handle = jQuery._data( elem, "handle" ); |
2161 | 2473 | |
2162 | 2474 | if ( handle ) { |
2163 | 2475 | handle.apply( elem, data ); |
— | — | @@ -2186,7 +2498,7 @@ |
2187 | 2499 | isClick = jQuery.nodeName( target, "a" ) && targetType === "click", |
2188 | 2500 | special = jQuery.event.special[ targetType ] || {}; |
2189 | 2501 | |
2190 | | - if ( (!special._default || special._default.call( elem, event ) === false) && |
| 2502 | + if ( (!special._default || special._default.call( elem, event ) === false) && |
2191 | 2503 | !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) { |
2192 | 2504 | |
2193 | 2505 | try { |
— | — | @@ -2198,7 +2510,7 @@ |
2199 | 2511 | target[ "on" + targetType ] = null; |
2200 | 2512 | } |
2201 | 2513 | |
2202 | | - jQuery.event.triggered = true; |
| 2514 | + jQuery.event.triggered = event.type; |
2203 | 2515 | target[ targetType ](); |
2204 | 2516 | } |
2205 | 2517 | |
— | — | @@ -2209,7 +2521,7 @@ |
2210 | 2522 | target[ "on" + targetType ] = old; |
2211 | 2523 | } |
2212 | 2524 | |
2213 | | - jQuery.event.triggered = false; |
| 2525 | + jQuery.event.triggered = undefined; |
2214 | 2526 | } |
2215 | 2527 | } |
2216 | 2528 | }, |
— | — | @@ -2234,12 +2546,8 @@ |
2235 | 2547 | |
2236 | 2548 | event.namespace = event.namespace || namespace_sort.join("."); |
2237 | 2549 | |
2238 | | - events = jQuery.data(this, this.nodeType ? "events" : "__events__"); |
| 2550 | + events = jQuery._data(this, "events"); |
2239 | 2551 | |
2240 | | - if ( typeof events === "function" ) { |
2241 | | - events = events.events; |
2242 | | - } |
2243 | | - |
2244 | 2552 | handlers = (events || {})[ event.type ]; |
2245 | 2553 | |
2246 | 2554 | if ( events && handlers ) { |
— | — | @@ -2256,7 +2564,7 @@ |
2257 | 2565 | event.handler = handleObj.handler; |
2258 | 2566 | event.data = handleObj.data; |
2259 | 2567 | event.handleObj = handleObj; |
2260 | | - |
| 2568 | + |
2261 | 2569 | var ret = handleObj.handler.apply( this, args ); |
2262 | 2570 | |
2263 | 2571 | if ( ret !== undefined ) { |
— | — | @@ -2355,7 +2663,7 @@ |
2356 | 2664 | add: function( handleObj ) { |
2357 | 2665 | jQuery.event.add( this, |
2358 | 2666 | liveConvert( handleObj.origType, handleObj.selector ), |
2359 | | - jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); |
| 2667 | + jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); |
2360 | 2668 | }, |
2361 | 2669 | |
2362 | 2670 | remove: function( handleObj ) { |
— | — | @@ -2385,7 +2693,7 @@ |
2386 | 2694 | if ( elem.removeEventListener ) { |
2387 | 2695 | elem.removeEventListener( type, handle, false ); |
2388 | 2696 | } |
2389 | | - } : |
| 2697 | + } : |
2390 | 2698 | function( elem, type, handle ) { |
2391 | 2699 | if ( elem.detachEvent ) { |
2392 | 2700 | elem.detachEvent( "on" + type, handle ); |
— | — | @@ -2402,6 +2710,12 @@ |
2403 | 2711 | if ( src && src.type ) { |
2404 | 2712 | this.originalEvent = src; |
2405 | 2713 | this.type = src.type; |
| 2714 | + |
| 2715 | + // Events bubbling up the document may have been marked as prevented |
| 2716 | + // by a handler lower down the tree; reflect the correct value. |
| 2717 | + this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || |
| 2718 | + src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse; |
| 2719 | + |
2406 | 2720 | // Event type |
2407 | 2721 | } else { |
2408 | 2722 | this.type = src; |
— | — | @@ -2432,7 +2746,7 @@ |
2433 | 2747 | if ( !e ) { |
2434 | 2748 | return; |
2435 | 2749 | } |
2436 | | - |
| 2750 | + |
2437 | 2751 | // if preventDefault exists run it on the original event |
2438 | 2752 | if ( e.preventDefault ) { |
2439 | 2753 | e.preventDefault(); |
— | — | @@ -2474,6 +2788,12 @@ |
2475 | 2789 | // Firefox sometimes assigns relatedTarget a XUL element |
2476 | 2790 | // which we cannot access the parentNode property of |
2477 | 2791 | try { |
| 2792 | + |
| 2793 | + // Chrome does something similar, the parentNode property |
| 2794 | + // can be accessed but is null. |
| 2795 | + if ( parent && parent !== document && !parent.parentNode ) { |
| 2796 | + return; |
| 2797 | + } |
2478 | 2798 | // Traverse up the tree |
2479 | 2799 | while ( parent && parent !== this ) { |
2480 | 2800 | parent = parent.parentNode; |
— | — | @@ -2518,24 +2838,22 @@ |
2519 | 2839 | |
2520 | 2840 | jQuery.event.special.submit = { |
2521 | 2841 | setup: function( data, namespaces ) { |
2522 | | - if ( this.nodeName.toLowerCase() !== "form" ) { |
| 2842 | + if ( this.nodeName && this.nodeName.toLowerCase() !== "form" ) { |
2523 | 2843 | jQuery.event.add(this, "click.specialSubmit", function( e ) { |
2524 | 2844 | var elem = e.target, |
2525 | 2845 | type = elem.type; |
2526 | 2846 | |
2527 | 2847 | if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { |
2528 | | - e.liveFired = undefined; |
2529 | | - return trigger( "submit", this, arguments ); |
| 2848 | + trigger( "submit", this, arguments ); |
2530 | 2849 | } |
2531 | 2850 | }); |
2532 | | - |
| 2851 | + |
2533 | 2852 | jQuery.event.add(this, "keypress.specialSubmit", function( e ) { |
2534 | 2853 | var elem = e.target, |
2535 | 2854 | type = elem.type; |
2536 | 2855 | |
2537 | 2856 | if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { |
2538 | | - e.liveFired = undefined; |
2539 | | - return trigger( "submit", this, arguments ); |
| 2857 | + trigger( "submit", this, arguments ); |
2540 | 2858 | } |
2541 | 2859 | }); |
2542 | 2860 | |
— | — | @@ -2583,14 +2901,14 @@ |
2584 | 2902 | return; |
2585 | 2903 | } |
2586 | 2904 | |
2587 | | - data = jQuery.data( elem, "_change_data" ); |
| 2905 | + data = jQuery._data( elem, "_change_data" ); |
2588 | 2906 | val = getVal(elem); |
2589 | 2907 | |
2590 | 2908 | // the current data will be also retrieved by beforeactivate |
2591 | 2909 | if ( e.type !== "focusout" || elem.type !== "radio" ) { |
2592 | | - jQuery.data( elem, "_change_data", val ); |
| 2910 | + jQuery._data( elem, "_change_data", val ); |
2593 | 2911 | } |
2594 | | - |
| 2912 | + |
2595 | 2913 | if ( data === undefined || val === data ) { |
2596 | 2914 | return; |
2597 | 2915 | } |
— | — | @@ -2598,13 +2916,13 @@ |
2599 | 2917 | if ( data != null || val ) { |
2600 | 2918 | e.type = "change"; |
2601 | 2919 | e.liveFired = undefined; |
2602 | | - return jQuery.event.trigger( e, arguments[1], elem ); |
| 2920 | + jQuery.event.trigger( e, arguments[1], elem ); |
2603 | 2921 | } |
2604 | 2922 | }; |
2605 | 2923 | |
2606 | 2924 | jQuery.event.special.change = { |
2607 | 2925 | filters: { |
2608 | | - focusout: testChange, |
| 2926 | + focusout: testChange, |
2609 | 2927 | |
2610 | 2928 | beforedeactivate: testChange, |
2611 | 2929 | |
— | — | @@ -2612,7 +2930,7 @@ |
2613 | 2931 | var elem = e.target, type = elem.type; |
2614 | 2932 | |
2615 | 2933 | if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) { |
2616 | | - return testChange.call( this, e ); |
| 2934 | + testChange.call( this, e ); |
2617 | 2935 | } |
2618 | 2936 | }, |
2619 | 2937 | |
— | — | @@ -2624,7 +2942,7 @@ |
2625 | 2943 | if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") || |
2626 | 2944 | (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || |
2627 | 2945 | type === "select-multiple" ) { |
2628 | | - return testChange.call( this, e ); |
| 2946 | + testChange.call( this, e ); |
2629 | 2947 | } |
2630 | 2948 | }, |
2631 | 2949 | |
— | — | @@ -2633,7 +2951,7 @@ |
2634 | 2952 | // information |
2635 | 2953 | beforeactivate: function( e ) { |
2636 | 2954 | var elem = e.target; |
2637 | | - jQuery.data( elem, "_change_data", getVal(elem) ); |
| 2955 | + jQuery._data( elem, "_change_data", getVal(elem) ); |
2638 | 2956 | } |
2639 | 2957 | }, |
2640 | 2958 | |
— | — | @@ -2663,30 +2981,50 @@ |
2664 | 2982 | } |
2665 | 2983 | |
2666 | 2984 | function trigger( type, elem, args ) { |
2667 | | - args[0].type = type; |
2668 | | - return jQuery.event.handle.apply( elem, args ); |
| 2985 | + // Piggyback on a donor event to simulate a different one. |
| 2986 | + // Fake originalEvent to avoid donor's stopPropagation, but if the |
| 2987 | + // simulated event prevents default then we do the same on the donor. |
| 2988 | + // Don't pass args or remember liveFired; they apply to the donor event. |
| 2989 | + var event = jQuery.extend( {}, args[ 0 ] ); |
| 2990 | + event.type = type; |
| 2991 | + event.originalEvent = {}; |
| 2992 | + event.liveFired = undefined; |
| 2993 | + jQuery.event.handle.call( elem, event ); |
| 2994 | + if ( event.isDefaultPrevented() ) { |
| 2995 | + args[ 0 ].preventDefault(); |
| 2996 | + } |
2669 | 2997 | } |
2670 | 2998 | |
2671 | 2999 | // Create "bubbling" focus and blur events |
2672 | 3000 | if ( document.addEventListener ) { |
2673 | 3001 | jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { |
| 3002 | + |
| 3003 | + // Attach a single capturing handler while someone wants focusin/focusout |
| 3004 | + var attaches = 0; |
| 3005 | + |
2674 | 3006 | jQuery.event.special[ fix ] = { |
2675 | 3007 | setup: function() { |
2676 | | - if ( focusCounts[fix]++ === 0 ) { |
| 3008 | + if ( attaches++ === 0 ) { |
2677 | 3009 | document.addEventListener( orig, handler, true ); |
2678 | 3010 | } |
2679 | | - }, |
2680 | | - teardown: function() { |
2681 | | - if ( --focusCounts[fix] === 0 ) { |
| 3011 | + }, |
| 3012 | + teardown: function() { |
| 3013 | + if ( --attaches === 0 ) { |
2682 | 3014 | document.removeEventListener( orig, handler, true ); |
2683 | 3015 | } |
2684 | 3016 | } |
2685 | 3017 | }; |
2686 | 3018 | |
2687 | | - function handler( e ) { |
2688 | | - e = jQuery.event.fix( e ); |
| 3019 | + function handler( donor ) { |
| 3020 | + // Donor event is always a native one; fix it and switch its type. |
| 3021 | + // Let focusin/out handler cancel the donor focus/blur event. |
| 3022 | + var e = jQuery.event.fix( donor ); |
2689 | 3023 | e.type = fix; |
2690 | | - return jQuery.event.trigger( e, null, e.target ); |
| 3024 | + e.originalEvent = {}; |
| 3025 | + jQuery.event.trigger( e, null, e.target ); |
| 3026 | + if ( e.isDefaultPrevented() ) { |
| 3027 | + donor.preventDefault(); |
| 3028 | + } |
2691 | 3029 | } |
2692 | 3030 | }); |
2693 | 3031 | } |
— | — | @@ -2700,7 +3038,7 @@ |
2701 | 3039 | } |
2702 | 3040 | return this; |
2703 | 3041 | } |
2704 | | - |
| 3042 | + |
2705 | 3043 | if ( jQuery.isFunction( data ) || data === false ) { |
2706 | 3044 | fn = data; |
2707 | 3045 | data = undefined; |
— | — | @@ -2740,20 +3078,20 @@ |
2741 | 3079 | |
2742 | 3080 | return this; |
2743 | 3081 | }, |
2744 | | - |
| 3082 | + |
2745 | 3083 | delegate: function( selector, types, data, fn ) { |
2746 | 3084 | return this.live( types, data, fn, selector ); |
2747 | 3085 | }, |
2748 | | - |
| 3086 | + |
2749 | 3087 | undelegate: function( selector, types, fn ) { |
2750 | 3088 | if ( arguments.length === 0 ) { |
2751 | 3089 | return this.unbind( "live" ); |
2752 | | - |
| 3090 | + |
2753 | 3091 | } else { |
2754 | 3092 | return this.die( types, null, fn, selector ); |
2755 | 3093 | } |
2756 | 3094 | }, |
2757 | | - |
| 3095 | + |
2758 | 3096 | trigger: function( type, data ) { |
2759 | 3097 | return this.each(function() { |
2760 | 3098 | jQuery.event.trigger( type, data, this ); |
— | — | @@ -2782,8 +3120,8 @@ |
2783 | 3121 | |
2784 | 3122 | return this.click( jQuery.proxy( fn, function( event ) { |
2785 | 3123 | // 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 ); |
| 3124 | + var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; |
| 3125 | + jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); |
2788 | 3126 | |
2789 | 3127 | // Make sure that clicks stop |
2790 | 3128 | event.preventDefault(); |
— | — | @@ -2810,12 +3148,12 @@ |
2811 | 3149 | var type, i = 0, match, namespaces, preType, |
2812 | 3150 | selector = origSelector || this.selector, |
2813 | 3151 | context = origSelector ? this : jQuery( this.context ); |
2814 | | - |
| 3152 | + |
2815 | 3153 | if ( typeof types === "object" && !types.preventDefault ) { |
2816 | 3154 | for ( var key in types ) { |
2817 | 3155 | context[ name ]( key, data, types[key], selector ); |
2818 | 3156 | } |
2819 | | - |
| 3157 | + |
2820 | 3158 | return this; |
2821 | 3159 | } |
2822 | 3160 | |
— | — | @@ -2862,7 +3200,7 @@ |
2863 | 3201 | context.unbind( "live." + liveConvert( type, selector ), fn ); |
2864 | 3202 | } |
2865 | 3203 | } |
2866 | | - |
| 3204 | + |
2867 | 3205 | return this; |
2868 | 3206 | }; |
2869 | 3207 | }); |
— | — | @@ -2871,17 +3209,13 @@ |
2872 | 3210 | var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret, |
2873 | 3211 | elems = [], |
2874 | 3212 | selectors = [], |
2875 | | - events = jQuery.data( this, this.nodeType ? "events" : "__events__" ); |
| 3213 | + events = jQuery._data( this, "events" ); |
2876 | 3214 | |
2877 | | - if ( typeof events === "function" ) { |
2878 | | - events = events.events; |
| 3215 | + // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911) |
| 3216 | + if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) { |
| 3217 | + return; |
2879 | 3218 | } |
2880 | 3219 | |
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 | 3220 | if ( event.namespace ) { |
2887 | 3221 | namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)"); |
2888 | 3222 | } |
— | — | @@ -2909,7 +3243,7 @@ |
2910 | 3244 | for ( j = 0; j < live.length; j++ ) { |
2911 | 3245 | handleObj = live[j]; |
2912 | 3246 | |
2913 | | - if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) { |
| 3247 | + if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) { |
2914 | 3248 | elem = close.elem; |
2915 | 3249 | related = null; |
2916 | 3250 | |
— | — | @@ -2979,27 +3313,10 @@ |
2980 | 3314 | } |
2981 | 3315 | }); |
2982 | 3316 | |
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 | 3317 | |
3000 | | - |
3001 | 3318 | /*! |
3002 | | - * Sizzle CSS Selector Engine - v1.0 |
3003 | | - * Copyright 2009, The Dojo Foundation |
| 3319 | + * Sizzle CSS Selector Engine |
| 3320 | + * Copyright 2011, The Dojo Foundation |
3004 | 3321 | * Released under the MIT, BSD, and GPL Licenses. |
3005 | 3322 | * More information: http://sizzlejs.com/ |
3006 | 3323 | */ |
— | — | @@ -3009,7 +3326,9 @@ |
3010 | 3327 | done = 0, |
3011 | 3328 | toString = Object.prototype.toString, |
3012 | 3329 | hasDuplicate = false, |
3013 | | - baseHasDuplicate = true; |
| 3330 | + baseHasDuplicate = true, |
| 3331 | + rBackslash = /\\/g, |
| 3332 | + rNonWord = /\W/; |
3014 | 3333 | |
3015 | 3334 | // Here we check if the JavaScript engine is using some sort of |
3016 | 3335 | // optimization where it does not always call our comparision |
— | — | @@ -3208,7 +3527,7 @@ |
3209 | 3528 | match.splice( 1, 1 ); |
3210 | 3529 | |
3211 | 3530 | if ( left.substr( left.length - 1 ) !== "\\" ) { |
3212 | | - match[1] = (match[1] || "").replace(/\\/g, ""); |
| 3531 | + match[1] = (match[1] || "").replace( rBackslash, "" ); |
3213 | 3532 | set = Expr.find[ type ]( match, context, isXML ); |
3214 | 3533 | |
3215 | 3534 | if ( set != null ) { |
— | — | @@ -3220,7 +3539,9 @@ |
3221 | 3540 | } |
3222 | 3541 | |
3223 | 3542 | if ( !set ) { |
3224 | | - set = context.getElementsByTagName( "*" ); |
| 3543 | + set = typeof context.getElementsByTagName !== "undefined" ? |
| 3544 | + context.getElementsByTagName( "*" ) : |
| 3545 | + []; |
3225 | 3546 | } |
3226 | 3547 | |
3227 | 3548 | return { set: set, expr: expr }; |
— | — | @@ -3328,9 +3649,9 @@ |
3329 | 3650 | ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, |
3330 | 3651 | CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, |
3331 | 3652 | NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, |
3332 | | - ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, |
| 3653 | + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, |
3333 | 3654 | TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, |
3334 | | - CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/, |
| 3655 | + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, |
3335 | 3656 | POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, |
3336 | 3657 | PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ |
3337 | 3658 | }, |
— | — | @@ -3345,13 +3666,16 @@ |
3346 | 3667 | attrHandle: { |
3347 | 3668 | href: function( elem ) { |
3348 | 3669 | return elem.getAttribute( "href" ); |
| 3670 | + }, |
| 3671 | + type: function( elem ) { |
| 3672 | + return elem.getAttribute( "type" ); |
3349 | 3673 | } |
3350 | 3674 | }, |
3351 | 3675 | |
3352 | 3676 | relative: { |
3353 | 3677 | "+": function(checkSet, part){ |
3354 | 3678 | var isPartStr = typeof part === "string", |
3355 | | - isTag = isPartStr && !/\W/.test( part ), |
| 3679 | + isTag = isPartStr && !rNonWord.test( part ), |
3356 | 3680 | isPartStrNotTag = isPartStr && !isTag; |
3357 | 3681 | |
3358 | 3682 | if ( isTag ) { |
— | — | @@ -3379,7 +3703,7 @@ |
3380 | 3704 | i = 0, |
3381 | 3705 | l = checkSet.length; |
3382 | 3706 | |
3383 | | - if ( isPartStr && !/\W/.test( part ) ) { |
| 3707 | + if ( isPartStr && !rNonWord.test( part ) ) { |
3384 | 3708 | part = part.toLowerCase(); |
3385 | 3709 | |
3386 | 3710 | for ( ; i < l; i++ ) { |
— | — | @@ -3413,7 +3737,7 @@ |
3414 | 3738 | doneName = done++, |
3415 | 3739 | checkFn = dirCheck; |
3416 | 3740 | |
3417 | | - if ( typeof part === "string" && !/\W/.test(part) ) { |
| 3741 | + if ( typeof part === "string" && !rNonWord.test( part ) ) { |
3418 | 3742 | part = part.toLowerCase(); |
3419 | 3743 | nodeCheck = part; |
3420 | 3744 | checkFn = dirNodeCheck; |
— | — | @@ -3427,7 +3751,7 @@ |
3428 | 3752 | doneName = done++, |
3429 | 3753 | checkFn = dirCheck; |
3430 | 3754 | |
3431 | | - if ( typeof part === "string" && !/\W/.test( part ) ) { |
| 3755 | + if ( typeof part === "string" && !rNonWord.test( part ) ) { |
3432 | 3756 | part = part.toLowerCase(); |
3433 | 3757 | nodeCheck = part; |
3434 | 3758 | checkFn = dirNodeCheck; |
— | — | @@ -3463,12 +3787,14 @@ |
3464 | 3788 | }, |
3465 | 3789 | |
3466 | 3790 | TAG: function( match, context ) { |
3467 | | - return context.getElementsByTagName( match[1] ); |
| 3791 | + if ( typeof context.getElementsByTagName !== "undefined" ) { |
| 3792 | + return context.getElementsByTagName( match[1] ); |
| 3793 | + } |
3468 | 3794 | } |
3469 | 3795 | }, |
3470 | 3796 | preFilter: { |
3471 | 3797 | CLASS: function( match, curLoop, inplace, result, not, isXML ) { |
3472 | | - match = " " + match[1].replace(/\\/g, "") + " "; |
| 3798 | + match = " " + match[1].replace( rBackslash, "" ) + " "; |
3473 | 3799 | |
3474 | 3800 | if ( isXML ) { |
3475 | 3801 | return match; |
— | — | @@ -3476,7 +3802,7 @@ |
3477 | 3803 | |
3478 | 3804 | for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { |
3479 | 3805 | if ( elem ) { |
3480 | | - if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) { |
| 3806 | + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { |
3481 | 3807 | if ( !inplace ) { |
3482 | 3808 | result.push( elem ); |
3483 | 3809 | } |
— | — | @@ -3491,17 +3817,23 @@ |
3492 | 3818 | }, |
3493 | 3819 | |
3494 | 3820 | ID: function( match ) { |
3495 | | - return match[1].replace(/\\/g, ""); |
| 3821 | + return match[1].replace( rBackslash, "" ); |
3496 | 3822 | }, |
3497 | 3823 | |
3498 | 3824 | TAG: function( match, curLoop ) { |
3499 | | - return match[1].toLowerCase(); |
| 3825 | + return match[1].replace( rBackslash, "" ).toLowerCase(); |
3500 | 3826 | }, |
3501 | 3827 | |
3502 | 3828 | CHILD: function( match ) { |
3503 | 3829 | if ( match[1] === "nth" ) { |
| 3830 | + if ( !match[2] ) { |
| 3831 | + Sizzle.error( match[0] ); |
| 3832 | + } |
| 3833 | + |
| 3834 | + match[2] = match[2].replace(/^\+|\s*/g, ''); |
| 3835 | + |
3504 | 3836 | // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' |
3505 | | - var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( |
| 3837 | + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( |
3506 | 3838 | match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || |
3507 | 3839 | !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); |
3508 | 3840 | |
— | — | @@ -3509,6 +3841,9 @@ |
3510 | 3842 | match[2] = (test[1] + (test[2] || 1)) - 0; |
3511 | 3843 | match[3] = test[3] - 0; |
3512 | 3844 | } |
| 3845 | + else if ( match[2] ) { |
| 3846 | + Sizzle.error( match[0] ); |
| 3847 | + } |
3513 | 3848 | |
3514 | 3849 | // TODO: Move to normal caching system |
3515 | 3850 | match[0] = done++; |
— | — | @@ -3517,12 +3852,15 @@ |
3518 | 3853 | }, |
3519 | 3854 | |
3520 | 3855 | ATTR: function( match, curLoop, inplace, result, not, isXML ) { |
3521 | | - var name = match[1].replace(/\\/g, ""); |
| 3856 | + var name = match[1] = match[1].replace( rBackslash, "" ); |
3522 | 3857 | |
3523 | 3858 | if ( !isXML && Expr.attrMap[name] ) { |
3524 | 3859 | match[1] = Expr.attrMap[name]; |
3525 | 3860 | } |
3526 | 3861 | |
| 3862 | + // Handle if an un-quoted value was used |
| 3863 | + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); |
| 3864 | + |
3527 | 3865 | if ( match[2] === "~=" ) { |
3528 | 3866 | match[4] = " " + match[4] + " "; |
3529 | 3867 | } |
— | — | @@ -3576,7 +3914,9 @@ |
3577 | 3915 | selected: function( elem ) { |
3578 | 3916 | // Accessing this property makes selected-by-default |
3579 | 3917 | // options in Safari work properly |
3580 | | - elem.parentNode.selectedIndex; |
| 3918 | + if ( elem.parentNode ) { |
| 3919 | + elem.parentNode.selectedIndex; |
| 3920 | + } |
3581 | 3921 | |
3582 | 3922 | return elem.selected === true; |
3583 | 3923 | }, |
— | — | @@ -3598,8 +3938,12 @@ |
3599 | 3939 | }, |
3600 | 3940 | |
3601 | 3941 | text: function( elem ) { |
3602 | | - return "text" === elem.type; |
| 3942 | + var attr = elem.getAttribute( "type" ), type = elem.type; |
| 3943 | + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) |
| 3944 | + // use getAttribute instead to test this case |
| 3945 | + return "text" === type && ( attr === type || attr === null ); |
3603 | 3946 | }, |
| 3947 | + |
3604 | 3948 | radio: function( elem ) { |
3605 | 3949 | return "radio" === elem.type; |
3606 | 3950 | }, |
— | — | @@ -3691,7 +4035,7 @@ |
3692 | 4036 | return true; |
3693 | 4037 | |
3694 | 4038 | } else { |
3695 | | - Sizzle.error( "Syntax error, unrecognized expression: " + name ); |
| 4039 | + Sizzle.error( name ); |
3696 | 4040 | } |
3697 | 4041 | }, |
3698 | 4042 | |
— | — | @@ -4081,13 +4425,47 @@ |
4082 | 4426 | Sizzle = function( query, context, extra, seed ) { |
4083 | 4427 | context = context || document; |
4084 | 4428 | |
4085 | | - // Make sure that attribute selectors are quoted |
4086 | | - query = query.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); |
4087 | | - |
4088 | 4429 | // Only use querySelectorAll on non-XML documents |
4089 | 4430 | // (ID selectors don't work in non-HTML documents) |
4090 | 4431 | if ( !seed && !Sizzle.isXML(context) ) { |
| 4432 | + // See if we find a selector to speed up |
| 4433 | + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); |
| 4434 | + |
| 4435 | + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { |
| 4436 | + // Speed-up: Sizzle("TAG") |
| 4437 | + if ( match[1] ) { |
| 4438 | + return makeArray( context.getElementsByTagName( query ), extra ); |
| 4439 | + |
| 4440 | + // Speed-up: Sizzle(".CLASS") |
| 4441 | + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { |
| 4442 | + return makeArray( context.getElementsByClassName( match[2] ), extra ); |
| 4443 | + } |
| 4444 | + } |
| 4445 | + |
4091 | 4446 | if ( context.nodeType === 9 ) { |
| 4447 | + // Speed-up: Sizzle("body") |
| 4448 | + // The body element only exists once, optimize finding it |
| 4449 | + if ( query === "body" && context.body ) { |
| 4450 | + return makeArray( [ context.body ], extra ); |
| 4451 | + |
| 4452 | + // Speed-up: Sizzle("#ID") |
| 4453 | + } else if ( match && match[3] ) { |
| 4454 | + var elem = context.getElementById( match[3] ); |
| 4455 | + |
| 4456 | + // Check parentNode to catch when Blackberry 4.6 returns |
| 4457 | + // nodes that are no longer in the document #6963 |
| 4458 | + if ( elem && elem.parentNode ) { |
| 4459 | + // Handle the case where IE and Opera return items |
| 4460 | + // by name instead of ID |
| 4461 | + if ( elem.id === match[3] ) { |
| 4462 | + return makeArray( [ elem ], extra ); |
| 4463 | + } |
| 4464 | + |
| 4465 | + } else { |
| 4466 | + return makeArray( [], extra ); |
| 4467 | + } |
| 4468 | + } |
| 4469 | + |
4092 | 4470 | try { |
4093 | 4471 | return makeArray( context.querySelectorAll(query), extra ); |
4094 | 4472 | } catch(qsaError) {} |
— | — | @@ -4097,20 +4475,30 @@ |
4098 | 4476 | // and working up from there (Thanks to Andrew Dupont for the technique) |
4099 | 4477 | // IE 8 doesn't work on object elements |
4100 | 4478 | } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { |
4101 | | - var old = context.getAttribute( "id" ), |
4102 | | - nid = old || id; |
| 4479 | + var oldContext = context, |
| 4480 | + old = context.getAttribute( "id" ), |
| 4481 | + nid = old || id, |
| 4482 | + hasParent = context.parentNode, |
| 4483 | + relativeHierarchySelector = /^\s*[+~]/.test( query ); |
4103 | 4484 | |
4104 | 4485 | if ( !old ) { |
4105 | 4486 | context.setAttribute( "id", nid ); |
| 4487 | + } else { |
| 4488 | + nid = nid.replace( /'/g, "\\$&" ); |
4106 | 4489 | } |
| 4490 | + if ( relativeHierarchySelector && hasParent ) { |
| 4491 | + context = context.parentNode; |
| 4492 | + } |
4107 | 4493 | |
4108 | 4494 | try { |
4109 | | - return makeArray( context.querySelectorAll( "#" + nid + " " + query ), extra ); |
| 4495 | + if ( !relativeHierarchySelector || hasParent ) { |
| 4496 | + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); |
| 4497 | + } |
4110 | 4498 | |
4111 | 4499 | } catch(pseudoError) { |
4112 | 4500 | } finally { |
4113 | 4501 | if ( !old ) { |
4114 | | - context.removeAttribute( "id" ); |
| 4502 | + oldContext.removeAttribute( "id" ); |
4115 | 4503 | } |
4116 | 4504 | } |
4117 | 4505 | } |
— | — | @@ -4130,19 +4518,23 @@ |
4131 | 4519 | |
4132 | 4520 | (function(){ |
4133 | 4521 | var html = document.documentElement, |
4134 | | - matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector, |
4135 | | - pseudoWorks = false; |
| 4522 | + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; |
4136 | 4523 | |
4137 | | - try { |
4138 | | - // This should fail with an exception |
4139 | | - // Gecko does not error, returns false instead |
4140 | | - matches.call( document.documentElement, "[test!='']:sizzle" ); |
| 4524 | + if ( matches ) { |
| 4525 | + // Check to see if it's possible to do matchesSelector |
| 4526 | + // on a disconnected node (IE 9 fails this) |
| 4527 | + var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), |
| 4528 | + pseudoWorks = false; |
| 4529 | + |
| 4530 | + try { |
| 4531 | + // This should fail with an exception |
| 4532 | + // Gecko does not error, returns false instead |
| 4533 | + matches.call( document.documentElement, "[test!='']:sizzle" ); |
4141 | 4534 | |
4142 | | - } catch( pseudoError ) { |
4143 | | - pseudoWorks = true; |
4144 | | - } |
| 4535 | + } catch( pseudoError ) { |
| 4536 | + pseudoWorks = true; |
| 4537 | + } |
4145 | 4538 | |
4146 | | - if ( matches ) { |
4147 | 4539 | Sizzle.matchesSelector = function( node, expr ) { |
4148 | 4540 | // Make sure that attribute selectors are quoted |
4149 | 4541 | expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); |
— | — | @@ -4150,7 +4542,15 @@ |
4151 | 4543 | if ( !Sizzle.isXML( node ) ) { |
4152 | 4544 | try { |
4153 | 4545 | if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { |
4154 | | - return matches.call( node, expr ); |
| 4546 | + var ret = matches.call( node, expr ); |
| 4547 | + |
| 4548 | + // IE 9's matchesSelector returns false on disconnected nodes |
| 4549 | + if ( ret || !disconnectedMatch || |
| 4550 | + // As well, disconnected nodes are said to be in a document |
| 4551 | + // fragment in IE 9, so check for that |
| 4552 | + node.document && node.document.nodeType !== 11 ) { |
| 4553 | + return ret; |
| 4554 | + } |
4155 | 4555 | } |
4156 | 4556 | } catch(e) {} |
4157 | 4557 | } |
— | — | @@ -4328,7 +4728,14 @@ |
4329 | 4729 | rmultiselector = /,/, |
4330 | 4730 | isSimple = /^.[^:#\[\.,]*$/, |
4331 | 4731 | slice = Array.prototype.slice, |
4332 | | - POS = jQuery.expr.match.POS; |
| 4732 | + POS = jQuery.expr.match.POS, |
| 4733 | + // methods guaranteed to produce a unique set when starting from a unique set |
| 4734 | + guaranteedUnique = { |
| 4735 | + children: true, |
| 4736 | + contents: true, |
| 4737 | + next: true, |
| 4738 | + prev: true |
| 4739 | + }; |
4333 | 4740 | |
4334 | 4741 | jQuery.fn.extend({ |
4335 | 4742 | find: function( selector ) { |
— | — | @@ -4373,7 +4780,7 @@ |
4374 | 4781 | filter: function( selector ) { |
4375 | 4782 | return this.pushStack( winnow(this, selector, true), "filter", selector ); |
4376 | 4783 | }, |
4377 | | - |
| 4784 | + |
4378 | 4785 | is: function( selector ) { |
4379 | 4786 | return !!selector && jQuery.filter( selector, this ).length > 0; |
4380 | 4787 | }, |
— | — | @@ -4391,7 +4798,7 @@ |
4392 | 4799 | selector = selectors[i]; |
4393 | 4800 | |
4394 | 4801 | if ( !matches[selector] ) { |
4395 | | - matches[selector] = jQuery.expr.match.POS.test( selector ) ? |
| 4802 | + matches[selector] = jQuery.expr.match.POS.test( selector ) ? |
4396 | 4803 | jQuery( selector, context || this.context ) : |
4397 | 4804 | selector; |
4398 | 4805 | } |
— | — | @@ -4414,7 +4821,7 @@ |
4415 | 4822 | return ret; |
4416 | 4823 | } |
4417 | 4824 | |
4418 | | - var pos = POS.test( selectors ) ? |
| 4825 | + var pos = POS.test( selectors ) ? |
4419 | 4826 | jQuery( selectors, context || this.context ) : null; |
4420 | 4827 | |
4421 | 4828 | for ( i = 0, l = this.length; i < l; i++ ) { |
— | — | @@ -4435,10 +4842,10 @@ |
4436 | 4843 | } |
4437 | 4844 | |
4438 | 4845 | ret = ret.length > 1 ? jQuery.unique(ret) : ret; |
4439 | | - |
| 4846 | + |
4440 | 4847 | return this.pushStack( ret, "closest", selectors ); |
4441 | 4848 | }, |
4442 | | - |
| 4849 | + |
4443 | 4850 | // Determine the position of an element within |
4444 | 4851 | // the matched set of elements |
4445 | 4852 | index: function( elem ) { |
— | — | @@ -4456,7 +4863,7 @@ |
4457 | 4864 | |
4458 | 4865 | add: function( selector, context ) { |
4459 | 4866 | var set = typeof selector === "string" ? |
4460 | | - jQuery( selector, context || this.context ) : |
| 4867 | + jQuery( selector, context ) : |
4461 | 4868 | jQuery.makeArray( selector ), |
4462 | 4869 | all = jQuery.merge( this.get(), set ); |
4463 | 4870 | |
— | — | @@ -4518,8 +4925,13 @@ |
4519 | 4926 | } |
4520 | 4927 | }, function( name, fn ) { |
4521 | 4928 | jQuery.fn[ name ] = function( until, selector ) { |
4522 | | - var ret = jQuery.map( this, fn, until ); |
4523 | | - |
| 4929 | + var ret = jQuery.map( this, fn, until ), |
| 4930 | + // The variable 'args' was introduced in |
| 4931 | + // https://github.com/jquery/jquery/commit/52a0238 |
| 4932 | + // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. |
| 4933 | + // http://code.google.com/p/v8/issues/detail?id=1050 |
| 4934 | + args = slice.call(arguments); |
| 4935 | + |
4524 | 4936 | if ( !runtil.test( name ) ) { |
4525 | 4937 | selector = until; |
4526 | 4938 | } |
— | — | @@ -4528,13 +4940,13 @@ |
4529 | 4941 | ret = jQuery.filter( selector, ret ); |
4530 | 4942 | } |
4531 | 4943 | |
4532 | | - ret = this.length > 1 ? jQuery.unique( ret ) : ret; |
| 4944 | + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; |
4533 | 4945 | |
4534 | 4946 | if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { |
4535 | 4947 | ret = ret.reverse(); |
4536 | 4948 | } |
4537 | 4949 | |
4538 | | - return this.pushStack( ret, name, slice.call(arguments).join(",") ); |
| 4950 | + return this.pushStack( ret, name, args.join(",") ); |
4539 | 4951 | }; |
4540 | 4952 | }); |
4541 | 4953 | |
— | — | @@ -4548,7 +4960,7 @@ |
4549 | 4961 | jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : |
4550 | 4962 | jQuery.find.matches(expr, elems); |
4551 | 4963 | }, |
4552 | | - |
| 4964 | + |
4553 | 4965 | dir: function( elem, dir, until ) { |
4554 | 4966 | var matched = [], |
4555 | 4967 | cur = elem[ dir ]; |
— | — | @@ -4628,9 +5040,8 @@ |
4629 | 5041 | rtbody = /<tbody/i, |
4630 | 5042 | rhtml = /<|&#?\w+;/, |
4631 | 5043 | rnocache = /<(?:script|object|embed|option|style)/i, |
4632 | | - // checked="checked" or checked (html5) |
| 5044 | + // checked="checked" or checked |
4633 | 5045 | rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, |
4634 | | - raction = /\=([^="'>\s]+\/)>/g, |
4635 | 5046 | wrapMap = { |
4636 | 5047 | option: [ 1, "<select multiple='multiple'>", "</select>" ], |
4637 | 5048 | legend: [ 1, "<fieldset>", "</fieldset>" ], |
— | — | @@ -4770,7 +5181,7 @@ |
4771 | 5182 | return set; |
4772 | 5183 | } |
4773 | 5184 | }, |
4774 | | - |
| 5185 | + |
4775 | 5186 | // keepData is for internal use only--do not document |
4776 | 5187 | remove: function( selector, keepData ) { |
4777 | 5188 | for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { |
— | — | @@ -4781,11 +5192,11 @@ |
4782 | 5193 | } |
4783 | 5194 | |
4784 | 5195 | if ( elem.parentNode ) { |
4785 | | - elem.parentNode.removeChild( elem ); |
| 5196 | + elem.parentNode.removeChild( elem ); |
4786 | 5197 | } |
4787 | 5198 | } |
4788 | 5199 | } |
4789 | | - |
| 5200 | + |
4790 | 5201 | return this; |
4791 | 5202 | }, |
4792 | 5203 | |
— | — | @@ -4801,48 +5212,17 @@ |
4802 | 5213 | elem.removeChild( elem.firstChild ); |
4803 | 5214 | } |
4804 | 5215 | } |
4805 | | - |
| 5216 | + |
4806 | 5217 | return this; |
4807 | 5218 | }, |
4808 | 5219 | |
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; |
| 5220 | + clone: function( dataAndEvents, deepDataAndEvents ) { |
| 5221 | + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; |
| 5222 | + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; |
4823 | 5223 | |
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 | | - } |
| 5224 | + return this.map( function () { |
| 5225 | + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); |
4837 | 5226 | }); |
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 | 5227 | }, |
4848 | 5228 | |
4849 | 5229 | html: function( value ) { |
— | — | @@ -4914,7 +5294,9 @@ |
4915 | 5295 | } |
4916 | 5296 | }); |
4917 | 5297 | } else { |
4918 | | - return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ); |
| 5298 | + return this.length ? |
| 5299 | + this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) : |
| 5300 | + this; |
4919 | 5301 | } |
4920 | 5302 | }, |
4921 | 5303 | |
— | — | @@ -4952,9 +5334,9 @@ |
4953 | 5335 | } else { |
4954 | 5336 | results = jQuery.buildFragment( args, this, scripts ); |
4955 | 5337 | } |
4956 | | - |
| 5338 | + |
4957 | 5339 | fragment = results.fragment; |
4958 | | - |
| 5340 | + |
4959 | 5341 | if ( fragment.childNodes.length === 1 ) { |
4960 | 5342 | first = fragment = fragment.firstChild; |
4961 | 5343 | } else { |
— | — | @@ -4964,13 +5346,20 @@ |
4965 | 5347 | if ( first ) { |
4966 | 5348 | table = table && jQuery.nodeName( first, "tr" ); |
4967 | 5349 | |
4968 | | - for ( var i = 0, l = this.length; i < l; i++ ) { |
| 5350 | + for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) { |
4969 | 5351 | callback.call( |
4970 | 5352 | table ? |
4971 | 5353 | root(this[i], first) : |
4972 | 5354 | this[i], |
4973 | | - i > 0 || results.cacheable || this.length > 1 ? |
4974 | | - fragment.cloneNode(true) : |
| 5355 | + // Make sure that we do not leak memory by inadvertently discarding |
| 5356 | + // the original fragment (which might have attached data) instead of |
| 5357 | + // using it; in addition, use the original fragment object for the last |
| 5358 | + // item instead of first because it can end up being emptied incorrectly |
| 5359 | + // in certain situations (Bug #8070). |
| 5360 | + // Fragments from the fragment cache must always be cloned and never used |
| 5361 | + // in place. |
| 5362 | + results.cacheable || (l > 1 && i < lastIndex) ? |
| 5363 | + jQuery.clone( fragment, true, true ) : |
4975 | 5364 | fragment |
4976 | 5365 | ); |
4977 | 5366 | } |
— | — | @@ -4992,41 +5381,97 @@ |
4993 | 5382 | elem; |
4994 | 5383 | } |
4995 | 5384 | |
4996 | | -function cloneCopyEvent(orig, ret) { |
4997 | | - var i = 0; |
| 5385 | +function cloneCopyEvent( src, dest ) { |
4998 | 5386 | |
4999 | | - ret.each(function() { |
5000 | | - if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) { |
5001 | | - return; |
5002 | | - } |
| 5387 | + if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { |
| 5388 | + return; |
| 5389 | + } |
5003 | 5390 | |
5004 | | - var oldData = jQuery.data( orig[i++] ), |
5005 | | - curData = jQuery.data( this, oldData ), |
5006 | | - events = oldData && oldData.events; |
| 5391 | + var internalKey = jQuery.expando, |
| 5392 | + oldData = jQuery.data( src ), |
| 5393 | + curData = jQuery.data( dest, oldData ); |
5007 | 5394 | |
| 5395 | + // Switch to use the internal data object, if it exists, for the next |
| 5396 | + // stage of data copying |
| 5397 | + if ( (oldData = oldData[ internalKey ]) ) { |
| 5398 | + var events = oldData.events; |
| 5399 | + curData = curData[ internalKey ] = jQuery.extend({}, oldData); |
| 5400 | + |
5008 | 5401 | if ( events ) { |
5009 | 5402 | delete curData.handle; |
5010 | 5403 | curData.events = {}; |
5011 | 5404 | |
5012 | 5405 | 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 ); |
| 5406 | + for ( var i = 0, l = events[ type ].length; i < l; i++ ) { |
| 5407 | + jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data ); |
5015 | 5408 | } |
5016 | 5409 | } |
5017 | 5410 | } |
5018 | | - }); |
| 5411 | + } |
5019 | 5412 | } |
5020 | 5413 | |
| 5414 | +function cloneFixAttributes(src, dest) { |
| 5415 | + // We do not need to do anything for non-Elements |
| 5416 | + if ( dest.nodeType !== 1 ) { |
| 5417 | + return; |
| 5418 | + } |
| 5419 | + |
| 5420 | + var nodeName = dest.nodeName.toLowerCase(); |
| 5421 | + |
| 5422 | + // clearAttributes removes the attributes, which we don't want, |
| 5423 | + // but also removes the attachEvent events, which we *do* want |
| 5424 | + dest.clearAttributes(); |
| 5425 | + |
| 5426 | + // mergeAttributes, in contrast, only merges back on the |
| 5427 | + // original attributes, not the events |
| 5428 | + dest.mergeAttributes(src); |
| 5429 | + |
| 5430 | + // IE6-8 fail to clone children inside object elements that use |
| 5431 | + // the proprietary classid attribute value (rather than the type |
| 5432 | + // attribute) to identify the type of content to display |
| 5433 | + if ( nodeName === "object" ) { |
| 5434 | + dest.outerHTML = src.outerHTML; |
| 5435 | + |
| 5436 | + } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) { |
| 5437 | + // IE6-8 fails to persist the checked state of a cloned checkbox |
| 5438 | + // or radio button. Worse, IE6-7 fail to give the cloned element |
| 5439 | + // a checked appearance if the defaultChecked value isn't also set |
| 5440 | + if ( src.checked ) { |
| 5441 | + dest.defaultChecked = dest.checked = src.checked; |
| 5442 | + } |
| 5443 | + |
| 5444 | + // IE6-7 get confused and end up setting the value of a cloned |
| 5445 | + // checkbox/radio button to an empty string instead of "on" |
| 5446 | + if ( dest.value !== src.value ) { |
| 5447 | + dest.value = src.value; |
| 5448 | + } |
| 5449 | + |
| 5450 | + // IE6-8 fails to return the selected option to the default selected |
| 5451 | + // state when cloning options |
| 5452 | + } else if ( nodeName === "option" ) { |
| 5453 | + dest.selected = src.defaultSelected; |
| 5454 | + |
| 5455 | + // IE6-8 fails to set the defaultValue to the correct value when |
| 5456 | + // cloning other types of input fields |
| 5457 | + } else if ( nodeName === "input" || nodeName === "textarea" ) { |
| 5458 | + dest.defaultValue = src.defaultValue; |
| 5459 | + } |
| 5460 | + |
| 5461 | + // Event data gets referenced instead of copied if the expando |
| 5462 | + // gets copied too |
| 5463 | + dest.removeAttribute( jQuery.expando ); |
| 5464 | +} |
| 5465 | + |
5021 | 5466 | jQuery.buildFragment = function( args, nodes, scripts ) { |
5022 | 5467 | var fragment, cacheable, cacheresults, |
5023 | 5468 | doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document); |
5024 | 5469 | |
5025 | | - // Only cache "small" (1/2 KB) strings that are associated with the main document |
| 5470 | + // Only cache "small" (1/2 KB) HTML strings that are associated with the main document |
5026 | 5471 | // Cloning options loses the selected state, so don't cache them |
5027 | 5472 | // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment |
5028 | 5473 | // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache |
5029 | 5474 | 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] )) ) { |
| 5475 | + args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) { |
5031 | 5476 | |
5032 | 5477 | cacheable = true; |
5033 | 5478 | cacheresults = jQuery.fragments[ args[0] ]; |
— | — | @@ -5062,24 +5507,82 @@ |
5063 | 5508 | var ret = [], |
5064 | 5509 | insert = jQuery( selector ), |
5065 | 5510 | parent = this.length === 1 && this[0].parentNode; |
5066 | | - |
| 5511 | + |
5067 | 5512 | if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) { |
5068 | 5513 | insert[ original ]( this[0] ); |
5069 | 5514 | return this; |
5070 | | - |
| 5515 | + |
5071 | 5516 | } else { |
5072 | 5517 | for ( var i = 0, l = insert.length; i < l; i++ ) { |
5073 | 5518 | var elems = (i > 0 ? this.clone(true) : this).get(); |
5074 | 5519 | jQuery( insert[i] )[ original ]( elems ); |
5075 | 5520 | ret = ret.concat( elems ); |
5076 | 5521 | } |
5077 | | - |
| 5522 | + |
5078 | 5523 | return this.pushStack( ret, name, insert.selector ); |
5079 | 5524 | } |
5080 | 5525 | }; |
5081 | 5526 | }); |
5082 | 5527 | |
| 5528 | +function getAll( elem ) { |
| 5529 | + if ( "getElementsByTagName" in elem ) { |
| 5530 | + return elem.getElementsByTagName( "*" ); |
| 5531 | + |
| 5532 | + } else if ( "querySelectorAll" in elem ) { |
| 5533 | + return elem.querySelectorAll( "*" ); |
| 5534 | + |
| 5535 | + } else { |
| 5536 | + return []; |
| 5537 | + } |
| 5538 | +} |
| 5539 | + |
5083 | 5540 | jQuery.extend({ |
| 5541 | + clone: function( elem, dataAndEvents, deepDataAndEvents ) { |
| 5542 | + var clone = elem.cloneNode(true), |
| 5543 | + srcElements, |
| 5544 | + destElements, |
| 5545 | + i; |
| 5546 | + |
| 5547 | + if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && |
| 5548 | + (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { |
| 5549 | + // IE copies events bound via attachEvent when using cloneNode. |
| 5550 | + // Calling detachEvent on the clone will also remove the events |
| 5551 | + // from the original. In order to get around this, we use some |
| 5552 | + // proprietary methods to clear the events. Thanks to MooTools |
| 5553 | + // guys for this hotness. |
| 5554 | + |
| 5555 | + cloneFixAttributes( elem, clone ); |
| 5556 | + |
| 5557 | + // Using Sizzle here is crazy slow, so we use getElementsByTagName |
| 5558 | + // instead |
| 5559 | + srcElements = getAll( elem ); |
| 5560 | + destElements = getAll( clone ); |
| 5561 | + |
| 5562 | + // Weird iteration because IE will replace the length property |
| 5563 | + // with an element if you are cloning the body and one of the |
| 5564 | + // elements on the page has a name or id of "length" |
| 5565 | + for ( i = 0; srcElements[i]; ++i ) { |
| 5566 | + cloneFixAttributes( srcElements[i], destElements[i] ); |
| 5567 | + } |
| 5568 | + } |
| 5569 | + |
| 5570 | + // Copy the events from the original to the clone |
| 5571 | + if ( dataAndEvents ) { |
| 5572 | + cloneCopyEvent( elem, clone ); |
| 5573 | + |
| 5574 | + if ( deepDataAndEvents ) { |
| 5575 | + srcElements = getAll( elem ); |
| 5576 | + destElements = getAll( clone ); |
| 5577 | + |
| 5578 | + for ( i = 0; srcElements[i]; ++i ) { |
| 5579 | + cloneCopyEvent( srcElements[i], destElements[i] ); |
| 5580 | + } |
| 5581 | + } |
| 5582 | + } |
| 5583 | + |
| 5584 | + // Return the cloned set |
| 5585 | + return clone; |
| 5586 | +}, |
5084 | 5587 | clean: function( elems, context, fragment, scripts ) { |
5085 | 5588 | context = context || document; |
5086 | 5589 | |
— | — | @@ -5161,7 +5664,7 @@ |
5162 | 5665 | for ( i = 0; ret[i]; i++ ) { |
5163 | 5666 | if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
5164 | 5667 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
5165 | | - |
| 5668 | + |
5166 | 5669 | } else { |
5167 | 5670 | if ( ret[i].nodeType === 1 ) { |
5168 | 5671 | ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
— | — | @@ -5173,40 +5676,45 @@ |
5174 | 5677 | |
5175 | 5678 | return ret; |
5176 | 5679 | }, |
5177 | | - |
| 5680 | + |
5178 | 5681 | cleanData: function( elems ) { |
5179 | | - var data, id, cache = jQuery.cache, |
5180 | | - special = jQuery.event.special, |
| 5682 | + var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special, |
5181 | 5683 | deleteExpando = jQuery.support.deleteExpando; |
5182 | | - |
| 5684 | + |
5183 | 5685 | for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
5184 | 5686 | if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { |
5185 | 5687 | continue; |
5186 | 5688 | } |
5187 | 5689 | |
5188 | 5690 | id = elem[ jQuery.expando ]; |
5189 | | - |
| 5691 | + |
5190 | 5692 | if ( id ) { |
5191 | | - data = cache[ id ]; |
5192 | | - |
| 5693 | + data = cache[ id ] && cache[ id ][ internalKey ]; |
| 5694 | + |
5193 | 5695 | if ( data && data.events ) { |
5194 | 5696 | for ( var type in data.events ) { |
5195 | 5697 | if ( special[ type ] ) { |
5196 | 5698 | jQuery.event.remove( elem, type ); |
5197 | 5699 | |
| 5700 | + // This is a shortcut to avoid jQuery.event.remove's overhead |
5198 | 5701 | } else { |
5199 | 5702 | jQuery.removeEvent( elem, type, data.handle ); |
5200 | 5703 | } |
5201 | 5704 | } |
| 5705 | + |
| 5706 | + // Null the DOM reference to avoid IE6/7/8 leak (#7054) |
| 5707 | + if ( data.handle ) { |
| 5708 | + data.handle.elem = null; |
| 5709 | + } |
5202 | 5710 | } |
5203 | | - |
| 5711 | + |
5204 | 5712 | if ( deleteExpando ) { |
5205 | 5713 | delete elem[ jQuery.expando ]; |
5206 | 5714 | |
5207 | 5715 | } else if ( elem.removeAttribute ) { |
5208 | 5716 | elem.removeAttribute( jQuery.expando ); |
5209 | 5717 | } |
5210 | | - |
| 5718 | + |
5211 | 5719 | delete cache[ id ]; |
5212 | 5720 | } |
5213 | 5721 | } |
— | — | @@ -5235,7 +5743,8 @@ |
5236 | 5744 | var ralpha = /alpha\([^)]*\)/i, |
5237 | 5745 | ropacity = /opacity=([^)]*)/, |
5238 | 5746 | rdashAlpha = /-([a-z])/ig, |
5239 | | - rupper = /([A-Z])/g, |
| 5747 | + // fixed for IE9, see #8346 |
| 5748 | + rupper = /([A-Z]|^ms)/g, |
5240 | 5749 | rnumpx = /^-?\d+(?:px)?$/i, |
5241 | 5750 | rnum = /^-?\d/, |
5242 | 5751 | |
— | — | @@ -5472,6 +5981,28 @@ |
5473 | 5982 | }; |
5474 | 5983 | } |
5475 | 5984 | |
| 5985 | +jQuery(function() { |
| 5986 | + // This hook cannot be added until DOM ready because the support test |
| 5987 | + // for it is not run until after DOM ready |
| 5988 | + if ( !jQuery.support.reliableMarginRight ) { |
| 5989 | + jQuery.cssHooks.marginRight = { |
| 5990 | + get: function( elem, computed ) { |
| 5991 | + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right |
| 5992 | + // Work around by temporarily setting element display to inline-block |
| 5993 | + var ret; |
| 5994 | + jQuery.swap( elem, { "display": "inline-block" }, function() { |
| 5995 | + if ( computed ) { |
| 5996 | + ret = curCSS( elem, "margin-right", "marginRight" ); |
| 5997 | + } else { |
| 5998 | + ret = elem.style.marginRight; |
| 5999 | + } |
| 6000 | + }); |
| 6001 | + return ret; |
| 6002 | + } |
| 6003 | + }; |
| 6004 | + } |
| 6005 | +}); |
| 6006 | + |
5476 | 6007 | if ( document.defaultView && document.defaultView.getComputedStyle ) { |
5477 | 6008 | getComputedStyle = function( elem, newName, name ) { |
5478 | 6009 | var ret, defaultView, computedStyle; |
— | — | @@ -5495,8 +6026,9 @@ |
5496 | 6027 | |
5497 | 6028 | if ( document.documentElement.currentStyle ) { |
5498 | 6029 | currentStyle = function( elem, name ) { |
5499 | | - var left, rsLeft, |
| 6030 | + var left, |
5500 | 6031 | ret = elem.currentStyle && elem.currentStyle[ name ], |
| 6032 | + rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ], |
5501 | 6033 | style = elem.style; |
5502 | 6034 | |
5503 | 6035 | // From the awesome hack by Dean Edwards |
— | — | @@ -5507,16 +6039,19 @@ |
5508 | 6040 | if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { |
5509 | 6041 | // Remember the original values |
5510 | 6042 | left = style.left; |
5511 | | - rsLeft = elem.runtimeStyle.left; |
5512 | 6043 | |
5513 | 6044 | // Put in the new values to get a computed value out |
5514 | | - elem.runtimeStyle.left = elem.currentStyle.left; |
| 6045 | + if ( rsLeft ) { |
| 6046 | + elem.runtimeStyle.left = elem.currentStyle.left; |
| 6047 | + } |
5515 | 6048 | style.left = name === "fontSize" ? "1em" : (ret || 0); |
5516 | 6049 | ret = style.pixelLeft + "px"; |
5517 | 6050 | |
5518 | 6051 | // Revert the changed values |
5519 | 6052 | style.left = left; |
5520 | | - elem.runtimeStyle.left = rsLeft; |
| 6053 | + if ( rsLeft ) { |
| 6054 | + elem.runtimeStyle.left = rsLeft; |
| 6055 | + } |
5521 | 6056 | } |
5522 | 6057 | |
5523 | 6058 | return ret === "" ? "auto" : ret; |
— | — | @@ -5565,22 +6100,145 @@ |
5566 | 6101 | |
5567 | 6102 | |
5568 | 6103 | |
5569 | | -var jsc = jQuery.now(), |
5570 | | - rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, |
5571 | | - rselectTextarea = /^(?:select|textarea)/i, |
| 6104 | +var r20 = /%20/g, |
| 6105 | + rbracket = /\[\]$/, |
| 6106 | + rCRLF = /\r?\n/g, |
| 6107 | + rhash = /#.*$/, |
| 6108 | + rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL |
5572 | 6109 | rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, |
| 6110 | + // #7653, #8125, #8152: local protocol detection |
| 6111 | + rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|widget):$/, |
5573 | 6112 | rnoContent = /^(?:GET|HEAD)$/, |
5574 | | - rbracket = /\[\]$/, |
5575 | | - jsre = /\=\?(&|$)/, |
| 6113 | + rprotocol = /^\/\//, |
5576 | 6114 | rquery = /\?/, |
| 6115 | + rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, |
| 6116 | + rselectTextarea = /^(?:select|textarea)/i, |
| 6117 | + rspacesAjax = /\s+/, |
5577 | 6118 | rts = /([?&])_=[^&]*/, |
5578 | | - rurl = /^(\w+:)?\/\/([^\/?#]+)/, |
5579 | | - r20 = /%20/g, |
5580 | | - rhash = /#.*$/, |
| 6119 | + rucHeaders = /(^|\-)([a-z])/g, |
| 6120 | + rucHeadersFunc = function( _, $1, $2 ) { |
| 6121 | + return $1 + $2.toUpperCase(); |
| 6122 | + }, |
| 6123 | + rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/, |
5581 | 6124 | |
5582 | 6125 | // Keep a copy of the old load method |
5583 | | - _load = jQuery.fn.load; |
| 6126 | + _load = jQuery.fn.load, |
5584 | 6127 | |
| 6128 | + /* Prefilters |
| 6129 | + * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) |
| 6130 | + * 2) These are called: |
| 6131 | + * - BEFORE asking for a transport |
| 6132 | + * - AFTER param serialization (s.data is a string if s.processData is true) |
| 6133 | + * 3) key is the dataType |
| 6134 | + * 4) the catchall symbol "*" can be used |
| 6135 | + * 5) execution will start with transport dataType and THEN continue down to "*" if needed |
| 6136 | + */ |
| 6137 | + prefilters = {}, |
| 6138 | + |
| 6139 | + /* Transports bindings |
| 6140 | + * 1) key is the dataType |
| 6141 | + * 2) the catchall symbol "*" can be used |
| 6142 | + * 3) selection will start with transport dataType and THEN go to "*" if needed |
| 6143 | + */ |
| 6144 | + transports = {}, |
| 6145 | + |
| 6146 | + // Document location |
| 6147 | + ajaxLocation, |
| 6148 | + |
| 6149 | + // Document location segments |
| 6150 | + ajaxLocParts; |
| 6151 | + |
| 6152 | +// #8138, IE may throw an exception when accessing |
| 6153 | +// a field from document.location if document.domain has been set |
| 6154 | +try { |
| 6155 | + ajaxLocation = document.location.href; |
| 6156 | +} catch( e ) { |
| 6157 | + // Use the href attribute of an A element |
| 6158 | + // since IE will modify it given document.location |
| 6159 | + ajaxLocation = document.createElement( "a" ); |
| 6160 | + ajaxLocation.href = ""; |
| 6161 | + ajaxLocation = ajaxLocation.href; |
| 6162 | +} |
| 6163 | + |
| 6164 | +// Segment location into parts |
| 6165 | +ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; |
| 6166 | + |
| 6167 | +// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport |
| 6168 | +function addToPrefiltersOrTransports( structure ) { |
| 6169 | + |
| 6170 | + // dataTypeExpression is optional and defaults to "*" |
| 6171 | + return function( dataTypeExpression, func ) { |
| 6172 | + |
| 6173 | + if ( typeof dataTypeExpression !== "string" ) { |
| 6174 | + func = dataTypeExpression; |
| 6175 | + dataTypeExpression = "*"; |
| 6176 | + } |
| 6177 | + |
| 6178 | + if ( jQuery.isFunction( func ) ) { |
| 6179 | + var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ), |
| 6180 | + i = 0, |
| 6181 | + length = dataTypes.length, |
| 6182 | + dataType, |
| 6183 | + list, |
| 6184 | + placeBefore; |
| 6185 | + |
| 6186 | + // For each dataType in the dataTypeExpression |
| 6187 | + for(; i < length; i++ ) { |
| 6188 | + dataType = dataTypes[ i ]; |
| 6189 | + // We control if we're asked to add before |
| 6190 | + // any existing element |
| 6191 | + placeBefore = /^\+/.test( dataType ); |
| 6192 | + if ( placeBefore ) { |
| 6193 | + dataType = dataType.substr( 1 ) || "*"; |
| 6194 | + } |
| 6195 | + list = structure[ dataType ] = structure[ dataType ] || []; |
| 6196 | + // then we add to the structure accordingly |
| 6197 | + list[ placeBefore ? "unshift" : "push" ]( func ); |
| 6198 | + } |
| 6199 | + } |
| 6200 | + }; |
| 6201 | +} |
| 6202 | + |
| 6203 | +//Base inspection function for prefilters and transports |
| 6204 | +function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR, |
| 6205 | + dataType /* internal */, inspected /* internal */ ) { |
| 6206 | + |
| 6207 | + dataType = dataType || options.dataTypes[ 0 ]; |
| 6208 | + inspected = inspected || {}; |
| 6209 | + |
| 6210 | + inspected[ dataType ] = true; |
| 6211 | + |
| 6212 | + var list = structure[ dataType ], |
| 6213 | + i = 0, |
| 6214 | + length = list ? list.length : 0, |
| 6215 | + executeOnly = ( structure === prefilters ), |
| 6216 | + selection; |
| 6217 | + |
| 6218 | + for(; i < length && ( executeOnly || !selection ); i++ ) { |
| 6219 | + selection = list[ i ]( options, originalOptions, jqXHR ); |
| 6220 | + // If we got redirected to another dataType |
| 6221 | + // we try there if executing only and not done already |
| 6222 | + if ( typeof selection === "string" ) { |
| 6223 | + if ( !executeOnly || inspected[ selection ] ) { |
| 6224 | + selection = undefined; |
| 6225 | + } else { |
| 6226 | + options.dataTypes.unshift( selection ); |
| 6227 | + selection = inspectPrefiltersOrTransports( |
| 6228 | + structure, options, originalOptions, jqXHR, selection, inspected ); |
| 6229 | + } |
| 6230 | + } |
| 6231 | + } |
| 6232 | + // If we're only executing or nothing was selected |
| 6233 | + // we try the catchall dataType if not done already |
| 6234 | + if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) { |
| 6235 | + selection = inspectPrefiltersOrTransports( |
| 6236 | + structure, options, originalOptions, jqXHR, "*", inspected ); |
| 6237 | + } |
| 6238 | + // unnecessary when only executing (prefilters) |
| 6239 | + // but it'll be ignored by the caller in that case |
| 6240 | + return selection; |
| 6241 | +} |
| 6242 | + |
5585 | 6243 | jQuery.fn.extend({ |
5586 | 6244 | load: function( url, params, callback ) { |
5587 | 6245 | if ( typeof url !== "string" && _load ) { |
— | — | @@ -5591,10 +6249,10 @@ |
5592 | 6250 | return this; |
5593 | 6251 | } |
5594 | 6252 | |
5595 | | - var off = url.indexOf(" "); |
| 6253 | + var off = url.indexOf( " " ); |
5596 | 6254 | if ( off >= 0 ) { |
5597 | | - var selector = url.slice(off, url.length); |
5598 | | - url = url.slice(0, off); |
| 6255 | + var selector = url.slice( off, url.length ); |
| 6256 | + url = url.slice( 0, off ); |
5599 | 6257 | } |
5600 | 6258 | |
5601 | 6259 | // Default to a GET request |
— | — | @@ -5606,7 +6264,7 @@ |
5607 | 6265 | if ( jQuery.isFunction( params ) ) { |
5608 | 6266 | // We assume that it's the callback |
5609 | 6267 | callback = params; |
5610 | | - params = null; |
| 6268 | + params = undefined; |
5611 | 6269 | |
5612 | 6270 | // Otherwise, build a param string |
5613 | 6271 | } else if ( typeof params === "object" ) { |
— | — | @@ -5623,26 +6281,34 @@ |
5624 | 6282 | type: type, |
5625 | 6283 | dataType: "html", |
5626 | 6284 | data: params, |
5627 | | - complete: function( res, status ) { |
| 6285 | + // Complete callback (responseText is used internally) |
| 6286 | + complete: function( jqXHR, status, responseText ) { |
| 6287 | + // Store the response as specified by the jqXHR object |
| 6288 | + responseText = jqXHR.responseText; |
5628 | 6289 | // If successful, inject the HTML into all the matched elements |
5629 | | - if ( status === "success" || status === "notmodified" ) { |
| 6290 | + if ( jqXHR.isResolved() ) { |
| 6291 | + // #4825: Get the actual response in case |
| 6292 | + // a dataFilter is present in ajaxSettings |
| 6293 | + jqXHR.done(function( r ) { |
| 6294 | + responseText = r; |
| 6295 | + }); |
5630 | 6296 | // See if a selector was specified |
5631 | 6297 | self.html( selector ? |
5632 | 6298 | // Create a dummy div to hold the results |
5633 | 6299 | jQuery("<div>") |
5634 | 6300 | // inject the contents of the document in, removing the scripts |
5635 | 6301 | // to avoid any 'Permission Denied' errors in IE |
5636 | | - .append(res.responseText.replace(rscript, "")) |
| 6302 | + .append(responseText.replace(rscript, "")) |
5637 | 6303 | |
5638 | 6304 | // Locate the specified elements |
5639 | 6305 | .find(selector) : |
5640 | 6306 | |
5641 | 6307 | // If not, just inject the full result |
5642 | | - res.responseText ); |
| 6308 | + responseText ); |
5643 | 6309 | } |
5644 | 6310 | |
5645 | 6311 | if ( callback ) { |
5646 | | - self.each( callback, [res.responseText, status, res] ); |
| 6312 | + self.each( callback, [ responseText, status, jqXHR ] ); |
5647 | 6313 | } |
5648 | 6314 | } |
5649 | 6315 | }); |
— | — | @@ -5651,88 +6317,94 @@ |
5652 | 6318 | }, |
5653 | 6319 | |
5654 | 6320 | serialize: function() { |
5655 | | - return jQuery.param(this.serializeArray()); |
| 6321 | + return jQuery.param( this.serializeArray() ); |
5656 | 6322 | }, |
5657 | 6323 | |
5658 | 6324 | serializeArray: function() { |
5659 | | - return this.map(function() { |
5660 | | - return this.elements ? jQuery.makeArray(this.elements) : this; |
| 6325 | + return this.map(function(){ |
| 6326 | + return this.elements ? jQuery.makeArray( this.elements ) : this; |
5661 | 6327 | }) |
5662 | | - .filter(function() { |
| 6328 | + .filter(function(){ |
5663 | 6329 | return this.name && !this.disabled && |
5664 | | - (this.checked || rselectTextarea.test(this.nodeName) || |
5665 | | - rinput.test(this.type)); |
| 6330 | + ( this.checked || rselectTextarea.test( this.nodeName ) || |
| 6331 | + rinput.test( this.type ) ); |
5666 | 6332 | }) |
5667 | | - .map(function( i, elem ) { |
5668 | | - var val = jQuery(this).val(); |
| 6333 | + .map(function( i, elem ){ |
| 6334 | + var val = jQuery( this ).val(); |
5669 | 6335 | |
5670 | 6336 | return val == null ? |
5671 | 6337 | null : |
5672 | | - jQuery.isArray(val) ? |
5673 | | - jQuery.map( val, function( val, i ) { |
5674 | | - return { name: elem.name, value: val }; |
| 6338 | + jQuery.isArray( val ) ? |
| 6339 | + jQuery.map( val, function( val, i ){ |
| 6340 | + return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
5675 | 6341 | }) : |
5676 | | - { name: elem.name, value: val }; |
| 6342 | + { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
5677 | 6343 | }).get(); |
5678 | 6344 | } |
5679 | 6345 | }); |
5680 | 6346 | |
5681 | 6347 | // 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); |
| 6348 | +jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){ |
| 6349 | + jQuery.fn[ o ] = function( f ){ |
| 6350 | + return this.bind( o, f ); |
5685 | 6351 | }; |
5686 | | -}); |
| 6352 | +} ); |
5687 | 6353 | |
5688 | | -jQuery.extend({ |
5689 | | - get: function( url, data, callback, type ) { |
5690 | | - // shift arguments if data argument was omited |
| 6354 | +jQuery.each( [ "get", "post" ], function( i, method ) { |
| 6355 | + jQuery[ method ] = function( url, data, callback, type ) { |
| 6356 | + // shift arguments if data argument was omitted |
5691 | 6357 | if ( jQuery.isFunction( data ) ) { |
5692 | 6358 | type = type || callback; |
5693 | 6359 | callback = data; |
5694 | | - data = null; |
| 6360 | + data = undefined; |
5695 | 6361 | } |
5696 | 6362 | |
5697 | 6363 | return jQuery.ajax({ |
5698 | | - type: "GET", |
| 6364 | + type: method, |
5699 | 6365 | url: url, |
5700 | 6366 | data: data, |
5701 | 6367 | success: callback, |
5702 | 6368 | dataType: type |
5703 | 6369 | }); |
5704 | | - }, |
| 6370 | + }; |
| 6371 | +} ); |
5705 | 6372 | |
| 6373 | +jQuery.extend({ |
| 6374 | + |
5706 | 6375 | getScript: function( url, callback ) { |
5707 | | - return jQuery.get(url, null, callback, "script"); |
| 6376 | + return jQuery.get( url, undefined, callback, "script" ); |
5708 | 6377 | }, |
5709 | 6378 | |
5710 | 6379 | getJSON: function( url, data, callback ) { |
5711 | | - return jQuery.get(url, data, callback, "json"); |
| 6380 | + return jQuery.get( url, data, callback, "json" ); |
5712 | 6381 | }, |
5713 | 6382 | |
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 = {}; |
| 6383 | + // Creates a full fledged settings object into target |
| 6384 | + // with both ajaxSettings and settings fields. |
| 6385 | + // If target is omitted, writes into ajaxSettings. |
| 6386 | + ajaxSetup: function ( target, settings ) { |
| 6387 | + if ( !settings ) { |
| 6388 | + // Only one parameter, we extend ajaxSettings |
| 6389 | + settings = target; |
| 6390 | + target = jQuery.extend( true, jQuery.ajaxSettings, settings ); |
| 6391 | + } else { |
| 6392 | + // target was provided, we extend into it |
| 6393 | + jQuery.extend( true, target, jQuery.ajaxSettings, settings ); |
5720 | 6394 | } |
5721 | | - |
5722 | | - return jQuery.ajax({ |
5723 | | - type: "POST", |
5724 | | - url: url, |
5725 | | - data: data, |
5726 | | - success: callback, |
5727 | | - dataType: type |
5728 | | - }); |
| 6395 | + // Flatten fields we don't want deep extended |
| 6396 | + for( var field in { context: 1, url: 1 } ) { |
| 6397 | + if ( field in settings ) { |
| 6398 | + target[ field ] = settings[ field ]; |
| 6399 | + } else if( field in jQuery.ajaxSettings ) { |
| 6400 | + target[ field ] = jQuery.ajaxSettings[ field ]; |
| 6401 | + } |
| 6402 | + } |
| 6403 | + return target; |
5729 | 6404 | }, |
5730 | 6405 | |
5731 | | - ajaxSetup: function( settings ) { |
5732 | | - jQuery.extend( jQuery.ajaxSettings, settings ); |
5733 | | - }, |
5734 | | - |
5735 | 6406 | ajaxSettings: { |
5736 | | - url: location.href, |
| 6407 | + url: ajaxLocation, |
| 6408 | + isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), |
5737 | 6409 | global: true, |
5738 | 6410 | type: "GET", |
5739 | 6411 | contentType: "application/x-www-form-urlencoded", |
— | — | @@ -5741,332 +6413,428 @@ |
5742 | 6414 | /* |
5743 | 6415 | timeout: 0, |
5744 | 6416 | data: null, |
| 6417 | + dataType: null, |
5745 | 6418 | username: null, |
5746 | 6419 | password: null, |
| 6420 | + cache: null, |
5747 | 6421 | traditional: false, |
| 6422 | + headers: {}, |
5748 | 6423 | */ |
5749 | | - // This function can be overriden by calling jQuery.ajaxSetup |
5750 | | - xhr: function() { |
5751 | | - return new window.XMLHttpRequest(); |
5752 | | - }, |
| 6424 | + |
5753 | 6425 | accepts: { |
5754 | 6426 | xml: "application/xml, text/xml", |
5755 | 6427 | html: "text/html", |
5756 | | - script: "text/javascript, application/javascript", |
| 6428 | + text: "text/plain", |
5757 | 6429 | json: "application/json, text/javascript", |
5758 | | - text: "text/plain", |
5759 | | - _default: "*/*" |
5760 | | - } |
5761 | | - }, |
| 6430 | + "*": "*/*" |
| 6431 | + }, |
5762 | 6432 | |
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); |
| 6433 | + contents: { |
| 6434 | + xml: /xml/, |
| 6435 | + html: /html/, |
| 6436 | + json: /json/ |
| 6437 | + }, |
5766 | 6438 | |
5767 | | - s.url = s.url.replace( rhash, "" ); |
| 6439 | + responseFields: { |
| 6440 | + xml: "responseXML", |
| 6441 | + text: "responseText" |
| 6442 | + }, |
5768 | 6443 | |
5769 | | - // Use original (not extended) context object if it was provided |
5770 | | - s.context = origSettings && origSettings.context != null ? origSettings.context : s; |
| 6444 | + // List of data converters |
| 6445 | + // 1) key format is "source_type destination_type" (a single space in-between) |
| 6446 | + // 2) the catchall symbol "*" can be used for source_type |
| 6447 | + converters: { |
5771 | 6448 | |
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 ); |
| 6449 | + // Convert anything to text |
| 6450 | + "* text": window.String, |
| 6451 | + |
| 6452 | + // Text to html (true = no transformation) |
| 6453 | + "text html": true, |
| 6454 | + |
| 6455 | + // Evaluate text as a json expression |
| 6456 | + "text json": jQuery.parseJSON, |
| 6457 | + |
| 6458 | + // Parse text as xml |
| 6459 | + "text xml": jQuery.parseXML |
5775 | 6460 | } |
| 6461 | + }, |
5776 | 6462 | |
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"; |
| 6463 | + ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), |
| 6464 | + ajaxTransport: addToPrefiltersOrTransports( transports ), |
| 6465 | + |
| 6466 | + // Main method |
| 6467 | + ajax: function( url, options ) { |
| 6468 | + |
| 6469 | + // If url is an object, simulate pre-1.5 signature |
| 6470 | + if ( typeof url === "object" ) { |
| 6471 | + options = url; |
| 6472 | + url = undefined; |
5787 | 6473 | } |
5788 | 6474 | |
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++); |
| 6475 | + // Force options to be an object |
| 6476 | + options = options || {}; |
5792 | 6477 | |
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 | | - } |
| 6478 | + var // Create the final options object |
| 6479 | + s = jQuery.ajaxSetup( {}, options ), |
| 6480 | + // Callbacks context |
| 6481 | + callbackContext = s.context || s, |
| 6482 | + // Context for global events |
| 6483 | + // It's the callbackContext if one was provided in the options |
| 6484 | + // and if it's a DOM node or a jQuery collection |
| 6485 | + globalEventContext = callbackContext !== s && |
| 6486 | + ( callbackContext.nodeType || callbackContext instanceof jQuery ) ? |
| 6487 | + jQuery( callbackContext ) : jQuery.event, |
| 6488 | + // Deferreds |
| 6489 | + deferred = jQuery.Deferred(), |
| 6490 | + completeDeferred = jQuery._Deferred(), |
| 6491 | + // Status-dependent callbacks |
| 6492 | + statusCode = s.statusCode || {}, |
| 6493 | + // ifModified key |
| 6494 | + ifModifiedKey, |
| 6495 | + // Headers (they are sent all at once) |
| 6496 | + requestHeaders = {}, |
| 6497 | + // Response headers |
| 6498 | + responseHeadersString, |
| 6499 | + responseHeaders, |
| 6500 | + // transport |
| 6501 | + transport, |
| 6502 | + // timeout handle |
| 6503 | + timeoutTimer, |
| 6504 | + // Cross-domain detection vars |
| 6505 | + parts, |
| 6506 | + // The jqXHR state |
| 6507 | + state = 0, |
| 6508 | + // To know if global events are to be dispatched |
| 6509 | + fireGlobals, |
| 6510 | + // Loop variable |
| 6511 | + i, |
| 6512 | + // Fake xhr |
| 6513 | + jqXHR = { |
5797 | 6514 | |
5798 | | - s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
| 6515 | + readyState: 0, |
5799 | 6516 | |
5800 | | - // We need to make sure |
5801 | | - // that a JSONP style response is executed properly |
5802 | | - s.dataType = "script"; |
| 6517 | + // Caches the header |
| 6518 | + setRequestHeader: function( name, value ) { |
| 6519 | + if ( !state ) { |
| 6520 | + requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value; |
| 6521 | + } |
| 6522 | + return this; |
| 6523 | + }, |
5803 | 6524 | |
5804 | | - // Handle JSONP-style loading |
5805 | | - var customJsonp = window[ jsonp ]; |
| 6525 | + // Raw string |
| 6526 | + getAllResponseHeaders: function() { |
| 6527 | + return state === 2 ? responseHeadersString : null; |
| 6528 | + }, |
5806 | 6529 | |
5807 | | - window[ jsonp ] = function( tmp ) { |
5808 | | - if ( jQuery.isFunction( customJsonp ) ) { |
5809 | | - customJsonp( tmp ); |
| 6530 | + // Builds headers hashtable if needed |
| 6531 | + getResponseHeader: function( key ) { |
| 6532 | + var match; |
| 6533 | + if ( state === 2 ) { |
| 6534 | + if ( !responseHeaders ) { |
| 6535 | + responseHeaders = {}; |
| 6536 | + while( ( match = rheaders.exec( responseHeadersString ) ) ) { |
| 6537 | + responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; |
| 6538 | + } |
| 6539 | + } |
| 6540 | + match = responseHeaders[ key.toLowerCase() ]; |
| 6541 | + } |
| 6542 | + return match === undefined ? null : match; |
| 6543 | + }, |
5810 | 6544 | |
5811 | | - } else { |
5812 | | - // Garbage collect |
5813 | | - window[ jsonp ] = undefined; |
| 6545 | + // Overrides response content-type header |
| 6546 | + overrideMimeType: function( type ) { |
| 6547 | + if ( !state ) { |
| 6548 | + s.mimeType = type; |
| 6549 | + } |
| 6550 | + return this; |
| 6551 | + }, |
5814 | 6552 | |
5815 | | - try { |
5816 | | - delete window[ jsonp ]; |
5817 | | - } catch( jsonpError ) {} |
| 6553 | + // Cancel the request |
| 6554 | + abort: function( statusText ) { |
| 6555 | + statusText = statusText || "abort"; |
| 6556 | + if ( transport ) { |
| 6557 | + transport.abort( statusText ); |
| 6558 | + } |
| 6559 | + done( 0, statusText ); |
| 6560 | + return this; |
5818 | 6561 | } |
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 | 6562 | }; |
5828 | | - } |
5829 | 6563 | |
5830 | | - if ( s.dataType === "script" && s.cache === null ) { |
5831 | | - s.cache = false; |
5832 | | - } |
| 6564 | + // Callback for when everything is done |
| 6565 | + // It is defined here because jslint complains if it is declared |
| 6566 | + // at the end of the function (which would be more logical and readable) |
| 6567 | + function done( status, statusText, responses, headers ) { |
5833 | 6568 | |
5834 | | - if ( s.cache === false && noContent ) { |
5835 | | - var ts = jQuery.now(); |
| 6569 | + // Called once |
| 6570 | + if ( state === 2 ) { |
| 6571 | + return; |
| 6572 | + } |
5836 | 6573 | |
5837 | | - // try replacing _= if it is there |
5838 | | - var ret = s.url.replace(rts, "$1_=" + ts); |
| 6574 | + // State is "done" now |
| 6575 | + state = 2; |
5839 | 6576 | |
5840 | | - // if nothing was replaced, add timestamp to the end |
5841 | | - s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : ""); |
5842 | | - } |
| 6577 | + // Clear timeout if it exists |
| 6578 | + if ( timeoutTimer ) { |
| 6579 | + clearTimeout( timeoutTimer ); |
| 6580 | + } |
5843 | 6581 | |
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 | | - } |
| 6582 | + // Dereference transport for early garbage collection |
| 6583 | + // (no matter how long the jqXHR object will be used) |
| 6584 | + transport = undefined; |
5848 | 6585 | |
5849 | | - // Watch for a new set of requests |
5850 | | - if ( s.global && jQuery.active++ === 0 ) { |
5851 | | - jQuery.event.trigger( "ajaxStart" ); |
5852 | | - } |
| 6586 | + // Cache response headers |
| 6587 | + responseHeadersString = headers || ""; |
5853 | 6588 | |
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); |
| 6589 | + // Set readyState |
| 6590 | + jqXHR.readyState = status ? 4 : 0; |
5857 | 6591 | |
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; |
| 6592 | + var isSuccess, |
| 6593 | + success, |
| 6594 | + error, |
| 6595 | + response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined, |
| 6596 | + lastModified, |
| 6597 | + etag; |
5867 | 6598 | |
5868 | | - // Handle Script loading |
5869 | | - if ( !jsonp ) { |
5870 | | - var done = false; |
| 6599 | + // If successful, handle type chaining |
| 6600 | + if ( status >= 200 && status < 300 || status === 304 ) { |
5871 | 6601 | |
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 ); |
| 6602 | + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 6603 | + if ( s.ifModified ) { |
5879 | 6604 | |
5880 | | - // Handle memory leak in IE |
5881 | | - script.onload = script.onreadystatechange = null; |
5882 | | - if ( head && script.parentNode ) { |
5883 | | - head.removeChild( script ); |
5884 | | - } |
| 6605 | + if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) { |
| 6606 | + jQuery.lastModified[ ifModifiedKey ] = lastModified; |
5885 | 6607 | } |
5886 | | - }; |
5887 | | - } |
| 6608 | + if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) { |
| 6609 | + jQuery.etag[ ifModifiedKey ] = etag; |
| 6610 | + } |
| 6611 | + } |
5888 | 6612 | |
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 ); |
| 6613 | + // If not modified |
| 6614 | + if ( status === 304 ) { |
5892 | 6615 | |
5893 | | - // We handle everything using the script element injection |
5894 | | - return undefined; |
5895 | | - } |
| 6616 | + statusText = "notmodified"; |
| 6617 | + isSuccess = true; |
5896 | 6618 | |
5897 | | - var requestDone = false; |
| 6619 | + // If we have data |
| 6620 | + } else { |
5898 | 6621 | |
5899 | | - // Create the request object |
5900 | | - var xhr = s.xhr(); |
| 6622 | + try { |
| 6623 | + success = ajaxConvert( s, response ); |
| 6624 | + statusText = "success"; |
| 6625 | + isSuccess = true; |
| 6626 | + } catch(e) { |
| 6627 | + // We have a parsererror |
| 6628 | + statusText = "parsererror"; |
| 6629 | + error = e; |
| 6630 | + } |
| 6631 | + } |
| 6632 | + } else { |
| 6633 | + // We extract error from statusText |
| 6634 | + // then normalize statusText and status for non-aborts |
| 6635 | + error = statusText; |
| 6636 | + if( !statusText || status ) { |
| 6637 | + statusText = "error"; |
| 6638 | + if ( status < 0 ) { |
| 6639 | + status = 0; |
| 6640 | + } |
| 6641 | + } |
| 6642 | + } |
5901 | 6643 | |
5902 | | - if ( !xhr ) { |
5903 | | - return; |
5904 | | - } |
| 6644 | + // Set data for the fake xhr object |
| 6645 | + jqXHR.status = status; |
| 6646 | + jqXHR.statusText = statusText; |
5905 | 6647 | |
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 | | - } |
| 6648 | + // Success/Error |
| 6649 | + if ( isSuccess ) { |
| 6650 | + deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); |
| 6651 | + } else { |
| 6652 | + deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); |
| 6653 | + } |
5913 | 6654 | |
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); |
| 6655 | + // Status-dependent callbacks |
| 6656 | + jqXHR.statusCode( statusCode ); |
| 6657 | + statusCode = undefined; |
| 6658 | + |
| 6659 | + if ( fireGlobals ) { |
| 6660 | + globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ), |
| 6661 | + [ jqXHR, s, isSuccess ? success : error ] ); |
5919 | 6662 | } |
5920 | 6663 | |
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 | | - } |
| 6664 | + // Complete |
| 6665 | + completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] ); |
5926 | 6666 | |
5927 | | - if ( jQuery.etag[s.url] ) { |
5928 | | - xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]); |
| 6667 | + if ( fireGlobals ) { |
| 6668 | + globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] ); |
| 6669 | + // Handle the global AJAX counter |
| 6670 | + if ( !( --jQuery.active ) ) { |
| 6671 | + jQuery.event.trigger( "ajaxStop" ); |
5929 | 6672 | } |
5930 | 6673 | } |
| 6674 | + } |
5931 | 6675 | |
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"); |
| 6676 | + // Attach deferreds |
| 6677 | + deferred.promise( jqXHR ); |
| 6678 | + jqXHR.success = jqXHR.done; |
| 6679 | + jqXHR.error = jqXHR.fail; |
| 6680 | + jqXHR.complete = completeDeferred.done; |
| 6681 | + |
| 6682 | + // Status-dependent callbacks |
| 6683 | + jqXHR.statusCode = function( map ) { |
| 6684 | + if ( map ) { |
| 6685 | + var tmp; |
| 6686 | + if ( state < 2 ) { |
| 6687 | + for( tmp in map ) { |
| 6688 | + statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ]; |
| 6689 | + } |
| 6690 | + } else { |
| 6691 | + tmp = map[ jqXHR.status ]; |
| 6692 | + jqXHR.then( tmp, tmp ); |
| 6693 | + } |
5936 | 6694 | } |
| 6695 | + return this; |
| 6696 | + }; |
5937 | 6697 | |
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 ) {} |
| 6698 | + // Remove hash character (#7531: and string promotion) |
| 6699 | + // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) |
| 6700 | + // We also use the url parameter if available |
| 6701 | + s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); |
5943 | 6702 | |
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 | | - } |
| 6703 | + // Extract dataTypes list |
| 6704 | + s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax ); |
5950 | 6705 | |
5951 | | - // close opended socket |
5952 | | - xhr.abort(); |
5953 | | - return false; |
| 6706 | + // Determine if a cross-domain request is in order |
| 6707 | + if ( s.crossDomain == null ) { |
| 6708 | + parts = rurl.exec( s.url.toLowerCase() ); |
| 6709 | + s.crossDomain = !!( parts && |
| 6710 | + ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] || |
| 6711 | + ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) != |
| 6712 | + ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) ) |
| 6713 | + ); |
5954 | 6714 | } |
5955 | 6715 | |
5956 | | - if ( s.global ) { |
5957 | | - jQuery.triggerGlobal( s, "ajaxSend", [xhr, s] ); |
| 6716 | + // Convert data if not already a string |
| 6717 | + if ( s.data && s.processData && typeof s.data !== "string" ) { |
| 6718 | + s.data = jQuery.param( s.data, s.traditional ); |
5958 | 6719 | } |
5959 | 6720 | |
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 | | - } |
| 6721 | + // Apply prefilters |
| 6722 | + inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); |
5969 | 6723 | |
5970 | | - requestDone = true; |
5971 | | - if ( xhr ) { |
5972 | | - xhr.onreadystatechange = jQuery.noop; |
5973 | | - } |
| 6724 | + // If request was aborted inside a prefiler, stop there |
| 6725 | + if ( state === 2 ) { |
| 6726 | + return false; |
| 6727 | + } |
5974 | 6728 | |
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; |
| 6729 | + // We can fire global events as of now if asked to |
| 6730 | + fireGlobals = s.global; |
5979 | 6731 | |
5980 | | - status = isTimeout === "timeout" ? |
5981 | | - "timeout" : |
5982 | | - !jQuery.httpSuccess( xhr ) ? |
5983 | | - "error" : |
5984 | | - s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? |
5985 | | - "notmodified" : |
5986 | | - "success"; |
| 6732 | + // Uppercase the type |
| 6733 | + s.type = s.type.toUpperCase(); |
5987 | 6734 | |
5988 | | - var errMsg; |
| 6735 | + // Determine if request has content |
| 6736 | + s.hasContent = !rnoContent.test( s.type ); |
5989 | 6737 | |
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 | | - } |
| 6738 | + // Watch for a new set of requests |
| 6739 | + if ( fireGlobals && jQuery.active++ === 0 ) { |
| 6740 | + jQuery.event.trigger( "ajaxStart" ); |
| 6741 | + } |
6000 | 6742 | |
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 | | - } |
| 6743 | + // More options handling for requests with no content |
| 6744 | + if ( !s.hasContent ) { |
6010 | 6745 | |
6011 | | - // Fire the complete handlers |
6012 | | - if ( !jsonp ) { |
6013 | | - jQuery.handleComplete( s, xhr, status, data ); |
6014 | | - } |
| 6746 | + // If data is available, append data to url |
| 6747 | + if ( s.data ) { |
| 6748 | + s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; |
| 6749 | + } |
6015 | 6750 | |
6016 | | - if ( isTimeout === "timeout" ) { |
6017 | | - xhr.abort(); |
6018 | | - } |
| 6751 | + // Get ifModifiedKey before adding the anti-cache parameter |
| 6752 | + ifModifiedKey = s.url; |
6019 | 6753 | |
6020 | | - // Stop memory leaks |
6021 | | - if ( s.async ) { |
6022 | | - xhr = null; |
6023 | | - } |
| 6754 | + // Add anti-cache in url if needed |
| 6755 | + if ( s.cache === false ) { |
| 6756 | + |
| 6757 | + var ts = jQuery.now(), |
| 6758 | + // try replacing _= if it is there |
| 6759 | + ret = s.url.replace( rts, "$1_=" + ts ); |
| 6760 | + |
| 6761 | + // if nothing was replaced, add timestamp to the end |
| 6762 | + s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); |
6024 | 6763 | } |
6025 | | - }; |
| 6764 | + } |
6026 | 6765 | |
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 | | - } |
| 6766 | + // Set the correct header, if data is being sent |
| 6767 | + if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { |
| 6768 | + requestHeaders[ "Content-Type" ] = s.contentType; |
| 6769 | + } |
6038 | 6770 | |
6039 | | - onreadystatechange( "abort" ); |
6040 | | - }; |
6041 | | - } catch( abortError ) {} |
| 6771 | + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
| 6772 | + if ( s.ifModified ) { |
| 6773 | + ifModifiedKey = ifModifiedKey || s.url; |
| 6774 | + if ( jQuery.lastModified[ ifModifiedKey ] ) { |
| 6775 | + requestHeaders[ "If-Modified-Since" ] = jQuery.lastModified[ ifModifiedKey ]; |
| 6776 | + } |
| 6777 | + if ( jQuery.etag[ ifModifiedKey ] ) { |
| 6778 | + requestHeaders[ "If-None-Match" ] = jQuery.etag[ ifModifiedKey ]; |
| 6779 | + } |
| 6780 | + } |
6042 | 6781 | |
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); |
| 6782 | + // Set the Accepts header for the server, depending on the dataType |
| 6783 | + requestHeaders.Accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? |
| 6784 | + s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) : |
| 6785 | + s.accepts[ "*" ]; |
| 6786 | + |
| 6787 | + // Check for headers option |
| 6788 | + for ( i in s.headers ) { |
| 6789 | + jqXHR.setRequestHeader( i, s.headers[ i ] ); |
6051 | 6790 | } |
6052 | 6791 | |
6053 | | - // Send the data |
6054 | | - try { |
6055 | | - xhr.send( noContent || s.data == null ? null : s.data ); |
| 6792 | + // Allow custom headers/mimetypes and early abort |
| 6793 | + if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { |
| 6794 | + // Abort if not done already |
| 6795 | + jqXHR.abort(); |
| 6796 | + return false; |
6056 | 6797 | |
6057 | | - } catch( sendError ) { |
6058 | | - jQuery.handleError( s, xhr, null, sendError ); |
| 6798 | + } |
6059 | 6799 | |
6060 | | - // Fire the complete handlers |
6061 | | - jQuery.handleComplete( s, xhr, status, data ); |
| 6800 | + // Install callbacks on deferreds |
| 6801 | + for ( i in { success: 1, error: 1, complete: 1 } ) { |
| 6802 | + jqXHR[ i ]( s[ i ] ); |
6062 | 6803 | } |
6063 | 6804 | |
6064 | | - // firefox 1.5 doesn't fire statechange for sync requests |
6065 | | - if ( !s.async ) { |
6066 | | - onreadystatechange(); |
| 6805 | + // Get transport |
| 6806 | + transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); |
| 6807 | + |
| 6808 | + // If no transport, we auto-abort |
| 6809 | + if ( !transport ) { |
| 6810 | + done( -1, "No Transport" ); |
| 6811 | + } else { |
| 6812 | + jqXHR.readyState = 1; |
| 6813 | + // Send global event |
| 6814 | + if ( fireGlobals ) { |
| 6815 | + globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); |
| 6816 | + } |
| 6817 | + // Timeout |
| 6818 | + if ( s.async && s.timeout > 0 ) { |
| 6819 | + timeoutTimer = setTimeout( function(){ |
| 6820 | + jqXHR.abort( "timeout" ); |
| 6821 | + }, s.timeout ); |
| 6822 | + } |
| 6823 | + |
| 6824 | + try { |
| 6825 | + state = 1; |
| 6826 | + transport.send( requestHeaders, done ); |
| 6827 | + } catch (e) { |
| 6828 | + // Propagate exception as error if not done |
| 6829 | + if ( status < 2 ) { |
| 6830 | + done( -1, e ); |
| 6831 | + // Simply rethrow otherwise |
| 6832 | + } else { |
| 6833 | + jQuery.error( e ); |
| 6834 | + } |
| 6835 | + } |
6067 | 6836 | } |
6068 | 6837 | |
6069 | | - // return XMLHttpRequest to allow aborting the request etc. |
6070 | | - return xhr; |
| 6838 | + return jqXHR; |
6071 | 6839 | }, |
6072 | 6840 | |
6073 | 6841 | // Serialize an array of form elements or a set of |
— | — | @@ -6075,37 +6843,37 @@ |
6076 | 6844 | var s = [], |
6077 | 6845 | add = function( key, value ) { |
6078 | 6846 | // 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); |
| 6847 | + value = jQuery.isFunction( value ) ? value() : value; |
| 6848 | + s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); |
6081 | 6849 | }; |
6082 | | - |
| 6850 | + |
6083 | 6851 | // Set traditional to true for jQuery <= 1.3.2 behavior. |
6084 | 6852 | if ( traditional === undefined ) { |
6085 | 6853 | traditional = jQuery.ajaxSettings.traditional; |
6086 | 6854 | } |
6087 | | - |
| 6855 | + |
6088 | 6856 | // If an array was passed in, assume that it is an array of form elements. |
6089 | | - if ( jQuery.isArray(a) || a.jquery ) { |
| 6857 | + if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
6090 | 6858 | // Serialize the form elements |
6091 | 6859 | jQuery.each( a, function() { |
6092 | 6860 | add( this.name, this.value ); |
6093 | | - }); |
6094 | | - |
| 6861 | + } ); |
| 6862 | + |
6095 | 6863 | } else { |
6096 | 6864 | // If traditional, encode the "old" way (the way 1.3.2 or older |
6097 | 6865 | // did it), otherwise encode params recursively. |
6098 | 6866 | for ( var prefix in a ) { |
6099 | | - buildParams( prefix, a[prefix], traditional, add ); |
| 6867 | + buildParams( prefix, a[ prefix ], traditional, add ); |
6100 | 6868 | } |
6101 | 6869 | } |
6102 | 6870 | |
6103 | 6871 | // Return the resulting serialization |
6104 | | - return s.join("&").replace(r20, "+"); |
| 6872 | + return s.join( "&" ).replace( r20, "+" ); |
6105 | 6873 | } |
6106 | 6874 | }); |
6107 | 6875 | |
6108 | 6876 | function buildParams( prefix, obj, traditional, add ) { |
6109 | | - if ( jQuery.isArray(obj) && obj.length ) { |
| 6877 | + if ( jQuery.isArray( obj ) && obj.length ) { |
6110 | 6878 | // Serialize array item. |
6111 | 6879 | jQuery.each( obj, function( i, v ) { |
6112 | 6880 | if ( traditional || rbracket.test( prefix ) ) { |
— | — | @@ -6123,18 +6891,20 @@ |
6124 | 6892 | buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add ); |
6125 | 6893 | } |
6126 | 6894 | }); |
6127 | | - |
| 6895 | + |
6128 | 6896 | } else if ( !traditional && obj != null && typeof obj === "object" ) { |
6129 | | - if ( jQuery.isEmptyObject( obj ) ) { |
| 6897 | + // If we see an array here, it is empty and should be treated as an empty |
| 6898 | + // object |
| 6899 | + if ( jQuery.isArray( obj ) || jQuery.isEmptyObject( obj ) ) { |
6130 | 6900 | add( prefix, "" ); |
6131 | 6901 | |
6132 | 6902 | // Serialize object item. |
6133 | 6903 | } else { |
6134 | | - jQuery.each( obj, function( k, v ) { |
6135 | | - buildParams( prefix + "[" + k + "]", v, traditional, add ); |
6136 | | - }); |
| 6904 | + for ( var name in obj ) { |
| 6905 | + buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); |
| 6906 | + } |
6137 | 6907 | } |
6138 | | - |
| 6908 | + |
6139 | 6909 | } else { |
6140 | 6910 | // Serialize scalar item. |
6141 | 6911 | add( prefix, obj ); |
— | — | @@ -6150,143 +6920,562 @@ |
6151 | 6921 | |
6152 | 6922 | // Last-Modified header cache for next request |
6153 | 6923 | lastModified: {}, |
6154 | | - etag: {}, |
| 6924 | + etag: {} |
6155 | 6925 | |
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 | | - } |
| 6926 | +}); |
6161 | 6927 | |
6162 | | - // Fire the global callback |
6163 | | - if ( s.global ) { |
6164 | | - jQuery.triggerGlobal( s, "ajaxError", [xhr, s, e] ); |
6165 | | - } |
6166 | | - }, |
| 6928 | +/* Handles responses to an ajax request: |
| 6929 | + * - sets all responseXXX fields accordingly |
| 6930 | + * - finds the right dataType (mediates between content-type and expected dataType) |
| 6931 | + * - returns the corresponding response |
| 6932 | + */ |
| 6933 | +function ajaxHandleResponses( s, jqXHR, responses ) { |
6167 | 6934 | |
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 ); |
| 6935 | + var contents = s.contents, |
| 6936 | + dataTypes = s.dataTypes, |
| 6937 | + responseFields = s.responseFields, |
| 6938 | + ct, |
| 6939 | + type, |
| 6940 | + finalDataType, |
| 6941 | + firstDataType; |
| 6942 | + |
| 6943 | + // Fill responseXXX fields |
| 6944 | + for( type in responseFields ) { |
| 6945 | + if ( type in responses ) { |
| 6946 | + jqXHR[ responseFields[type] ] = responses[ type ]; |
6172 | 6947 | } |
| 6948 | + } |
6173 | 6949 | |
6174 | | - // Fire the global callback |
6175 | | - if ( s.global ) { |
6176 | | - jQuery.triggerGlobal( s, "ajaxSuccess", [xhr, s] ); |
| 6950 | + // Remove auto dataType and get content-type in the process |
| 6951 | + while( dataTypes[ 0 ] === "*" ) { |
| 6952 | + dataTypes.shift(); |
| 6953 | + if ( ct === undefined ) { |
| 6954 | + ct = s.mimeType || jqXHR.getResponseHeader( "content-type" ); |
6177 | 6955 | } |
6178 | | - }, |
| 6956 | + } |
6179 | 6957 | |
6180 | | - handleComplete: function( s, xhr, status ) { |
6181 | | - // Process result |
6182 | | - if ( s.complete ) { |
6183 | | - s.complete.call( s.context, xhr, status ); |
| 6958 | + // Check if we're dealing with a known content-type |
| 6959 | + if ( ct ) { |
| 6960 | + for ( type in contents ) { |
| 6961 | + if ( contents[ type ] && contents[ type ].test( ct ) ) { |
| 6962 | + dataTypes.unshift( type ); |
| 6963 | + break; |
| 6964 | + } |
6184 | 6965 | } |
| 6966 | + } |
6185 | 6967 | |
6186 | | - // The request was completed |
6187 | | - if ( s.global ) { |
6188 | | - jQuery.triggerGlobal( s, "ajaxComplete", [xhr, s] ); |
| 6968 | + // Check to see if we have a response for the expected dataType |
| 6969 | + if ( dataTypes[ 0 ] in responses ) { |
| 6970 | + finalDataType = dataTypes[ 0 ]; |
| 6971 | + } else { |
| 6972 | + // Try convertible dataTypes |
| 6973 | + for ( type in responses ) { |
| 6974 | + if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { |
| 6975 | + finalDataType = type; |
| 6976 | + break; |
| 6977 | + } |
| 6978 | + if ( !firstDataType ) { |
| 6979 | + firstDataType = type; |
| 6980 | + } |
6189 | 6981 | } |
| 6982 | + // Or just use first one |
| 6983 | + finalDataType = finalDataType || firstDataType; |
| 6984 | + } |
6190 | 6985 | |
6191 | | - // Handle the global AJAX counter |
6192 | | - if ( s.global && jQuery.active-- === 1 ) { |
6193 | | - jQuery.event.trigger( "ajaxStop" ); |
| 6986 | + // If we found a dataType |
| 6987 | + // We add the dataType to the list if needed |
| 6988 | + // and return the corresponding response |
| 6989 | + if ( finalDataType ) { |
| 6990 | + if ( finalDataType !== dataTypes[ 0 ] ) { |
| 6991 | + dataTypes.unshift( finalDataType ); |
6194 | 6992 | } |
6195 | | - }, |
6196 | | - |
6197 | | - triggerGlobal: function( s, type, args ) { |
6198 | | - (s.context && s.context.url == null ? jQuery(s.context) : jQuery.event).trigger(type, args); |
6199 | | - }, |
| 6993 | + return responses[ finalDataType ]; |
| 6994 | + } |
| 6995 | +} |
6200 | 6996 | |
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) {} |
| 6997 | +// Chain conversions given the request and the original response |
| 6998 | +function ajaxConvert( s, response ) { |
6209 | 6999 | |
6210 | | - return false; |
6211 | | - }, |
| 7000 | + // Apply the dataFilter if provided |
| 7001 | + if ( s.dataFilter ) { |
| 7002 | + response = s.dataFilter( response, s.dataType ); |
| 7003 | + } |
6212 | 7004 | |
6213 | | - // Determines if an XMLHttpRequest returns NotModified |
6214 | | - httpNotModified: function( xhr, url ) { |
6215 | | - var lastModified = xhr.getResponseHeader("Last-Modified"), |
6216 | | - etag = xhr.getResponseHeader("Etag"); |
| 7005 | + var dataTypes = s.dataTypes, |
| 7006 | + converters = {}, |
| 7007 | + i, |
| 7008 | + key, |
| 7009 | + length = dataTypes.length, |
| 7010 | + tmp, |
| 7011 | + // Current and previous dataTypes |
| 7012 | + current = dataTypes[ 0 ], |
| 7013 | + prev, |
| 7014 | + // Conversion expression |
| 7015 | + conversion, |
| 7016 | + // Conversion function |
| 7017 | + conv, |
| 7018 | + // Conversion functions (transitive conversion) |
| 7019 | + conv1, |
| 7020 | + conv2; |
6217 | 7021 | |
6218 | | - if ( lastModified ) { |
6219 | | - jQuery.lastModified[url] = lastModified; |
6220 | | - } |
| 7022 | + // For each dataType in the chain |
| 7023 | + for( i = 1; i < length; i++ ) { |
6221 | 7024 | |
6222 | | - if ( etag ) { |
6223 | | - jQuery.etag[url] = etag; |
| 7025 | + // Create converters map |
| 7026 | + // with lowercased keys |
| 7027 | + if ( i === 1 ) { |
| 7028 | + for( key in s.converters ) { |
| 7029 | + if( typeof key === "string" ) { |
| 7030 | + converters[ key.toLowerCase() ] = s.converters[ key ]; |
| 7031 | + } |
| 7032 | + } |
6224 | 7033 | } |
6225 | 7034 | |
6226 | | - return xhr.status === 304; |
6227 | | - }, |
| 7035 | + // Get the dataTypes |
| 7036 | + prev = current; |
| 7037 | + current = dataTypes[ i ]; |
6228 | 7038 | |
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; |
| 7039 | + // If current is auto dataType, update it to prev |
| 7040 | + if( current === "*" ) { |
| 7041 | + current = prev; |
| 7042 | + // If no auto and dataTypes are actually different |
| 7043 | + } else if ( prev !== "*" && prev !== current ) { |
6233 | 7044 | |
6234 | | - if ( xml && data.documentElement.nodeName === "parsererror" ) { |
6235 | | - jQuery.error( "parsererror" ); |
6236 | | - } |
| 7045 | + // Get the converter |
| 7046 | + conversion = prev + " " + current; |
| 7047 | + conv = converters[ conversion ] || converters[ "* " + current ]; |
6237 | 7048 | |
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 ); |
| 7049 | + // If there is no direct converter, search transitively |
| 7050 | + if ( !conv ) { |
| 7051 | + conv2 = undefined; |
| 7052 | + for( conv1 in converters ) { |
| 7053 | + tmp = conv1.split( " " ); |
| 7054 | + if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) { |
| 7055 | + conv2 = converters[ tmp[1] + " " + current ]; |
| 7056 | + if ( conv2 ) { |
| 7057 | + conv1 = converters[ conv1 ]; |
| 7058 | + if ( conv1 === true ) { |
| 7059 | + conv = conv2; |
| 7060 | + } else if ( conv2 === true ) { |
| 7061 | + conv = conv1; |
| 7062 | + } |
| 7063 | + break; |
| 7064 | + } |
| 7065 | + } |
| 7066 | + } |
| 7067 | + } |
| 7068 | + // If we found no converter, dispatch an error |
| 7069 | + if ( !( conv || conv2 ) ) { |
| 7070 | + jQuery.error( "No conversion from " + conversion.replace(" "," to ") ); |
| 7071 | + } |
| 7072 | + // If found converter is not an equivalence |
| 7073 | + if ( conv !== true ) { |
| 7074 | + // Convert with 1 or 2 converters accordingly |
| 7075 | + response = conv ? conv( response ) : conv2( conv1(response) ); |
| 7076 | + } |
6242 | 7077 | } |
| 7078 | + } |
| 7079 | + return response; |
| 7080 | +} |
6243 | 7081 | |
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 ); |
6249 | 7082 | |
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 ); |
| 7083 | + |
| 7084 | + |
| 7085 | +var jsc = jQuery.now(), |
| 7086 | + jsre = /(\=)\?(&|$)|\?\?/i; |
| 7087 | + |
| 7088 | +// Default jsonp settings |
| 7089 | +jQuery.ajaxSetup({ |
| 7090 | + jsonp: "callback", |
| 7091 | + jsonpCallback: function() { |
| 7092 | + return jQuery.expando + "_" + ( jsc++ ); |
| 7093 | + } |
| 7094 | +}); |
| 7095 | + |
| 7096 | +// Detect, normalize options and install callbacks for jsonp requests |
| 7097 | +jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { |
| 7098 | + |
| 7099 | + var dataIsString = ( typeof s.data === "string" ); |
| 7100 | + |
| 7101 | + if ( s.dataTypes[ 0 ] === "jsonp" || |
| 7102 | + originalSettings.jsonpCallback || |
| 7103 | + originalSettings.jsonp != null || |
| 7104 | + s.jsonp !== false && ( jsre.test( s.url ) || |
| 7105 | + dataIsString && jsre.test( s.data ) ) ) { |
| 7106 | + |
| 7107 | + var responseContainer, |
| 7108 | + jsonpCallback = s.jsonpCallback = |
| 7109 | + jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback, |
| 7110 | + previous = window[ jsonpCallback ], |
| 7111 | + url = s.url, |
| 7112 | + data = s.data, |
| 7113 | + replace = "$1" + jsonpCallback + "$2", |
| 7114 | + cleanUp = function() { |
| 7115 | + // Set callback back to previous value |
| 7116 | + window[ jsonpCallback ] = previous; |
| 7117 | + // Call if it was a function and we have a response |
| 7118 | + if ( responseContainer && jQuery.isFunction( previous ) ) { |
| 7119 | + window[ jsonpCallback ]( responseContainer[ 0 ] ); |
| 7120 | + } |
| 7121 | + }; |
| 7122 | + |
| 7123 | + if ( s.jsonp !== false ) { |
| 7124 | + url = url.replace( jsre, replace ); |
| 7125 | + if ( s.url === url ) { |
| 7126 | + if ( dataIsString ) { |
| 7127 | + data = data.replace( jsre, replace ); |
| 7128 | + } |
| 7129 | + if ( s.data === data ) { |
| 7130 | + // Add callback manually |
| 7131 | + url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback; |
| 7132 | + } |
6253 | 7133 | } |
6254 | 7134 | } |
6255 | 7135 | |
6256 | | - return data; |
| 7136 | + s.url = url; |
| 7137 | + s.data = data; |
| 7138 | + |
| 7139 | + // Install callback |
| 7140 | + window[ jsonpCallback ] = function( response ) { |
| 7141 | + responseContainer = [ response ]; |
| 7142 | + }; |
| 7143 | + |
| 7144 | + // Install cleanUp function |
| 7145 | + jqXHR.then( cleanUp, cleanUp ); |
| 7146 | + |
| 7147 | + // Use data converter to retrieve json after script execution |
| 7148 | + s.converters["script json"] = function() { |
| 7149 | + if ( !responseContainer ) { |
| 7150 | + jQuery.error( jsonpCallback + " was not called" ); |
| 7151 | + } |
| 7152 | + return responseContainer[ 0 ]; |
| 7153 | + }; |
| 7154 | + |
| 7155 | + // force json dataType |
| 7156 | + s.dataTypes[ 0 ] = "json"; |
| 7157 | + |
| 7158 | + // Delegate to script |
| 7159 | + return "script"; |
6257 | 7160 | } |
| 7161 | +} ); |
6258 | 7162 | |
| 7163 | + |
| 7164 | + |
| 7165 | + |
| 7166 | +// Install script dataType |
| 7167 | +jQuery.ajaxSetup({ |
| 7168 | + accepts: { |
| 7169 | + script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" |
| 7170 | + }, |
| 7171 | + contents: { |
| 7172 | + script: /javascript|ecmascript/ |
| 7173 | + }, |
| 7174 | + converters: { |
| 7175 | + "text script": function( text ) { |
| 7176 | + jQuery.globalEval( text ); |
| 7177 | + return text; |
| 7178 | + } |
| 7179 | + } |
6259 | 7180 | }); |
6260 | 7181 | |
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) {} |
| 7182 | +// Handle cache's special case and global |
| 7183 | +jQuery.ajaxPrefilter( "script", function( s ) { |
| 7184 | + if ( s.cache === undefined ) { |
| 7185 | + s.cache = false; |
| 7186 | + } |
| 7187 | + if ( s.crossDomain ) { |
| 7188 | + s.type = "GET"; |
| 7189 | + s.global = false; |
| 7190 | + } |
| 7191 | +} ); |
| 7192 | + |
| 7193 | +// Bind script tag hack transport |
| 7194 | +jQuery.ajaxTransport( "script", function(s) { |
| 7195 | + |
| 7196 | + // This transport only deals with cross domain requests |
| 7197 | + if ( s.crossDomain ) { |
| 7198 | + |
| 7199 | + var script, |
| 7200 | + head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; |
| 7201 | + |
| 7202 | + return { |
| 7203 | + |
| 7204 | + send: function( _, callback ) { |
| 7205 | + |
| 7206 | + script = document.createElement( "script" ); |
| 7207 | + |
| 7208 | + script.async = "async"; |
| 7209 | + |
| 7210 | + if ( s.scriptCharset ) { |
| 7211 | + script.charset = s.scriptCharset; |
| 7212 | + } |
| 7213 | + |
| 7214 | + script.src = s.url; |
| 7215 | + |
| 7216 | + // Attach handlers for all browsers |
| 7217 | + script.onload = script.onreadystatechange = function( _, isAbort ) { |
| 7218 | + |
| 7219 | + if ( !script.readyState || /loaded|complete/.test( script.readyState ) ) { |
| 7220 | + |
| 7221 | + // Handle memory leak in IE |
| 7222 | + script.onload = script.onreadystatechange = null; |
| 7223 | + |
| 7224 | + // Remove the script |
| 7225 | + if ( head && script.parentNode ) { |
| 7226 | + head.removeChild( script ); |
| 7227 | + } |
| 7228 | + |
| 7229 | + // Dereference the script |
| 7230 | + script = undefined; |
| 7231 | + |
| 7232 | + // Callback if not abort |
| 7233 | + if ( !isAbort ) { |
| 7234 | + callback( 200, "success" ); |
| 7235 | + } |
| 7236 | + } |
| 7237 | + }; |
| 7238 | + // Use insertBefore instead of appendChild to circumvent an IE6 bug. |
| 7239 | + // This arises when a base node is used (#2709 and #4378). |
| 7240 | + head.insertBefore( script, head.firstChild ); |
| 7241 | + }, |
| 7242 | + |
| 7243 | + abort: function() { |
| 7244 | + if ( script ) { |
| 7245 | + script.onload( 0, 1 ); |
| 7246 | + } |
| 7247 | + } |
| 7248 | + }; |
| 7249 | + } |
| 7250 | +} ); |
| 7251 | + |
| 7252 | + |
| 7253 | + |
| 7254 | + |
| 7255 | +var // #5280: next active xhr id and list of active xhrs' callbacks |
| 7256 | + xhrId = jQuery.now(), |
| 7257 | + xhrCallbacks, |
| 7258 | + |
| 7259 | + // XHR used to determine supports properties |
| 7260 | + testXHR; |
| 7261 | + |
| 7262 | +// #5280: Internet Explorer will keep connections alive if we don't abort on unload |
| 7263 | +function xhrOnUnloadAbort() { |
| 7264 | + jQuery( window ).unload(function() { |
| 7265 | + // Abort all pending requests |
| 7266 | + for ( var key in xhrCallbacks ) { |
| 7267 | + xhrCallbacks[ key ]( 0, 1 ); |
6274 | 7268 | } |
| 7269 | + }); |
| 7270 | +} |
6275 | 7271 | |
6276 | | - try { |
6277 | | - return new window.ActiveXObject("Microsoft.XMLHTTP"); |
6278 | | - } catch(activeError) {} |
6279 | | - }; |
| 7272 | +// Functions to create xhrs |
| 7273 | +function createStandardXHR() { |
| 7274 | + try { |
| 7275 | + return new window.XMLHttpRequest(); |
| 7276 | + } catch( e ) {} |
6280 | 7277 | } |
6281 | 7278 | |
6282 | | -// Does this browser support XHR requests? |
6283 | | -jQuery.support.ajax = !!jQuery.ajaxSettings.xhr(); |
| 7279 | +function createActiveXHR() { |
| 7280 | + try { |
| 7281 | + return new window.ActiveXObject( "Microsoft.XMLHTTP" ); |
| 7282 | + } catch( e ) {} |
| 7283 | +} |
6284 | 7284 | |
| 7285 | +// Create the request object |
| 7286 | +// (This is still attached to ajaxSettings for backward compatibility) |
| 7287 | +jQuery.ajaxSettings.xhr = window.ActiveXObject ? |
| 7288 | + /* Microsoft failed to properly |
| 7289 | + * implement the XMLHttpRequest in IE7 (can't request local files), |
| 7290 | + * so we use the ActiveXObject when it is available |
| 7291 | + * Additionally XMLHttpRequest can be disabled in IE7/IE8 so |
| 7292 | + * we need a fallback. |
| 7293 | + */ |
| 7294 | + function() { |
| 7295 | + return !this.isLocal && createStandardXHR() || createActiveXHR(); |
| 7296 | + } : |
| 7297 | + // For all other browsers, use the standard XMLHttpRequest object |
| 7298 | + createStandardXHR; |
6285 | 7299 | |
| 7300 | +// Test if we can create an xhr object |
| 7301 | +testXHR = jQuery.ajaxSettings.xhr(); |
| 7302 | +jQuery.support.ajax = !!testXHR; |
6286 | 7303 | |
| 7304 | +// Does this browser support crossDomain XHR requests |
| 7305 | +jQuery.support.cors = testXHR && ( "withCredentials" in testXHR ); |
6287 | 7306 | |
| 7307 | +// No need for the temporary xhr anymore |
| 7308 | +testXHR = undefined; |
| 7309 | + |
| 7310 | +// Create transport if the browser can provide an xhr |
| 7311 | +if ( jQuery.support.ajax ) { |
| 7312 | + |
| 7313 | + jQuery.ajaxTransport(function( s ) { |
| 7314 | + // Cross domain only allowed if supported through XMLHttpRequest |
| 7315 | + if ( !s.crossDomain || jQuery.support.cors ) { |
| 7316 | + |
| 7317 | + var callback; |
| 7318 | + |
| 7319 | + return { |
| 7320 | + send: function( headers, complete ) { |
| 7321 | + |
| 7322 | + // Get a new xhr |
| 7323 | + var xhr = s.xhr(), |
| 7324 | + handle, |
| 7325 | + i; |
| 7326 | + |
| 7327 | + // Open the socket |
| 7328 | + // Passing null username, generates a login popup on Opera (#2865) |
| 7329 | + if ( s.username ) { |
| 7330 | + xhr.open( s.type, s.url, s.async, s.username, s.password ); |
| 7331 | + } else { |
| 7332 | + xhr.open( s.type, s.url, s.async ); |
| 7333 | + } |
| 7334 | + |
| 7335 | + // Apply custom fields if provided |
| 7336 | + if ( s.xhrFields ) { |
| 7337 | + for ( i in s.xhrFields ) { |
| 7338 | + xhr[ i ] = s.xhrFields[ i ]; |
| 7339 | + } |
| 7340 | + } |
| 7341 | + |
| 7342 | + // Override mime type if needed |
| 7343 | + if ( s.mimeType && xhr.overrideMimeType ) { |
| 7344 | + xhr.overrideMimeType( s.mimeType ); |
| 7345 | + } |
| 7346 | + |
| 7347 | + // X-Requested-With header |
| 7348 | + // For cross-domain requests, seeing as conditions for a preflight are |
| 7349 | + // akin to a jigsaw puzzle, we simply never set it to be sure. |
| 7350 | + // (it can always be set on a per-request basis or even using ajaxSetup) |
| 7351 | + // For same-domain requests, won't change header if already provided. |
| 7352 | + if ( !s.crossDomain && !headers["X-Requested-With"] ) { |
| 7353 | + headers[ "X-Requested-With" ] = "XMLHttpRequest"; |
| 7354 | + } |
| 7355 | + |
| 7356 | + // Need an extra try/catch for cross domain requests in Firefox 3 |
| 7357 | + try { |
| 7358 | + for ( i in headers ) { |
| 7359 | + xhr.setRequestHeader( i, headers[ i ] ); |
| 7360 | + } |
| 7361 | + } catch( _ ) {} |
| 7362 | + |
| 7363 | + // Do send the request |
| 7364 | + // This may raise an exception which is actually |
| 7365 | + // handled in jQuery.ajax (so no try/catch here) |
| 7366 | + xhr.send( ( s.hasContent && s.data ) || null ); |
| 7367 | + |
| 7368 | + // Listener |
| 7369 | + callback = function( _, isAbort ) { |
| 7370 | + |
| 7371 | + var status, |
| 7372 | + statusText, |
| 7373 | + responseHeaders, |
| 7374 | + responses, |
| 7375 | + xml; |
| 7376 | + |
| 7377 | + // Firefox throws exceptions when accessing properties |
| 7378 | + // of an xhr when a network error occured |
| 7379 | + // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) |
| 7380 | + try { |
| 7381 | + |
| 7382 | + // Was never called and is aborted or complete |
| 7383 | + if ( callback && ( isAbort || xhr.readyState === 4 ) ) { |
| 7384 | + |
| 7385 | + // Only called once |
| 7386 | + callback = undefined; |
| 7387 | + |
| 7388 | + // Do not keep as active anymore |
| 7389 | + if ( handle ) { |
| 7390 | + xhr.onreadystatechange = jQuery.noop; |
| 7391 | + delete xhrCallbacks[ handle ]; |
| 7392 | + } |
| 7393 | + |
| 7394 | + // If it's an abort |
| 7395 | + if ( isAbort ) { |
| 7396 | + // Abort it manually if needed |
| 7397 | + if ( xhr.readyState !== 4 ) { |
| 7398 | + xhr.abort(); |
| 7399 | + } |
| 7400 | + } else { |
| 7401 | + status = xhr.status; |
| 7402 | + responseHeaders = xhr.getAllResponseHeaders(); |
| 7403 | + responses = {}; |
| 7404 | + xml = xhr.responseXML; |
| 7405 | + |
| 7406 | + // Construct response list |
| 7407 | + if ( xml && xml.documentElement /* #4958 */ ) { |
| 7408 | + responses.xml = xml; |
| 7409 | + } |
| 7410 | + responses.text = xhr.responseText; |
| 7411 | + |
| 7412 | + // Firefox throws an exception when accessing |
| 7413 | + // statusText for faulty cross-domain requests |
| 7414 | + try { |
| 7415 | + statusText = xhr.statusText; |
| 7416 | + } catch( e ) { |
| 7417 | + // We normalize with Webkit giving an empty statusText |
| 7418 | + statusText = ""; |
| 7419 | + } |
| 7420 | + |
| 7421 | + // Filter status for non standard behaviors |
| 7422 | + |
| 7423 | + // If the request is local and we have data: assume a success |
| 7424 | + // (success with no data won't get notified, that's the best we |
| 7425 | + // can do given current implementations) |
| 7426 | + if ( !status && s.isLocal && !s.crossDomain ) { |
| 7427 | + status = responses.text ? 200 : 404; |
| 7428 | + // IE - #1450: sometimes returns 1223 when it should be 204 |
| 7429 | + } else if ( status === 1223 ) { |
| 7430 | + status = 204; |
| 7431 | + } |
| 7432 | + } |
| 7433 | + } |
| 7434 | + } catch( firefoxAccessException ) { |
| 7435 | + if ( !isAbort ) { |
| 7436 | + complete( -1, firefoxAccessException ); |
| 7437 | + } |
| 7438 | + } |
| 7439 | + |
| 7440 | + // Call complete if needed |
| 7441 | + if ( responses ) { |
| 7442 | + complete( status, statusText, responses, responseHeaders ); |
| 7443 | + } |
| 7444 | + }; |
| 7445 | + |
| 7446 | + // if we're in sync mode or it's in cache |
| 7447 | + // and has been retrieved directly (IE6 & IE7) |
| 7448 | + // we need to manually fire the callback |
| 7449 | + if ( !s.async || xhr.readyState === 4 ) { |
| 7450 | + callback(); |
| 7451 | + } else { |
| 7452 | + // Create the active xhrs callbacks list if needed |
| 7453 | + // and attach the unload handler |
| 7454 | + if ( !xhrCallbacks ) { |
| 7455 | + xhrCallbacks = {}; |
| 7456 | + xhrOnUnloadAbort(); |
| 7457 | + } |
| 7458 | + // Add to list of active xhrs callbacks |
| 7459 | + handle = xhrId++; |
| 7460 | + xhr.onreadystatechange = xhrCallbacks[ handle ] = callback; |
| 7461 | + } |
| 7462 | + }, |
| 7463 | + |
| 7464 | + abort: function() { |
| 7465 | + if ( callback ) { |
| 7466 | + callback(0,1); |
| 7467 | + } |
| 7468 | + } |
| 7469 | + }; |
| 7470 | + } |
| 7471 | + }); |
| 7472 | +} |
| 7473 | + |
| 7474 | + |
| 7475 | + |
| 7476 | + |
6288 | 7477 | var elemdisplay = {}, |
6289 | 7478 | rfxtypes = /^(?:toggle|show|hide)$/, |
6290 | | - rfxnum = /^([+\-]=)?([\d+.\-]+)(.*)$/, |
| 7479 | + rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i, |
6291 | 7480 | timerId, |
6292 | 7481 | fxAttrs = [ |
6293 | 7482 | // height animations |
— | — | @@ -6311,7 +7500,7 @@ |
6312 | 7501 | |
6313 | 7502 | // Reset the inline display of this element to learn if it is |
6314 | 7503 | // being hidden by cascaded rules or not |
6315 | | - if ( !jQuery.data(elem, "olddisplay") && display === "none" ) { |
| 7504 | + if ( !jQuery._data(elem, "olddisplay") && display === "none" ) { |
6316 | 7505 | display = elem.style.display = ""; |
6317 | 7506 | } |
6318 | 7507 | |
— | — | @@ -6319,7 +7508,7 @@ |
6320 | 7509 | // in a stylesheet to whatever the default browser style is |
6321 | 7510 | // for such an element |
6322 | 7511 | if ( display === "" && jQuery.css( elem, "display" ) === "none" ) { |
6323 | | - jQuery.data(elem, "olddisplay", defaultDisplay(elem.nodeName)); |
| 7512 | + jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName)); |
6324 | 7513 | } |
6325 | 7514 | } |
6326 | 7515 | |
— | — | @@ -6330,7 +7519,7 @@ |
6331 | 7520 | display = elem.style.display; |
6332 | 7521 | |
6333 | 7522 | if ( display === "" || display === "none" ) { |
6334 | | - elem.style.display = jQuery.data(elem, "olddisplay") || ""; |
| 7523 | + elem.style.display = jQuery._data(elem, "olddisplay") || ""; |
6335 | 7524 | } |
6336 | 7525 | } |
6337 | 7526 | |
— | — | @@ -6346,8 +7535,8 @@ |
6347 | 7536 | for ( var i = 0, j = this.length; i < j; i++ ) { |
6348 | 7537 | var display = jQuery.css( this[i], "display" ); |
6349 | 7538 | |
6350 | | - if ( display !== "none" ) { |
6351 | | - jQuery.data( this[i], "olddisplay", display ); |
| 7539 | + if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) { |
| 7540 | + jQuery._data( this[i], "olddisplay", display ); |
6352 | 7541 | } |
6353 | 7542 | } |
6354 | 7543 | |
— | — | @@ -6469,11 +7658,11 @@ |
6470 | 7659 | |
6471 | 7660 | } else { |
6472 | 7661 | var parts = rfxnum.exec(val), |
6473 | | - start = e.cur() || 0; |
| 7662 | + start = e.cur(); |
6474 | 7663 | |
6475 | 7664 | if ( parts ) { |
6476 | 7665 | var end = parseFloat( parts[2] ), |
6477 | | - unit = parts[3] || "px"; |
| 7666 | + unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" ); |
6478 | 7667 | |
6479 | 7668 | // We need to compute starting value |
6480 | 7669 | if ( unit !== "px" ) { |
— | — | @@ -6620,8 +7809,12 @@ |
6621 | 7810 | return this.elem[ this.prop ]; |
6622 | 7811 | } |
6623 | 7812 | |
6624 | | - var r = parseFloat( jQuery.css( this.elem, this.prop ) ); |
6625 | | - return r && r > -10000 ? r : 0; |
| 7813 | + var parsed, |
| 7814 | + r = jQuery.css( this.elem, this.prop ); |
| 7815 | + // Empty strings, null, undefined and "auto" are converted to 0, |
| 7816 | + // complex values such as "rotate(1rad)" are returned as is, |
| 7817 | + // simple values such as "10px" are parsed to Float. |
| 7818 | + return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed; |
6626 | 7819 | }, |
6627 | 7820 | |
6628 | 7821 | // Start an animation from one number to another |
— | — | @@ -6632,7 +7825,7 @@ |
6633 | 7826 | this.startTime = jQuery.now(); |
6634 | 7827 | this.start = from; |
6635 | 7828 | this.end = to; |
6636 | | - this.unit = unit || this.unit || "px"; |
| 7829 | + this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" ); |
6637 | 7830 | this.now = this.start; |
6638 | 7831 | this.pos = this.state = 0; |
6639 | 7832 | |
— | — | @@ -6815,7 +8008,7 @@ |
6816 | 8009 | jQuery.fn.offset = function( options ) { |
6817 | 8010 | var elem = this[0], box; |
6818 | 8011 | |
6819 | | - if ( options ) { |
| 8012 | + if ( options ) { |
6820 | 8013 | return this.each(function( i ) { |
6821 | 8014 | jQuery.offset.setOffset( this, options, i ); |
6822 | 8015 | }); |
— | — | @@ -6838,15 +8031,15 @@ |
6839 | 8032 | |
6840 | 8033 | // Make sure we're not dealing with a disconnected DOM node |
6841 | 8034 | if ( !box || !jQuery.contains( docElem, elem ) ) { |
6842 | | - return box || { top: 0, left: 0 }; |
| 8035 | + return box ? { top: box.top, left: box.left } : { top: 0, left: 0 }; |
6843 | 8036 | } |
6844 | 8037 | |
6845 | 8038 | var body = doc.body, |
6846 | 8039 | win = getWindow(doc), |
6847 | 8040 | clientTop = docElem.clientTop || body.clientTop || 0, |
6848 | 8041 | 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), |
| 8042 | + scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop, |
| 8043 | + scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft, |
6851 | 8044 | top = box.top + scrollTop - clientTop, |
6852 | 8045 | left = box.left + scrollLeft - clientLeft; |
6853 | 8046 | |
— | — | @@ -6857,7 +8050,7 @@ |
6858 | 8051 | jQuery.fn.offset = function( options ) { |
6859 | 8052 | var elem = this[0]; |
6860 | 8053 | |
6861 | | - if ( options ) { |
| 8054 | + if ( options ) { |
6862 | 8055 | return this.each(function( i ) { |
6863 | 8056 | jQuery.offset.setOffset( this, options, i ); |
6864 | 8057 | }); |
— | — | @@ -6959,7 +8152,6 @@ |
6960 | 8153 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
6961 | 8154 | |
6962 | 8155 | body.removeChild( container ); |
6963 | | - body = container = innerDiv = checkDiv = table = td = null; |
6964 | 8156 | jQuery.offset.initialize = jQuery.noop; |
6965 | 8157 | }, |
6966 | 8158 | |
— | — | @@ -6976,7 +8168,7 @@ |
6977 | 8169 | |
6978 | 8170 | return { top: top, left: left }; |
6979 | 8171 | }, |
6980 | | - |
| 8172 | + |
6981 | 8173 | setOffset: function( elem, options, i ) { |
6982 | 8174 | var position = jQuery.css( elem, "position" ); |
6983 | 8175 | |
— | — | @@ -6989,10 +8181,10 @@ |
6990 | 8182 | curOffset = curElem.offset(), |
6991 | 8183 | curCSSTop = jQuery.css( elem, "top" ), |
6992 | 8184 | curCSSLeft = jQuery.css( elem, "left" ), |
6993 | | - calculatePosition = (position === "absolute" && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1), |
| 8185 | + calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1, |
6994 | 8186 | props = {}, curPosition = {}, curTop, curLeft; |
6995 | 8187 | |
6996 | | - // need to be able to calculate position if either top or left is auto and position is absolute |
| 8188 | + // need to be able to calculate position if either top or left is auto and position is either absolute or fixed |
6997 | 8189 | if ( calculatePosition ) { |
6998 | 8190 | curPosition = curElem.position(); |
6999 | 8191 | } |
— | — | @@ -7010,7 +8202,7 @@ |
7011 | 8203 | if (options.left != null) { |
7012 | 8204 | props.left = (options.left - curOffset.left) + curLeft; |
7013 | 8205 | } |
7014 | | - |
| 8206 | + |
7015 | 8207 | if ( "using" in options ) { |
7016 | 8208 | options.using.call( elem, props ); |
7017 | 8209 | } else { |
— | — | @@ -7070,7 +8262,7 @@ |
7071 | 8263 | |
7072 | 8264 | jQuery.fn[ method ] = function(val) { |
7073 | 8265 | var elem = this[0], win; |
7074 | | - |
| 8266 | + |
7075 | 8267 | if ( !elem ) { |
7076 | 8268 | return null; |
7077 | 8269 | } |
— | — | @@ -7083,7 +8275,7 @@ |
7084 | 8276 | if ( win ) { |
7085 | 8277 | win.scrollTo( |
7086 | 8278 | !i ? val : jQuery(win).scrollLeft(), |
7087 | | - i ? val : jQuery(win).scrollTop() |
| 8279 | + i ? val : jQuery(win).scrollTop() |
7088 | 8280 | ); |
7089 | 8281 | |
7090 | 8282 | } else { |
— | — | @@ -7138,7 +8330,7 @@ |
7139 | 8331 | if ( !elem ) { |
7140 | 8332 | return size == null ? null : this; |
7141 | 8333 | } |
7142 | | - |
| 8334 | + |
7143 | 8335 | if ( jQuery.isFunction( size ) ) { |
7144 | 8336 | return this.each(function( i ) { |
7145 | 8337 | var self = jQuery( this ); |
— | — | @@ -7148,8 +8340,10 @@ |
7149 | 8341 | |
7150 | 8342 | if ( jQuery.isWindow( elem ) ) { |
7151 | 8343 | // 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 ]; |
| 8344 | + // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat |
| 8345 | + var docElemProp = elem.document.documentElement[ "client" + name ]; |
| 8346 | + return elem.document.compatMode === "CSS1Compat" && docElemProp || |
| 8347 | + elem.document.body[ "client" + name ] || docElemProp; |
7154 | 8348 | |
7155 | 8349 | // Get document width or height |
7156 | 8350 | } else if ( elem.nodeType === 9 ) { |
— | — | @@ -7176,4 +8370,5 @@ |
7177 | 8371 | }); |
7178 | 8372 | |
7179 | 8373 | |
| 8374 | +window.jQuery = window.$ = jQuery; |
7180 | 8375 | })(window); |