Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -38,7 +38,6 @@ |
39 | 39 | added to the textarea on the edit form. |
40 | 40 | * mw.util.getScript has been implemented (like wfScript in GlobalFunctions.php) |
41 | 41 | * (bug 29067) Creating "user.tokens" module (like user.options) in ResourceLoader. |
42 | | -* (bug 28904) Update jQuery version from 1.4.4 to 1.5.2 (the latest update to 1.5) |
43 | 42 | |
44 | 43 | === Bug fixes in 1.19 === |
45 | 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.5.2 |
| 3 | + * jQuery JavaScript Library v1.4.4 |
4 | 4 | * http://jquery.com/ |
5 | 5 | * |
6 | | - * Copyright 2011, John Resig |
| 6 | + * Copyright 2010, 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 2011, The Dojo Foundation |
| 12 | + * Copyright 2010, The Dojo Foundation |
13 | 13 | * Released under the MIT, BSD, and GPL Licenses. |
14 | 14 | * |
15 | | - * Date: Thu Mar 31 15:28:23 2011 -0400 |
| 15 | + * Date: Thu Nov 11 19:04:53 2010 -0500 |
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, rootjQuery ); |
| 26 | + return new jQuery.fn.init( selector, context ); |
27 | 27 | }, |
28 | 28 | |
29 | 29 | // Map over jQuery in case of overwrite |
— | — | @@ -38,13 +38,20 @@ |
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 | + |
42 | 45 | // Check if a string has a non-whitespace character in it |
43 | 46 | rnotwhite = /\S/, |
| 47 | + rwhite = /\s/, |
44 | 48 | |
45 | 49 | // Used for trimming whitespace |
46 | 50 | trimLeft = /^\s+/, |
47 | 51 | trimRight = /\s+$/, |
48 | 52 | |
| 53 | + // Check for non-word characters |
| 54 | + rnonword = /\W/, |
| 55 | + |
49 | 56 | // Check for digits |
50 | 57 | rdigit = /\d/, |
51 | 58 | |
— | — | @@ -68,10 +75,13 @@ |
69 | 76 | |
70 | 77 | // For matching the engine and version of the browser |
71 | 78 | browserMatch, |
| 79 | + |
| 80 | + // Has the ready events already been bound? |
| 81 | + readyBound = false, |
| 82 | + |
| 83 | + // The functions to execute on DOM ready |
| 84 | + readyList = [], |
72 | 85 | |
73 | | - // The deferred used on DOM ready |
74 | | - readyList, |
75 | | - |
76 | 86 | // The ready event handler |
77 | 87 | DOMContentLoaded, |
78 | 88 | |
— | — | @@ -82,13 +92,12 @@ |
83 | 93 | slice = Array.prototype.slice, |
84 | 94 | trim = String.prototype.trim, |
85 | 95 | indexOf = Array.prototype.indexOf, |
86 | | - |
| 96 | + |
87 | 97 | // [[Class]] -> type pairs |
88 | 98 | class2type = {}; |
89 | 99 | |
90 | 100 | jQuery.fn = jQuery.prototype = { |
91 | | - constructor: jQuery, |
92 | | - init: function( selector, context, rootjQuery ) { |
| 101 | + init: function( selector, context ) { |
93 | 102 | var match, elem, ret, doc; |
94 | 103 | |
95 | 104 | // Handle $(""), $(null), or $(undefined) |
— | — | @@ -102,7 +111,7 @@ |
103 | 112 | this.length = 1; |
104 | 113 | return this; |
105 | 114 | } |
106 | | - |
| 115 | + |
107 | 116 | // The body element only exists once, optimize finding it |
108 | 117 | if ( selector === "body" && !context && document.body ) { |
109 | 118 | this.context = document; |
— | — | @@ -122,7 +131,6 @@ |
123 | 132 | |
124 | 133 | // HANDLE: $(html) -> $(array) |
125 | 134 | if ( match[1] ) { |
126 | | - context = context instanceof jQuery ? context[0] : context; |
127 | 135 | doc = (context ? context.ownerDocument || context : document); |
128 | 136 | |
129 | 137 | // If a single string is passed in and it's a single tag |
— | — | @@ -140,11 +148,11 @@ |
141 | 149 | |
142 | 150 | } else { |
143 | 151 | ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); |
144 | | - selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes; |
| 152 | + selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; |
145 | 153 | } |
146 | | - |
| 154 | + |
147 | 155 | return jQuery.merge( this, selector ); |
148 | | - |
| 156 | + |
149 | 157 | // HANDLE: $("#id") |
150 | 158 | } else { |
151 | 159 | elem = document.getElementById( match[2] ); |
— | — | @@ -168,6 +176,13 @@ |
169 | 177 | return this; |
170 | 178 | } |
171 | 179 | |
| 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 | + |
172 | 187 | // HANDLE: $(expr, $(...)) |
173 | 188 | } else if ( !context || context.jquery ) { |
174 | 189 | return (context || rootjQuery).find( selector ); |
— | — | @@ -175,7 +190,7 @@ |
176 | 191 | // HANDLE: $(expr, context) |
177 | 192 | // (which is just equivalent to: $(context).find(expr) |
178 | 193 | } else { |
179 | | - return this.constructor( context ).find( selector ); |
| 194 | + return jQuery( context ).find( selector ); |
180 | 195 | } |
181 | 196 | |
182 | 197 | // HANDLE: $(function) |
— | — | @@ -196,7 +211,7 @@ |
197 | 212 | selector: "", |
198 | 213 | |
199 | 214 | // The current version of jQuery being used |
200 | | - jquery: "1.5.2", |
| 215 | + jquery: "1.4.4", |
201 | 216 | |
202 | 217 | // The default length of a jQuery object is 0 |
203 | 218 | length: 0, |
— | — | @@ -219,18 +234,18 @@ |
220 | 235 | this.toArray() : |
221 | 236 | |
222 | 237 | // Return just the object |
223 | | - ( num < 0 ? this[ this.length + num ] : this[ num ] ); |
| 238 | + ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] ); |
224 | 239 | }, |
225 | 240 | |
226 | 241 | // Take an array of elements and push it onto the stack |
227 | 242 | // (returning the new matched element set) |
228 | 243 | pushStack: function( elems, name, selector ) { |
229 | 244 | // Build a new jQuery matched element set |
230 | | - var ret = this.constructor(); |
| 245 | + var ret = jQuery(); |
231 | 246 | |
232 | 247 | if ( jQuery.isArray( elems ) ) { |
233 | 248 | push.apply( ret, elems ); |
234 | | - |
| 249 | + |
235 | 250 | } else { |
236 | 251 | jQuery.merge( ret, elems ); |
237 | 252 | } |
— | — | @@ -256,17 +271,25 @@ |
257 | 272 | each: function( callback, args ) { |
258 | 273 | return jQuery.each( this, callback, args ); |
259 | 274 | }, |
260 | | - |
| 275 | + |
261 | 276 | ready: function( fn ) { |
262 | 277 | // Attach the listeners |
263 | 278 | jQuery.bindReady(); |
264 | 279 | |
265 | | - // Add the callback |
266 | | - readyList.done( fn ); |
| 280 | + // If the DOM is already ready |
| 281 | + if ( jQuery.isReady ) { |
| 282 | + // Execute the function immediately |
| 283 | + fn.call( document, jQuery ); |
267 | 284 | |
| 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 | + |
268 | 291 | return this; |
269 | 292 | }, |
270 | | - |
| 293 | + |
271 | 294 | eq: function( i ) { |
272 | 295 | return i === -1 ? |
273 | 296 | this.slice( i ) : |
— | — | @@ -291,9 +314,9 @@ |
292 | 315 | return callback.call( elem, i, elem ); |
293 | 316 | })); |
294 | 317 | }, |
295 | | - |
| 318 | + |
296 | 319 | end: function() { |
297 | | - return this.prevObject || this.constructor(null); |
| 320 | + return this.prevObject || jQuery(null); |
298 | 321 | }, |
299 | 322 | |
300 | 323 | // For internal use only. |
— | — | @@ -307,7 +330,7 @@ |
308 | 331 | jQuery.fn.init.prototype = jQuery.fn; |
309 | 332 | |
310 | 333 | jQuery.extend = jQuery.fn.extend = function() { |
311 | | - var options, name, src, copy, copyIsArray, clone, |
| 334 | + var options, name, src, copy, copyIsArray, clone, |
312 | 335 | target = arguments[0] || {}, |
313 | 336 | i = 1, |
314 | 337 | length = arguments.length, |
— | — | @@ -380,14 +403,14 @@ |
381 | 404 | |
382 | 405 | return jQuery; |
383 | 406 | }, |
384 | | - |
| 407 | + |
385 | 408 | // Is the DOM ready to be used? Set to true once it occurs. |
386 | 409 | isReady: false, |
387 | 410 | |
388 | 411 | // A counter to track how many items to wait for before |
389 | 412 | // the ready event fires. See #6781 |
390 | 413 | readyWait: 1, |
391 | | - |
| 414 | + |
392 | 415 | // Handle when the DOM is ready |
393 | 416 | ready: function( wait ) { |
394 | 417 | // A third-party is pushing the ready event forwards |
— | — | @@ -411,21 +434,33 @@ |
412 | 435 | } |
413 | 436 | |
414 | 437 | // If there are functions bound, to execute |
415 | | - readyList.resolveWith( document, [ jQuery ] ); |
| 438 | + if ( readyList ) { |
| 439 | + // Execute all of them |
| 440 | + var fn, |
| 441 | + i = 0, |
| 442 | + ready = readyList; |
416 | 443 | |
417 | | - // Trigger any bound ready events |
418 | | - if ( jQuery.fn.trigger ) { |
419 | | - jQuery( document ).trigger( "ready" ).unbind( "ready" ); |
| 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 | + } |
420 | 455 | } |
421 | 456 | } |
422 | 457 | }, |
423 | | - |
| 458 | + |
424 | 459 | bindReady: function() { |
425 | | - if ( readyList ) { |
| 460 | + if ( readyBound ) { |
426 | 461 | return; |
427 | 462 | } |
428 | 463 | |
429 | | - readyList = jQuery._Deferred(); |
| 464 | + readyBound = true; |
430 | 465 | |
431 | 466 | // Catch cases where $(document).ready() is called after the |
432 | 467 | // browser event has already occurred. |
— | — | @@ -438,7 +473,7 @@ |
439 | 474 | if ( document.addEventListener ) { |
440 | 475 | // Use the handy event callback |
441 | 476 | document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); |
442 | | - |
| 477 | + |
443 | 478 | // A fallback to window.onload, that will always work |
444 | 479 | window.addEventListener( "load", jQuery.ready, false ); |
445 | 480 | |
— | — | @@ -447,7 +482,7 @@ |
448 | 483 | // ensure firing before onload, |
449 | 484 | // maybe late but safe also for iframes |
450 | 485 | document.attachEvent("onreadystatechange", DOMContentLoaded); |
451 | | - |
| 486 | + |
452 | 487 | // A fallback to window.onload, that will always work |
453 | 488 | window.attachEvent( "onload", jQuery.ready ); |
454 | 489 | |
— | — | @@ -498,20 +533,20 @@ |
499 | 534 | if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { |
500 | 535 | return false; |
501 | 536 | } |
502 | | - |
| 537 | + |
503 | 538 | // Not own constructor property must be Object |
504 | 539 | if ( obj.constructor && |
505 | 540 | !hasOwn.call(obj, "constructor") && |
506 | 541 | !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { |
507 | 542 | return false; |
508 | 543 | } |
509 | | - |
| 544 | + |
510 | 545 | // Own properties are enumerated firstly, so to speed up, |
511 | 546 | // if last one is own, then all properties are own. |
512 | | - |
| 547 | + |
513 | 548 | var key; |
514 | 549 | for ( key in obj ) {} |
515 | | - |
| 550 | + |
516 | 551 | return key === undefined || hasOwn.call( obj, key ); |
517 | 552 | }, |
518 | 553 | |
— | — | @@ -521,11 +556,11 @@ |
522 | 557 | } |
523 | 558 | return true; |
524 | 559 | }, |
525 | | - |
| 560 | + |
526 | 561 | error: function( msg ) { |
527 | 562 | throw msg; |
528 | 563 | }, |
529 | | - |
| 564 | + |
530 | 565 | parseJSON: function( data ) { |
531 | 566 | if ( typeof data !== "string" || !data ) { |
532 | 567 | return null; |
— | — | @@ -533,7 +568,7 @@ |
534 | 569 | |
535 | 570 | // Make sure leading/trailing whitespace is removed (IE can't handle it) |
536 | 571 | data = jQuery.trim( data ); |
537 | | - |
| 572 | + |
538 | 573 | // Make sure the incoming data is actual JSON |
539 | 574 | // Logic borrowed from http://json.org/json2.js |
540 | 575 | if ( rvalidchars.test(data.replace(rvalidescape, "@") |
— | — | @@ -550,28 +585,6 @@ |
551 | 586 | } |
552 | 587 | }, |
553 | 588 | |
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 | | - |
576 | 589 | noop: function() {}, |
577 | 590 | |
578 | 591 | // Evalulates a script in a global context |
— | — | @@ -579,10 +592,12 @@ |
580 | 593 | if ( data && rnotwhite.test(data) ) { |
581 | 594 | // Inspired by code by Andrea Giammarchi |
582 | 595 | // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html |
583 | | - var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement, |
584 | | - script = document.createElement( "script" ); |
| 596 | + var head = document.getElementsByTagName("head")[0] || document.documentElement, |
| 597 | + script = document.createElement("script"); |
585 | 598 | |
586 | | - if ( jQuery.support.scriptEval() ) { |
| 599 | + script.type = "text/javascript"; |
| 600 | + |
| 601 | + if ( jQuery.support.scriptEval ) { |
587 | 602 | script.appendChild( document.createTextNode( data ) ); |
588 | 603 | } else { |
589 | 604 | script.text = data; |
— | — | @@ -695,7 +710,7 @@ |
696 | 711 | for ( var l = second.length; j < l; j++ ) { |
697 | 712 | first[ i++ ] = second[ j ]; |
698 | 713 | } |
699 | | - |
| 714 | + |
700 | 715 | } else { |
701 | 716 | while ( second[j] !== undefined ) { |
702 | 717 | first[ i++ ] = second[ j++ ]; |
— | — | @@ -737,7 +752,6 @@ |
738 | 753 | } |
739 | 754 | } |
740 | 755 | |
741 | | - // Flatten any nested arrays |
742 | 756 | return ret.concat.apply( [], ret ); |
743 | 757 | }, |
744 | 758 | |
— | — | @@ -776,7 +790,7 @@ |
777 | 791 | // The value/s can be optionally by executed if its a function |
778 | 792 | access: function( elems, key, value, exec, fn, pass ) { |
779 | 793 | var length = elems.length; |
780 | | - |
| 794 | + |
781 | 795 | // Setting many attributes |
782 | 796 | if ( typeof key === "object" ) { |
783 | 797 | for ( var k in key ) { |
— | — | @@ -784,19 +798,19 @@ |
785 | 799 | } |
786 | 800 | return elems; |
787 | 801 | } |
788 | | - |
| 802 | + |
789 | 803 | // Setting one attribute |
790 | 804 | if ( value !== undefined ) { |
791 | 805 | // Optionally, function values get executed if exec is true |
792 | 806 | exec = !pass && exec && jQuery.isFunction(value); |
793 | | - |
| 807 | + |
794 | 808 | for ( var i = 0; i < length; i++ ) { |
795 | 809 | fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); |
796 | 810 | } |
797 | | - |
| 811 | + |
798 | 812 | return elems; |
799 | 813 | } |
800 | | - |
| 814 | + |
801 | 815 | // Getting an attribute |
802 | 816 | return length ? fn( elems[0], key ) : undefined; |
803 | 817 | }, |
— | — | @@ -819,27 +833,6 @@ |
820 | 834 | return { browser: match[1] || "", version: match[2] || "0" }; |
821 | 835 | }, |
822 | 836 | |
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 | | - |
844 | 837 | browser: {} |
845 | 838 | }); |
846 | 839 | |
— | — | @@ -865,8 +858,9 @@ |
866 | 859 | }; |
867 | 860 | } |
868 | 861 | |
869 | | -// IE doesn't match non-breaking spaces with \s |
870 | | -if ( rnotwhite.test( "\xA0" ) ) { |
| 862 | +// Verify that \s matches non-breaking spaces |
| 863 | +// (IE fails on this test) |
| 864 | +if ( !rwhite.test( "\xA0" ) ) { |
871 | 865 | trimLeft = /^[\s\xA0]+/; |
872 | 866 | trimRight = /[\s\xA0]+$/; |
873 | 867 | } |
— | — | @@ -911,188 +905,19 @@ |
912 | 906 | } |
913 | 907 | |
914 | 908 | // Expose jQuery to the global object |
915 | | -return jQuery; |
| 909 | +return (window.jQuery = window.$ = jQuery); |
916 | 910 | |
917 | 911 | })(); |
918 | 912 | |
919 | 913 | |
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 | | - |
1092 | 914 | (function() { |
1093 | 915 | |
1094 | 916 | jQuery.support = {}; |
1095 | 917 | |
1096 | | - var div = document.createElement("div"); |
| 918 | + var root = document.documentElement, |
| 919 | + script = document.createElement("script"), |
| 920 | + div = document.createElement("div"), |
| 921 | + id = "script" + jQuery.now(); |
1097 | 922 | |
1098 | 923 | div.style.display = "none"; |
1099 | 924 | div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>"; |
— | — | @@ -1100,8 +925,7 @@ |
1101 | 926 | var all = div.getElementsByTagName("*"), |
1102 | 927 | a = div.getElementsByTagName("a")[0], |
1103 | 928 | select = document.createElement("select"), |
1104 | | - opt = select.appendChild( document.createElement("option") ), |
1105 | | - input = div.getElementsByTagName("input")[0]; |
| 929 | + opt = select.appendChild( document.createElement("option") ); |
1106 | 930 | |
1107 | 931 | // Can't get basic test support |
1108 | 932 | if ( !all || !all.length || !a ) { |
— | — | @@ -1140,7 +964,7 @@ |
1141 | 965 | // Make sure that if no value is specified for a checkbox |
1142 | 966 | // that it defaults to "on". |
1143 | 967 | // (WebKit defaults to "" instead) |
1144 | | - checkOn: input.value === "on", |
| 968 | + checkOn: div.getElementsByTagName("input")[0].value === "on", |
1145 | 969 | |
1146 | 970 | // Make sure that a selected-by-default option has a working selected property. |
1147 | 971 | // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) |
— | — | @@ -1150,62 +974,46 @@ |
1151 | 975 | deleteExpando: true, |
1152 | 976 | optDisabled: false, |
1153 | 977 | checkClone: false, |
| 978 | + scriptEval: false, |
1154 | 979 | noCloneEvent: true, |
1155 | | - noCloneChecked: true, |
1156 | 980 | boxModel: null, |
1157 | 981 | inlineBlockNeedsLayout: false, |
1158 | 982 | shrinkWrapBlocks: false, |
1159 | | - reliableHiddenOffsets: true, |
1160 | | - reliableMarginRight: true |
| 983 | + reliableHiddenOffsets: true |
1161 | 984 | }; |
1162 | 985 | |
1163 | | - input.checked = true; |
1164 | | - jQuery.support.noCloneChecked = input.cloneNode( true ).checked; |
1165 | | - |
1166 | 986 | // Make sure that the options inside disabled selects aren't marked as disabled |
1167 | 987 | // (WebKit marks them as diabled) |
1168 | 988 | select.disabled = true; |
1169 | 989 | jQuery.support.optDisabled = !opt.disabled; |
1170 | 990 | |
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(); |
| 991 | + script.type = "text/javascript"; |
| 992 | + try { |
| 993 | + script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
| 994 | + } catch(e) {} |
1177 | 995 | |
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) {} |
| 996 | + root.insertBefore( script, root.firstChild ); |
1184 | 997 | |
1185 | | - root.insertBefore( script, root.firstChild ); |
| 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 | + } |
1186 | 1005 | |
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 | | - |
1200 | 1006 | // Test to see if it's possible to delete an expando from an element |
1201 | 1007 | // Fails in Internet Explorer |
1202 | 1008 | try { |
1203 | | - delete div.test; |
| 1009 | + delete script.test; |
1204 | 1010 | |
1205 | 1011 | } catch(e) { |
1206 | 1012 | jQuery.support.deleteExpando = false; |
1207 | 1013 | } |
1208 | 1014 | |
1209 | | - if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { |
| 1015 | + root.removeChild( script ); |
| 1016 | + |
| 1017 | + if ( div.attachEvent && div.fireEvent ) { |
1210 | 1018 | div.attachEvent("onclick", function click() { |
1211 | 1019 | // Cloning a node shouldn't copy over any |
1212 | 1020 | // bound event handlers (IE does this) |
— | — | @@ -1227,16 +1035,10 @@ |
1228 | 1036 | // Figure out if the W3C box model works as expected |
1229 | 1037 | // document.body must exist before we can do this |
1230 | 1038 | jQuery(function() { |
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 | | - |
| 1039 | + var div = document.createElement("div"); |
1239 | 1040 | div.style.width = div.style.paddingLeft = "1px"; |
1240 | | - body.appendChild( div ); |
| 1041 | + |
| 1042 | + document.body.appendChild( div ); |
1241 | 1043 | jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
1242 | 1044 | |
1243 | 1045 | if ( "zoom" in div.style ) { |
— | — | @@ -1255,7 +1057,7 @@ |
1256 | 1058 | jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2; |
1257 | 1059 | } |
1258 | 1060 | |
1259 | | - div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>"; |
| 1061 | + div.innerHTML = "<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>"; |
1260 | 1062 | var tds = div.getElementsByTagName("td"); |
1261 | 1063 | |
1262 | 1064 | // Check if table cells still have offsetWidth/Height when they are set |
— | — | @@ -1275,18 +1077,7 @@ |
1276 | 1078 | jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0; |
1277 | 1079 | div.innerHTML = ""; |
1278 | 1080 | |
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"; |
| 1081 | + document.body.removeChild( div ).style.display = "none"; |
1291 | 1082 | div = tds = null; |
1292 | 1083 | }); |
1293 | 1084 | |
— | — | @@ -1296,19 +1087,13 @@ |
1297 | 1088 | var el = document.createElement("div"); |
1298 | 1089 | eventName = "on" + eventName; |
1299 | 1090 | |
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 | | - |
1308 | 1091 | var isSupported = (eventName in el); |
1309 | 1092 | if ( !isSupported ) { |
1310 | 1093 | el.setAttribute(eventName, "return;"); |
1311 | 1094 | isSupported = typeof el[eventName] === "function"; |
1312 | 1095 | } |
| 1096 | + el = null; |
| 1097 | + |
1313 | 1098 | return isSupported; |
1314 | 1099 | }; |
1315 | 1100 | |
— | — | @@ -1316,12 +1101,13 @@ |
1317 | 1102 | jQuery.support.changeBubbles = eventSupported("change"); |
1318 | 1103 | |
1319 | 1104 | // release memory in IE |
1320 | | - div = all = a = null; |
| 1105 | + root = script = div = all = a = null; |
1321 | 1106 | })(); |
1322 | 1107 | |
1323 | 1108 | |
1324 | 1109 | |
1325 | | -var rbrace = /^(?:\{.*\}|\[.*\])$/; |
| 1110 | +var windowData = {}, |
| 1111 | + rbrace = /^(?:\{.*\}|\[.*\])$/; |
1326 | 1112 | |
1327 | 1113 | jQuery.extend({ |
1328 | 1114 | cache: {}, |
— | — | @@ -1329,9 +1115,8 @@ |
1330 | 1116 | // Please use with caution |
1331 | 1117 | uuid: 0, |
1332 | 1118 | |
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, "" ), |
| 1119 | + // Unique for each copy of jQuery on the page |
| 1120 | + expando: "jQuery" + jQuery.now(), |
1336 | 1121 | |
1337 | 1122 | // The following elements throw uncatchable exceptions if you |
1338 | 1123 | // attempt to add expando properties to them. |
— | — | @@ -1342,185 +1127,103 @@ |
1343 | 1128 | "applet": true |
1344 | 1129 | }, |
1345 | 1130 | |
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 */ ) { |
| 1131 | + data: function( elem, name, data ) { |
1353 | 1132 | if ( !jQuery.acceptData( elem ) ) { |
1354 | 1133 | return; |
1355 | 1134 | } |
1356 | 1135 | |
1357 | | - var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache, |
| 1136 | + elem = elem == window ? |
| 1137 | + windowData : |
| 1138 | + elem; |
1358 | 1139 | |
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, |
| 1140 | + var isNode = elem.nodeType, |
| 1141 | + id = isNode ? elem[ jQuery.expando ] : null, |
| 1142 | + cache = jQuery.cache, thisCache; |
1362 | 1143 | |
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 ) { |
| 1144 | + if ( isNode && !id && typeof name === "string" && data === undefined ) { |
1374 | 1145 | return; |
1375 | 1146 | } |
1376 | 1147 | |
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 | | - } |
| 1148 | + // Get the data from the object directly |
| 1149 | + if ( !isNode ) { |
| 1150 | + cache = elem; |
1386 | 1151 | |
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 | | - } |
| 1152 | + // Compute a unique ID for the element |
| 1153 | + } else if ( !id ) { |
| 1154 | + elem[ jQuery.expando ] = id = ++jQuery.uuid; |
1396 | 1155 | } |
1397 | 1156 | |
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 { |
| 1157 | + // Avoid generating a new cache unless none exists and we |
| 1158 | + // want to manipulate it. |
| 1159 | + if ( typeof name === "object" ) { |
| 1160 | + if ( isNode ) { |
1404 | 1161 | cache[ id ] = jQuery.extend(cache[ id ], name); |
1405 | | - } |
1406 | | - } |
1407 | 1162 | |
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 ] = {}; |
| 1163 | + } else { |
| 1164 | + jQuery.extend( cache, name ); |
1416 | 1165 | } |
1417 | 1166 | |
1418 | | - thisCache = thisCache[ internalKey ]; |
| 1167 | + } else if ( isNode && !cache[ id ] ) { |
| 1168 | + cache[ id ] = {}; |
1419 | 1169 | } |
1420 | 1170 | |
| 1171 | + thisCache = isNode ? cache[ id ] : cache; |
| 1172 | + |
| 1173 | + // Prevent overriding the named cache with undefined values |
1421 | 1174 | if ( data !== undefined ) { |
1422 | 1175 | thisCache[ name ] = data; |
1423 | 1176 | } |
1424 | 1177 | |
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; |
| 1178 | + return typeof name === "string" ? thisCache[ name ] : thisCache; |
1433 | 1179 | }, |
1434 | 1180 | |
1435 | | - removeData: function( elem, name, pvt /* Internal Use Only */ ) { |
| 1181 | + removeData: function( elem, name ) { |
1436 | 1182 | if ( !jQuery.acceptData( elem ) ) { |
1437 | 1183 | return; |
1438 | 1184 | } |
1439 | 1185 | |
1440 | | - var internalKey = jQuery.expando, isNode = elem.nodeType, |
| 1186 | + elem = elem == window ? |
| 1187 | + windowData : |
| 1188 | + elem; |
1441 | 1189 | |
1442 | | - // See jQuery.data for more information |
1443 | | - cache = isNode ? jQuery.cache : elem, |
| 1190 | + var isNode = elem.nodeType, |
| 1191 | + id = isNode ? elem[ jQuery.expando ] : elem, |
| 1192 | + cache = jQuery.cache, |
| 1193 | + thisCache = isNode ? cache[ id ] : id; |
1444 | 1194 | |
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 | | - |
| 1195 | + // If we want to remove a specific section of the element's data |
1454 | 1196 | if ( name ) { |
1455 | | - var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ]; |
1456 | | - |
1457 | 1197 | if ( thisCache ) { |
| 1198 | + // Remove the section of cache data |
1458 | 1199 | delete thisCache[ name ]; |
1459 | 1200 | |
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; |
| 1201 | + // If we've removed all the data, remove the element's cache |
| 1202 | + if ( isNode && jQuery.isEmptyObject(thisCache) ) { |
| 1203 | + jQuery.removeData( elem ); |
1464 | 1204 | } |
1465 | 1205 | } |
1466 | | - } |
1467 | 1206 | |
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 ]; |
| 1207 | + // Otherwise, we want to remove all of the element's data |
1486 | 1208 | } else { |
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 ) { |
| 1209 | + if ( isNode && jQuery.support.deleteExpando ) { |
1511 | 1210 | delete elem[ jQuery.expando ]; |
| 1211 | + |
1512 | 1212 | } else if ( elem.removeAttribute ) { |
1513 | 1213 | 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 |
1514 | 1220 | } else { |
1515 | | - elem[ jQuery.expando ] = null; |
| 1221 | + for ( var n in elem ) { |
| 1222 | + delete elem[ n ]; |
| 1223 | + } |
1516 | 1224 | } |
1517 | 1225 | } |
1518 | 1226 | }, |
1519 | 1227 | |
1520 | | - // For internal use only. |
1521 | | - _data: function( elem, name, data ) { |
1522 | | - return jQuery.data( elem, name, data, true ); |
1523 | | - }, |
1524 | | - |
1525 | 1228 | // A method for determining if a DOM node can handle the data expando |
1526 | 1229 | acceptData: function( elem ) { |
1527 | 1230 | if ( elem.nodeName ) { |
— | — | @@ -1541,17 +1244,15 @@ |
1542 | 1245 | |
1543 | 1246 | if ( typeof key === "undefined" ) { |
1544 | 1247 | if ( this.length ) { |
| 1248 | + var attr = this[0].attributes, name; |
1545 | 1249 | data = jQuery.data( this[0] ); |
1546 | 1250 | |
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; |
| 1251 | + for ( var i = 0, l = attr.length; i < l; i++ ) { |
| 1252 | + name = attr[i].name; |
1551 | 1253 | |
1552 | | - if ( name.indexOf( "data-" ) === 0 ) { |
1553 | | - name = name.substr( 5 ); |
1554 | | - dataAttr( this[0], name, data[ name ] ); |
1555 | | - } |
| 1254 | + if ( name.indexOf( "data-" ) === 0 ) { |
| 1255 | + name = name.substr( 5 ); |
| 1256 | + dataAttr( this[0], name, data[ name ] ); |
1556 | 1257 | } |
1557 | 1258 | } |
1558 | 1259 | } |
— | — | @@ -1626,22 +1327,9 @@ |
1627 | 1328 | return data; |
1628 | 1329 | } |
1629 | 1330 | |
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 | | - } |
1639 | 1331 | |
1640 | | - return true; |
1641 | | -} |
1642 | 1332 | |
1643 | 1333 | |
1644 | | - |
1645 | | - |
1646 | 1334 | jQuery.extend({ |
1647 | 1335 | queue: function( elem, type, data ) { |
1648 | 1336 | if ( !elem ) { |
— | — | @@ -1649,7 +1337,7 @@ |
1650 | 1338 | } |
1651 | 1339 | |
1652 | 1340 | type = (type || "fx") + "queue"; |
1653 | | - var q = jQuery._data( elem, type ); |
| 1341 | + var q = jQuery.data( elem, type ); |
1654 | 1342 | |
1655 | 1343 | // Speed up dequeue by getting out quickly if this is just a lookup |
1656 | 1344 | if ( !data ) { |
— | — | @@ -1657,7 +1345,7 @@ |
1658 | 1346 | } |
1659 | 1347 | |
1660 | 1348 | if ( !q || jQuery.isArray(data) ) { |
1661 | | - q = jQuery._data( elem, type, jQuery.makeArray(data) ); |
| 1349 | + q = jQuery.data( elem, type, jQuery.makeArray(data) ); |
1662 | 1350 | |
1663 | 1351 | } else { |
1664 | 1352 | q.push( data ); |
— | — | @@ -1688,10 +1376,6 @@ |
1689 | 1377 | jQuery.dequeue(elem, type); |
1690 | 1378 | }); |
1691 | 1379 | } |
1692 | | - |
1693 | | - if ( !queue.length ) { |
1694 | | - jQuery.removeData( elem, type + "queue", true ); |
1695 | | - } |
1696 | 1380 | } |
1697 | 1381 | }); |
1698 | 1382 | |
— | — | @@ -1741,7 +1425,7 @@ |
1742 | 1426 | |
1743 | 1427 | |
1744 | 1428 | |
1745 | | -var rclass = /[\n\t\r]/g, |
| 1429 | +var rclass = /[\n\t]/g, |
1746 | 1430 | rspaces = /\s+/, |
1747 | 1431 | rreturn = /\r/g, |
1748 | 1432 | rspecialurl = /^(?:href|src|style)$/, |
— | — | @@ -1874,11 +1558,11 @@ |
1875 | 1559 | } else if ( type === "undefined" || type === "boolean" ) { |
1876 | 1560 | if ( this.className ) { |
1877 | 1561 | // store className if set |
1878 | | - jQuery._data( this, "__className__", this.className ); |
| 1562 | + jQuery.data( this, "__className__", this.className ); |
1879 | 1563 | } |
1880 | 1564 | |
1881 | 1565 | // toggle whole className |
1882 | | - this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; |
| 1566 | + this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || ""; |
1883 | 1567 | } |
1884 | 1568 | }); |
1885 | 1569 | }, |
— | — | @@ -1923,7 +1607,7 @@ |
1924 | 1608 | var option = options[ i ]; |
1925 | 1609 | |
1926 | 1610 | // Don't return options that are disabled or in a disabled optgroup |
1927 | | - if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && |
| 1611 | + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && |
1928 | 1612 | (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { |
1929 | 1613 | |
1930 | 1614 | // Get the specific value for the option |
— | — | @@ -1939,11 +1623,6 @@ |
1940 | 1624 | } |
1941 | 1625 | } |
1942 | 1626 | |
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 | | - |
1948 | 1627 | return values; |
1949 | 1628 | } |
1950 | 1629 | |
— | — | @@ -1951,6 +1630,7 @@ |
1952 | 1631 | if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) { |
1953 | 1632 | return elem.getAttribute("value") === null ? "on" : elem.value; |
1954 | 1633 | } |
| 1634 | + |
1955 | 1635 | |
1956 | 1636 | // Everything else, we just grab the value |
1957 | 1637 | return (elem.value || "").replace(rreturn, ""); |
— | — | @@ -2016,10 +1696,10 @@ |
2017 | 1697 | height: true, |
2018 | 1698 | offset: true |
2019 | 1699 | }, |
2020 | | - |
| 1700 | + |
2021 | 1701 | attr: function( elem, name, value, pass ) { |
2022 | | - // don't get/set attributes on text, comment and attribute nodes |
2023 | | - if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) { |
| 1702 | + // don't set attributes on text and comment nodes |
| 1703 | + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
2024 | 1704 | return undefined; |
2025 | 1705 | } |
2026 | 1706 | |
— | — | @@ -2034,96 +1714,88 @@ |
2035 | 1715 | // Try to normalize/fix the name |
2036 | 1716 | name = notxml && jQuery.props[ name ] || name; |
2037 | 1717 | |
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 ); |
| 1718 | + // These attributes require special treatment |
| 1719 | + var special = rspecialurl.test( name ); |
2042 | 1720 | |
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; |
| 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; |
2049 | 1727 | |
2050 | | - // Make sure that it also works with optgroups, see #5701 |
2051 | | - if ( parent.parentNode ) { |
2052 | | - parent.parentNode.selectedIndex; |
2053 | | - } |
| 1728 | + // Make sure that it also works with optgroups, see #5701 |
| 1729 | + if ( parent.parentNode ) { |
| 1730 | + parent.parentNode.selectedIndex; |
2054 | 1731 | } |
2055 | 1732 | } |
| 1733 | + } |
2056 | 1734 | |
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 | | - } |
| 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 | + } |
2065 | 1743 | |
2066 | | - if ( value === null ) { |
2067 | | - if ( elem.nodeType === 1 ) { |
2068 | | - elem.removeAttribute( name ); |
2069 | | - } |
2070 | | - |
2071 | | - } else { |
2072 | | - elem[ name ] = value; |
| 1744 | + if ( value === null ) { |
| 1745 | + if ( elem.nodeType === 1 ) { |
| 1746 | + elem.removeAttribute( name ); |
2073 | 1747 | } |
2074 | | - } |
2075 | 1748 | |
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; |
| 1749 | + } else { |
| 1750 | + elem[ name ] = value; |
2079 | 1751 | } |
| 1752 | + } |
2080 | 1753 | |
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 ]; |
| 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; |
2094 | 1757 | } |
2095 | 1758 | |
2096 | | - if ( !jQuery.support.style && notxml && name === "style" ) { |
2097 | | - if ( set ) { |
2098 | | - elem.style.cssText = "" + value; |
2099 | | - } |
| 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" ); |
2100 | 1763 | |
2101 | | - return elem.style.cssText; |
| 1764 | + return attributeNode && attributeNode.specified ? |
| 1765 | + attributeNode.value : |
| 1766 | + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? |
| 1767 | + 0 : |
| 1768 | + undefined; |
2102 | 1769 | } |
2103 | 1770 | |
| 1771 | + return elem[ name ]; |
| 1772 | + } |
| 1773 | + |
| 1774 | + if ( !jQuery.support.style && notxml && name === "style" ) { |
2104 | 1775 | if ( set ) { |
2105 | | - // convert the value to a string (all browsers do this but IE) see #1070 |
2106 | | - elem.setAttribute( name, "" + value ); |
| 1776 | + elem.style.cssText = "" + value; |
2107 | 1777 | } |
2108 | 1778 | |
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; |
| 1779 | + return elem.style.cssText; |
2122 | 1780 | } |
2123 | | - // Handle everything which isn't a DOM element node |
| 1781 | + |
2124 | 1782 | if ( set ) { |
2125 | | - elem[ name ] = value; |
| 1783 | + // convert the value to a string (all browsers do this but IE) see #1070 |
| 1784 | + elem.setAttribute( name, "" + value ); |
2126 | 1785 | } |
2127 | | - return elem[ name ]; |
| 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; |
2128 | 1800 | } |
2129 | 1801 | }); |
2130 | 1802 | |
— | — | @@ -2137,7 +1809,8 @@ |
2138 | 1810 | rescape = /[^\w\s.|`]/g, |
2139 | 1811 | fcleanup = function( nm ) { |
2140 | 1812 | return nm.replace(rescape, "\\$&"); |
2141 | | - }; |
| 1813 | + }, |
| 1814 | + focusCounts = { focusin: 0, focusout: 0 }; |
2142 | 1815 | |
2143 | 1816 | /* |
2144 | 1817 | * A number of helper functions used for managing events. |
— | — | @@ -2153,22 +1826,17 @@ |
2154 | 1827 | return; |
2155 | 1828 | } |
2156 | 1829 | |
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 | | - } |
| 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; |
2165 | 1834 | } |
2166 | | - catch ( e ) {} |
2167 | 1835 | |
2168 | 1836 | if ( handler === false ) { |
2169 | 1837 | handler = returnFalse; |
2170 | 1838 | } else if ( !handler ) { |
2171 | 1839 | // Fixes bug #7229. Fix recommended by jdalton |
2172 | | - return; |
| 1840 | + return; |
2173 | 1841 | } |
2174 | 1842 | |
2175 | 1843 | var handleObjIn, handleObj; |
— | — | @@ -2184,7 +1852,7 @@ |
2185 | 1853 | } |
2186 | 1854 | |
2187 | 1855 | // Init the element's event structure |
2188 | | - var elemData = jQuery._data( elem ); |
| 1856 | + var elemData = jQuery.data( elem ); |
2189 | 1857 | |
2190 | 1858 | // If no elemData is found then we must be trying to bind to one of the |
2191 | 1859 | // banned noData elements |
— | — | @@ -2192,18 +1860,34 @@ |
2193 | 1861 | return; |
2194 | 1862 | } |
2195 | 1863 | |
2196 | | - var events = elemData.events, |
| 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 ], |
2197 | 1868 | 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; |
2198 | 1876 | |
2199 | | - if ( !events ) { |
| 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 | + |
2200 | 1884 | elemData.events = events = {}; |
2201 | 1885 | } |
2202 | 1886 | |
2203 | 1887 | if ( !eventHandle ) { |
2204 | | - elemData.handle = eventHandle = function( e ) { |
| 1888 | + elemData.handle = eventHandle = function() { |
2205 | 1889 | // Handle the second event of a trigger and when |
2206 | 1890 | // an event is called after a page has unloaded |
2207 | | - return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? |
| 1891 | + return typeof jQuery !== "undefined" && !jQuery.event.triggered ? |
2208 | 1892 | jQuery.event.handle.apply( eventHandle.elem, arguments ) : |
2209 | 1893 | undefined; |
2210 | 1894 | }; |
— | — | @@ -2261,10 +1945,10 @@ |
2262 | 1946 | } |
2263 | 1947 | } |
2264 | 1948 | } |
| 1949 | + |
| 1950 | + if ( special.add ) { |
| 1951 | + special.add.call( elem, handleObj ); |
2265 | 1952 | |
2266 | | - if ( special.add ) { |
2267 | | - special.add.call( elem, handleObj ); |
2268 | | - |
2269 | 1953 | if ( !handleObj.handler.guid ) { |
2270 | 1954 | handleObj.handler.guid = handler.guid; |
2271 | 1955 | } |
— | — | @@ -2295,12 +1979,18 @@ |
2296 | 1980 | } |
2297 | 1981 | |
2298 | 1982 | var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, |
2299 | | - elemData = jQuery.hasData( elem ) && jQuery._data( elem ), |
2300 | | - events = elemData && elemData.events; |
| 1983 | + eventKey = elem.nodeType ? "events" : "__events__", |
| 1984 | + elemData = jQuery.data( elem ), |
| 1985 | + events = elemData && elemData[ eventKey ]; |
2301 | 1986 | |
2302 | 1987 | if ( !elemData || !events ) { |
2303 | 1988 | return; |
2304 | 1989 | } |
| 1990 | + |
| 1991 | + if ( typeof events === "function" ) { |
| 1992 | + elemData = events; |
| 1993 | + events = events.events; |
| 1994 | + } |
2305 | 1995 | |
2306 | 1996 | // types is actually an event object here |
2307 | 1997 | if ( types && types.type ) { |
— | — | @@ -2334,7 +2024,7 @@ |
2335 | 2025 | namespaces = type.split("."); |
2336 | 2026 | type = namespaces.shift(); |
2337 | 2027 | |
2338 | | - namespace = new RegExp("(^|\\.)" + |
| 2028 | + namespace = new RegExp("(^|\\.)" + |
2339 | 2029 | jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)"); |
2340 | 2030 | } |
2341 | 2031 | |
— | — | @@ -2401,8 +2091,11 @@ |
2402 | 2092 | delete elemData.events; |
2403 | 2093 | delete elemData.handle; |
2404 | 2094 | |
2405 | | - if ( jQuery.isEmptyObject( elemData ) ) { |
2406 | | - jQuery.removeData( elem, undefined, true ); |
| 2095 | + if ( typeof elemData === "function" ) { |
| 2096 | + jQuery.removeData( elem, eventKey ); |
| 2097 | + |
| 2098 | + } else if ( jQuery.isEmptyObject( elemData ) ) { |
| 2099 | + jQuery.removeData( elem ); |
2407 | 2100 | } |
2408 | 2101 | } |
2409 | 2102 | }, |
— | — | @@ -2434,16 +2127,9 @@ |
2435 | 2128 | |
2436 | 2129 | // Only trigger if we've ever bound an event for it |
2437 | 2130 | if ( jQuery.event.global[ type ] ) { |
2438 | | - // XXX This code smells terrible. event.js should not be directly |
2439 | | - // inspecting the data cache |
2440 | 2131 | jQuery.each( jQuery.cache, function() { |
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 ); |
| 2132 | + if ( this.events && this.events[type] ) { |
| 2133 | + jQuery.event.trigger( event, data, this.handle.elem ); |
2448 | 2134 | } |
2449 | 2135 | }); |
2450 | 2136 | } |
— | — | @@ -2468,7 +2154,9 @@ |
2469 | 2155 | event.currentTarget = elem; |
2470 | 2156 | |
2471 | 2157 | // Trigger the event, it is assumed that "handle" is a function |
2472 | | - var handle = jQuery._data( elem, "handle" ); |
| 2158 | + var handle = elem.nodeType ? |
| 2159 | + jQuery.data( elem, "handle" ) : |
| 2160 | + (jQuery.data( elem, "__events__" ) || {}).handle; |
2473 | 2161 | |
2474 | 2162 | if ( handle ) { |
2475 | 2163 | handle.apply( elem, data ); |
— | — | @@ -2498,7 +2186,7 @@ |
2499 | 2187 | isClick = jQuery.nodeName( target, "a" ) && targetType === "click", |
2500 | 2188 | special = jQuery.event.special[ targetType ] || {}; |
2501 | 2189 | |
2502 | | - if ( (!special._default || special._default.call( elem, event ) === false) && |
| 2190 | + if ( (!special._default || special._default.call( elem, event ) === false) && |
2503 | 2191 | !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) { |
2504 | 2192 | |
2505 | 2193 | try { |
— | — | @@ -2510,7 +2198,7 @@ |
2511 | 2199 | target[ "on" + targetType ] = null; |
2512 | 2200 | } |
2513 | 2201 | |
2514 | | - jQuery.event.triggered = event.type; |
| 2202 | + jQuery.event.triggered = true; |
2515 | 2203 | target[ targetType ](); |
2516 | 2204 | } |
2517 | 2205 | |
— | — | @@ -2521,7 +2209,7 @@ |
2522 | 2210 | target[ "on" + targetType ] = old; |
2523 | 2211 | } |
2524 | 2212 | |
2525 | | - jQuery.event.triggered = undefined; |
| 2213 | + jQuery.event.triggered = false; |
2526 | 2214 | } |
2527 | 2215 | } |
2528 | 2216 | }, |
— | — | @@ -2546,8 +2234,12 @@ |
2547 | 2235 | |
2548 | 2236 | event.namespace = event.namespace || namespace_sort.join("."); |
2549 | 2237 | |
2550 | | - events = jQuery._data(this, "events"); |
| 2238 | + events = jQuery.data(this, this.nodeType ? "events" : "__events__"); |
2551 | 2239 | |
| 2240 | + if ( typeof events === "function" ) { |
| 2241 | + events = events.events; |
| 2242 | + } |
| 2243 | + |
2552 | 2244 | handlers = (events || {})[ event.type ]; |
2553 | 2245 | |
2554 | 2246 | if ( events && handlers ) { |
— | — | @@ -2564,7 +2256,7 @@ |
2565 | 2257 | event.handler = handleObj.handler; |
2566 | 2258 | event.data = handleObj.data; |
2567 | 2259 | event.handleObj = handleObj; |
2568 | | - |
| 2260 | + |
2569 | 2261 | var ret = handleObj.handler.apply( this, args ); |
2570 | 2262 | |
2571 | 2263 | if ( ret !== undefined ) { |
— | — | @@ -2663,7 +2355,7 @@ |
2664 | 2356 | add: function( handleObj ) { |
2665 | 2357 | jQuery.event.add( this, |
2666 | 2358 | liveConvert( handleObj.origType, handleObj.selector ), |
2667 | | - jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); |
| 2359 | + jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); |
2668 | 2360 | }, |
2669 | 2361 | |
2670 | 2362 | remove: function( handleObj ) { |
— | — | @@ -2693,7 +2385,7 @@ |
2694 | 2386 | if ( elem.removeEventListener ) { |
2695 | 2387 | elem.removeEventListener( type, handle, false ); |
2696 | 2388 | } |
2697 | | - } : |
| 2389 | + } : |
2698 | 2390 | function( elem, type, handle ) { |
2699 | 2391 | if ( elem.detachEvent ) { |
2700 | 2392 | elem.detachEvent( "on" + type, handle ); |
— | — | @@ -2710,12 +2402,6 @@ |
2711 | 2403 | if ( src && src.type ) { |
2712 | 2404 | this.originalEvent = src; |
2713 | 2405 | 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 | | - |
2720 | 2406 | // Event type |
2721 | 2407 | } else { |
2722 | 2408 | this.type = src; |
— | — | @@ -2746,7 +2432,7 @@ |
2747 | 2433 | if ( !e ) { |
2748 | 2434 | return; |
2749 | 2435 | } |
2750 | | - |
| 2436 | + |
2751 | 2437 | // if preventDefault exists run it on the original event |
2752 | 2438 | if ( e.preventDefault ) { |
2753 | 2439 | e.preventDefault(); |
— | — | @@ -2788,12 +2474,6 @@ |
2789 | 2475 | // Firefox sometimes assigns relatedTarget a XUL element |
2790 | 2476 | // which we cannot access the parentNode property of |
2791 | 2477 | 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 | | - } |
2798 | 2478 | // Traverse up the tree |
2799 | 2479 | while ( parent && parent !== this ) { |
2800 | 2480 | parent = parent.parentNode; |
— | — | @@ -2838,22 +2518,24 @@ |
2839 | 2519 | |
2840 | 2520 | jQuery.event.special.submit = { |
2841 | 2521 | setup: function( data, namespaces ) { |
2842 | | - if ( this.nodeName && this.nodeName.toLowerCase() !== "form" ) { |
| 2522 | + if ( this.nodeName.toLowerCase() !== "form" ) { |
2843 | 2523 | jQuery.event.add(this, "click.specialSubmit", function( e ) { |
2844 | 2524 | var elem = e.target, |
2845 | 2525 | type = elem.type; |
2846 | 2526 | |
2847 | 2527 | if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { |
2848 | | - trigger( "submit", this, arguments ); |
| 2528 | + e.liveFired = undefined; |
| 2529 | + return trigger( "submit", this, arguments ); |
2849 | 2530 | } |
2850 | 2531 | }); |
2851 | | - |
| 2532 | + |
2852 | 2533 | jQuery.event.add(this, "keypress.specialSubmit", function( e ) { |
2853 | 2534 | var elem = e.target, |
2854 | 2535 | type = elem.type; |
2855 | 2536 | |
2856 | 2537 | if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { |
2857 | | - trigger( "submit", this, arguments ); |
| 2538 | + e.liveFired = undefined; |
| 2539 | + return trigger( "submit", this, arguments ); |
2858 | 2540 | } |
2859 | 2541 | }); |
2860 | 2542 | |
— | — | @@ -2901,14 +2583,14 @@ |
2902 | 2584 | return; |
2903 | 2585 | } |
2904 | 2586 | |
2905 | | - data = jQuery._data( elem, "_change_data" ); |
| 2587 | + data = jQuery.data( elem, "_change_data" ); |
2906 | 2588 | val = getVal(elem); |
2907 | 2589 | |
2908 | 2590 | // the current data will be also retrieved by beforeactivate |
2909 | 2591 | if ( e.type !== "focusout" || elem.type !== "radio" ) { |
2910 | | - jQuery._data( elem, "_change_data", val ); |
| 2592 | + jQuery.data( elem, "_change_data", val ); |
2911 | 2593 | } |
2912 | | - |
| 2594 | + |
2913 | 2595 | if ( data === undefined || val === data ) { |
2914 | 2596 | return; |
2915 | 2597 | } |
— | — | @@ -2916,13 +2598,13 @@ |
2917 | 2599 | if ( data != null || val ) { |
2918 | 2600 | e.type = "change"; |
2919 | 2601 | e.liveFired = undefined; |
2920 | | - jQuery.event.trigger( e, arguments[1], elem ); |
| 2602 | + return jQuery.event.trigger( e, arguments[1], elem ); |
2921 | 2603 | } |
2922 | 2604 | }; |
2923 | 2605 | |
2924 | 2606 | jQuery.event.special.change = { |
2925 | 2607 | filters: { |
2926 | | - focusout: testChange, |
| 2608 | + focusout: testChange, |
2927 | 2609 | |
2928 | 2610 | beforedeactivate: testChange, |
2929 | 2611 | |
— | — | @@ -2930,7 +2612,7 @@ |
2931 | 2613 | var elem = e.target, type = elem.type; |
2932 | 2614 | |
2933 | 2615 | if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) { |
2934 | | - testChange.call( this, e ); |
| 2616 | + return testChange.call( this, e ); |
2935 | 2617 | } |
2936 | 2618 | }, |
2937 | 2619 | |
— | — | @@ -2942,7 +2624,7 @@ |
2943 | 2625 | if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") || |
2944 | 2626 | (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || |
2945 | 2627 | type === "select-multiple" ) { |
2946 | | - testChange.call( this, e ); |
| 2628 | + return testChange.call( this, e ); |
2947 | 2629 | } |
2948 | 2630 | }, |
2949 | 2631 | |
— | — | @@ -2951,7 +2633,7 @@ |
2952 | 2634 | // information |
2953 | 2635 | beforeactivate: function( e ) { |
2954 | 2636 | var elem = e.target; |
2955 | | - jQuery._data( elem, "_change_data", getVal(elem) ); |
| 2637 | + jQuery.data( elem, "_change_data", getVal(elem) ); |
2956 | 2638 | } |
2957 | 2639 | }, |
2958 | 2640 | |
— | — | @@ -2981,50 +2663,30 @@ |
2982 | 2664 | } |
2983 | 2665 | |
2984 | 2666 | function trigger( type, 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 | | - } |
| 2667 | + args[0].type = type; |
| 2668 | + return jQuery.event.handle.apply( elem, args ); |
2997 | 2669 | } |
2998 | 2670 | |
2999 | 2671 | // Create "bubbling" focus and blur events |
3000 | 2672 | if ( document.addEventListener ) { |
3001 | 2673 | 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 | | - |
3006 | 2674 | jQuery.event.special[ fix ] = { |
3007 | 2675 | setup: function() { |
3008 | | - if ( attaches++ === 0 ) { |
| 2676 | + if ( focusCounts[fix]++ === 0 ) { |
3009 | 2677 | document.addEventListener( orig, handler, true ); |
3010 | 2678 | } |
3011 | | - }, |
3012 | | - teardown: function() { |
3013 | | - if ( --attaches === 0 ) { |
| 2679 | + }, |
| 2680 | + teardown: function() { |
| 2681 | + if ( --focusCounts[fix] === 0 ) { |
3014 | 2682 | document.removeEventListener( orig, handler, true ); |
3015 | 2683 | } |
3016 | 2684 | } |
3017 | 2685 | }; |
3018 | 2686 | |
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 ); |
| 2687 | + function handler( e ) { |
| 2688 | + e = jQuery.event.fix( e ); |
3023 | 2689 | e.type = fix; |
3024 | | - e.originalEvent = {}; |
3025 | | - jQuery.event.trigger( e, null, e.target ); |
3026 | | - if ( e.isDefaultPrevented() ) { |
3027 | | - donor.preventDefault(); |
3028 | | - } |
| 2690 | + return jQuery.event.trigger( e, null, e.target ); |
3029 | 2691 | } |
3030 | 2692 | }); |
3031 | 2693 | } |
— | — | @@ -3038,7 +2700,7 @@ |
3039 | 2701 | } |
3040 | 2702 | return this; |
3041 | 2703 | } |
3042 | | - |
| 2704 | + |
3043 | 2705 | if ( jQuery.isFunction( data ) || data === false ) { |
3044 | 2706 | fn = data; |
3045 | 2707 | data = undefined; |
— | — | @@ -3078,20 +2740,20 @@ |
3079 | 2741 | |
3080 | 2742 | return this; |
3081 | 2743 | }, |
3082 | | - |
| 2744 | + |
3083 | 2745 | delegate: function( selector, types, data, fn ) { |
3084 | 2746 | return this.live( types, data, fn, selector ); |
3085 | 2747 | }, |
3086 | | - |
| 2748 | + |
3087 | 2749 | undelegate: function( selector, types, fn ) { |
3088 | 2750 | if ( arguments.length === 0 ) { |
3089 | 2751 | return this.unbind( "live" ); |
3090 | | - |
| 2752 | + |
3091 | 2753 | } else { |
3092 | 2754 | return this.die( types, null, fn, selector ); |
3093 | 2755 | } |
3094 | 2756 | }, |
3095 | | - |
| 2757 | + |
3096 | 2758 | trigger: function( type, data ) { |
3097 | 2759 | return this.each(function() { |
3098 | 2760 | jQuery.event.trigger( type, data, this ); |
— | — | @@ -3120,8 +2782,8 @@ |
3121 | 2783 | |
3122 | 2784 | return this.click( jQuery.proxy( fn, function( event ) { |
3123 | 2785 | // Figure out which function to execute |
3124 | | - var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; |
3125 | | - jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); |
| 2786 | + var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i; |
| 2787 | + jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 ); |
3126 | 2788 | |
3127 | 2789 | // Make sure that clicks stop |
3128 | 2790 | event.preventDefault(); |
— | — | @@ -3148,12 +2810,12 @@ |
3149 | 2811 | var type, i = 0, match, namespaces, preType, |
3150 | 2812 | selector = origSelector || this.selector, |
3151 | 2813 | context = origSelector ? this : jQuery( this.context ); |
3152 | | - |
| 2814 | + |
3153 | 2815 | if ( typeof types === "object" && !types.preventDefault ) { |
3154 | 2816 | for ( var key in types ) { |
3155 | 2817 | context[ name ]( key, data, types[key], selector ); |
3156 | 2818 | } |
3157 | | - |
| 2819 | + |
3158 | 2820 | return this; |
3159 | 2821 | } |
3160 | 2822 | |
— | — | @@ -3200,7 +2862,7 @@ |
3201 | 2863 | context.unbind( "live." + liveConvert( type, selector ), fn ); |
3202 | 2864 | } |
3203 | 2865 | } |
3204 | | - |
| 2866 | + |
3205 | 2867 | return this; |
3206 | 2868 | }; |
3207 | 2869 | }); |
— | — | @@ -3209,13 +2871,17 @@ |
3210 | 2872 | var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret, |
3211 | 2873 | elems = [], |
3212 | 2874 | selectors = [], |
3213 | | - events = jQuery._data( this, "events" ); |
| 2875 | + events = jQuery.data( this, this.nodeType ? "events" : "__events__" ); |
3214 | 2876 | |
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; |
| 2877 | + if ( typeof events === "function" ) { |
| 2878 | + events = events.events; |
3218 | 2879 | } |
3219 | 2880 | |
| 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 | + |
3220 | 2886 | if ( event.namespace ) { |
3221 | 2887 | namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)"); |
3222 | 2888 | } |
— | — | @@ -3243,7 +2909,7 @@ |
3244 | 2910 | for ( j = 0; j < live.length; j++ ) { |
3245 | 2911 | handleObj = live[j]; |
3246 | 2912 | |
3247 | | - if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) { |
| 2913 | + if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) { |
3248 | 2914 | elem = close.elem; |
3249 | 2915 | related = null; |
3250 | 2916 | |
— | — | @@ -3313,10 +2979,27 @@ |
3314 | 2980 | } |
3315 | 2981 | }); |
3316 | 2982 | |
| 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 | +} |
3317 | 2999 | |
| 3000 | + |
3318 | 3001 | /*! |
3319 | | - * Sizzle CSS Selector Engine |
3320 | | - * Copyright 2011, The Dojo Foundation |
| 3002 | + * Sizzle CSS Selector Engine - v1.0 |
| 3003 | + * Copyright 2009, The Dojo Foundation |
3321 | 3004 | * Released under the MIT, BSD, and GPL Licenses. |
3322 | 3005 | * More information: http://sizzlejs.com/ |
3323 | 3006 | */ |
— | — | @@ -3326,9 +3009,7 @@ |
3327 | 3010 | done = 0, |
3328 | 3011 | toString = Object.prototype.toString, |
3329 | 3012 | hasDuplicate = false, |
3330 | | - baseHasDuplicate = true, |
3331 | | - rBackslash = /\\/g, |
3332 | | - rNonWord = /\W/; |
| 3013 | + baseHasDuplicate = true; |
3333 | 3014 | |
3334 | 3015 | // Here we check if the JavaScript engine is using some sort of |
3335 | 3016 | // optimization where it does not always call our comparision |
— | — | @@ -3527,7 +3208,7 @@ |
3528 | 3209 | match.splice( 1, 1 ); |
3529 | 3210 | |
3530 | 3211 | if ( left.substr( left.length - 1 ) !== "\\" ) { |
3531 | | - match[1] = (match[1] || "").replace( rBackslash, "" ); |
| 3212 | + match[1] = (match[1] || "").replace(/\\/g, ""); |
3532 | 3213 | set = Expr.find[ type ]( match, context, isXML ); |
3533 | 3214 | |
3534 | 3215 | if ( set != null ) { |
— | — | @@ -3539,9 +3220,7 @@ |
3540 | 3221 | } |
3541 | 3222 | |
3542 | 3223 | if ( !set ) { |
3543 | | - set = typeof context.getElementsByTagName !== "undefined" ? |
3544 | | - context.getElementsByTagName( "*" ) : |
3545 | | - []; |
| 3224 | + set = context.getElementsByTagName( "*" ); |
3546 | 3225 | } |
3547 | 3226 | |
3548 | 3227 | return { set: set, expr: expr }; |
— | — | @@ -3649,9 +3328,9 @@ |
3650 | 3329 | ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, |
3651 | 3330 | CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, |
3652 | 3331 | NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, |
3653 | | - ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, |
| 3332 | + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, |
3654 | 3333 | TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, |
3655 | | - CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, |
| 3334 | + CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/, |
3656 | 3335 | POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, |
3657 | 3336 | PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ |
3658 | 3337 | }, |
— | — | @@ -3666,16 +3345,13 @@ |
3667 | 3346 | attrHandle: { |
3668 | 3347 | href: function( elem ) { |
3669 | 3348 | return elem.getAttribute( "href" ); |
3670 | | - }, |
3671 | | - type: function( elem ) { |
3672 | | - return elem.getAttribute( "type" ); |
3673 | 3349 | } |
3674 | 3350 | }, |
3675 | 3351 | |
3676 | 3352 | relative: { |
3677 | 3353 | "+": function(checkSet, part){ |
3678 | 3354 | var isPartStr = typeof part === "string", |
3679 | | - isTag = isPartStr && !rNonWord.test( part ), |
| 3355 | + isTag = isPartStr && !/\W/.test( part ), |
3680 | 3356 | isPartStrNotTag = isPartStr && !isTag; |
3681 | 3357 | |
3682 | 3358 | if ( isTag ) { |
— | — | @@ -3703,7 +3379,7 @@ |
3704 | 3380 | i = 0, |
3705 | 3381 | l = checkSet.length; |
3706 | 3382 | |
3707 | | - if ( isPartStr && !rNonWord.test( part ) ) { |
| 3383 | + if ( isPartStr && !/\W/.test( part ) ) { |
3708 | 3384 | part = part.toLowerCase(); |
3709 | 3385 | |
3710 | 3386 | for ( ; i < l; i++ ) { |
— | — | @@ -3737,7 +3413,7 @@ |
3738 | 3414 | doneName = done++, |
3739 | 3415 | checkFn = dirCheck; |
3740 | 3416 | |
3741 | | - if ( typeof part === "string" && !rNonWord.test( part ) ) { |
| 3417 | + if ( typeof part === "string" && !/\W/.test(part) ) { |
3742 | 3418 | part = part.toLowerCase(); |
3743 | 3419 | nodeCheck = part; |
3744 | 3420 | checkFn = dirNodeCheck; |
— | — | @@ -3751,7 +3427,7 @@ |
3752 | 3428 | doneName = done++, |
3753 | 3429 | checkFn = dirCheck; |
3754 | 3430 | |
3755 | | - if ( typeof part === "string" && !rNonWord.test( part ) ) { |
| 3431 | + if ( typeof part === "string" && !/\W/.test( part ) ) { |
3756 | 3432 | part = part.toLowerCase(); |
3757 | 3433 | nodeCheck = part; |
3758 | 3434 | checkFn = dirNodeCheck; |
— | — | @@ -3787,14 +3463,12 @@ |
3788 | 3464 | }, |
3789 | 3465 | |
3790 | 3466 | TAG: function( match, context ) { |
3791 | | - if ( typeof context.getElementsByTagName !== "undefined" ) { |
3792 | | - return context.getElementsByTagName( match[1] ); |
3793 | | - } |
| 3467 | + return context.getElementsByTagName( match[1] ); |
3794 | 3468 | } |
3795 | 3469 | }, |
3796 | 3470 | preFilter: { |
3797 | 3471 | CLASS: function( match, curLoop, inplace, result, not, isXML ) { |
3798 | | - match = " " + match[1].replace( rBackslash, "" ) + " "; |
| 3472 | + match = " " + match[1].replace(/\\/g, "") + " "; |
3799 | 3473 | |
3800 | 3474 | if ( isXML ) { |
3801 | 3475 | return match; |
— | — | @@ -3802,7 +3476,7 @@ |
3803 | 3477 | |
3804 | 3478 | for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { |
3805 | 3479 | if ( elem ) { |
3806 | | - if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { |
| 3480 | + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) { |
3807 | 3481 | if ( !inplace ) { |
3808 | 3482 | result.push( elem ); |
3809 | 3483 | } |
— | — | @@ -3817,23 +3491,17 @@ |
3818 | 3492 | }, |
3819 | 3493 | |
3820 | 3494 | ID: function( match ) { |
3821 | | - return match[1].replace( rBackslash, "" ); |
| 3495 | + return match[1].replace(/\\/g, ""); |
3822 | 3496 | }, |
3823 | 3497 | |
3824 | 3498 | TAG: function( match, curLoop ) { |
3825 | | - return match[1].replace( rBackslash, "" ).toLowerCase(); |
| 3499 | + return match[1].toLowerCase(); |
3826 | 3500 | }, |
3827 | 3501 | |
3828 | 3502 | CHILD: function( match ) { |
3829 | 3503 | if ( match[1] === "nth" ) { |
3830 | | - if ( !match[2] ) { |
3831 | | - Sizzle.error( match[0] ); |
3832 | | - } |
3833 | | - |
3834 | | - match[2] = match[2].replace(/^\+|\s*/g, ''); |
3835 | | - |
3836 | 3504 | // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' |
3837 | | - var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( |
| 3505 | + var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( |
3838 | 3506 | match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || |
3839 | 3507 | !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); |
3840 | 3508 | |
— | — | @@ -3841,9 +3509,6 @@ |
3842 | 3510 | match[2] = (test[1] + (test[2] || 1)) - 0; |
3843 | 3511 | match[3] = test[3] - 0; |
3844 | 3512 | } |
3845 | | - else if ( match[2] ) { |
3846 | | - Sizzle.error( match[0] ); |
3847 | | - } |
3848 | 3513 | |
3849 | 3514 | // TODO: Move to normal caching system |
3850 | 3515 | match[0] = done++; |
— | — | @@ -3852,15 +3517,12 @@ |
3853 | 3518 | }, |
3854 | 3519 | |
3855 | 3520 | ATTR: function( match, curLoop, inplace, result, not, isXML ) { |
3856 | | - var name = match[1] = match[1].replace( rBackslash, "" ); |
| 3521 | + var name = match[1].replace(/\\/g, ""); |
3857 | 3522 | |
3858 | 3523 | if ( !isXML && Expr.attrMap[name] ) { |
3859 | 3524 | match[1] = Expr.attrMap[name]; |
3860 | 3525 | } |
3861 | 3526 | |
3862 | | - // Handle if an un-quoted value was used |
3863 | | - match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); |
3864 | | - |
3865 | 3527 | if ( match[2] === "~=" ) { |
3866 | 3528 | match[4] = " " + match[4] + " "; |
3867 | 3529 | } |
— | — | @@ -3914,9 +3576,7 @@ |
3915 | 3577 | selected: function( elem ) { |
3916 | 3578 | // Accessing this property makes selected-by-default |
3917 | 3579 | // options in Safari work properly |
3918 | | - if ( elem.parentNode ) { |
3919 | | - elem.parentNode.selectedIndex; |
3920 | | - } |
| 3580 | + elem.parentNode.selectedIndex; |
3921 | 3581 | |
3922 | 3582 | return elem.selected === true; |
3923 | 3583 | }, |
— | — | @@ -3938,12 +3598,8 @@ |
3939 | 3599 | }, |
3940 | 3600 | |
3941 | 3601 | text: function( elem ) { |
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 ); |
| 3602 | + return "text" === elem.type; |
3946 | 3603 | }, |
3947 | | - |
3948 | 3604 | radio: function( elem ) { |
3949 | 3605 | return "radio" === elem.type; |
3950 | 3606 | }, |
— | — | @@ -4035,7 +3691,7 @@ |
4036 | 3692 | return true; |
4037 | 3693 | |
4038 | 3694 | } else { |
4039 | | - Sizzle.error( name ); |
| 3695 | + Sizzle.error( "Syntax error, unrecognized expression: " + name ); |
4040 | 3696 | } |
4041 | 3697 | }, |
4042 | 3698 | |
— | — | @@ -4425,47 +4081,13 @@ |
4426 | 4082 | Sizzle = function( query, context, extra, seed ) { |
4427 | 4083 | context = context || document; |
4428 | 4084 | |
| 4085 | + // Make sure that attribute selectors are quoted |
| 4086 | + query = query.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); |
| 4087 | + |
4429 | 4088 | // Only use querySelectorAll on non-XML documents |
4430 | 4089 | // (ID selectors don't work in non-HTML documents) |
4431 | 4090 | 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 | | - |
4446 | 4091 | 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 | | - |
4470 | 4092 | try { |
4471 | 4093 | return makeArray( context.querySelectorAll(query), extra ); |
4472 | 4094 | } catch(qsaError) {} |
— | — | @@ -4475,30 +4097,20 @@ |
4476 | 4098 | // and working up from there (Thanks to Andrew Dupont for the technique) |
4477 | 4099 | // IE 8 doesn't work on object elements |
4478 | 4100 | } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { |
4479 | | - var oldContext = context, |
4480 | | - old = context.getAttribute( "id" ), |
4481 | | - nid = old || id, |
4482 | | - hasParent = context.parentNode, |
4483 | | - relativeHierarchySelector = /^\s*[+~]/.test( query ); |
| 4101 | + var old = context.getAttribute( "id" ), |
| 4102 | + nid = old || id; |
4484 | 4103 | |
4485 | 4104 | if ( !old ) { |
4486 | 4105 | context.setAttribute( "id", nid ); |
4487 | | - } else { |
4488 | | - nid = nid.replace( /'/g, "\\$&" ); |
4489 | 4106 | } |
4490 | | - if ( relativeHierarchySelector && hasParent ) { |
4491 | | - context = context.parentNode; |
4492 | | - } |
4493 | 4107 | |
4494 | 4108 | try { |
4495 | | - if ( !relativeHierarchySelector || hasParent ) { |
4496 | | - return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); |
4497 | | - } |
| 4109 | + return makeArray( context.querySelectorAll( "#" + nid + " " + query ), extra ); |
4498 | 4110 | |
4499 | 4111 | } catch(pseudoError) { |
4500 | 4112 | } finally { |
4501 | 4113 | if ( !old ) { |
4502 | | - oldContext.removeAttribute( "id" ); |
| 4114 | + context.removeAttribute( "id" ); |
4503 | 4115 | } |
4504 | 4116 | } |
4505 | 4117 | } |
— | — | @@ -4518,23 +4130,19 @@ |
4519 | 4131 | |
4520 | 4132 | (function(){ |
4521 | 4133 | var html = document.documentElement, |
4522 | | - matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; |
| 4134 | + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector, |
| 4135 | + pseudoWorks = false; |
4523 | 4136 | |
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" ); |
| 4137 | + try { |
| 4138 | + // This should fail with an exception |
| 4139 | + // Gecko does not error, returns false instead |
| 4140 | + matches.call( document.documentElement, "[test!='']:sizzle" ); |
4534 | 4141 | |
4535 | | - } catch( pseudoError ) { |
4536 | | - pseudoWorks = true; |
4537 | | - } |
| 4142 | + } catch( pseudoError ) { |
| 4143 | + pseudoWorks = true; |
| 4144 | + } |
4538 | 4145 | |
| 4146 | + if ( matches ) { |
4539 | 4147 | Sizzle.matchesSelector = function( node, expr ) { |
4540 | 4148 | // Make sure that attribute selectors are quoted |
4541 | 4149 | expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); |
— | — | @@ -4542,15 +4150,7 @@ |
4543 | 4151 | if ( !Sizzle.isXML( node ) ) { |
4544 | 4152 | try { |
4545 | 4153 | if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( 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 | | - } |
| 4154 | + return matches.call( node, expr ); |
4555 | 4155 | } |
4556 | 4156 | } catch(e) {} |
4557 | 4157 | } |
— | — | @@ -4728,14 +4328,7 @@ |
4729 | 4329 | rmultiselector = /,/, |
4730 | 4330 | isSimple = /^.[^:#\[\.,]*$/, |
4731 | 4331 | slice = Array.prototype.slice, |
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 | | - }; |
| 4332 | + POS = jQuery.expr.match.POS; |
4740 | 4333 | |
4741 | 4334 | jQuery.fn.extend({ |
4742 | 4335 | find: function( selector ) { |
— | — | @@ -4780,7 +4373,7 @@ |
4781 | 4374 | filter: function( selector ) { |
4782 | 4375 | return this.pushStack( winnow(this, selector, true), "filter", selector ); |
4783 | 4376 | }, |
4784 | | - |
| 4377 | + |
4785 | 4378 | is: function( selector ) { |
4786 | 4379 | return !!selector && jQuery.filter( selector, this ).length > 0; |
4787 | 4380 | }, |
— | — | @@ -4798,7 +4391,7 @@ |
4799 | 4392 | selector = selectors[i]; |
4800 | 4393 | |
4801 | 4394 | if ( !matches[selector] ) { |
4802 | | - matches[selector] = jQuery.expr.match.POS.test( selector ) ? |
| 4395 | + matches[selector] = jQuery.expr.match.POS.test( selector ) ? |
4803 | 4396 | jQuery( selector, context || this.context ) : |
4804 | 4397 | selector; |
4805 | 4398 | } |
— | — | @@ -4821,7 +4414,7 @@ |
4822 | 4415 | return ret; |
4823 | 4416 | } |
4824 | 4417 | |
4825 | | - var pos = POS.test( selectors ) ? |
| 4418 | + var pos = POS.test( selectors ) ? |
4826 | 4419 | jQuery( selectors, context || this.context ) : null; |
4827 | 4420 | |
4828 | 4421 | for ( i = 0, l = this.length; i < l; i++ ) { |
— | — | @@ -4842,10 +4435,10 @@ |
4843 | 4436 | } |
4844 | 4437 | |
4845 | 4438 | ret = ret.length > 1 ? jQuery.unique(ret) : ret; |
4846 | | - |
| 4439 | + |
4847 | 4440 | return this.pushStack( ret, "closest", selectors ); |
4848 | 4441 | }, |
4849 | | - |
| 4442 | + |
4850 | 4443 | // Determine the position of an element within |
4851 | 4444 | // the matched set of elements |
4852 | 4445 | index: function( elem ) { |
— | — | @@ -4863,7 +4456,7 @@ |
4864 | 4457 | |
4865 | 4458 | add: function( selector, context ) { |
4866 | 4459 | var set = typeof selector === "string" ? |
4867 | | - jQuery( selector, context ) : |
| 4460 | + jQuery( selector, context || this.context ) : |
4868 | 4461 | jQuery.makeArray( selector ), |
4869 | 4462 | all = jQuery.merge( this.get(), set ); |
4870 | 4463 | |
— | — | @@ -4925,13 +4518,8 @@ |
4926 | 4519 | } |
4927 | 4520 | }, function( name, fn ) { |
4928 | 4521 | jQuery.fn[ name ] = function( until, selector ) { |
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 | | - |
| 4522 | + var ret = jQuery.map( this, fn, until ); |
| 4523 | + |
4936 | 4524 | if ( !runtil.test( name ) ) { |
4937 | 4525 | selector = until; |
4938 | 4526 | } |
— | — | @@ -4940,13 +4528,13 @@ |
4941 | 4529 | ret = jQuery.filter( selector, ret ); |
4942 | 4530 | } |
4943 | 4531 | |
4944 | | - ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; |
| 4532 | + ret = this.length > 1 ? jQuery.unique( ret ) : ret; |
4945 | 4533 | |
4946 | 4534 | if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { |
4947 | 4535 | ret = ret.reverse(); |
4948 | 4536 | } |
4949 | 4537 | |
4950 | | - return this.pushStack( ret, name, args.join(",") ); |
| 4538 | + return this.pushStack( ret, name, slice.call(arguments).join(",") ); |
4951 | 4539 | }; |
4952 | 4540 | }); |
4953 | 4541 | |
— | — | @@ -4960,7 +4548,7 @@ |
4961 | 4549 | jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : |
4962 | 4550 | jQuery.find.matches(expr, elems); |
4963 | 4551 | }, |
4964 | | - |
| 4552 | + |
4965 | 4553 | dir: function( elem, dir, until ) { |
4966 | 4554 | var matched = [], |
4967 | 4555 | cur = elem[ dir ]; |
— | — | @@ -5040,8 +4628,9 @@ |
5041 | 4629 | rtbody = /<tbody/i, |
5042 | 4630 | rhtml = /<|&#?\w+;/, |
5043 | 4631 | rnocache = /<(?:script|object|embed|option|style)/i, |
5044 | | - // checked="checked" or checked |
| 4632 | + // checked="checked" or checked (html5) |
5045 | 4633 | rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, |
| 4634 | + raction = /\=([^="'>\s]+\/)>/g, |
5046 | 4635 | wrapMap = { |
5047 | 4636 | option: [ 1, "<select multiple='multiple'>", "</select>" ], |
5048 | 4637 | legend: [ 1, "<fieldset>", "</fieldset>" ], |
— | — | @@ -5181,7 +4770,7 @@ |
5182 | 4771 | return set; |
5183 | 4772 | } |
5184 | 4773 | }, |
5185 | | - |
| 4774 | + |
5186 | 4775 | // keepData is for internal use only--do not document |
5187 | 4776 | remove: function( selector, keepData ) { |
5188 | 4777 | for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { |
— | — | @@ -5192,11 +4781,11 @@ |
5193 | 4782 | } |
5194 | 4783 | |
5195 | 4784 | if ( elem.parentNode ) { |
5196 | | - elem.parentNode.removeChild( elem ); |
| 4785 | + elem.parentNode.removeChild( elem ); |
5197 | 4786 | } |
5198 | 4787 | } |
5199 | 4788 | } |
5200 | | - |
| 4789 | + |
5201 | 4790 | return this; |
5202 | 4791 | }, |
5203 | 4792 | |
— | — | @@ -5212,17 +4801,48 @@ |
5213 | 4802 | elem.removeChild( elem.firstChild ); |
5214 | 4803 | } |
5215 | 4804 | } |
5216 | | - |
| 4805 | + |
5217 | 4806 | return this; |
5218 | 4807 | }, |
5219 | 4808 | |
5220 | | - clone: function( dataAndEvents, deepDataAndEvents ) { |
5221 | | - dataAndEvents = dataAndEvents == null ? false : dataAndEvents; |
5222 | | - deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; |
| 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; |
5223 | 4823 | |
5224 | | - return this.map( function () { |
5225 | | - return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); |
| 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 | + } |
5226 | 4837 | }); |
| 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; |
5227 | 4847 | }, |
5228 | 4848 | |
5229 | 4849 | html: function( value ) { |
— | — | @@ -5294,9 +4914,7 @@ |
5295 | 4915 | } |
5296 | 4916 | }); |
5297 | 4917 | } else { |
5298 | | - return this.length ? |
5299 | | - this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) : |
5300 | | - this; |
| 4918 | + return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ); |
5301 | 4919 | } |
5302 | 4920 | }, |
5303 | 4921 | |
— | — | @@ -5334,9 +4952,9 @@ |
5335 | 4953 | } else { |
5336 | 4954 | results = jQuery.buildFragment( args, this, scripts ); |
5337 | 4955 | } |
5338 | | - |
| 4956 | + |
5339 | 4957 | fragment = results.fragment; |
5340 | | - |
| 4958 | + |
5341 | 4959 | if ( fragment.childNodes.length === 1 ) { |
5342 | 4960 | first = fragment = fragment.firstChild; |
5343 | 4961 | } else { |
— | — | @@ -5346,20 +4964,13 @@ |
5347 | 4965 | if ( first ) { |
5348 | 4966 | table = table && jQuery.nodeName( first, "tr" ); |
5349 | 4967 | |
5350 | | - for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) { |
| 4968 | + for ( var i = 0, l = this.length; i < l; i++ ) { |
5351 | 4969 | callback.call( |
5352 | 4970 | table ? |
5353 | 4971 | root(this[i], first) : |
5354 | 4972 | this[i], |
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 ) : |
| 4973 | + i > 0 || results.cacheable || this.length > 1 ? |
| 4974 | + fragment.cloneNode(true) : |
5364 | 4975 | fragment |
5365 | 4976 | ); |
5366 | 4977 | } |
— | — | @@ -5381,97 +4992,41 @@ |
5382 | 4993 | elem; |
5383 | 4994 | } |
5384 | 4995 | |
5385 | | -function cloneCopyEvent( src, dest ) { |
| 4996 | +function cloneCopyEvent(orig, ret) { |
| 4997 | + var i = 0; |
5386 | 4998 | |
5387 | | - if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { |
5388 | | - return; |
5389 | | - } |
| 4999 | + ret.each(function() { |
| 5000 | + if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) { |
| 5001 | + return; |
| 5002 | + } |
5390 | 5003 | |
5391 | | - var internalKey = jQuery.expando, |
5392 | | - oldData = jQuery.data( src ), |
5393 | | - curData = jQuery.data( dest, oldData ); |
| 5004 | + var oldData = jQuery.data( orig[i++] ), |
| 5005 | + curData = jQuery.data( this, oldData ), |
| 5006 | + events = oldData && oldData.events; |
5394 | 5007 | |
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 | | - |
5401 | 5008 | if ( events ) { |
5402 | 5009 | delete curData.handle; |
5403 | 5010 | curData.events = {}; |
5404 | 5011 | |
5405 | 5012 | for ( var type in events ) { |
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 ); |
| 5013 | + for ( var handler in events[ type ] ) { |
| 5014 | + jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data ); |
5408 | 5015 | } |
5409 | 5016 | } |
5410 | 5017 | } |
5411 | | - } |
| 5018 | + }); |
5412 | 5019 | } |
5413 | 5020 | |
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 | | - |
5466 | 5021 | jQuery.buildFragment = function( args, nodes, scripts ) { |
5467 | 5022 | var fragment, cacheable, cacheresults, |
5468 | 5023 | doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document); |
5469 | 5024 | |
5470 | | - // Only cache "small" (1/2 KB) HTML strings that are associated with the main document |
| 5025 | + // Only cache "small" (1/2 KB) strings that are associated with the main document |
5471 | 5026 | // Cloning options loses the selected state, so don't cache them |
5472 | 5027 | // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment |
5473 | 5028 | // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache |
5474 | 5029 | if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document && |
5475 | | - args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) { |
| 5030 | + !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) { |
5476 | 5031 | |
5477 | 5032 | cacheable = true; |
5478 | 5033 | cacheresults = jQuery.fragments[ args[0] ]; |
— | — | @@ -5507,82 +5062,24 @@ |
5508 | 5063 | var ret = [], |
5509 | 5064 | insert = jQuery( selector ), |
5510 | 5065 | parent = this.length === 1 && this[0].parentNode; |
5511 | | - |
| 5066 | + |
5512 | 5067 | if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) { |
5513 | 5068 | insert[ original ]( this[0] ); |
5514 | 5069 | return this; |
5515 | | - |
| 5070 | + |
5516 | 5071 | } else { |
5517 | 5072 | for ( var i = 0, l = insert.length; i < l; i++ ) { |
5518 | 5073 | var elems = (i > 0 ? this.clone(true) : this).get(); |
5519 | 5074 | jQuery( insert[i] )[ original ]( elems ); |
5520 | 5075 | ret = ret.concat( elems ); |
5521 | 5076 | } |
5522 | | - |
| 5077 | + |
5523 | 5078 | return this.pushStack( ret, name, insert.selector ); |
5524 | 5079 | } |
5525 | 5080 | }; |
5526 | 5081 | }); |
5527 | 5082 | |
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 | | - |
5540 | 5083 | 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 | | -}, |
5587 | 5084 | clean: function( elems, context, fragment, scripts ) { |
5588 | 5085 | context = context || document; |
5589 | 5086 | |
— | — | @@ -5664,7 +5161,7 @@ |
5665 | 5162 | for ( i = 0; ret[i]; i++ ) { |
5666 | 5163 | if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
5667 | 5164 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
5668 | | - |
| 5165 | + |
5669 | 5166 | } else { |
5670 | 5167 | if ( ret[i].nodeType === 1 ) { |
5671 | 5168 | ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); |
— | — | @@ -5676,45 +5173,40 @@ |
5677 | 5174 | |
5678 | 5175 | return ret; |
5679 | 5176 | }, |
5680 | | - |
| 5177 | + |
5681 | 5178 | cleanData: function( elems ) { |
5682 | | - var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special, |
| 5179 | + var data, id, cache = jQuery.cache, |
| 5180 | + special = jQuery.event.special, |
5683 | 5181 | deleteExpando = jQuery.support.deleteExpando; |
5684 | | - |
| 5182 | + |
5685 | 5183 | for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
5686 | 5184 | if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { |
5687 | 5185 | continue; |
5688 | 5186 | } |
5689 | 5187 | |
5690 | 5188 | id = elem[ jQuery.expando ]; |
5691 | | - |
| 5189 | + |
5692 | 5190 | if ( id ) { |
5693 | | - data = cache[ id ] && cache[ id ][ internalKey ]; |
5694 | | - |
| 5191 | + data = cache[ id ]; |
| 5192 | + |
5695 | 5193 | if ( data && data.events ) { |
5696 | 5194 | for ( var type in data.events ) { |
5697 | 5195 | if ( special[ type ] ) { |
5698 | 5196 | jQuery.event.remove( elem, type ); |
5699 | 5197 | |
5700 | | - // This is a shortcut to avoid jQuery.event.remove's overhead |
5701 | 5198 | } else { |
5702 | 5199 | jQuery.removeEvent( elem, type, data.handle ); |
5703 | 5200 | } |
5704 | 5201 | } |
5705 | | - |
5706 | | - // Null the DOM reference to avoid IE6/7/8 leak (#7054) |
5707 | | - if ( data.handle ) { |
5708 | | - data.handle.elem = null; |
5709 | | - } |
5710 | 5202 | } |
5711 | | - |
| 5203 | + |
5712 | 5204 | if ( deleteExpando ) { |
5713 | 5205 | delete elem[ jQuery.expando ]; |
5714 | 5206 | |
5715 | 5207 | } else if ( elem.removeAttribute ) { |
5716 | 5208 | elem.removeAttribute( jQuery.expando ); |
5717 | 5209 | } |
5718 | | - |
| 5210 | + |
5719 | 5211 | delete cache[ id ]; |
5720 | 5212 | } |
5721 | 5213 | } |
— | — | @@ -5743,8 +5235,7 @@ |
5744 | 5236 | var ralpha = /alpha\([^)]*\)/i, |
5745 | 5237 | ropacity = /opacity=([^)]*)/, |
5746 | 5238 | rdashAlpha = /-([a-z])/ig, |
5747 | | - // fixed for IE9, see #8346 |
5748 | | - rupper = /([A-Z]|^ms)/g, |
| 5239 | + rupper = /([A-Z])/g, |
5749 | 5240 | rnumpx = /^-?\d+(?:px)?$/i, |
5750 | 5241 | rnum = /^-?\d/, |
5751 | 5242 | |
— | — | @@ -5981,28 +5472,6 @@ |
5982 | 5473 | }; |
5983 | 5474 | } |
5984 | 5475 | |
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 | | - |
6007 | 5476 | if ( document.defaultView && document.defaultView.getComputedStyle ) { |
6008 | 5477 | getComputedStyle = function( elem, newName, name ) { |
6009 | 5478 | var ret, defaultView, computedStyle; |
— | — | @@ -6026,9 +5495,8 @@ |
6027 | 5496 | |
6028 | 5497 | if ( document.documentElement.currentStyle ) { |
6029 | 5498 | currentStyle = function( elem, name ) { |
6030 | | - var left, |
| 5499 | + var left, rsLeft, |
6031 | 5500 | ret = elem.currentStyle && elem.currentStyle[ name ], |
6032 | | - rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ], |
6033 | 5501 | style = elem.style; |
6034 | 5502 | |
6035 | 5503 | // From the awesome hack by Dean Edwards |
— | — | @@ -6039,19 +5507,16 @@ |
6040 | 5508 | if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { |
6041 | 5509 | // Remember the original values |
6042 | 5510 | left = style.left; |
| 5511 | + rsLeft = elem.runtimeStyle.left; |
6043 | 5512 | |
6044 | 5513 | // Put in the new values to get a computed value out |
6045 | | - if ( rsLeft ) { |
6046 | | - elem.runtimeStyle.left = elem.currentStyle.left; |
6047 | | - } |
| 5514 | + elem.runtimeStyle.left = elem.currentStyle.left; |
6048 | 5515 | style.left = name === "fontSize" ? "1em" : (ret || 0); |
6049 | 5516 | ret = style.pixelLeft + "px"; |
6050 | 5517 | |
6051 | 5518 | // Revert the changed values |
6052 | 5519 | style.left = left; |
6053 | | - if ( rsLeft ) { |
6054 | | - elem.runtimeStyle.left = rsLeft; |
6055 | | - } |
| 5520 | + elem.runtimeStyle.left = rsLeft; |
6056 | 5521 | } |
6057 | 5522 | |
6058 | 5523 | return ret === "" ? "auto" : ret; |
— | — | @@ -6100,145 +5565,22 @@ |
6101 | 5566 | |
6102 | 5567 | |
6103 | 5568 | |
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 |
| 5569 | +var jsc = jQuery.now(), |
| 5570 | + rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, |
| 5571 | + rselectTextarea = /^(?:select|textarea)/i, |
6109 | 5572 | 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):$/, |
6112 | 5573 | rnoContent = /^(?:GET|HEAD)$/, |
6113 | | - rprotocol = /^\/\//, |
| 5574 | + rbracket = /\[\]$/, |
| 5575 | + jsre = /\=\?(&|$)/, |
6114 | 5576 | rquery = /\?/, |
6115 | | - rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, |
6116 | | - rselectTextarea = /^(?:select|textarea)/i, |
6117 | | - rspacesAjax = /\s+/, |
6118 | 5577 | rts = /([?&])_=[^&]*/, |
6119 | | - rucHeaders = /(^|\-)([a-z])/g, |
6120 | | - rucHeadersFunc = function( _, $1, $2 ) { |
6121 | | - return $1 + $2.toUpperCase(); |
6122 | | - }, |
6123 | | - rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/, |
| 5578 | + rurl = /^(\w+:)?\/\/([^\/?#]+)/, |
| 5579 | + r20 = /%20/g, |
| 5580 | + rhash = /#.*$/, |
6124 | 5581 | |
6125 | 5582 | // Keep a copy of the old load method |
6126 | | - _load = jQuery.fn.load, |
| 5583 | + _load = jQuery.fn.load; |
6127 | 5584 | |
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 | | - |
6243 | 5585 | jQuery.fn.extend({ |
6244 | 5586 | load: function( url, params, callback ) { |
6245 | 5587 | if ( typeof url !== "string" && _load ) { |
— | — | @@ -6249,10 +5591,10 @@ |
6250 | 5592 | return this; |
6251 | 5593 | } |
6252 | 5594 | |
6253 | | - var off = url.indexOf( " " ); |
| 5595 | + var off = url.indexOf(" "); |
6254 | 5596 | if ( off >= 0 ) { |
6255 | | - var selector = url.slice( off, url.length ); |
6256 | | - url = url.slice( 0, off ); |
| 5597 | + var selector = url.slice(off, url.length); |
| 5598 | + url = url.slice(0, off); |
6257 | 5599 | } |
6258 | 5600 | |
6259 | 5601 | // Default to a GET request |
— | — | @@ -6264,7 +5606,7 @@ |
6265 | 5607 | if ( jQuery.isFunction( params ) ) { |
6266 | 5608 | // We assume that it's the callback |
6267 | 5609 | callback = params; |
6268 | | - params = undefined; |
| 5610 | + params = null; |
6269 | 5611 | |
6270 | 5612 | // Otherwise, build a param string |
6271 | 5613 | } else if ( typeof params === "object" ) { |
— | — | @@ -6281,34 +5623,26 @@ |
6282 | 5624 | type: type, |
6283 | 5625 | dataType: "html", |
6284 | 5626 | data: params, |
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; |
| 5627 | + complete: function( res, status ) { |
6289 | 5628 | // If successful, inject the HTML into all the matched elements |
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 | | - }); |
| 5629 | + if ( status === "success" || status === "notmodified" ) { |
6296 | 5630 | // See if a selector was specified |
6297 | 5631 | self.html( selector ? |
6298 | 5632 | // Create a dummy div to hold the results |
6299 | 5633 | jQuery("<div>") |
6300 | 5634 | // inject the contents of the document in, removing the scripts |
6301 | 5635 | // to avoid any 'Permission Denied' errors in IE |
6302 | | - .append(responseText.replace(rscript, "")) |
| 5636 | + .append(res.responseText.replace(rscript, "")) |
6303 | 5637 | |
6304 | 5638 | // Locate the specified elements |
6305 | 5639 | .find(selector) : |
6306 | 5640 | |
6307 | 5641 | // If not, just inject the full result |
6308 | | - responseText ); |
| 5642 | + res.responseText ); |
6309 | 5643 | } |
6310 | 5644 | |
6311 | 5645 | if ( callback ) { |
6312 | | - self.each( callback, [ responseText, status, jqXHR ] ); |
| 5646 | + self.each( callback, [res.responseText, status, res] ); |
6313 | 5647 | } |
6314 | 5648 | } |
6315 | 5649 | }); |
— | — | @@ -6317,94 +5651,88 @@ |
6318 | 5652 | }, |
6319 | 5653 | |
6320 | 5654 | serialize: function() { |
6321 | | - return jQuery.param( this.serializeArray() ); |
| 5655 | + return jQuery.param(this.serializeArray()); |
6322 | 5656 | }, |
6323 | 5657 | |
6324 | 5658 | serializeArray: function() { |
6325 | | - return this.map(function(){ |
6326 | | - return this.elements ? jQuery.makeArray( this.elements ) : this; |
| 5659 | + return this.map(function() { |
| 5660 | + return this.elements ? jQuery.makeArray(this.elements) : this; |
6327 | 5661 | }) |
6328 | | - .filter(function(){ |
| 5662 | + .filter(function() { |
6329 | 5663 | return this.name && !this.disabled && |
6330 | | - ( this.checked || rselectTextarea.test( this.nodeName ) || |
6331 | | - rinput.test( this.type ) ); |
| 5664 | + (this.checked || rselectTextarea.test(this.nodeName) || |
| 5665 | + rinput.test(this.type)); |
6332 | 5666 | }) |
6333 | | - .map(function( i, elem ){ |
6334 | | - var val = jQuery( this ).val(); |
| 5667 | + .map(function( i, elem ) { |
| 5668 | + var val = jQuery(this).val(); |
6335 | 5669 | |
6336 | 5670 | return val == null ? |
6337 | 5671 | null : |
6338 | | - jQuery.isArray( val ) ? |
6339 | | - jQuery.map( val, function( val, i ){ |
6340 | | - return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
| 5672 | + jQuery.isArray(val) ? |
| 5673 | + jQuery.map( val, function( val, i ) { |
| 5674 | + return { name: elem.name, value: val }; |
6341 | 5675 | }) : |
6342 | | - { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; |
| 5676 | + { name: elem.name, value: val }; |
6343 | 5677 | }).get(); |
6344 | 5678 | } |
6345 | 5679 | }); |
6346 | 5680 | |
6347 | 5681 | // Attach a bunch of functions for handling common AJAX events |
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 ); |
| 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); |
6351 | 5685 | }; |
6352 | | -} ); |
| 5686 | +}); |
6353 | 5687 | |
6354 | | -jQuery.each( [ "get", "post" ], function( i, method ) { |
6355 | | - jQuery[ method ] = function( url, data, callback, type ) { |
6356 | | - // shift arguments if data argument was omitted |
| 5688 | +jQuery.extend({ |
| 5689 | + get: function( url, data, callback, type ) { |
| 5690 | + // shift arguments if data argument was omited |
6357 | 5691 | if ( jQuery.isFunction( data ) ) { |
6358 | 5692 | type = type || callback; |
6359 | 5693 | callback = data; |
6360 | | - data = undefined; |
| 5694 | + data = null; |
6361 | 5695 | } |
6362 | 5696 | |
6363 | 5697 | return jQuery.ajax({ |
6364 | | - type: method, |
| 5698 | + type: "GET", |
6365 | 5699 | url: url, |
6366 | 5700 | data: data, |
6367 | 5701 | success: callback, |
6368 | 5702 | dataType: type |
6369 | 5703 | }); |
6370 | | - }; |
6371 | | -} ); |
| 5704 | + }, |
6372 | 5705 | |
6373 | | -jQuery.extend({ |
6374 | | - |
6375 | 5706 | getScript: function( url, callback ) { |
6376 | | - return jQuery.get( url, undefined, callback, "script" ); |
| 5707 | + return jQuery.get(url, null, callback, "script"); |
6377 | 5708 | }, |
6378 | 5709 | |
6379 | 5710 | getJSON: function( url, data, callback ) { |
6380 | | - return jQuery.get( url, data, callback, "json" ); |
| 5711 | + return jQuery.get(url, data, callback, "json"); |
6381 | 5712 | }, |
6382 | 5713 | |
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 ); |
| 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 = {}; |
6394 | 5720 | } |
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; |
| 5721 | + |
| 5722 | + return jQuery.ajax({ |
| 5723 | + type: "POST", |
| 5724 | + url: url, |
| 5725 | + data: data, |
| 5726 | + success: callback, |
| 5727 | + dataType: type |
| 5728 | + }); |
6404 | 5729 | }, |
6405 | 5730 | |
| 5731 | + ajaxSetup: function( settings ) { |
| 5732 | + jQuery.extend( jQuery.ajaxSettings, settings ); |
| 5733 | + }, |
| 5734 | + |
6406 | 5735 | ajaxSettings: { |
6407 | | - url: ajaxLocation, |
6408 | | - isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), |
| 5736 | + url: location.href, |
6409 | 5737 | global: true, |
6410 | 5738 | type: "GET", |
6411 | 5739 | contentType: "application/x-www-form-urlencoded", |
— | — | @@ -6413,428 +5741,332 @@ |
6414 | 5742 | /* |
6415 | 5743 | timeout: 0, |
6416 | 5744 | data: null, |
6417 | | - dataType: null, |
6418 | 5745 | username: null, |
6419 | 5746 | password: null, |
6420 | | - cache: null, |
6421 | 5747 | traditional: false, |
6422 | | - headers: {}, |
6423 | 5748 | */ |
6424 | | - |
| 5749 | + // This function can be overriden by calling jQuery.ajaxSetup |
| 5750 | + xhr: function() { |
| 5751 | + return new window.XMLHttpRequest(); |
| 5752 | + }, |
6425 | 5753 | accepts: { |
6426 | 5754 | xml: "application/xml, text/xml", |
6427 | 5755 | html: "text/html", |
6428 | | - text: "text/plain", |
| 5756 | + script: "text/javascript, application/javascript", |
6429 | 5757 | json: "application/json, text/javascript", |
6430 | | - "*": "*/*" |
6431 | | - }, |
| 5758 | + text: "text/plain", |
| 5759 | + _default: "*/*" |
| 5760 | + } |
| 5761 | + }, |
6432 | 5762 | |
6433 | | - contents: { |
6434 | | - xml: /xml/, |
6435 | | - html: /html/, |
6436 | | - json: /json/ |
6437 | | - }, |
| 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); |
6438 | 5766 | |
6439 | | - responseFields: { |
6440 | | - xml: "responseXML", |
6441 | | - text: "responseText" |
6442 | | - }, |
| 5767 | + s.url = s.url.replace( rhash, "" ); |
6443 | 5768 | |
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: { |
| 5769 | + // Use original (not extended) context object if it was provided |
| 5770 | + s.context = origSettings && origSettings.context != null ? origSettings.context : s; |
6448 | 5771 | |
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 |
| 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 ); |
6460 | 5775 | } |
6461 | | - }, |
6462 | 5776 | |
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; |
| 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"; |
6473 | 5787 | } |
6474 | 5788 | |
6475 | | - // Force options to be an object |
6476 | | - options = options || {}; |
| 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++); |
6477 | 5792 | |
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 = { |
| 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 | + } |
6514 | 5797 | |
6515 | | - readyState: 0, |
| 5798 | + s.url = s.url.replace(jsre, "=" + jsonp + "$1"); |
6516 | 5799 | |
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 | | - }, |
| 5800 | + // We need to make sure |
| 5801 | + // that a JSONP style response is executed properly |
| 5802 | + s.dataType = "script"; |
6524 | 5803 | |
6525 | | - // Raw string |
6526 | | - getAllResponseHeaders: function() { |
6527 | | - return state === 2 ? responseHeadersString : null; |
6528 | | - }, |
| 5804 | + // Handle JSONP-style loading |
| 5805 | + var customJsonp = window[ jsonp ]; |
6529 | 5806 | |
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 | | - }, |
| 5807 | + window[ jsonp ] = function( tmp ) { |
| 5808 | + if ( jQuery.isFunction( customJsonp ) ) { |
| 5809 | + customJsonp( tmp ); |
6544 | 5810 | |
6545 | | - // Overrides response content-type header |
6546 | | - overrideMimeType: function( type ) { |
6547 | | - if ( !state ) { |
6548 | | - s.mimeType = type; |
6549 | | - } |
6550 | | - return this; |
6551 | | - }, |
| 5811 | + } else { |
| 5812 | + // Garbage collect |
| 5813 | + window[ jsonp ] = undefined; |
6552 | 5814 | |
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; |
| 5815 | + try { |
| 5816 | + delete window[ jsonp ]; |
| 5817 | + } catch( jsonpError ) {} |
6561 | 5818 | } |
| 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 | + } |
6562 | 5827 | }; |
| 5828 | + } |
6563 | 5829 | |
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 ) { |
| 5830 | + if ( s.dataType === "script" && s.cache === null ) { |
| 5831 | + s.cache = false; |
| 5832 | + } |
6568 | 5833 | |
6569 | | - // Called once |
6570 | | - if ( state === 2 ) { |
6571 | | - return; |
6572 | | - } |
| 5834 | + if ( s.cache === false && noContent ) { |
| 5835 | + var ts = jQuery.now(); |
6573 | 5836 | |
6574 | | - // State is "done" now |
6575 | | - state = 2; |
| 5837 | + // try replacing _= if it is there |
| 5838 | + var ret = s.url.replace(rts, "$1_=" + ts); |
6576 | 5839 | |
6577 | | - // Clear timeout if it exists |
6578 | | - if ( timeoutTimer ) { |
6579 | | - clearTimeout( timeoutTimer ); |
6580 | | - } |
| 5840 | + // if nothing was replaced, add timestamp to the end |
| 5841 | + s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : ""); |
| 5842 | + } |
6581 | 5843 | |
6582 | | - // Dereference transport for early garbage collection |
6583 | | - // (no matter how long the jqXHR object will be used) |
6584 | | - transport = undefined; |
| 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 | + } |
6585 | 5848 | |
6586 | | - // Cache response headers |
6587 | | - responseHeadersString = headers || ""; |
| 5849 | + // Watch for a new set of requests |
| 5850 | + if ( s.global && jQuery.active++ === 0 ) { |
| 5851 | + jQuery.event.trigger( "ajaxStart" ); |
| 5852 | + } |
6588 | 5853 | |
6589 | | - // Set readyState |
6590 | | - jqXHR.readyState = status ? 4 : 0; |
| 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); |
6591 | 5857 | |
6592 | | - var isSuccess, |
6593 | | - success, |
6594 | | - error, |
6595 | | - response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined, |
6596 | | - lastModified, |
6597 | | - etag; |
| 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; |
6598 | 5867 | |
6599 | | - // If successful, handle type chaining |
6600 | | - if ( status >= 200 && status < 300 || status === 304 ) { |
| 5868 | + // Handle Script loading |
| 5869 | + if ( !jsonp ) { |
| 5870 | + var done = false; |
6601 | 5871 | |
6602 | | - // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. |
6603 | | - if ( s.ifModified ) { |
| 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 ); |
6604 | 5879 | |
6605 | | - if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) { |
6606 | | - jQuery.lastModified[ ifModifiedKey ] = lastModified; |
| 5880 | + // Handle memory leak in IE |
| 5881 | + script.onload = script.onreadystatechange = null; |
| 5882 | + if ( head && script.parentNode ) { |
| 5883 | + head.removeChild( script ); |
| 5884 | + } |
6607 | 5885 | } |
6608 | | - if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) { |
6609 | | - jQuery.etag[ ifModifiedKey ] = etag; |
6610 | | - } |
6611 | | - } |
| 5886 | + }; |
| 5887 | + } |
6612 | 5888 | |
6613 | | - // If not modified |
6614 | | - if ( status === 304 ) { |
| 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 ); |
6615 | 5892 | |
6616 | | - statusText = "notmodified"; |
6617 | | - isSuccess = true; |
| 5893 | + // We handle everything using the script element injection |
| 5894 | + return undefined; |
| 5895 | + } |
6618 | 5896 | |
6619 | | - // If we have data |
6620 | | - } else { |
| 5897 | + var requestDone = false; |
6621 | 5898 | |
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 | | - } |
| 5899 | + // Create the request object |
| 5900 | + var xhr = s.xhr(); |
6643 | 5901 | |
6644 | | - // Set data for the fake xhr object |
6645 | | - jqXHR.status = status; |
6646 | | - jqXHR.statusText = statusText; |
| 5902 | + if ( !xhr ) { |
| 5903 | + return; |
| 5904 | + } |
6647 | 5905 | |
6648 | | - // Success/Error |
6649 | | - if ( isSuccess ) { |
6650 | | - deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); |
6651 | | - } else { |
6652 | | - deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); |
6653 | | - } |
| 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 | + } |
6654 | 5913 | |
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 ] ); |
| 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); |
6662 | 5919 | } |
6663 | 5920 | |
6664 | | - // Complete |
6665 | | - completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] ); |
| 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 | + } |
6666 | 5926 | |
6667 | | - if ( fireGlobals ) { |
6668 | | - globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] ); |
6669 | | - // Handle the global AJAX counter |
6670 | | - if ( !( --jQuery.active ) ) { |
6671 | | - jQuery.event.trigger( "ajaxStop" ); |
| 5927 | + if ( jQuery.etag[s.url] ) { |
| 5928 | + xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]); |
6672 | 5929 | } |
6673 | 5930 | } |
6674 | | - } |
6675 | 5931 | |
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 | | - } |
| 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"); |
6694 | 5936 | } |
6695 | | - return this; |
6696 | | - }; |
6697 | 5937 | |
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 ] + "//" ); |
| 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 ) {} |
6702 | 5943 | |
6703 | | - // Extract dataTypes list |
6704 | | - s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax ); |
| 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 | + } |
6705 | 5950 | |
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 | | - ); |
| 5951 | + // close opended socket |
| 5952 | + xhr.abort(); |
| 5953 | + return false; |
6714 | 5954 | } |
6715 | 5955 | |
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 ); |
| 5956 | + if ( s.global ) { |
| 5957 | + jQuery.triggerGlobal( s, "ajaxSend", [xhr, s] ); |
6719 | 5958 | } |
6720 | 5959 | |
6721 | | - // Apply prefilters |
6722 | | - inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); |
| 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 | + } |
6723 | 5969 | |
6724 | | - // If request was aborted inside a prefiler, stop there |
6725 | | - if ( state === 2 ) { |
6726 | | - return false; |
6727 | | - } |
| 5970 | + requestDone = true; |
| 5971 | + if ( xhr ) { |
| 5972 | + xhr.onreadystatechange = jQuery.noop; |
| 5973 | + } |
6728 | 5974 | |
6729 | | - // We can fire global events as of now if asked to |
6730 | | - fireGlobals = s.global; |
| 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; |
6731 | 5979 | |
6732 | | - // Uppercase the type |
6733 | | - s.type = s.type.toUpperCase(); |
| 5980 | + status = isTimeout === "timeout" ? |
| 5981 | + "timeout" : |
| 5982 | + !jQuery.httpSuccess( xhr ) ? |
| 5983 | + "error" : |
| 5984 | + s.ifModified && jQuery.httpNotModified( xhr, s.url ) ? |
| 5985 | + "notmodified" : |
| 5986 | + "success"; |
6734 | 5987 | |
6735 | | - // Determine if request has content |
6736 | | - s.hasContent = !rnoContent.test( s.type ); |
| 5988 | + var errMsg; |
6737 | 5989 | |
6738 | | - // Watch for a new set of requests |
6739 | | - if ( fireGlobals && jQuery.active++ === 0 ) { |
6740 | | - jQuery.event.trigger( "ajaxStart" ); |
6741 | | - } |
| 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 | + } |
6742 | 6000 | |
6743 | | - // More options handling for requests with no content |
6744 | | - if ( !s.hasContent ) { |
| 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 | + } |
6745 | 6010 | |
6746 | | - // If data is available, append data to url |
6747 | | - if ( s.data ) { |
6748 | | - s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; |
6749 | | - } |
| 6011 | + // Fire the complete handlers |
| 6012 | + if ( !jsonp ) { |
| 6013 | + jQuery.handleComplete( s, xhr, status, data ); |
| 6014 | + } |
6750 | 6015 | |
6751 | | - // Get ifModifiedKey before adding the anti-cache parameter |
6752 | | - ifModifiedKey = s.url; |
| 6016 | + if ( isTimeout === "timeout" ) { |
| 6017 | + xhr.abort(); |
| 6018 | + } |
6753 | 6019 | |
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 : "" ); |
| 6020 | + // Stop memory leaks |
| 6021 | + if ( s.async ) { |
| 6022 | + xhr = null; |
| 6023 | + } |
6763 | 6024 | } |
6764 | | - } |
| 6025 | + }; |
6765 | 6026 | |
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 | | - } |
| 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 | + } |
6770 | 6038 | |
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 | | - } |
| 6039 | + onreadystatechange( "abort" ); |
| 6040 | + }; |
| 6041 | + } catch( abortError ) {} |
6781 | 6042 | |
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 ] ); |
| 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); |
6790 | 6051 | } |
6791 | 6052 | |
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; |
| 6053 | + // Send the data |
| 6054 | + try { |
| 6055 | + xhr.send( noContent || s.data == null ? null : s.data ); |
6797 | 6056 | |
6798 | | - } |
| 6057 | + } catch( sendError ) { |
| 6058 | + jQuery.handleError( s, xhr, null, sendError ); |
6799 | 6059 | |
6800 | | - // Install callbacks on deferreds |
6801 | | - for ( i in { success: 1, error: 1, complete: 1 } ) { |
6802 | | - jqXHR[ i ]( s[ i ] ); |
| 6060 | + // Fire the complete handlers |
| 6061 | + jQuery.handleComplete( s, xhr, status, data ); |
6803 | 6062 | } |
6804 | 6063 | |
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 | | - } |
| 6064 | + // firefox 1.5 doesn't fire statechange for sync requests |
| 6065 | + if ( !s.async ) { |
| 6066 | + onreadystatechange(); |
6836 | 6067 | } |
6837 | 6068 | |
6838 | | - return jqXHR; |
| 6069 | + // return XMLHttpRequest to allow aborting the request etc. |
| 6070 | + return xhr; |
6839 | 6071 | }, |
6840 | 6072 | |
6841 | 6073 | // Serialize an array of form elements or a set of |
— | — | @@ -6843,37 +6075,37 @@ |
6844 | 6076 | var s = [], |
6845 | 6077 | add = function( key, value ) { |
6846 | 6078 | // If value is a function, invoke it and return its value |
6847 | | - value = jQuery.isFunction( value ) ? value() : value; |
6848 | | - s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); |
| 6079 | + value = jQuery.isFunction(value) ? value() : value; |
| 6080 | + s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value); |
6849 | 6081 | }; |
6850 | | - |
| 6082 | + |
6851 | 6083 | // Set traditional to true for jQuery <= 1.3.2 behavior. |
6852 | 6084 | if ( traditional === undefined ) { |
6853 | 6085 | traditional = jQuery.ajaxSettings.traditional; |
6854 | 6086 | } |
6855 | | - |
| 6087 | + |
6856 | 6088 | // If an array was passed in, assume that it is an array of form elements. |
6857 | | - if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { |
| 6089 | + if ( jQuery.isArray(a) || a.jquery ) { |
6858 | 6090 | // Serialize the form elements |
6859 | 6091 | jQuery.each( a, function() { |
6860 | 6092 | add( this.name, this.value ); |
6861 | | - } ); |
6862 | | - |
| 6093 | + }); |
| 6094 | + |
6863 | 6095 | } else { |
6864 | 6096 | // If traditional, encode the "old" way (the way 1.3.2 or older |
6865 | 6097 | // did it), otherwise encode params recursively. |
6866 | 6098 | for ( var prefix in a ) { |
6867 | | - buildParams( prefix, a[ prefix ], traditional, add ); |
| 6099 | + buildParams( prefix, a[prefix], traditional, add ); |
6868 | 6100 | } |
6869 | 6101 | } |
6870 | 6102 | |
6871 | 6103 | // Return the resulting serialization |
6872 | | - return s.join( "&" ).replace( r20, "+" ); |
| 6104 | + return s.join("&").replace(r20, "+"); |
6873 | 6105 | } |
6874 | 6106 | }); |
6875 | 6107 | |
6876 | 6108 | function buildParams( prefix, obj, traditional, add ) { |
6877 | | - if ( jQuery.isArray( obj ) && obj.length ) { |
| 6109 | + if ( jQuery.isArray(obj) && obj.length ) { |
6878 | 6110 | // Serialize array item. |
6879 | 6111 | jQuery.each( obj, function( i, v ) { |
6880 | 6112 | if ( traditional || rbracket.test( prefix ) ) { |
— | — | @@ -6891,20 +6123,18 @@ |
6892 | 6124 | buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add ); |
6893 | 6125 | } |
6894 | 6126 | }); |
6895 | | - |
| 6127 | + |
6896 | 6128 | } else if ( !traditional && obj != null && typeof obj === "object" ) { |
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 ) ) { |
| 6129 | + if ( jQuery.isEmptyObject( obj ) ) { |
6900 | 6130 | add( prefix, "" ); |
6901 | 6131 | |
6902 | 6132 | // Serialize object item. |
6903 | 6133 | } else { |
6904 | | - for ( var name in obj ) { |
6905 | | - buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); |
6906 | | - } |
| 6134 | + jQuery.each( obj, function( k, v ) { |
| 6135 | + buildParams( prefix + "[" + k + "]", v, traditional, add ); |
| 6136 | + }); |
6907 | 6137 | } |
6908 | | - |
| 6138 | + |
6909 | 6139 | } else { |
6910 | 6140 | // Serialize scalar item. |
6911 | 6141 | add( prefix, obj ); |
— | — | @@ -6920,562 +6150,143 @@ |
6921 | 6151 | |
6922 | 6152 | // Last-Modified header cache for next request |
6923 | 6153 | lastModified: {}, |
6924 | | - etag: {} |
| 6154 | + etag: {}, |
6925 | 6155 | |
6926 | | -}); |
| 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 | + } |
6927 | 6161 | |
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 ) { |
| 6162 | + // Fire the global callback |
| 6163 | + if ( s.global ) { |
| 6164 | + jQuery.triggerGlobal( s, "ajaxError", [xhr, s, e] ); |
| 6165 | + } |
| 6166 | + }, |
6934 | 6167 | |
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 ]; |
| 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 ); |
6947 | 6172 | } |
6948 | | - } |
6949 | 6173 | |
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" ); |
| 6174 | + // Fire the global callback |
| 6175 | + if ( s.global ) { |
| 6176 | + jQuery.triggerGlobal( s, "ajaxSuccess", [xhr, s] ); |
6955 | 6177 | } |
6956 | | - } |
| 6178 | + }, |
6957 | 6179 | |
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 | | - } |
| 6180 | + handleComplete: function( s, xhr, status ) { |
| 6181 | + // Process result |
| 6182 | + if ( s.complete ) { |
| 6183 | + s.complete.call( s.context, xhr, status ); |
6965 | 6184 | } |
6966 | | - } |
6967 | 6185 | |
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 | | - } |
| 6186 | + // The request was completed |
| 6187 | + if ( s.global ) { |
| 6188 | + jQuery.triggerGlobal( s, "ajaxComplete", [xhr, s] ); |
6981 | 6189 | } |
6982 | | - // Or just use first one |
6983 | | - finalDataType = finalDataType || firstDataType; |
6984 | | - } |
6985 | 6190 | |
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 ); |
| 6191 | + // Handle the global AJAX counter |
| 6192 | + if ( s.global && jQuery.active-- === 1 ) { |
| 6193 | + jQuery.event.trigger( "ajaxStop" ); |
6992 | 6194 | } |
6993 | | - return responses[ finalDataType ]; |
6994 | | - } |
6995 | | -} |
| 6195 | + }, |
| 6196 | + |
| 6197 | + triggerGlobal: function( s, type, args ) { |
| 6198 | + (s.context && s.context.url == null ? jQuery(s.context) : jQuery.event).trigger(type, args); |
| 6199 | + }, |
6996 | 6200 | |
6997 | | -// Chain conversions given the request and the original response |
6998 | | -function ajaxConvert( s, response ) { |
| 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) {} |
6999 | 6209 | |
7000 | | - // Apply the dataFilter if provided |
7001 | | - if ( s.dataFilter ) { |
7002 | | - response = s.dataFilter( response, s.dataType ); |
7003 | | - } |
| 6210 | + return false; |
| 6211 | + }, |
7004 | 6212 | |
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; |
| 6213 | + // Determines if an XMLHttpRequest returns NotModified |
| 6214 | + httpNotModified: function( xhr, url ) { |
| 6215 | + var lastModified = xhr.getResponseHeader("Last-Modified"), |
| 6216 | + etag = xhr.getResponseHeader("Etag"); |
7021 | 6217 | |
7022 | | - // For each dataType in the chain |
7023 | | - for( i = 1; i < length; i++ ) { |
| 6218 | + if ( lastModified ) { |
| 6219 | + jQuery.lastModified[url] = lastModified; |
| 6220 | + } |
7024 | 6221 | |
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 | | - } |
| 6222 | + if ( etag ) { |
| 6223 | + jQuery.etag[url] = etag; |
7033 | 6224 | } |
7034 | 6225 | |
7035 | | - // Get the dataTypes |
7036 | | - prev = current; |
7037 | | - current = dataTypes[ i ]; |
| 6226 | + return xhr.status === 304; |
| 6227 | + }, |
7038 | 6228 | |
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 ) { |
| 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; |
7044 | 6233 | |
7045 | | - // Get the converter |
7046 | | - conversion = prev + " " + current; |
7047 | | - conv = converters[ conversion ] || converters[ "* " + current ]; |
| 6234 | + if ( xml && data.documentElement.nodeName === "parsererror" ) { |
| 6235 | + jQuery.error( "parsererror" ); |
| 6236 | + } |
7048 | 6237 | |
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 | | - } |
| 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 ); |
7077 | 6242 | } |
7078 | | - } |
7079 | | - return response; |
7080 | | -} |
7081 | 6243 | |
| 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 ); |
7082 | 6249 | |
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 | | - } |
| 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 ); |
7133 | 6253 | } |
7134 | 6254 | } |
7135 | 6255 | |
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"; |
| 6256 | + return data; |
7160 | 6257 | } |
7161 | | -} ); |
7162 | 6258 | |
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 | | - } |
7180 | 6259 | }); |
7181 | 6260 | |
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 ); |
| 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) {} |
7268 | 6274 | } |
7269 | | - }); |
7270 | | -} |
7271 | 6275 | |
7272 | | -// Functions to create xhrs |
7273 | | -function createStandardXHR() { |
7274 | | - try { |
7275 | | - return new window.XMLHttpRequest(); |
7276 | | - } catch( e ) {} |
| 6276 | + try { |
| 6277 | + return new window.ActiveXObject("Microsoft.XMLHTTP"); |
| 6278 | + } catch(activeError) {} |
| 6279 | + }; |
7277 | 6280 | } |
7278 | 6281 | |
7279 | | -function createActiveXHR() { |
7280 | | - try { |
7281 | | - return new window.ActiveXObject( "Microsoft.XMLHTTP" ); |
7282 | | - } catch( e ) {} |
7283 | | -} |
| 6282 | +// Does this browser support XHR requests? |
| 6283 | +jQuery.support.ajax = !!jQuery.ajaxSettings.xhr(); |
7284 | 6284 | |
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; |
7299 | 6285 | |
7300 | | -// Test if we can create an xhr object |
7301 | | -testXHR = jQuery.ajaxSettings.xhr(); |
7302 | | -jQuery.support.ajax = !!testXHR; |
7303 | 6286 | |
7304 | | -// Does this browser support crossDomain XHR requests |
7305 | | -jQuery.support.cors = testXHR && ( "withCredentials" in testXHR ); |
7306 | 6287 | |
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 | | - |
7477 | 6288 | var elemdisplay = {}, |
7478 | 6289 | rfxtypes = /^(?:toggle|show|hide)$/, |
7479 | | - rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i, |
| 6290 | + rfxnum = /^([+\-]=)?([\d+.\-]+)(.*)$/, |
7480 | 6291 | timerId, |
7481 | 6292 | fxAttrs = [ |
7482 | 6293 | // height animations |
— | — | @@ -7500,7 +6311,7 @@ |
7501 | 6312 | |
7502 | 6313 | // Reset the inline display of this element to learn if it is |
7503 | 6314 | // being hidden by cascaded rules or not |
7504 | | - if ( !jQuery._data(elem, "olddisplay") && display === "none" ) { |
| 6315 | + if ( !jQuery.data(elem, "olddisplay") && display === "none" ) { |
7505 | 6316 | display = elem.style.display = ""; |
7506 | 6317 | } |
7507 | 6318 | |
— | — | @@ -7508,7 +6319,7 @@ |
7509 | 6320 | // in a stylesheet to whatever the default browser style is |
7510 | 6321 | // for such an element |
7511 | 6322 | if ( display === "" && jQuery.css( elem, "display" ) === "none" ) { |
7512 | | - jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName)); |
| 6323 | + jQuery.data(elem, "olddisplay", defaultDisplay(elem.nodeName)); |
7513 | 6324 | } |
7514 | 6325 | } |
7515 | 6326 | |
— | — | @@ -7519,7 +6330,7 @@ |
7520 | 6331 | display = elem.style.display; |
7521 | 6332 | |
7522 | 6333 | if ( display === "" || display === "none" ) { |
7523 | | - elem.style.display = jQuery._data(elem, "olddisplay") || ""; |
| 6334 | + elem.style.display = jQuery.data(elem, "olddisplay") || ""; |
7524 | 6335 | } |
7525 | 6336 | } |
7526 | 6337 | |
— | — | @@ -7535,8 +6346,8 @@ |
7536 | 6347 | for ( var i = 0, j = this.length; i < j; i++ ) { |
7537 | 6348 | var display = jQuery.css( this[i], "display" ); |
7538 | 6349 | |
7539 | | - if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) { |
7540 | | - jQuery._data( this[i], "olddisplay", display ); |
| 6350 | + if ( display !== "none" ) { |
| 6351 | + jQuery.data( this[i], "olddisplay", display ); |
7541 | 6352 | } |
7542 | 6353 | } |
7543 | 6354 | |
— | — | @@ -7658,11 +6469,11 @@ |
7659 | 6470 | |
7660 | 6471 | } else { |
7661 | 6472 | var parts = rfxnum.exec(val), |
7662 | | - start = e.cur(); |
| 6473 | + start = e.cur() || 0; |
7663 | 6474 | |
7664 | 6475 | if ( parts ) { |
7665 | 6476 | var end = parseFloat( parts[2] ), |
7666 | | - unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" ); |
| 6477 | + unit = parts[3] || "px"; |
7667 | 6478 | |
7668 | 6479 | // We need to compute starting value |
7669 | 6480 | if ( unit !== "px" ) { |
— | — | @@ -7809,12 +6620,8 @@ |
7810 | 6621 | return this.elem[ this.prop ]; |
7811 | 6622 | } |
7812 | 6623 | |
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; |
| 6624 | + var r = parseFloat( jQuery.css( this.elem, this.prop ) ); |
| 6625 | + return r && r > -10000 ? r : 0; |
7819 | 6626 | }, |
7820 | 6627 | |
7821 | 6628 | // Start an animation from one number to another |
— | — | @@ -7825,7 +6632,7 @@ |
7826 | 6633 | this.startTime = jQuery.now(); |
7827 | 6634 | this.start = from; |
7828 | 6635 | this.end = to; |
7829 | | - this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" ); |
| 6636 | + this.unit = unit || this.unit || "px"; |
7830 | 6637 | this.now = this.start; |
7831 | 6638 | this.pos = this.state = 0; |
7832 | 6639 | |
— | — | @@ -8008,7 +6815,7 @@ |
8009 | 6816 | jQuery.fn.offset = function( options ) { |
8010 | 6817 | var elem = this[0], box; |
8011 | 6818 | |
8012 | | - if ( options ) { |
| 6819 | + if ( options ) { |
8013 | 6820 | return this.each(function( i ) { |
8014 | 6821 | jQuery.offset.setOffset( this, options, i ); |
8015 | 6822 | }); |
— | — | @@ -8031,15 +6838,15 @@ |
8032 | 6839 | |
8033 | 6840 | // Make sure we're not dealing with a disconnected DOM node |
8034 | 6841 | if ( !box || !jQuery.contains( docElem, elem ) ) { |
8035 | | - return box ? { top: box.top, left: box.left } : { top: 0, left: 0 }; |
| 6842 | + return box || { top: 0, left: 0 }; |
8036 | 6843 | } |
8037 | 6844 | |
8038 | 6845 | var body = doc.body, |
8039 | 6846 | win = getWindow(doc), |
8040 | 6847 | clientTop = docElem.clientTop || body.clientTop || 0, |
8041 | 6848 | clientLeft = docElem.clientLeft || body.clientLeft || 0, |
8042 | | - scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop, |
8043 | | - scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft, |
| 6849 | + scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ), |
| 6850 | + scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft), |
8044 | 6851 | top = box.top + scrollTop - clientTop, |
8045 | 6852 | left = box.left + scrollLeft - clientLeft; |
8046 | 6853 | |
— | — | @@ -8050,7 +6857,7 @@ |
8051 | 6858 | jQuery.fn.offset = function( options ) { |
8052 | 6859 | var elem = this[0]; |
8053 | 6860 | |
8054 | | - if ( options ) { |
| 6861 | + if ( options ) { |
8055 | 6862 | return this.each(function( i ) { |
8056 | 6863 | jQuery.offset.setOffset( this, options, i ); |
8057 | 6864 | }); |
— | — | @@ -8152,6 +6959,7 @@ |
8153 | 6960 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
8154 | 6961 | |
8155 | 6962 | body.removeChild( container ); |
| 6963 | + body = container = innerDiv = checkDiv = table = td = null; |
8156 | 6964 | jQuery.offset.initialize = jQuery.noop; |
8157 | 6965 | }, |
8158 | 6966 | |
— | — | @@ -8168,7 +6976,7 @@ |
8169 | 6977 | |
8170 | 6978 | return { top: top, left: left }; |
8171 | 6979 | }, |
8172 | | - |
| 6980 | + |
8173 | 6981 | setOffset: function( elem, options, i ) { |
8174 | 6982 | var position = jQuery.css( elem, "position" ); |
8175 | 6983 | |
— | — | @@ -8181,10 +6989,10 @@ |
8182 | 6990 | curOffset = curElem.offset(), |
8183 | 6991 | curCSSTop = jQuery.css( elem, "top" ), |
8184 | 6992 | curCSSLeft = jQuery.css( elem, "left" ), |
8185 | | - calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1, |
| 6993 | + calculatePosition = (position === "absolute" && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1), |
8186 | 6994 | props = {}, curPosition = {}, curTop, curLeft; |
8187 | 6995 | |
8188 | | - // need to be able to calculate position if either top or left is auto and position is either absolute or fixed |
| 6996 | + // need to be able to calculate position if either top or left is auto and position is absolute |
8189 | 6997 | if ( calculatePosition ) { |
8190 | 6998 | curPosition = curElem.position(); |
8191 | 6999 | } |
— | — | @@ -8202,7 +7010,7 @@ |
8203 | 7011 | if (options.left != null) { |
8204 | 7012 | props.left = (options.left - curOffset.left) + curLeft; |
8205 | 7013 | } |
8206 | | - |
| 7014 | + |
8207 | 7015 | if ( "using" in options ) { |
8208 | 7016 | options.using.call( elem, props ); |
8209 | 7017 | } else { |
— | — | @@ -8262,7 +7070,7 @@ |
8263 | 7071 | |
8264 | 7072 | jQuery.fn[ method ] = function(val) { |
8265 | 7073 | var elem = this[0], win; |
8266 | | - |
| 7074 | + |
8267 | 7075 | if ( !elem ) { |
8268 | 7076 | return null; |
8269 | 7077 | } |
— | — | @@ -8275,7 +7083,7 @@ |
8276 | 7084 | if ( win ) { |
8277 | 7085 | win.scrollTo( |
8278 | 7086 | !i ? val : jQuery(win).scrollLeft(), |
8279 | | - i ? val : jQuery(win).scrollTop() |
| 7087 | + i ? val : jQuery(win).scrollTop() |
8280 | 7088 | ); |
8281 | 7089 | |
8282 | 7090 | } else { |
— | — | @@ -8330,7 +7138,7 @@ |
8331 | 7139 | if ( !elem ) { |
8332 | 7140 | return size == null ? null : this; |
8333 | 7141 | } |
8334 | | - |
| 7142 | + |
8335 | 7143 | if ( jQuery.isFunction( size ) ) { |
8336 | 7144 | return this.each(function( i ) { |
8337 | 7145 | var self = jQuery( this ); |
— | — | @@ -8340,10 +7148,8 @@ |
8341 | 7149 | |
8342 | 7150 | if ( jQuery.isWindow( elem ) ) { |
8343 | 7151 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode |
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; |
| 7152 | + return elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || |
| 7153 | + elem.document.body[ "client" + name ]; |
8348 | 7154 | |
8349 | 7155 | // Get document width or height |
8350 | 7156 | } else if ( elem.nodeType === 9 ) { |
— | — | @@ -8370,5 +7176,4 @@ |
8371 | 7177 | }); |
8372 | 7178 | |
8373 | 7179 | |
8374 | | -window.jQuery = window.$ = jQuery; |
8375 | 7180 | })(window); |