Index: trunk/phase3/resources/jquery/jquery.js |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | /*! |
3 | | - * jQuery JavaScript Library v1.4.2 |
| 3 | + * jQuery JavaScript Library v1.4.4 |
4 | 4 | * http://jquery.com/ |
5 | 5 | * |
6 | 6 | * Copyright 2010, John Resig |
— | — | @@ -11,10 +11,14 @@ |
12 | 12 | * Copyright 2010, The Dojo Foundation |
13 | 13 | * Released under the MIT, BSD, and GPL Licenses. |
14 | 14 | * |
15 | | - * Date: Sat Feb 13 22:33:48 2010 -0500 |
| 15 | + * Date: Thu Nov 11 19:04:53 2010 -0500 |
16 | 16 | */ |
17 | 17 | (function( window, undefined ) { |
18 | 18 | |
| 19 | +// Use the correct document accordingly with window argument (sandbox) |
| 20 | +var document = window.document; |
| 21 | +var jQuery = (function() { |
| 22 | + |
19 | 23 | // Define a local copy of jQuery |
20 | 24 | var jQuery = function( selector, context ) { |
21 | 25 | // The jQuery object is actually just the init constructor 'enhanced' |
— | — | @@ -27,28 +31,45 @@ |
28 | 32 | // Map over the $ in case of overwrite |
29 | 33 | _$ = window.$, |
30 | 34 | |
31 | | - // Use the correct document accordingly with window argument (sandbox) |
32 | | - document = window.document, |
33 | | - |
34 | 35 | // A central reference to the root jQuery(document) |
35 | 36 | rootjQuery, |
36 | 37 | |
37 | 38 | // A simple way to check for HTML strings or ID strings |
38 | 39 | // (both of which we optimize for) |
39 | | - quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/, |
| 40 | + quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/, |
40 | 41 | |
41 | 42 | // Is it a simple selector |
42 | 43 | isSimple = /^.[^:#\[\.,]*$/, |
43 | 44 | |
44 | 45 | // Check if a string has a non-whitespace character in it |
45 | 46 | rnotwhite = /\S/, |
| 47 | + rwhite = /\s/, |
46 | 48 | |
47 | 49 | // Used for trimming whitespace |
48 | | - rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g, |
| 50 | + trimLeft = /^\s+/, |
| 51 | + trimRight = /\s+$/, |
49 | 52 | |
| 53 | + // Check for non-word characters |
| 54 | + rnonword = /\W/, |
| 55 | + |
| 56 | + // Check for digits |
| 57 | + rdigit = /\d/, |
| 58 | + |
50 | 59 | // Match a standalone tag |
51 | 60 | rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, |
52 | 61 | |
| 62 | + // JSON RegExp |
| 63 | + rvalidchars = /^[\],:{}\s]*$/, |
| 64 | + rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, |
| 65 | + rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, |
| 66 | + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, |
| 67 | + |
| 68 | + // Useragent RegExp |
| 69 | + rwebkit = /(webkit)[ \/]([\w.]+)/, |
| 70 | + ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, |
| 71 | + rmsie = /(msie) ([\w.]+)/, |
| 72 | + rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, |
| 73 | + |
53 | 74 | // Keep a UserAgent string for use with jQuery.browser |
54 | 75 | userAgent = navigator.userAgent, |
55 | 76 | |
— | — | @@ -66,10 +87,14 @@ |
67 | 88 | |
68 | 89 | // Save a reference to some core methods |
69 | 90 | toString = Object.prototype.toString, |
70 | | - hasOwnProperty = Object.prototype.hasOwnProperty, |
| 91 | + hasOwn = Object.prototype.hasOwnProperty, |
71 | 92 | push = Array.prototype.push, |
72 | 93 | slice = Array.prototype.slice, |
73 | | - indexOf = Array.prototype.indexOf; |
| 94 | + trim = String.prototype.trim, |
| 95 | + indexOf = Array.prototype.indexOf, |
| 96 | + |
| 97 | + // [[Class]] -> type pairs |
| 98 | + class2type = {}; |
74 | 99 | |
75 | 100 | jQuery.fn = jQuery.prototype = { |
76 | 101 | init: function( selector, context ) { |
— | — | @@ -88,7 +113,7 @@ |
89 | 114 | } |
90 | 115 | |
91 | 116 | // The body element only exists once, optimize finding it |
92 | | - if ( selector === "body" && !context ) { |
| 117 | + if ( selector === "body" && !context && document.body ) { |
93 | 118 | this.context = document; |
94 | 119 | this[0] = document.body; |
95 | 120 | this.selector = "body"; |
— | — | @@ -122,7 +147,7 @@ |
123 | 148 | } |
124 | 149 | |
125 | 150 | } else { |
126 | | - ret = buildFragment( [ match[1] ], [ doc ] ); |
| 151 | + ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); |
127 | 152 | selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; |
128 | 153 | } |
129 | 154 | |
— | — | @@ -132,7 +157,9 @@ |
133 | 158 | } else { |
134 | 159 | elem = document.getElementById( match[2] ); |
135 | 160 | |
136 | | - if ( elem ) { |
| 161 | + // Check parentNode to catch when Blackberry 4.6 returns |
| 162 | + // nodes that are no longer in the document #6963 |
| 163 | + if ( elem && elem.parentNode ) { |
137 | 164 | // Handle the case where IE and Opera return items |
138 | 165 | // by name instead of ID |
139 | 166 | if ( elem.id !== match[2] ) { |
— | — | @@ -150,7 +177,7 @@ |
151 | 178 | } |
152 | 179 | |
153 | 180 | // HANDLE: $("TAG") |
154 | | - } else if ( !context && /^\w+$/.test( selector ) ) { |
| 181 | + } else if ( !context && !rnonword.test( selector ) ) { |
155 | 182 | this.selector = selector; |
156 | 183 | this.context = document; |
157 | 184 | selector = document.getElementsByTagName( selector ); |
— | — | @@ -184,7 +211,7 @@ |
185 | 212 | selector: "", |
186 | 213 | |
187 | 214 | // The current version of jQuery being used |
188 | | - jquery: "1.4.2", |
| 215 | + jquery: "1.4.4", |
189 | 216 | |
190 | 217 | // The default length of a jQuery object is 0 |
191 | 218 | length: 0, |
— | — | @@ -303,8 +330,11 @@ |
304 | 331 | jQuery.fn.init.prototype = jQuery.fn; |
305 | 332 | |
306 | 333 | jQuery.extend = jQuery.fn.extend = function() { |
307 | | - // copy reference to target object |
308 | | - var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy; |
| 334 | + var options, name, src, copy, copyIsArray, clone, |
| 335 | + target = arguments[0] || {}, |
| 336 | + i = 1, |
| 337 | + length = arguments.length, |
| 338 | + deep = false; |
309 | 339 | |
310 | 340 | // Handle a deep copy situation |
311 | 341 | if ( typeof target === "boolean" ) { |
— | — | @@ -338,11 +368,16 @@ |
339 | 369 | continue; |
340 | 370 | } |
341 | 371 | |
342 | | - // Recurse if we're merging object literal values or arrays |
343 | | - if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) { |
344 | | - var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src |
345 | | - : jQuery.isArray(copy) ? [] : {}; |
| 372 | + // Recurse if we're merging plain objects or arrays |
| 373 | + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { |
| 374 | + if ( copyIsArray ) { |
| 375 | + copyIsArray = false; |
| 376 | + clone = src && jQuery.isArray(src) ? src : []; |
346 | 377 | |
| 378 | + } else { |
| 379 | + clone = src && jQuery.isPlainObject(src) ? src : {}; |
| 380 | + } |
| 381 | + |
347 | 382 | // Never move original objects, clone them |
348 | 383 | target[ name ] = jQuery.extend( deep, clone, copy ); |
349 | 384 | |
— | — | @@ -371,34 +406,51 @@ |
372 | 407 | |
373 | 408 | // Is the DOM ready to be used? Set to true once it occurs. |
374 | 409 | isReady: false, |
| 410 | + |
| 411 | + // A counter to track how many items to wait for before |
| 412 | + // the ready event fires. See #6781 |
| 413 | + readyWait: 1, |
375 | 414 | |
376 | 415 | // Handle when the DOM is ready |
377 | | - ready: function() { |
| 416 | + ready: function( wait ) { |
| 417 | + // A third-party is pushing the ready event forwards |
| 418 | + if ( wait === true ) { |
| 419 | + jQuery.readyWait--; |
| 420 | + } |
| 421 | + |
378 | 422 | // Make sure that the DOM is not already loaded |
379 | | - if ( !jQuery.isReady ) { |
| 423 | + if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) { |
380 | 424 | // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). |
381 | 425 | if ( !document.body ) { |
382 | | - return setTimeout( jQuery.ready, 13 ); |
| 426 | + return setTimeout( jQuery.ready, 1 ); |
383 | 427 | } |
384 | 428 | |
385 | 429 | // Remember that the DOM is ready |
386 | 430 | jQuery.isReady = true; |
387 | 431 | |
| 432 | + // If a normal DOM Ready event fired, decrement, and wait if need be |
| 433 | + if ( wait !== true && --jQuery.readyWait > 0 ) { |
| 434 | + return; |
| 435 | + } |
| 436 | + |
388 | 437 | // If there are functions bound, to execute |
389 | 438 | if ( readyList ) { |
390 | 439 | // Execute all of them |
391 | | - var fn, i = 0; |
392 | | - while ( (fn = readyList[ i++ ]) ) { |
393 | | - fn.call( document, jQuery ); |
394 | | - } |
| 440 | + var fn, |
| 441 | + i = 0, |
| 442 | + ready = readyList; |
395 | 443 | |
396 | 444 | // Reset the list of functions |
397 | 445 | readyList = null; |
398 | | - } |
399 | 446 | |
400 | | - // Trigger any bound ready events |
401 | | - if ( jQuery.fn.triggerHandler ) { |
402 | | - jQuery( document ).triggerHandler( "ready" ); |
| 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 | + } |
403 | 455 | } |
404 | 456 | } |
405 | 457 | }, |
— | — | @@ -413,7 +465,8 @@ |
414 | 466 | // Catch cases where $(document).ready() is called after the |
415 | 467 | // browser event has already occurred. |
416 | 468 | if ( document.readyState === "complete" ) { |
417 | | - return jQuery.ready(); |
| 469 | + // Handle it asynchronously to allow scripts the opportunity to delay ready |
| 470 | + return setTimeout( jQuery.ready, 1 ); |
418 | 471 | } |
419 | 472 | |
420 | 473 | // Mozilla, Opera and webkit nightlies currently support this event |
— | — | @@ -451,25 +504,40 @@ |
452 | 505 | // Since version 1.3, DOM methods and functions like alert |
453 | 506 | // aren't supported. They return false on IE (#2968). |
454 | 507 | isFunction: function( obj ) { |
455 | | - return toString.call(obj) === "[object Function]"; |
| 508 | + return jQuery.type(obj) === "function"; |
456 | 509 | }, |
457 | 510 | |
458 | | - isArray: function( obj ) { |
459 | | - return toString.call(obj) === "[object Array]"; |
| 511 | + isArray: Array.isArray || function( obj ) { |
| 512 | + return jQuery.type(obj) === "array"; |
460 | 513 | }, |
461 | 514 | |
| 515 | + // A crude way of determining if an object is a window |
| 516 | + isWindow: function( obj ) { |
| 517 | + return obj && typeof obj === "object" && "setInterval" in obj; |
| 518 | + }, |
| 519 | + |
| 520 | + isNaN: function( obj ) { |
| 521 | + return obj == null || !rdigit.test( obj ) || isNaN( obj ); |
| 522 | + }, |
| 523 | + |
| 524 | + type: function( obj ) { |
| 525 | + return obj == null ? |
| 526 | + String( obj ) : |
| 527 | + class2type[ toString.call(obj) ] || "object"; |
| 528 | + }, |
| 529 | + |
462 | 530 | isPlainObject: function( obj ) { |
463 | 531 | // Must be an Object. |
464 | 532 | // Because of IE, we also have to check the presence of the constructor property. |
465 | 533 | // Make sure that DOM nodes and window objects don't pass through, as well |
466 | | - if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) { |
| 534 | + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { |
467 | 535 | return false; |
468 | 536 | } |
469 | 537 | |
470 | 538 | // Not own constructor property must be Object |
471 | | - if ( obj.constructor |
472 | | - && !hasOwnProperty.call(obj, "constructor") |
473 | | - && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) { |
| 539 | + if ( obj.constructor && |
| 540 | + !hasOwn.call(obj, "constructor") && |
| 541 | + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { |
474 | 542 | return false; |
475 | 543 | } |
476 | 544 | |
— | — | @@ -479,7 +547,7 @@ |
480 | 548 | var key; |
481 | 549 | for ( key in obj ) {} |
482 | 550 | |
483 | | - return key === undefined || hasOwnProperty.call( obj, key ); |
| 551 | + return key === undefined || hasOwn.call( obj, key ); |
484 | 552 | }, |
485 | 553 | |
486 | 554 | isEmptyObject: function( obj ) { |
— | — | @@ -503,9 +571,9 @@ |
504 | 572 | |
505 | 573 | // Make sure the incoming data is actual JSON |
506 | 574 | // Logic borrowed from http://json.org/json2.js |
507 | | - if ( /^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@") |
508 | | - .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]") |
509 | | - .replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) { |
| 575 | + if ( rvalidchars.test(data.replace(rvalidescape, "@") |
| 576 | + .replace(rvalidtokens, "]") |
| 577 | + .replace(rvalidbraces, "")) ) { |
510 | 578 | |
511 | 579 | // Try to use the native JSON parser first |
512 | 580 | return window.JSON && window.JSON.parse ? |
— | — | @@ -584,10 +652,21 @@ |
585 | 653 | return object; |
586 | 654 | }, |
587 | 655 | |
588 | | - trim: function( text ) { |
589 | | - return (text || "").replace( rtrim, "" ); |
590 | | - }, |
| 656 | + // Use native String.trim function wherever possible |
| 657 | + trim: trim ? |
| 658 | + function( text ) { |
| 659 | + return text == null ? |
| 660 | + "" : |
| 661 | + trim.call( text ); |
| 662 | + } : |
591 | 663 | |
| 664 | + // Otherwise use our own trimming functionality |
| 665 | + function( text ) { |
| 666 | + return text == null ? |
| 667 | + "" : |
| 668 | + text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); |
| 669 | + }, |
| 670 | + |
592 | 671 | // results is for internal usage only |
593 | 672 | makeArray: function( array, results ) { |
594 | 673 | var ret = results || []; |
— | — | @@ -596,7 +675,10 @@ |
597 | 676 | // The window, strings (and functions) also have 'length' |
598 | 677 | // The extra typeof function check is to prevent crashes |
599 | 678 | // in Safari 2 (See: #3039) |
600 | | - if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) { |
| 679 | + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 |
| 680 | + var type = jQuery.type(array); |
| 681 | + |
| 682 | + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { |
601 | 683 | push.call( ret, array ); |
602 | 684 | } else { |
603 | 685 | jQuery.merge( ret, array ); |
— | — | @@ -621,7 +703,8 @@ |
622 | 704 | }, |
623 | 705 | |
624 | 706 | merge: function( first, second ) { |
625 | | - var i = first.length, j = 0; |
| 707 | + var i = first.length, |
| 708 | + j = 0; |
626 | 709 | |
627 | 710 | if ( typeof second.length === "number" ) { |
628 | 711 | for ( var l = second.length; j < l; j++ ) { |
— | — | @@ -640,12 +723,14 @@ |
641 | 724 | }, |
642 | 725 | |
643 | 726 | grep: function( elems, callback, inv ) { |
644 | | - var ret = []; |
| 727 | + var ret = [], retVal; |
| 728 | + inv = !!inv; |
645 | 729 | |
646 | 730 | // Go through the array, only saving the items |
647 | 731 | // that pass the validator function |
648 | 732 | for ( var i = 0, length = elems.length; i < length; i++ ) { |
649 | | - if ( !inv !== !callback( elems[ i ], i ) ) { |
| 733 | + retVal = !!callback( elems[ i ], i ); |
| 734 | + if ( inv !== retVal ) { |
650 | 735 | ret.push( elems[ i ] ); |
651 | 736 | } |
652 | 737 | } |
— | — | @@ -701,16 +786,49 @@ |
702 | 787 | return proxy; |
703 | 788 | }, |
704 | 789 | |
| 790 | + // Mutifunctional method to get and set values to a collection |
| 791 | + // The value/s can be optionally by executed if its a function |
| 792 | + access: function( elems, key, value, exec, fn, pass ) { |
| 793 | + var length = elems.length; |
| 794 | + |
| 795 | + // Setting many attributes |
| 796 | + if ( typeof key === "object" ) { |
| 797 | + for ( var k in key ) { |
| 798 | + jQuery.access( elems, k, key[k], exec, fn, value ); |
| 799 | + } |
| 800 | + return elems; |
| 801 | + } |
| 802 | + |
| 803 | + // Setting one attribute |
| 804 | + if ( value !== undefined ) { |
| 805 | + // Optionally, function values get executed if exec is true |
| 806 | + exec = !pass && exec && jQuery.isFunction(value); |
| 807 | + |
| 808 | + for ( var i = 0; i < length; i++ ) { |
| 809 | + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); |
| 810 | + } |
| 811 | + |
| 812 | + return elems; |
| 813 | + } |
| 814 | + |
| 815 | + // Getting an attribute |
| 816 | + return length ? fn( elems[0], key ) : undefined; |
| 817 | + }, |
| 818 | + |
| 819 | + now: function() { |
| 820 | + return (new Date()).getTime(); |
| 821 | + }, |
| 822 | + |
705 | 823 | // Use of jQuery.browser is frowned upon. |
706 | 824 | // More details: http://docs.jquery.com/Utilities/jQuery.browser |
707 | 825 | uaMatch: function( ua ) { |
708 | 826 | ua = ua.toLowerCase(); |
709 | 827 | |
710 | | - var match = /(webkit)[ \/]([\w.]+)/.exec( ua ) || |
711 | | - /(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) || |
712 | | - /(msie) ([\w.]+)/.exec( ua ) || |
713 | | - !/compatible/.test( ua ) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) || |
714 | | - []; |
| 828 | + var match = rwebkit.exec( ua ) || |
| 829 | + ropera.exec( ua ) || |
| 830 | + rmsie.exec( ua ) || |
| 831 | + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || |
| 832 | + []; |
715 | 833 | |
716 | 834 | return { browser: match[1] || "", version: match[2] || "0" }; |
717 | 835 | }, |
— | — | @@ -718,6 +836,11 @@ |
719 | 837 | browser: {} |
720 | 838 | }); |
721 | 839 | |
| 840 | +// Populate the class2type map |
| 841 | +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { |
| 842 | + class2type[ "[object " + name + "]" ] = name.toLowerCase(); |
| 843 | +}); |
| 844 | + |
722 | 845 | browserMatch = jQuery.uaMatch( userAgent ); |
723 | 846 | if ( browserMatch.browser ) { |
724 | 847 | jQuery.browser[ browserMatch.browser ] = true; |
— | — | @@ -735,6 +858,13 @@ |
736 | 859 | }; |
737 | 860 | } |
738 | 861 | |
| 862 | +// Verify that \s matches non-breaking spaces |
| 863 | +// (IE fails on this test) |
| 864 | +if ( !rwhite.test( "\xA0" ) ) { |
| 865 | + trimLeft = /^[\s\xA0]+/; |
| 866 | + trimRight = /[\s\xA0]+$/; |
| 867 | +} |
| 868 | + |
739 | 869 | // All jQuery objects should point back to these |
740 | 870 | rootjQuery = jQuery(document); |
741 | 871 | |
— | — | @@ -765,7 +895,7 @@ |
766 | 896 | // If IE is used, use the trick by Diego Perini |
767 | 897 | // http://javascript.nwbox.com/IEContentLoaded/ |
768 | 898 | document.documentElement.doScroll("left"); |
769 | | - } catch( error ) { |
| 899 | + } catch(e) { |
770 | 900 | setTimeout( doScrollCheck, 1 ); |
771 | 901 | return; |
772 | 902 | } |
— | — | @@ -774,54 +904,12 @@ |
775 | 905 | jQuery.ready(); |
776 | 906 | } |
777 | 907 | |
778 | | -function evalScript( i, elem ) { |
779 | | - if ( elem.src ) { |
780 | | - jQuery.ajax({ |
781 | | - url: elem.src, |
782 | | - async: false, |
783 | | - dataType: "script" |
784 | | - }); |
785 | | - } else { |
786 | | - jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
787 | | - } |
| 908 | +// Expose jQuery to the global object |
| 909 | +return (window.jQuery = window.$ = jQuery); |
788 | 910 | |
789 | | - if ( elem.parentNode ) { |
790 | | - elem.parentNode.removeChild( elem ); |
791 | | - } |
792 | | -} |
| 911 | +})(); |
793 | 912 | |
794 | | -// Mutifunctional method to get and set values to a collection |
795 | | -// The value/s can be optionally by executed if its a function |
796 | | -function access( elems, key, value, exec, fn, pass ) { |
797 | | - var length = elems.length; |
798 | | - |
799 | | - // Setting many attributes |
800 | | - if ( typeof key === "object" ) { |
801 | | - for ( var k in key ) { |
802 | | - access( elems, k, key[k], exec, fn, value ); |
803 | | - } |
804 | | - return elems; |
805 | | - } |
806 | | - |
807 | | - // Setting one attribute |
808 | | - if ( value !== undefined ) { |
809 | | - // Optionally, function values get executed if exec is true |
810 | | - exec = !pass && exec && jQuery.isFunction(value); |
811 | | - |
812 | | - for ( var i = 0; i < length; i++ ) { |
813 | | - fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); |
814 | | - } |
815 | | - |
816 | | - return elems; |
817 | | - } |
818 | | - |
819 | | - // Getting an attribute |
820 | | - return length ? fn( elems[0], key ) : undefined; |
821 | | -} |
822 | 913 | |
823 | | -function now() { |
824 | | - return (new Date).getTime(); |
825 | | -} |
826 | 914 | (function() { |
827 | 915 | |
828 | 916 | jQuery.support = {}; |
— | — | @@ -829,13 +917,15 @@ |
830 | 918 | var root = document.documentElement, |
831 | 919 | script = document.createElement("script"), |
832 | 920 | div = document.createElement("div"), |
833 | | - id = "script" + now(); |
| 921 | + id = "script" + jQuery.now(); |
834 | 922 | |
835 | 923 | div.style.display = "none"; |
836 | 924 | div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>"; |
837 | 925 | |
838 | 926 | var all = div.getElementsByTagName("*"), |
839 | | - a = div.getElementsByTagName("a")[0]; |
| 927 | + a = div.getElementsByTagName("a")[0], |
| 928 | + select = document.createElement("select"), |
| 929 | + opt = select.appendChild( document.createElement("option") ); |
840 | 930 | |
841 | 931 | // Can't get basic test support |
842 | 932 | if ( !all || !all.length || !a ) { |
— | — | @@ -878,18 +968,25 @@ |
879 | 969 | |
880 | 970 | // Make sure that a selected-by-default option has a working selected property. |
881 | 971 | // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) |
882 | | - optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected, |
| 972 | + optSelected: opt.selected, |
883 | 973 | |
884 | | - parentNode: div.removeChild( div.appendChild( document.createElement("div") ) ).parentNode === null, |
885 | | - |
886 | 974 | // Will be defined later |
887 | 975 | deleteExpando: true, |
| 976 | + optDisabled: false, |
888 | 977 | checkClone: false, |
889 | 978 | scriptEval: false, |
890 | 979 | noCloneEvent: true, |
891 | | - boxModel: null |
| 980 | + boxModel: null, |
| 981 | + inlineBlockNeedsLayout: false, |
| 982 | + shrinkWrapBlocks: false, |
| 983 | + reliableHiddenOffsets: true |
892 | 984 | }; |
893 | 985 | |
| 986 | + // Make sure that the options inside disabled selects aren't marked as disabled |
| 987 | + // (WebKit marks them as diabled) |
| 988 | + select.disabled = true; |
| 989 | + jQuery.support.optDisabled = !opt.disabled; |
| 990 | + |
894 | 991 | script.type = "text/javascript"; |
895 | 992 | try { |
896 | 993 | script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
— | — | @@ -909,7 +1006,7 @@ |
910 | 1007 | // Fails in Internet Explorer |
911 | 1008 | try { |
912 | 1009 | delete script.test; |
913 | | - |
| 1010 | + |
914 | 1011 | } catch(e) { |
915 | 1012 | jQuery.support.deleteExpando = false; |
916 | 1013 | } |
— | — | @@ -943,27 +1040,63 @@ |
944 | 1041 | |
945 | 1042 | document.body.appendChild( div ); |
946 | 1043 | jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2; |
947 | | - document.body.removeChild( div ).style.display = 'none'; |
948 | 1044 | |
949 | | - div = null; |
| 1045 | + if ( "zoom" in div.style ) { |
| 1046 | + // Check if natively block-level elements act like inline-block |
| 1047 | + // elements when setting their display to 'inline' and giving |
| 1048 | + // them layout |
| 1049 | + // (IE < 8 does this) |
| 1050 | + div.style.display = "inline"; |
| 1051 | + div.style.zoom = 1; |
| 1052 | + jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2; |
| 1053 | + |
| 1054 | + // Check if elements with layout shrink-wrap their children |
| 1055 | + // (IE 6 does this) |
| 1056 | + div.style.display = ""; |
| 1057 | + div.innerHTML = "<div style='width:4px;'></div>"; |
| 1058 | + jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2; |
| 1059 | + } |
| 1060 | + |
| 1061 | + div.innerHTML = "<table><tr><td style='padding:0;display:none'></td><td>t</td></tr></table>"; |
| 1062 | + var tds = div.getElementsByTagName("td"); |
| 1063 | + |
| 1064 | + // Check if table cells still have offsetWidth/Height when they are set |
| 1065 | + // to display:none and there are still other visible table cells in a |
| 1066 | + // table row; if so, offsetWidth/Height are not reliable for use when |
| 1067 | + // determining if an element has been hidden directly using |
| 1068 | + // display:none (it is still safe to use offsets if a parent element is |
| 1069 | + // hidden; don safety goggles and see bug #4512 for more information). |
| 1070 | + // (only IE 8 fails this test) |
| 1071 | + jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0; |
| 1072 | + |
| 1073 | + tds[0].style.display = ""; |
| 1074 | + tds[1].style.display = "none"; |
| 1075 | + |
| 1076 | + // Check if empty table cells still have offsetWidth/Height |
| 1077 | + // (IE < 8 fail this test) |
| 1078 | + jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0; |
| 1079 | + div.innerHTML = ""; |
| 1080 | + |
| 1081 | + document.body.removeChild( div ).style.display = "none"; |
| 1082 | + div = tds = null; |
950 | 1083 | }); |
951 | 1084 | |
952 | 1085 | // Technique from Juriy Zaytsev |
953 | 1086 | // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ |
954 | | - var eventSupported = function( eventName ) { |
955 | | - var el = document.createElement("div"); |
956 | | - eventName = "on" + eventName; |
| 1087 | + var eventSupported = function( eventName ) { |
| 1088 | + var el = document.createElement("div"); |
| 1089 | + eventName = "on" + eventName; |
957 | 1090 | |
958 | | - var isSupported = (eventName in el); |
959 | | - if ( !isSupported ) { |
960 | | - el.setAttribute(eventName, "return;"); |
961 | | - isSupported = typeof el[eventName] === "function"; |
962 | | - } |
963 | | - el = null; |
| 1091 | + var isSupported = (eventName in el); |
| 1092 | + if ( !isSupported ) { |
| 1093 | + el.setAttribute(eventName, "return;"); |
| 1094 | + isSupported = typeof el[eventName] === "function"; |
| 1095 | + } |
| 1096 | + el = null; |
964 | 1097 | |
965 | | - return isSupported; |
| 1098 | + return isSupported; |
966 | 1099 | }; |
967 | | - |
| 1100 | + |
968 | 1101 | jQuery.support.submitBubbles = eventSupported("submit"); |
969 | 1102 | jQuery.support.changeBubbles = eventSupported("change"); |
970 | 1103 | |
— | — | @@ -971,35 +1104,31 @@ |
972 | 1105 | root = script = div = all = a = null; |
973 | 1106 | })(); |
974 | 1107 | |
975 | | -jQuery.props = { |
976 | | - "for": "htmlFor", |
977 | | - "class": "className", |
978 | | - readonly: "readOnly", |
979 | | - maxlength: "maxLength", |
980 | | - cellspacing: "cellSpacing", |
981 | | - rowspan: "rowSpan", |
982 | | - colspan: "colSpan", |
983 | | - tabindex: "tabIndex", |
984 | | - usemap: "useMap", |
985 | | - frameborder: "frameBorder" |
986 | | -}; |
987 | | -var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
988 | 1108 | |
| 1109 | + |
| 1110 | +var windowData = {}, |
| 1111 | + rbrace = /^(?:\{.*\}|\[.*\])$/; |
| 1112 | + |
989 | 1113 | jQuery.extend({ |
990 | 1114 | cache: {}, |
991 | | - |
992 | | - expando:expando, |
993 | 1115 | |
| 1116 | + // Please use with caution |
| 1117 | + uuid: 0, |
| 1118 | + |
| 1119 | + // Unique for each copy of jQuery on the page |
| 1120 | + expando: "jQuery" + jQuery.now(), |
| 1121 | + |
994 | 1122 | // The following elements throw uncatchable exceptions if you |
995 | 1123 | // attempt to add expando properties to them. |
996 | 1124 | noData: { |
997 | 1125 | "embed": true, |
998 | | - "object": true, |
| 1126 | + // Ban all objects except for Flash (which handle expandos) |
| 1127 | + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", |
999 | 1128 | "applet": true |
1000 | 1129 | }, |
1001 | 1130 | |
1002 | 1131 | data: function( elem, name, data ) { |
1003 | | - if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { |
| 1132 | + if ( !jQuery.acceptData( elem ) ) { |
1004 | 1133 | return; |
1005 | 1134 | } |
1006 | 1135 | |
— | — | @@ -1007,29 +1136,38 @@ |
1008 | 1137 | windowData : |
1009 | 1138 | elem; |
1010 | 1139 | |
1011 | | - var id = elem[ expando ], cache = jQuery.cache, thisCache; |
| 1140 | + var isNode = elem.nodeType, |
| 1141 | + id = isNode ? elem[ jQuery.expando ] : null, |
| 1142 | + cache = jQuery.cache, thisCache; |
1012 | 1143 | |
1013 | | - if ( !id && typeof name === "string" && data === undefined ) { |
1014 | | - return null; |
| 1144 | + if ( isNode && !id && typeof name === "string" && data === undefined ) { |
| 1145 | + return; |
1015 | 1146 | } |
1016 | 1147 | |
| 1148 | + // Get the data from the object directly |
| 1149 | + if ( !isNode ) { |
| 1150 | + cache = elem; |
| 1151 | + |
1017 | 1152 | // Compute a unique ID for the element |
1018 | | - if ( !id ) { |
1019 | | - id = ++uuid; |
| 1153 | + } else if ( !id ) { |
| 1154 | + elem[ jQuery.expando ] = id = ++jQuery.uuid; |
1020 | 1155 | } |
1021 | 1156 | |
1022 | 1157 | // Avoid generating a new cache unless none exists and we |
1023 | 1158 | // want to manipulate it. |
1024 | 1159 | if ( typeof name === "object" ) { |
1025 | | - elem[ expando ] = id; |
1026 | | - thisCache = cache[ id ] = jQuery.extend(true, {}, name); |
| 1160 | + if ( isNode ) { |
| 1161 | + cache[ id ] = jQuery.extend(cache[ id ], name); |
1027 | 1162 | |
1028 | | - } else if ( !cache[ id ] ) { |
1029 | | - elem[ expando ] = id; |
| 1163 | + } else { |
| 1164 | + jQuery.extend( cache, name ); |
| 1165 | + } |
| 1166 | + |
| 1167 | + } else if ( isNode && !cache[ id ] ) { |
1030 | 1168 | cache[ id ] = {}; |
1031 | 1169 | } |
1032 | 1170 | |
1033 | | - thisCache = cache[ id ]; |
| 1171 | + thisCache = isNode ? cache[ id ] : cache; |
1034 | 1172 | |
1035 | 1173 | // Prevent overriding the named cache with undefined values |
1036 | 1174 | if ( data !== undefined ) { |
— | — | @@ -1040,7 +1178,7 @@ |
1041 | 1179 | }, |
1042 | 1180 | |
1043 | 1181 | removeData: function( elem, name ) { |
1044 | | - if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { |
| 1182 | + if ( !jQuery.acceptData( elem ) ) { |
1045 | 1183 | return; |
1046 | 1184 | } |
1047 | 1185 | |
— | — | @@ -1048,7 +1186,10 @@ |
1049 | 1187 | windowData : |
1050 | 1188 | elem; |
1051 | 1189 | |
1052 | | - var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ]; |
| 1190 | + var isNode = elem.nodeType, |
| 1191 | + id = isNode ? elem[ jQuery.expando ] : elem, |
| 1192 | + cache = jQuery.cache, |
| 1193 | + thisCache = isNode ? cache[ id ] : id; |
1053 | 1194 | |
1054 | 1195 | // If we want to remove a specific section of the element's data |
1055 | 1196 | if ( name ) { |
— | — | @@ -1057,31 +1198,67 @@ |
1058 | 1199 | delete thisCache[ name ]; |
1059 | 1200 | |
1060 | 1201 | // If we've removed all the data, remove the element's cache |
1061 | | - if ( jQuery.isEmptyObject(thisCache) ) { |
| 1202 | + if ( isNode && jQuery.isEmptyObject(thisCache) ) { |
1062 | 1203 | jQuery.removeData( elem ); |
1063 | 1204 | } |
1064 | 1205 | } |
1065 | 1206 | |
1066 | 1207 | // Otherwise, we want to remove all of the element's data |
1067 | 1208 | } else { |
1068 | | - if ( jQuery.support.deleteExpando ) { |
| 1209 | + if ( isNode && jQuery.support.deleteExpando ) { |
1069 | 1210 | delete elem[ jQuery.expando ]; |
1070 | 1211 | |
1071 | 1212 | } else if ( elem.removeAttribute ) { |
1072 | 1213 | elem.removeAttribute( jQuery.expando ); |
1073 | | - } |
1074 | 1214 | |
1075 | 1215 | // Completely remove the data cache |
1076 | | - delete cache[ id ]; |
| 1216 | + } else if ( isNode ) { |
| 1217 | + delete cache[ id ]; |
| 1218 | + |
| 1219 | + // Remove all fields from the object |
| 1220 | + } else { |
| 1221 | + for ( var n in elem ) { |
| 1222 | + delete elem[ n ]; |
| 1223 | + } |
| 1224 | + } |
1077 | 1225 | } |
| 1226 | + }, |
| 1227 | + |
| 1228 | + // A method for determining if a DOM node can handle the data expando |
| 1229 | + acceptData: function( elem ) { |
| 1230 | + if ( elem.nodeName ) { |
| 1231 | + var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; |
| 1232 | + |
| 1233 | + if ( match ) { |
| 1234 | + return !(match === true || elem.getAttribute("classid") !== match); |
| 1235 | + } |
| 1236 | + } |
| 1237 | + |
| 1238 | + return true; |
1078 | 1239 | } |
1079 | 1240 | }); |
1080 | 1241 | |
1081 | 1242 | jQuery.fn.extend({ |
1082 | 1243 | data: function( key, value ) { |
1083 | | - if ( typeof key === "undefined" && this.length ) { |
1084 | | - return jQuery.data( this[0] ); |
| 1244 | + var data = null; |
1085 | 1245 | |
| 1246 | + if ( typeof key === "undefined" ) { |
| 1247 | + if ( this.length ) { |
| 1248 | + var attr = this[0].attributes, name; |
| 1249 | + data = jQuery.data( this[0] ); |
| 1250 | + |
| 1251 | + for ( var i = 0, l = attr.length; i < l; i++ ) { |
| 1252 | + name = attr[i].name; |
| 1253 | + |
| 1254 | + if ( name.indexOf( "data-" ) === 0 ) { |
| 1255 | + name = name.substr( 5 ); |
| 1256 | + dataAttr( this[0], name, data[ name ] ); |
| 1257 | + } |
| 1258 | + } |
| 1259 | + } |
| 1260 | + |
| 1261 | + return data; |
| 1262 | + |
1086 | 1263 | } else if ( typeof key === "object" ) { |
1087 | 1264 | return this.each(function() { |
1088 | 1265 | jQuery.data( this, key ); |
— | — | @@ -1092,17 +1269,26 @@ |
1093 | 1270 | parts[1] = parts[1] ? "." + parts[1] : ""; |
1094 | 1271 | |
1095 | 1272 | if ( value === undefined ) { |
1096 | | - var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
| 1273 | + data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); |
1097 | 1274 | |
| 1275 | + // Try to fetch any internally stored data first |
1098 | 1276 | if ( data === undefined && this.length ) { |
1099 | 1277 | data = jQuery.data( this[0], key ); |
| 1278 | + data = dataAttr( this[0], key, data ); |
1100 | 1279 | } |
| 1280 | + |
1101 | 1281 | return data === undefined && parts[1] ? |
1102 | 1282 | this.data( parts[0] ) : |
1103 | 1283 | data; |
| 1284 | + |
1104 | 1285 | } else { |
1105 | | - return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() { |
| 1286 | + return this.each(function() { |
| 1287 | + var $this = jQuery( this ), |
| 1288 | + args = [ parts[0], value ]; |
| 1289 | + |
| 1290 | + $this.triggerHandler( "setData" + parts[1] + "!", args ); |
1106 | 1291 | jQuery.data( this, key, value ); |
| 1292 | + $this.triggerHandler( "changeData" + parts[1] + "!", args ); |
1107 | 1293 | }); |
1108 | 1294 | } |
1109 | 1295 | }, |
— | — | @@ -1113,6 +1299,37 @@ |
1114 | 1300 | }); |
1115 | 1301 | } |
1116 | 1302 | }); |
| 1303 | + |
| 1304 | +function dataAttr( elem, key, data ) { |
| 1305 | + // If nothing was found internally, try to fetch any |
| 1306 | + // data from the HTML5 data-* attribute |
| 1307 | + if ( data === undefined && elem.nodeType === 1 ) { |
| 1308 | + data = elem.getAttribute( "data-" + key ); |
| 1309 | + |
| 1310 | + if ( typeof data === "string" ) { |
| 1311 | + try { |
| 1312 | + data = data === "true" ? true : |
| 1313 | + data === "false" ? false : |
| 1314 | + data === "null" ? null : |
| 1315 | + !jQuery.isNaN( data ) ? parseFloat( data ) : |
| 1316 | + rbrace.test( data ) ? jQuery.parseJSON( data ) : |
| 1317 | + data; |
| 1318 | + } catch( e ) {} |
| 1319 | + |
| 1320 | + // Make sure we set the data so it isn't changed later |
| 1321 | + jQuery.data( elem, key, data ); |
| 1322 | + |
| 1323 | + } else { |
| 1324 | + data = undefined; |
| 1325 | + } |
| 1326 | + } |
| 1327 | + |
| 1328 | + return data; |
| 1329 | +} |
| 1330 | + |
| 1331 | + |
| 1332 | + |
| 1333 | + |
1117 | 1334 | jQuery.extend({ |
1118 | 1335 | queue: function( elem, type, data ) { |
1119 | 1336 | if ( !elem ) { |
— | — | @@ -1140,7 +1357,8 @@ |
1141 | 1358 | dequeue: function( elem, type ) { |
1142 | 1359 | type = type || "fx"; |
1143 | 1360 | |
1144 | | - var queue = jQuery.queue( elem, type ), fn = queue.shift(); |
| 1361 | + var queue = jQuery.queue( elem, type ), |
| 1362 | + fn = queue.shift(); |
1145 | 1363 | |
1146 | 1364 | // If the fx queue is dequeued, always remove the progress sentinel |
1147 | 1365 | if ( fn === "inprogress" ) { |
— | — | @@ -1171,7 +1389,7 @@ |
1172 | 1390 | if ( data === undefined ) { |
1173 | 1391 | return jQuery.queue( this[0], type ); |
1174 | 1392 | } |
1175 | | - return this.each(function( i, elem ) { |
| 1393 | + return this.each(function( i ) { |
1176 | 1394 | var queue = jQuery.queue( this, type, data ); |
1177 | 1395 | |
1178 | 1396 | if ( type === "fx" && queue[0] !== "inprogress" ) { |
— | — | @@ -1203,18 +1421,35 @@ |
1204 | 1422 | return this.queue( type || "fx", [] ); |
1205 | 1423 | } |
1206 | 1424 | }); |
| 1425 | + |
| 1426 | + |
| 1427 | + |
| 1428 | + |
1207 | 1429 | var rclass = /[\n\t]/g, |
1208 | | - rspace = /\s+/, |
| 1430 | + rspaces = /\s+/, |
1209 | 1431 | rreturn = /\r/g, |
1210 | | - rspecialurl = /href|src|style/, |
1211 | | - rtype = /(button|input)/i, |
1212 | | - rfocusable = /(button|input|object|select|textarea)/i, |
1213 | | - rclickable = /^(a|area)$/i, |
1214 | | - rradiocheck = /radio|checkbox/; |
| 1432 | + rspecialurl = /^(?:href|src|style)$/, |
| 1433 | + rtype = /^(?:button|input)$/i, |
| 1434 | + rfocusable = /^(?:button|input|object|select|textarea)$/i, |
| 1435 | + rclickable = /^a(?:rea)?$/i, |
| 1436 | + rradiocheck = /^(?:radio|checkbox)$/i; |
1215 | 1437 | |
| 1438 | +jQuery.props = { |
| 1439 | + "for": "htmlFor", |
| 1440 | + "class": "className", |
| 1441 | + readonly: "readOnly", |
| 1442 | + maxlength: "maxLength", |
| 1443 | + cellspacing: "cellSpacing", |
| 1444 | + rowspan: "rowSpan", |
| 1445 | + colspan: "colSpan", |
| 1446 | + tabindex: "tabIndex", |
| 1447 | + usemap: "useMap", |
| 1448 | + frameborder: "frameBorder" |
| 1449 | +}; |
| 1450 | + |
1216 | 1451 | jQuery.fn.extend({ |
1217 | 1452 | attr: function( name, value ) { |
1218 | | - return access( this, name, value, true, jQuery.attr ); |
| 1453 | + return jQuery.access( this, name, value, true, jQuery.attr ); |
1219 | 1454 | }, |
1220 | 1455 | |
1221 | 1456 | removeAttr: function( name, fn ) { |
— | — | @@ -1235,7 +1470,7 @@ |
1236 | 1471 | } |
1237 | 1472 | |
1238 | 1473 | if ( value && typeof value === "string" ) { |
1239 | | - var classNames = (value || "").split( rspace ); |
| 1474 | + var classNames = (value || "").split( rspaces ); |
1240 | 1475 | |
1241 | 1476 | for ( var i = 0, l = this.length; i < l; i++ ) { |
1242 | 1477 | var elem = this[i]; |
— | — | @@ -1245,7 +1480,9 @@ |
1246 | 1481 | elem.className = value; |
1247 | 1482 | |
1248 | 1483 | } else { |
1249 | | - var className = " " + elem.className + " ", setClass = elem.className; |
| 1484 | + var className = " " + elem.className + " ", |
| 1485 | + setClass = elem.className; |
| 1486 | + |
1250 | 1487 | for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
1251 | 1488 | if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { |
1252 | 1489 | setClass += " " + classNames[c]; |
— | — | @@ -1269,7 +1506,7 @@ |
1270 | 1507 | } |
1271 | 1508 | |
1272 | 1509 | if ( (value && typeof value === "string") || value === undefined ) { |
1273 | | - var classNames = (value || "").split(rspace); |
| 1510 | + var classNames = (value || "").split( rspaces ); |
1274 | 1511 | |
1275 | 1512 | for ( var i = 0, l = this.length; i < l; i++ ) { |
1276 | 1513 | var elem = this[i]; |
— | — | @@ -1293,7 +1530,8 @@ |
1294 | 1531 | }, |
1295 | 1532 | |
1296 | 1533 | toggleClass: function( value, stateVal ) { |
1297 | | - var type = typeof value, isBool = typeof stateVal === "boolean"; |
| 1534 | + var type = typeof value, |
| 1535 | + isBool = typeof stateVal === "boolean"; |
1298 | 1536 | |
1299 | 1537 | if ( jQuery.isFunction( value ) ) { |
1300 | 1538 | return this.each(function(i) { |
— | — | @@ -1305,9 +1543,11 @@ |
1306 | 1544 | return this.each(function() { |
1307 | 1545 | if ( type === "string" ) { |
1308 | 1546 | // toggle individual class names |
1309 | | - var className, i = 0, self = jQuery(this), |
| 1547 | + var className, |
| 1548 | + i = 0, |
| 1549 | + self = jQuery( this ), |
1310 | 1550 | state = stateVal, |
1311 | | - classNames = value.split( rspace ); |
| 1551 | + classNames = value.split( rspaces ); |
1312 | 1552 | |
1313 | 1553 | while ( (className = classNames[ i++ ]) ) { |
1314 | 1554 | // check each className given, space seperated list |
— | — | @@ -1339,12 +1579,15 @@ |
1340 | 1580 | }, |
1341 | 1581 | |
1342 | 1582 | val: function( value ) { |
1343 | | - if ( value === undefined ) { |
| 1583 | + if ( !arguments.length ) { |
1344 | 1584 | var elem = this[0]; |
1345 | 1585 | |
1346 | 1586 | if ( elem ) { |
1347 | 1587 | if ( jQuery.nodeName( elem, "option" ) ) { |
1348 | | - return (elem.attributes.value || {}).specified ? elem.value : elem.text; |
| 1588 | + // attributes.value is undefined in Blackberry 4.7 but |
| 1589 | + // uses .value. See #6932 |
| 1590 | + var val = elem.attributes.value; |
| 1591 | + return !val || val.specified ? elem.value : elem.text; |
1349 | 1592 | } |
1350 | 1593 | |
1351 | 1594 | // We need to handle select boxes special |
— | — | @@ -1363,8 +1606,11 @@ |
1364 | 1607 | for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { |
1365 | 1608 | var option = options[ i ]; |
1366 | 1609 | |
1367 | | - if ( option.selected ) { |
1368 | | - // Get the specifc value for the option |
| 1610 | + // Don't return options that are disabled or in a disabled optgroup |
| 1611 | + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && |
| 1612 | + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { |
| 1613 | + |
| 1614 | + // Get the specific value for the option |
1369 | 1615 | value = jQuery(option).val(); |
1370 | 1616 | |
1371 | 1617 | // We don't need an array for one selects |
— | — | @@ -1407,10 +1653,15 @@ |
1408 | 1654 | val = value.call(this, i, self.val()); |
1409 | 1655 | } |
1410 | 1656 | |
1411 | | - // Typecast each time if the value is a Function and the appended |
1412 | | - // value is therefore different each time. |
1413 | | - if ( typeof val === "number" ) { |
| 1657 | + // Treat null/undefined as ""; convert numbers to string |
| 1658 | + if ( val == null ) { |
| 1659 | + val = ""; |
| 1660 | + } else if ( typeof val === "number" ) { |
1414 | 1661 | val += ""; |
| 1662 | + } else if ( jQuery.isArray(val) ) { |
| 1663 | + val = jQuery.map(val, function (value) { |
| 1664 | + return value == null ? "" : value + ""; |
| 1665 | + }); |
1415 | 1666 | } |
1416 | 1667 | |
1417 | 1668 | if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) { |
— | — | @@ -1463,89 +1714,103 @@ |
1464 | 1715 | // Try to normalize/fix the name |
1465 | 1716 | name = notxml && jQuery.props[ name ] || name; |
1466 | 1717 | |
1467 | | - // Only do all the following if this is a node (faster for style) |
1468 | | - if ( elem.nodeType === 1 ) { |
1469 | | - // These attributes require special treatment |
1470 | | - var special = rspecialurl.test( name ); |
| 1718 | + // These attributes require special treatment |
| 1719 | + var special = rspecialurl.test( name ); |
1471 | 1720 | |
1472 | | - // Safari mis-reports the default selected property of an option |
1473 | | - // Accessing the parent's selectedIndex property fixes it |
1474 | | - if ( name === "selected" && !jQuery.support.optSelected ) { |
1475 | | - var parent = elem.parentNode; |
1476 | | - if ( parent ) { |
1477 | | - parent.selectedIndex; |
1478 | | - |
1479 | | - // Make sure that it also works with optgroups, see #5701 |
1480 | | - if ( parent.parentNode ) { |
1481 | | - parent.parentNode.selectedIndex; |
1482 | | - } |
| 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; |
| 1727 | + |
| 1728 | + // Make sure that it also works with optgroups, see #5701 |
| 1729 | + if ( parent.parentNode ) { |
| 1730 | + parent.parentNode.selectedIndex; |
1483 | 1731 | } |
1484 | 1732 | } |
| 1733 | + } |
1485 | 1734 | |
1486 | | - // If applicable, access the attribute via the DOM 0 way |
1487 | | - if ( name in elem && notxml && !special ) { |
1488 | | - if ( set ) { |
1489 | | - // We can't allow the type property to be changed (since it causes problems in IE) |
1490 | | - if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) { |
1491 | | - jQuery.error( "type property can't be changed" ); |
| 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 | + } |
| 1743 | + |
| 1744 | + if ( value === null ) { |
| 1745 | + if ( elem.nodeType === 1 ) { |
| 1746 | + elem.removeAttribute( name ); |
1492 | 1747 | } |
1493 | 1748 | |
| 1749 | + } else { |
1494 | 1750 | elem[ name ] = value; |
1495 | 1751 | } |
| 1752 | + } |
1496 | 1753 | |
1497 | | - // browsers index elements by id/name on forms, give priority to attributes. |
1498 | | - if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) { |
1499 | | - return elem.getAttributeNode( name ).nodeValue; |
1500 | | - } |
| 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; |
| 1757 | + } |
1501 | 1758 | |
1502 | | - // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set |
1503 | | - // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ |
1504 | | - if ( name === "tabIndex" ) { |
1505 | | - var attributeNode = elem.getAttributeNode( "tabIndex" ); |
| 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" ); |
1506 | 1763 | |
1507 | | - return attributeNode && attributeNode.specified ? |
1508 | | - attributeNode.value : |
1509 | | - rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? |
1510 | | - 0 : |
1511 | | - undefined; |
1512 | | - } |
1513 | | - |
1514 | | - return elem[ name ]; |
| 1764 | + return attributeNode && attributeNode.specified ? |
| 1765 | + attributeNode.value : |
| 1766 | + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? |
| 1767 | + 0 : |
| 1768 | + undefined; |
1515 | 1769 | } |
1516 | 1770 | |
1517 | | - if ( !jQuery.support.style && notxml && name === "style" ) { |
1518 | | - if ( set ) { |
1519 | | - elem.style.cssText = "" + value; |
1520 | | - } |
| 1771 | + return elem[ name ]; |
| 1772 | + } |
1521 | 1773 | |
1522 | | - return elem.style.cssText; |
1523 | | - } |
1524 | | - |
| 1774 | + if ( !jQuery.support.style && notxml && name === "style" ) { |
1525 | 1775 | if ( set ) { |
1526 | | - // convert the value to a string (all browsers do this but IE) see #1070 |
1527 | | - elem.setAttribute( name, "" + value ); |
| 1776 | + elem.style.cssText = "" + value; |
1528 | 1777 | } |
1529 | 1778 | |
1530 | | - var attr = !jQuery.support.hrefNormalized && notxml && special ? |
1531 | | - // Some attributes require a special call on IE |
1532 | | - elem.getAttribute( name, 2 ) : |
1533 | | - elem.getAttribute( name ); |
| 1779 | + return elem.style.cssText; |
| 1780 | + } |
1534 | 1781 | |
1535 | | - // Non-existent attributes return null, we normalize to undefined |
1536 | | - return attr === null ? undefined : attr; |
| 1782 | + if ( set ) { |
| 1783 | + // convert the value to a string (all browsers do this but IE) see #1070 |
| 1784 | + elem.setAttribute( name, "" + value ); |
1537 | 1785 | } |
1538 | 1786 | |
1539 | | - // elem is actually elem.style ... set the style |
1540 | | - // Using attr for specific style information is now deprecated. Use style instead. |
1541 | | - return jQuery.style( elem, name, value ); |
| 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; |
1542 | 1800 | } |
1543 | 1801 | }); |
| 1802 | + |
| 1803 | + |
| 1804 | + |
| 1805 | + |
1544 | 1806 | var rnamespaces = /\.(.*)$/, |
| 1807 | + rformElems = /^(?:textarea|input|select)$/i, |
| 1808 | + rperiod = /\./g, |
| 1809 | + rspace = / /g, |
| 1810 | + rescape = /[^\w\s.|`]/g, |
1545 | 1811 | fcleanup = function( nm ) { |
1546 | | - return nm.replace(/[^\w\s\.\|`]/g, function( ch ) { |
1547 | | - return "\\" + ch; |
1548 | | - }); |
1549 | | - }; |
| 1812 | + return nm.replace(rescape, "\\$&"); |
| 1813 | + }, |
| 1814 | + focusCounts = { focusin: 0, focusout: 0 }; |
1550 | 1815 | |
1551 | 1816 | /* |
1552 | 1817 | * A number of helper functions used for managing events. |
— | — | @@ -1563,10 +1828,17 @@ |
1564 | 1829 | |
1565 | 1830 | // For whatever reason, IE has trouble passing the window object |
1566 | 1831 | // around, causing it to be cloned in the process |
1567 | | - if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) { |
| 1832 | + if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) { |
1568 | 1833 | elem = window; |
1569 | 1834 | } |
1570 | 1835 | |
| 1836 | + if ( handler === false ) { |
| 1837 | + handler = returnFalse; |
| 1838 | + } else if ( !handler ) { |
| 1839 | + // Fixes bug #7229. Fix recommended by jdalton |
| 1840 | + return; |
| 1841 | + } |
| 1842 | + |
1571 | 1843 | var handleObjIn, handleObj; |
1572 | 1844 | |
1573 | 1845 | if ( handler.handler ) { |
— | — | @@ -1588,9 +1860,29 @@ |
1589 | 1861 | return; |
1590 | 1862 | } |
1591 | 1863 | |
1592 | | - var events = elemData.events = elemData.events || {}, |
1593 | | - eventHandle = elemData.handle, eventHandle; |
| 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 ], |
| 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; |
1594 | 1876 | |
| 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 | + |
| 1884 | + elemData.events = events = {}; |
| 1885 | + } |
| 1886 | + |
1595 | 1887 | if ( !eventHandle ) { |
1596 | 1888 | elemData.handle = eventHandle = function() { |
1597 | 1889 | // Handle the second event of a trigger and when |
— | — | @@ -1628,7 +1920,9 @@ |
1629 | 1921 | } |
1630 | 1922 | |
1631 | 1923 | handleObj.type = type; |
1632 | | - handleObj.guid = handler.guid; |
| 1924 | + if ( !handleObj.guid ) { |
| 1925 | + handleObj.guid = handler.guid; |
| 1926 | + } |
1633 | 1927 | |
1634 | 1928 | // Get the current list of functions bound to this event |
1635 | 1929 | var handlers = events[ type ], |
— | — | @@ -1680,13 +1974,23 @@ |
1681 | 1975 | return; |
1682 | 1976 | } |
1683 | 1977 | |
1684 | | - var ret, type, fn, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, |
| 1978 | + if ( handler === false ) { |
| 1979 | + handler = returnFalse; |
| 1980 | + } |
| 1981 | + |
| 1982 | + var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, |
| 1983 | + eventKey = elem.nodeType ? "events" : "__events__", |
1685 | 1984 | elemData = jQuery.data( elem ), |
1686 | | - events = elemData && elemData.events; |
| 1985 | + events = elemData && elemData[ eventKey ]; |
1687 | 1986 | |
1688 | 1987 | if ( !elemData || !events ) { |
1689 | 1988 | return; |
1690 | 1989 | } |
| 1990 | + |
| 1991 | + if ( typeof events === "function" ) { |
| 1992 | + elemData = events; |
| 1993 | + events = events.events; |
| 1994 | + } |
1691 | 1995 | |
1692 | 1996 | // types is actually an event object here |
1693 | 1997 | if ( types && types.type ) { |
— | — | @@ -1721,7 +2025,7 @@ |
1722 | 2026 | type = namespaces.shift(); |
1723 | 2027 | |
1724 | 2028 | namespace = new RegExp("(^|\\.)" + |
1725 | | - jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)") |
| 2029 | + jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)"); |
1726 | 2030 | } |
1727 | 2031 | |
1728 | 2032 | eventType = events[ type ]; |
— | — | @@ -1731,7 +2035,7 @@ |
1732 | 2036 | } |
1733 | 2037 | |
1734 | 2038 | if ( !handler ) { |
1735 | | - for ( var j = 0; j < eventType.length; j++ ) { |
| 2039 | + for ( j = 0; j < eventType.length; j++ ) { |
1736 | 2040 | handleObj = eventType[ j ]; |
1737 | 2041 | |
1738 | 2042 | if ( all || namespace.test( handleObj.namespace ) ) { |
— | — | @@ -1745,7 +2049,7 @@ |
1746 | 2050 | |
1747 | 2051 | special = jQuery.event.special[ type ] || {}; |
1748 | 2052 | |
1749 | | - for ( var j = pos || 0; j < eventType.length; j++ ) { |
| 2053 | + for ( j = pos || 0; j < eventType.length; j++ ) { |
1750 | 2054 | handleObj = eventType[ j ]; |
1751 | 2055 | |
1752 | 2056 | if ( handler.guid === handleObj.guid ) { |
— | — | @@ -1769,7 +2073,7 @@ |
1770 | 2074 | // remove generic event handler if no more handlers exist |
1771 | 2075 | if ( eventType.length === 0 || pos != null && eventType.length === 1 ) { |
1772 | 2076 | if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { |
1773 | | - removeEvent( elem, type, elemData.handle ); |
| 2077 | + jQuery.removeEvent( elem, type, elemData.handle ); |
1774 | 2078 | } |
1775 | 2079 | |
1776 | 2080 | ret = null; |
— | — | @@ -1787,7 +2091,10 @@ |
1788 | 2092 | delete elemData.events; |
1789 | 2093 | delete elemData.handle; |
1790 | 2094 | |
1791 | | - if ( jQuery.isEmptyObject( elemData ) ) { |
| 2095 | + if ( typeof elemData === "function" ) { |
| 2096 | + jQuery.removeData( elem, eventKey ); |
| 2097 | + |
| 2098 | + } else if ( jQuery.isEmptyObject( elemData ) ) { |
1792 | 2099 | jQuery.removeData( elem ); |
1793 | 2100 | } |
1794 | 2101 | } |
— | — | @@ -1802,7 +2109,7 @@ |
1803 | 2110 | if ( !bubbling ) { |
1804 | 2111 | event = typeof event === "object" ? |
1805 | 2112 | // jQuery.Event object |
1806 | | - event[expando] ? event : |
| 2113 | + event[ jQuery.expando ] ? event : |
1807 | 2114 | // Object literal |
1808 | 2115 | jQuery.extend( jQuery.Event(type), event ) : |
1809 | 2116 | // Just the event type (string) |
— | — | @@ -1847,7 +2154,10 @@ |
1848 | 2155 | event.currentTarget = elem; |
1849 | 2156 | |
1850 | 2157 | // Trigger the event, it is assumed that "handle" is a function |
1851 | | - var handle = jQuery.data( elem, "handle" ); |
| 2158 | + var handle = elem.nodeType ? |
| 2159 | + jQuery.data( elem, "handle" ) : |
| 2160 | + (jQuery.data( elem, "__events__" ) || {}).handle; |
| 2161 | + |
1852 | 2162 | if ( handle ) { |
1853 | 2163 | handle.apply( elem, data ); |
1854 | 2164 | } |
— | — | @@ -1859,41 +2169,44 @@ |
1860 | 2170 | if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) { |
1861 | 2171 | if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) { |
1862 | 2172 | event.result = false; |
| 2173 | + event.preventDefault(); |
1863 | 2174 | } |
1864 | 2175 | } |
1865 | 2176 | |
1866 | 2177 | // prevent IE from throwing an error for some elements with some event types, see #3533 |
1867 | | - } catch (e) {} |
| 2178 | + } catch (inlineError) {} |
1868 | 2179 | |
1869 | 2180 | if ( !event.isPropagationStopped() && parent ) { |
1870 | 2181 | jQuery.event.trigger( event, data, parent, true ); |
1871 | 2182 | |
1872 | 2183 | } else if ( !event.isDefaultPrevented() ) { |
1873 | | - var target = event.target, old, |
1874 | | - isClick = jQuery.nodeName(target, "a") && type === "click", |
1875 | | - special = jQuery.event.special[ type ] || {}; |
| 2184 | + var old, |
| 2185 | + target = event.target, |
| 2186 | + targetType = type.replace( rnamespaces, "" ), |
| 2187 | + isClick = jQuery.nodeName( target, "a" ) && targetType === "click", |
| 2188 | + special = jQuery.event.special[ targetType ] || {}; |
1876 | 2189 | |
1877 | 2190 | if ( (!special._default || special._default.call( elem, event ) === false) && |
1878 | 2191 | !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) { |
1879 | 2192 | |
1880 | 2193 | try { |
1881 | | - if ( target[ type ] ) { |
| 2194 | + if ( target[ targetType ] ) { |
1882 | 2195 | // Make sure that we don't accidentally re-trigger the onFOO events |
1883 | | - old = target[ "on" + type ]; |
| 2196 | + old = target[ "on" + targetType ]; |
1884 | 2197 | |
1885 | 2198 | if ( old ) { |
1886 | | - target[ "on" + type ] = null; |
| 2199 | + target[ "on" + targetType ] = null; |
1887 | 2200 | } |
1888 | 2201 | |
1889 | 2202 | jQuery.event.triggered = true; |
1890 | | - target[ type ](); |
| 2203 | + target[ targetType ](); |
1891 | 2204 | } |
1892 | 2205 | |
1893 | 2206 | // prevent IE from throwing an error for some elements with some event types, see #3533 |
1894 | | - } catch (e) {} |
| 2207 | + } catch (triggerError) {} |
1895 | 2208 | |
1896 | 2209 | if ( old ) { |
1897 | | - target[ "on" + type ] = old; |
| 2210 | + target[ "on" + targetType ] = old; |
1898 | 2211 | } |
1899 | 2212 | |
1900 | 2213 | jQuery.event.triggered = false; |
— | — | @@ -1902,9 +2215,11 @@ |
1903 | 2216 | }, |
1904 | 2217 | |
1905 | 2218 | handle: function( event ) { |
1906 | | - var all, handlers, namespaces, namespace, events; |
| 2219 | + var all, handlers, namespaces, namespace_re, events, |
| 2220 | + namespace_sort = [], |
| 2221 | + args = jQuery.makeArray( arguments ); |
1907 | 2222 | |
1908 | | - event = arguments[0] = jQuery.event.fix( event || window.event ); |
| 2223 | + event = args[0] = jQuery.event.fix( event || window.event ); |
1909 | 2224 | event.currentTarget = this; |
1910 | 2225 | |
1911 | 2226 | // Namespaced event handlers |
— | — | @@ -1913,11 +2228,20 @@ |
1914 | 2229 | if ( !all ) { |
1915 | 2230 | namespaces = event.type.split("."); |
1916 | 2231 | event.type = namespaces.shift(); |
1917 | | - namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)"); |
| 2232 | + namespace_sort = namespaces.slice(0).sort(); |
| 2233 | + namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)"); |
1918 | 2234 | } |
1919 | 2235 | |
1920 | | - var events = jQuery.data(this, "events"), handlers = events[ event.type ]; |
| 2236 | + event.namespace = event.namespace || namespace_sort.join("."); |
1921 | 2237 | |
| 2238 | + events = jQuery.data(this, this.nodeType ? "events" : "__events__"); |
| 2239 | + |
| 2240 | + if ( typeof events === "function" ) { |
| 2241 | + events = events.events; |
| 2242 | + } |
| 2243 | + |
| 2244 | + handlers = (events || {})[ event.type ]; |
| 2245 | + |
1922 | 2246 | if ( events && handlers ) { |
1923 | 2247 | // Clone the handlers to prevent manipulation |
1924 | 2248 | handlers = handlers.slice(0); |
— | — | @@ -1926,14 +2250,14 @@ |
1927 | 2251 | var handleObj = handlers[ j ]; |
1928 | 2252 | |
1929 | 2253 | // Filter the functions by class |
1930 | | - if ( all || namespace.test( handleObj.namespace ) ) { |
| 2254 | + if ( all || namespace_re.test( handleObj.namespace ) ) { |
1931 | 2255 | // Pass in a reference to the handler function itself |
1932 | 2256 | // So that we can later remove it |
1933 | 2257 | event.handler = handleObj.handler; |
1934 | 2258 | event.data = handleObj.data; |
1935 | 2259 | event.handleObj = handleObj; |
1936 | 2260 | |
1937 | | - var ret = handleObj.handler.apply( this, arguments ); |
| 2261 | + var ret = handleObj.handler.apply( this, args ); |
1938 | 2262 | |
1939 | 2263 | if ( ret !== undefined ) { |
1940 | 2264 | event.result = ret; |
— | — | @@ -1953,10 +2277,10 @@ |
1954 | 2278 | return event.result; |
1955 | 2279 | }, |
1956 | 2280 | |
1957 | | - props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), |
| 2281 | + props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), |
1958 | 2282 | |
1959 | 2283 | fix: function( event ) { |
1960 | | - if ( event[ expando ] ) { |
| 2284 | + if ( event[ jQuery.expando ] ) { |
1961 | 2285 | return event; |
1962 | 2286 | } |
1963 | 2287 | |
— | — | @@ -1972,7 +2296,8 @@ |
1973 | 2297 | |
1974 | 2298 | // Fix target property, if necessary |
1975 | 2299 | if ( !event.target ) { |
1976 | | - event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either |
| 2300 | + // Fixes #1925 where srcElement might not be defined either |
| 2301 | + event.target = event.srcElement || document; |
1977 | 2302 | } |
1978 | 2303 | |
1979 | 2304 | // check if target is a textnode (safari) |
— | — | @@ -1987,14 +2312,16 @@ |
1988 | 2313 | |
1989 | 2314 | // Calculate pageX/Y if missing and clientX/Y available |
1990 | 2315 | if ( event.pageX == null && event.clientX != null ) { |
1991 | | - var doc = document.documentElement, body = document.body; |
| 2316 | + var doc = document.documentElement, |
| 2317 | + body = document.body; |
| 2318 | + |
1992 | 2319 | event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); |
1993 | 2320 | event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); |
1994 | 2321 | } |
1995 | 2322 | |
1996 | 2323 | // Add which for key events |
1997 | | - if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) { |
1998 | | - event.which = event.charCode || event.keyCode; |
| 2324 | + if ( event.which == null && (event.charCode != null || event.keyCode != null) ) { |
| 2325 | + event.which = event.charCode != null ? event.charCode : event.keyCode; |
1999 | 2326 | } |
2000 | 2327 | |
2001 | 2328 | // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs) |
— | — | @@ -2026,36 +2353,24 @@ |
2027 | 2354 | |
2028 | 2355 | live: { |
2029 | 2356 | add: function( handleObj ) { |
2030 | | - jQuery.event.add( this, handleObj.origType, jQuery.extend({}, handleObj, {handler: liveHandler}) ); |
| 2357 | + jQuery.event.add( this, |
| 2358 | + liveConvert( handleObj.origType, handleObj.selector ), |
| 2359 | + jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); |
2031 | 2360 | }, |
2032 | 2361 | |
2033 | 2362 | remove: function( handleObj ) { |
2034 | | - var remove = true, |
2035 | | - type = handleObj.origType.replace(rnamespaces, ""); |
2036 | | - |
2037 | | - jQuery.each( jQuery.data(this, "events").live || [], function() { |
2038 | | - if ( type === this.origType.replace(rnamespaces, "") ) { |
2039 | | - remove = false; |
2040 | | - return false; |
2041 | | - } |
2042 | | - }); |
2043 | | - |
2044 | | - if ( remove ) { |
2045 | | - jQuery.event.remove( this, handleObj.origType, liveHandler ); |
2046 | | - } |
| 2363 | + jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj ); |
2047 | 2364 | } |
2048 | | - |
2049 | 2365 | }, |
2050 | 2366 | |
2051 | 2367 | beforeunload: { |
2052 | 2368 | setup: function( data, namespaces, eventHandle ) { |
2053 | 2369 | // We only want to do this special case on windows |
2054 | | - if ( this.setInterval ) { |
| 2370 | + if ( jQuery.isWindow( this ) ) { |
2055 | 2371 | this.onbeforeunload = eventHandle; |
2056 | 2372 | } |
| 2373 | + }, |
2057 | 2374 | |
2058 | | - return false; |
2059 | | - }, |
2060 | 2375 | teardown: function( namespaces, eventHandle ) { |
2061 | 2376 | if ( this.onbeforeunload === eventHandle ) { |
2062 | 2377 | this.onbeforeunload = null; |
— | — | @@ -2065,12 +2380,16 @@ |
2066 | 2381 | } |
2067 | 2382 | }; |
2068 | 2383 | |
2069 | | -var removeEvent = document.removeEventListener ? |
| 2384 | +jQuery.removeEvent = document.removeEventListener ? |
2070 | 2385 | function( elem, type, handle ) { |
2071 | | - elem.removeEventListener( type, handle, false ); |
| 2386 | + if ( elem.removeEventListener ) { |
| 2387 | + elem.removeEventListener( type, handle, false ); |
| 2388 | + } |
2072 | 2389 | } : |
2073 | 2390 | function( elem, type, handle ) { |
2074 | | - elem.detachEvent( "on" + type, handle ); |
| 2391 | + if ( elem.detachEvent ) { |
| 2392 | + elem.detachEvent( "on" + type, handle ); |
| 2393 | + } |
2075 | 2394 | }; |
2076 | 2395 | |
2077 | 2396 | jQuery.Event = function( src ) { |
— | — | @@ -2090,10 +2409,10 @@ |
2091 | 2410 | |
2092 | 2411 | // timeStamp is buggy for some events on Firefox(#3843) |
2093 | 2412 | // So we won't rely on the native value |
2094 | | - this.timeStamp = now(); |
| 2413 | + this.timeStamp = jQuery.now(); |
2095 | 2414 | |
2096 | 2415 | // Mark it as fixed |
2097 | | - this[ expando ] = true; |
| 2416 | + this[ jQuery.expando ] = true; |
2098 | 2417 | }; |
2099 | 2418 | |
2100 | 2419 | function returnFalse() { |
— | — | @@ -2117,9 +2436,11 @@ |
2118 | 2437 | // if preventDefault exists run it on the original event |
2119 | 2438 | if ( e.preventDefault ) { |
2120 | 2439 | e.preventDefault(); |
| 2440 | + |
| 2441 | + // otherwise set the returnValue property of the original event to false (IE) |
| 2442 | + } else { |
| 2443 | + e.returnValue = false; |
2121 | 2444 | } |
2122 | | - // otherwise set the returnValue property of the original event to false (IE) |
2123 | | - e.returnValue = false; |
2124 | 2445 | }, |
2125 | 2446 | stopPropagation: function() { |
2126 | 2447 | this.isPropagationStopped = returnTrue; |
— | — | @@ -2199,17 +2520,21 @@ |
2200 | 2521 | setup: function( data, namespaces ) { |
2201 | 2522 | if ( this.nodeName.toLowerCase() !== "form" ) { |
2202 | 2523 | jQuery.event.add(this, "click.specialSubmit", function( e ) { |
2203 | | - var elem = e.target, type = elem.type; |
| 2524 | + var elem = e.target, |
| 2525 | + type = elem.type; |
2204 | 2526 | |
2205 | 2527 | if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { |
| 2528 | + e.liveFired = undefined; |
2206 | 2529 | return trigger( "submit", this, arguments ); |
2207 | 2530 | } |
2208 | 2531 | }); |
2209 | 2532 | |
2210 | 2533 | jQuery.event.add(this, "keypress.specialSubmit", function( e ) { |
2211 | | - var elem = e.target, type = elem.type; |
| 2534 | + var elem = e.target, |
| 2535 | + type = elem.type; |
2212 | 2536 | |
2213 | 2537 | if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { |
| 2538 | + e.liveFired = undefined; |
2214 | 2539 | return trigger( "submit", this, arguments ); |
2215 | 2540 | } |
2216 | 2541 | }); |
— | — | @@ -2229,10 +2554,8 @@ |
2230 | 2555 | // change delegation, happens here so we have bind. |
2231 | 2556 | if ( !jQuery.support.changeBubbles ) { |
2232 | 2557 | |
2233 | | - var formElems = /textarea|input|select/i, |
| 2558 | + var changeFilters, |
2234 | 2559 | |
2235 | | - changeFilters, |
2236 | | - |
2237 | 2560 | getVal = function( elem ) { |
2238 | 2561 | var type = elem.type, val = elem.value; |
2239 | 2562 | |
— | — | @@ -2256,7 +2579,7 @@ |
2257 | 2580 | testChange = function testChange( e ) { |
2258 | 2581 | var elem = e.target, data, val; |
2259 | 2582 | |
2260 | | - if ( !formElems.test( elem.nodeName ) || elem.readOnly ) { |
| 2583 | + if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) { |
2261 | 2584 | return; |
2262 | 2585 | } |
2263 | 2586 | |
— | — | @@ -2274,6 +2597,7 @@ |
2275 | 2598 | |
2276 | 2599 | if ( data != null || val ) { |
2277 | 2600 | e.type = "change"; |
| 2601 | + e.liveFired = undefined; |
2278 | 2602 | return jQuery.event.trigger( e, arguments[1], elem ); |
2279 | 2603 | } |
2280 | 2604 | }; |
— | — | @@ -2282,6 +2606,8 @@ |
2283 | 2607 | filters: { |
2284 | 2608 | focusout: testChange, |
2285 | 2609 | |
| 2610 | + beforedeactivate: testChange, |
| 2611 | + |
2286 | 2612 | click: function( e ) { |
2287 | 2613 | var elem = e.target, type = elem.type; |
2288 | 2614 | |
— | — | @@ -2304,7 +2630,7 @@ |
2305 | 2631 | |
2306 | 2632 | // Beforeactivate happens also before the previous element is blurred |
2307 | 2633 | // with this event you can't trigger a change event, but you can store |
2308 | | - // information/focus[in] is not needed anymore |
| 2634 | + // information |
2309 | 2635 | beforeactivate: function( e ) { |
2310 | 2636 | var elem = e.target; |
2311 | 2637 | jQuery.data( elem, "_change_data", getVal(elem) ); |
— | — | @@ -2320,17 +2646,20 @@ |
2321 | 2647 | jQuery.event.add( this, type + ".specialChange", changeFilters[type] ); |
2322 | 2648 | } |
2323 | 2649 | |
2324 | | - return formElems.test( this.nodeName ); |
| 2650 | + return rformElems.test( this.nodeName ); |
2325 | 2651 | }, |
2326 | 2652 | |
2327 | 2653 | teardown: function( namespaces ) { |
2328 | 2654 | jQuery.event.remove( this, ".specialChange" ); |
2329 | 2655 | |
2330 | | - return formElems.test( this.nodeName ); |
| 2656 | + return rformElems.test( this.nodeName ); |
2331 | 2657 | } |
2332 | 2658 | }; |
2333 | 2659 | |
2334 | 2660 | changeFilters = jQuery.event.special.change.filters; |
| 2661 | + |
| 2662 | + // Handle when the input is .focus()'d |
| 2663 | + changeFilters.focus = changeFilters.beforeactivate; |
2335 | 2664 | } |
2336 | 2665 | |
2337 | 2666 | function trigger( type, elem, args ) { |
— | — | @@ -2343,17 +2672,21 @@ |
2344 | 2673 | jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { |
2345 | 2674 | jQuery.event.special[ fix ] = { |
2346 | 2675 | setup: function() { |
2347 | | - this.addEventListener( orig, handler, true ); |
| 2676 | + if ( focusCounts[fix]++ === 0 ) { |
| 2677 | + document.addEventListener( orig, handler, true ); |
| 2678 | + } |
2348 | 2679 | }, |
2349 | 2680 | teardown: function() { |
2350 | | - this.removeEventListener( orig, handler, true ); |
| 2681 | + if ( --focusCounts[fix] === 0 ) { |
| 2682 | + document.removeEventListener( orig, handler, true ); |
| 2683 | + } |
2351 | 2684 | } |
2352 | 2685 | }; |
2353 | 2686 | |
2354 | 2687 | function handler( e ) { |
2355 | 2688 | e = jQuery.event.fix( e ); |
2356 | 2689 | e.type = fix; |
2357 | | - return jQuery.event.handle.call( this, e ); |
| 2690 | + return jQuery.event.trigger( e, null, e.target ); |
2358 | 2691 | } |
2359 | 2692 | }); |
2360 | 2693 | } |
— | — | @@ -2368,7 +2701,7 @@ |
2369 | 2702 | return this; |
2370 | 2703 | } |
2371 | 2704 | |
2372 | | - if ( jQuery.isFunction( data ) ) { |
| 2705 | + if ( jQuery.isFunction( data ) || data === false ) { |
2373 | 2706 | fn = data; |
2374 | 2707 | data = undefined; |
2375 | 2708 | } |
— | — | @@ -2439,7 +2772,8 @@ |
2440 | 2773 | |
2441 | 2774 | toggle: function( fn ) { |
2442 | 2775 | // Save reference to arguments for access in closure |
2443 | | - var args = arguments, i = 1; |
| 2776 | + var args = arguments, |
| 2777 | + i = 1; |
2444 | 2778 | |
2445 | 2779 | // link all the functions, so any of them can unbind this click handler |
2446 | 2780 | while ( i < args.length ) { |
— | — | @@ -2476,6 +2810,14 @@ |
2477 | 2811 | var type, i = 0, match, namespaces, preType, |
2478 | 2812 | selector = origSelector || this.selector, |
2479 | 2813 | context = origSelector ? this : jQuery( this.context ); |
| 2814 | + |
| 2815 | + if ( typeof types === "object" && !types.preventDefault ) { |
| 2816 | + for ( var key in types ) { |
| 2817 | + context[ name ]( key, data, types[key], selector ); |
| 2818 | + } |
| 2819 | + |
| 2820 | + return this; |
| 2821 | + } |
2480 | 2822 | |
2481 | 2823 | if ( jQuery.isFunction( data ) ) { |
2482 | 2824 | fn = data; |
— | — | @@ -2510,30 +2852,39 @@ |
2511 | 2853 | |
2512 | 2854 | if ( name === "live" ) { |
2513 | 2855 | // bind live handler |
2514 | | - context.each(function(){ |
2515 | | - jQuery.event.add( this, liveConvert( type, selector ), |
| 2856 | + for ( var j = 0, l = context.length; j < l; j++ ) { |
| 2857 | + jQuery.event.add( context[j], "live." + liveConvert( type, selector ), |
2516 | 2858 | { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } ); |
2517 | | - }); |
| 2859 | + } |
2518 | 2860 | |
2519 | 2861 | } else { |
2520 | 2862 | // unbind live handler |
2521 | | - context.unbind( liveConvert( type, selector ), fn ); |
| 2863 | + context.unbind( "live." + liveConvert( type, selector ), fn ); |
2522 | 2864 | } |
2523 | 2865 | } |
2524 | 2866 | |
2525 | 2867 | return this; |
2526 | | - } |
| 2868 | + }; |
2527 | 2869 | }); |
2528 | 2870 | |
2529 | 2871 | function liveHandler( event ) { |
2530 | | - var stop, elems = [], selectors = [], args = arguments, |
2531 | | - related, match, handleObj, elem, j, i, l, data, |
2532 | | - events = jQuery.data( this, "events" ); |
| 2872 | + var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret, |
| 2873 | + elems = [], |
| 2874 | + selectors = [], |
| 2875 | + events = jQuery.data( this, this.nodeType ? "events" : "__events__" ); |
2533 | 2876 | |
| 2877 | + if ( typeof events === "function" ) { |
| 2878 | + events = events.events; |
| 2879 | + } |
| 2880 | + |
2534 | 2881 | // Make sure we avoid non-left-click bubbling in Firefox (#3861) |
2535 | 2882 | if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) { |
2536 | 2883 | return; |
2537 | 2884 | } |
| 2885 | + |
| 2886 | + if ( event.namespace ) { |
| 2887 | + namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)"); |
| 2888 | + } |
2538 | 2889 | |
2539 | 2890 | event.liveFired = this; |
2540 | 2891 | |
— | — | @@ -2553,20 +2904,23 @@ |
2554 | 2905 | match = jQuery( event.target ).closest( selectors, event.currentTarget ); |
2555 | 2906 | |
2556 | 2907 | for ( i = 0, l = match.length; i < l; i++ ) { |
| 2908 | + close = match[i]; |
| 2909 | + |
2557 | 2910 | for ( j = 0; j < live.length; j++ ) { |
2558 | 2911 | handleObj = live[j]; |
2559 | 2912 | |
2560 | | - if ( match[i].selector === handleObj.selector ) { |
2561 | | - elem = match[i].elem; |
| 2913 | + if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) { |
| 2914 | + elem = close.elem; |
2562 | 2915 | related = null; |
2563 | 2916 | |
2564 | 2917 | // Those two events require additional checking |
2565 | 2918 | if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) { |
| 2919 | + event.type = handleObj.preType; |
2566 | 2920 | related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0]; |
2567 | 2921 | } |
2568 | 2922 | |
2569 | 2923 | if ( !related || related !== elem ) { |
2570 | | - elems.push({ elem: elem, handleObj: handleObj }); |
| 2924 | + elems.push({ elem: elem, handleObj: handleObj, level: close.level }); |
2571 | 2925 | } |
2572 | 2926 | } |
2573 | 2927 | } |
— | — | @@ -2574,13 +2928,26 @@ |
2575 | 2929 | |
2576 | 2930 | for ( i = 0, l = elems.length; i < l; i++ ) { |
2577 | 2931 | match = elems[i]; |
| 2932 | + |
| 2933 | + if ( maxLevel && match.level > maxLevel ) { |
| 2934 | + break; |
| 2935 | + } |
| 2936 | + |
2578 | 2937 | event.currentTarget = match.elem; |
2579 | 2938 | event.data = match.handleObj.data; |
2580 | 2939 | event.handleObj = match.handleObj; |
2581 | 2940 | |
2582 | | - if ( match.handleObj.origHandler.apply( match.elem, args ) === false ) { |
2583 | | - stop = false; |
2584 | | - break; |
| 2941 | + ret = match.handleObj.origHandler.apply( match.elem, arguments ); |
| 2942 | + |
| 2943 | + if ( ret === false || event.isPropagationStopped() ) { |
| 2944 | + maxLevel = match.level; |
| 2945 | + |
| 2946 | + if ( ret === false ) { |
| 2947 | + stop = false; |
| 2948 | + } |
| 2949 | + if ( event.isImmediatePropagationStopped() ) { |
| 2950 | + break; |
| 2951 | + } |
2585 | 2952 | } |
2586 | 2953 | } |
2587 | 2954 | |
— | — | @@ -2588,7 +2955,7 @@ |
2589 | 2956 | } |
2590 | 2957 | |
2591 | 2958 | function liveConvert( type, selector ) { |
2592 | | - return "live." + (type && type !== "*" ? type + "." : "") + selector.replace(/\./g, "`").replace(/ /g, "&"); |
| 2959 | + return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&"); |
2593 | 2960 | } |
2594 | 2961 | |
2595 | 2962 | jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + |
— | — | @@ -2596,8 +2963,15 @@ |
2597 | 2964 | "change select submit keydown keypress keyup error").split(" "), function( i, name ) { |
2598 | 2965 | |
2599 | 2966 | // Handle event binding |
2600 | | - jQuery.fn[ name ] = function( fn ) { |
2601 | | - return fn ? this.bind( name, fn ) : this.trigger( name ); |
| 2967 | + jQuery.fn[ name ] = function( data, fn ) { |
| 2968 | + if ( fn == null ) { |
| 2969 | + fn = data; |
| 2970 | + data = null; |
| 2971 | + } |
| 2972 | + |
| 2973 | + return arguments.length > 0 ? |
| 2974 | + this.bind( name, data, fn ) : |
| 2975 | + this.trigger( name ); |
2602 | 2976 | }; |
2603 | 2977 | |
2604 | 2978 | if ( jQuery.attrFn ) { |
— | — | @@ -2610,7 +2984,7 @@ |
2611 | 2985 | // More info: |
2612 | 2986 | // - http://isaacschlueter.com/2006/10/msie-memory-leaks/ |
2613 | 2987 | if ( window.attachEvent && !window.addEventListener ) { |
2614 | | - window.attachEvent("onunload", function() { |
| 2988 | + jQuery(window).bind("unload", function() { |
2615 | 2989 | for ( var id in jQuery.cache ) { |
2616 | 2990 | if ( jQuery.cache[ id ].handle ) { |
2617 | 2991 | // Try/Catch is to handle iframes being unloaded, see #4280 |
— | — | @@ -2621,6 +2995,8 @@ |
2622 | 2996 | } |
2623 | 2997 | }); |
2624 | 2998 | } |
| 2999 | + |
| 3000 | + |
2625 | 3001 | /*! |
2626 | 3002 | * Sizzle CSS Selector Engine - v1.0 |
2627 | 3003 | * Copyright 2009, The Dojo Foundation |
— | — | @@ -2629,7 +3005,7 @@ |
2630 | 3006 | */ |
2631 | 3007 | (function(){ |
2632 | 3008 | |
2633 | | -var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, |
| 3009 | +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, |
2634 | 3010 | done = 0, |
2635 | 3011 | toString = Object.prototype.toString, |
2636 | 3012 | hasDuplicate = false, |
— | — | @@ -2639,15 +3015,17 @@ |
2640 | 3016 | // optimization where it does not always call our comparision |
2641 | 3017 | // function. If that is the case, discard the hasDuplicate value. |
2642 | 3018 | // Thus far that includes Google Chrome. |
2643 | | -[0, 0].sort(function(){ |
| 3019 | +[0, 0].sort(function() { |
2644 | 3020 | baseHasDuplicate = false; |
2645 | 3021 | return 0; |
2646 | 3022 | }); |
2647 | 3023 | |
2648 | | -var Sizzle = function(selector, context, results, seed) { |
| 3024 | +var Sizzle = function( selector, context, results, seed ) { |
2649 | 3025 | results = results || []; |
2650 | | - var origContext = context = context || document; |
| 3026 | + context = context || document; |
2651 | 3027 | |
| 3028 | + var origContext = context; |
| 3029 | + |
2652 | 3030 | if ( context.nodeType !== 1 && context.nodeType !== 9 ) { |
2653 | 3031 | return []; |
2654 | 3032 | } |
— | — | @@ -2656,24 +3034,34 @@ |
2657 | 3035 | return results; |
2658 | 3036 | } |
2659 | 3037 | |
2660 | | - var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context), |
| 3038 | + var m, set, checkSet, extra, ret, cur, pop, i, |
| 3039 | + prune = true, |
| 3040 | + contextXML = Sizzle.isXML( context ), |
| 3041 | + parts = [], |
2661 | 3042 | soFar = selector; |
2662 | 3043 | |
2663 | 3044 | // Reset the position of the chunker regexp (start from head) |
2664 | | - while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) { |
2665 | | - soFar = m[3]; |
| 3045 | + do { |
| 3046 | + chunker.exec( "" ); |
| 3047 | + m = chunker.exec( soFar ); |
| 3048 | + |
| 3049 | + if ( m ) { |
| 3050 | + soFar = m[3]; |
2666 | 3051 | |
2667 | | - parts.push( m[1] ); |
| 3052 | + parts.push( m[1] ); |
2668 | 3053 | |
2669 | | - if ( m[2] ) { |
2670 | | - extra = m[3]; |
2671 | | - break; |
| 3054 | + if ( m[2] ) { |
| 3055 | + extra = m[3]; |
| 3056 | + break; |
| 3057 | + } |
2672 | 3058 | } |
2673 | | - } |
| 3059 | + } while ( m ); |
2674 | 3060 | |
2675 | 3061 | if ( parts.length > 1 && origPOS.exec( selector ) ) { |
| 3062 | + |
2676 | 3063 | if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { |
2677 | 3064 | set = posProcess( parts[0] + parts[1], context ); |
| 3065 | + |
2678 | 3066 | } else { |
2679 | 3067 | set = Expr.relative[ parts[0] ] ? |
2680 | 3068 | [ context ] : |
— | — | @@ -2689,29 +3077,38 @@ |
2690 | 3078 | set = posProcess( selector, set ); |
2691 | 3079 | } |
2692 | 3080 | } |
| 3081 | + |
2693 | 3082 | } else { |
2694 | 3083 | // Take a shortcut and set the context if the root selector is an ID |
2695 | 3084 | // (but not if it'll be faster if the inner selector is an ID) |
2696 | 3085 | if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && |
2697 | 3086 | Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { |
2698 | | - var ret = Sizzle.find( parts.shift(), context, contextXML ); |
2699 | | - context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0]; |
| 3087 | + |
| 3088 | + ret = Sizzle.find( parts.shift(), context, contextXML ); |
| 3089 | + context = ret.expr ? |
| 3090 | + Sizzle.filter( ret.expr, ret.set )[0] : |
| 3091 | + ret.set[0]; |
2700 | 3092 | } |
2701 | 3093 | |
2702 | 3094 | if ( context ) { |
2703 | | - var ret = seed ? |
| 3095 | + ret = seed ? |
2704 | 3096 | { expr: parts.pop(), set: makeArray(seed) } : |
2705 | 3097 | Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); |
2706 | | - set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set; |
2707 | 3098 | |
| 3099 | + set = ret.expr ? |
| 3100 | + Sizzle.filter( ret.expr, ret.set ) : |
| 3101 | + ret.set; |
| 3102 | + |
2708 | 3103 | if ( parts.length > 0 ) { |
2709 | | - checkSet = makeArray(set); |
| 3104 | + checkSet = makeArray( set ); |
| 3105 | + |
2710 | 3106 | } else { |
2711 | 3107 | prune = false; |
2712 | 3108 | } |
2713 | 3109 | |
2714 | 3110 | while ( parts.length ) { |
2715 | | - var cur = parts.pop(), pop = cur; |
| 3111 | + cur = parts.pop(); |
| 3112 | + pop = cur; |
2716 | 3113 | |
2717 | 3114 | if ( !Expr.relative[ cur ] ) { |
2718 | 3115 | cur = ""; |
— | — | @@ -2725,6 +3122,7 @@ |
2726 | 3123 | |
2727 | 3124 | Expr.relative[ cur ]( checkSet, pop, contextXML ); |
2728 | 3125 | } |
| 3126 | + |
2729 | 3127 | } else { |
2730 | 3128 | checkSet = parts = []; |
2731 | 3129 | } |
— | — | @@ -2741,19 +3139,22 @@ |
2742 | 3140 | if ( toString.call(checkSet) === "[object Array]" ) { |
2743 | 3141 | if ( !prune ) { |
2744 | 3142 | results.push.apply( results, checkSet ); |
| 3143 | + |
2745 | 3144 | } else if ( context && context.nodeType === 1 ) { |
2746 | | - for ( var i = 0; checkSet[i] != null; i++ ) { |
2747 | | - if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) { |
| 3145 | + for ( i = 0; checkSet[i] != null; i++ ) { |
| 3146 | + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { |
2748 | 3147 | results.push( set[i] ); |
2749 | 3148 | } |
2750 | 3149 | } |
| 3150 | + |
2751 | 3151 | } else { |
2752 | | - for ( var i = 0; checkSet[i] != null; i++ ) { |
| 3152 | + for ( i = 0; checkSet[i] != null; i++ ) { |
2753 | 3153 | if ( checkSet[i] && checkSet[i].nodeType === 1 ) { |
2754 | 3154 | results.push( set[i] ); |
2755 | 3155 | } |
2756 | 3156 | } |
2757 | 3157 | } |
| 3158 | + |
2758 | 3159 | } else { |
2759 | 3160 | makeArray( checkSet, results ); |
2760 | 3161 | } |
— | — | @@ -2766,15 +3167,15 @@ |
2767 | 3168 | return results; |
2768 | 3169 | }; |
2769 | 3170 | |
2770 | | -Sizzle.uniqueSort = function(results){ |
| 3171 | +Sizzle.uniqueSort = function( results ) { |
2771 | 3172 | if ( sortOrder ) { |
2772 | 3173 | hasDuplicate = baseHasDuplicate; |
2773 | | - results.sort(sortOrder); |
| 3174 | + results.sort( sortOrder ); |
2774 | 3175 | |
2775 | 3176 | if ( hasDuplicate ) { |
2776 | 3177 | for ( var i = 1; i < results.length; i++ ) { |
2777 | | - if ( results[i] === results[i-1] ) { |
2778 | | - results.splice(i--, 1); |
| 3178 | + if ( results[i] === results[ i - 1 ] ) { |
| 3179 | + results.splice( i--, 1 ); |
2779 | 3180 | } |
2780 | 3181 | } |
2781 | 3182 | } |
— | — | @@ -2783,27 +3184,33 @@ |
2784 | 3185 | return results; |
2785 | 3186 | }; |
2786 | 3187 | |
2787 | | -Sizzle.matches = function(expr, set){ |
2788 | | - return Sizzle(expr, null, null, set); |
| 3188 | +Sizzle.matches = function( expr, set ) { |
| 3189 | + return Sizzle( expr, null, null, set ); |
2789 | 3190 | }; |
2790 | 3191 | |
2791 | | -Sizzle.find = function(expr, context, isXML){ |
2792 | | - var set, match; |
| 3192 | +Sizzle.matchesSelector = function( node, expr ) { |
| 3193 | + return Sizzle( expr, null, null, [node] ).length > 0; |
| 3194 | +}; |
2793 | 3195 | |
| 3196 | +Sizzle.find = function( expr, context, isXML ) { |
| 3197 | + var set; |
| 3198 | + |
2794 | 3199 | if ( !expr ) { |
2795 | 3200 | return []; |
2796 | 3201 | } |
2797 | 3202 | |
2798 | 3203 | for ( var i = 0, l = Expr.order.length; i < l; i++ ) { |
2799 | | - var type = Expr.order[i], match; |
| 3204 | + var match, |
| 3205 | + type = Expr.order[i]; |
2800 | 3206 | |
2801 | 3207 | if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { |
2802 | 3208 | var left = match[1]; |
2803 | | - match.splice(1,1); |
| 3209 | + match.splice( 1, 1 ); |
2804 | 3210 | |
2805 | 3211 | if ( left.substr( left.length - 1 ) !== "\\" ) { |
2806 | 3212 | match[1] = (match[1] || "").replace(/\\/g, ""); |
2807 | 3213 | set = Expr.find[ type ]( match, context, isXML ); |
| 3214 | + |
2808 | 3215 | if ( set != null ) { |
2809 | 3216 | expr = expr.replace( Expr.match[ type ], "" ); |
2810 | 3217 | break; |
— | — | @@ -2813,20 +3220,26 @@ |
2814 | 3221 | } |
2815 | 3222 | |
2816 | 3223 | if ( !set ) { |
2817 | | - set = context.getElementsByTagName("*"); |
| 3224 | + set = context.getElementsByTagName( "*" ); |
2818 | 3225 | } |
2819 | 3226 | |
2820 | | - return {set: set, expr: expr}; |
| 3227 | + return { set: set, expr: expr }; |
2821 | 3228 | }; |
2822 | 3229 | |
2823 | | -Sizzle.filter = function(expr, set, inplace, not){ |
2824 | | - var old = expr, result = [], curLoop = set, match, anyFound, |
2825 | | - isXMLFilter = set && set[0] && isXML(set[0]); |
| 3230 | +Sizzle.filter = function( expr, set, inplace, not ) { |
| 3231 | + var match, anyFound, |
| 3232 | + old = expr, |
| 3233 | + result = [], |
| 3234 | + curLoop = set, |
| 3235 | + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); |
2826 | 3236 | |
2827 | 3237 | while ( expr && set.length ) { |
2828 | 3238 | for ( var type in Expr.filter ) { |
2829 | 3239 | if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { |
2830 | | - var filter = Expr.filter[ type ], found, item, left = match[1]; |
| 3240 | + var found, item, |
| 3241 | + filter = Expr.filter[ type ], |
| 3242 | + left = match[1]; |
| 3243 | + |
2831 | 3244 | anyFound = false; |
2832 | 3245 | |
2833 | 3246 | match.splice(1,1); |
— | — | @@ -2844,6 +3257,7 @@ |
2845 | 3258 | |
2846 | 3259 | if ( !match ) { |
2847 | 3260 | anyFound = found = true; |
| 3261 | + |
2848 | 3262 | } else if ( match === true ) { |
2849 | 3263 | continue; |
2850 | 3264 | } |
— | — | @@ -2858,9 +3272,11 @@ |
2859 | 3273 | if ( inplace && found != null ) { |
2860 | 3274 | if ( pass ) { |
2861 | 3275 | anyFound = true; |
| 3276 | + |
2862 | 3277 | } else { |
2863 | 3278 | curLoop[i] = false; |
2864 | 3279 | } |
| 3280 | + |
2865 | 3281 | } else if ( pass ) { |
2866 | 3282 | result.push( item ); |
2867 | 3283 | anyFound = true; |
— | — | @@ -2889,6 +3305,7 @@ |
2890 | 3306 | if ( expr === old ) { |
2891 | 3307 | if ( anyFound == null ) { |
2892 | 3308 | Sizzle.error( expr ); |
| 3309 | + |
2893 | 3310 | } else { |
2894 | 3311 | break; |
2895 | 3312 | } |
— | — | @@ -2906,30 +3323,35 @@ |
2907 | 3324 | |
2908 | 3325 | var Expr = Sizzle.selectors = { |
2909 | 3326 | order: [ "ID", "NAME", "TAG" ], |
| 3327 | + |
2910 | 3328 | match: { |
2911 | | - ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/, |
2912 | | - CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/, |
2913 | | - NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/, |
2914 | | - ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, |
2915 | | - TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/, |
2916 | | - CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/, |
2917 | | - POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/, |
2918 | | - PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ |
| 3329 | + ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, |
| 3330 | + CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, |
| 3331 | + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, |
| 3332 | + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/, |
| 3333 | + TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, |
| 3334 | + CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/, |
| 3335 | + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, |
| 3336 | + PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ |
2919 | 3337 | }, |
| 3338 | + |
2920 | 3339 | leftMatch: {}, |
| 3340 | + |
2921 | 3341 | attrMap: { |
2922 | 3342 | "class": "className", |
2923 | 3343 | "for": "htmlFor" |
2924 | 3344 | }, |
| 3345 | + |
2925 | 3346 | attrHandle: { |
2926 | | - href: function(elem){ |
2927 | | - return elem.getAttribute("href"); |
| 3347 | + href: function( elem ) { |
| 3348 | + return elem.getAttribute( "href" ); |
2928 | 3349 | } |
2929 | 3350 | }, |
| 3351 | + |
2930 | 3352 | relative: { |
2931 | 3353 | "+": function(checkSet, part){ |
2932 | 3354 | var isPartStr = typeof part === "string", |
2933 | | - isTag = isPartStr && !/\W/.test(part), |
| 3355 | + isTag = isPartStr && !/\W/.test( part ), |
2934 | 3356 | isPartStrNotTag = isPartStr && !isTag; |
2935 | 3357 | |
2936 | 3358 | if ( isTag ) { |
— | — | @@ -2950,22 +3372,29 @@ |
2951 | 3373 | Sizzle.filter( part, checkSet, true ); |
2952 | 3374 | } |
2953 | 3375 | }, |
2954 | | - ">": function(checkSet, part){ |
2955 | | - var isPartStr = typeof part === "string"; |
2956 | 3376 | |
2957 | | - if ( isPartStr && !/\W/.test(part) ) { |
| 3377 | + ">": function( checkSet, part ) { |
| 3378 | + var elem, |
| 3379 | + isPartStr = typeof part === "string", |
| 3380 | + i = 0, |
| 3381 | + l = checkSet.length; |
| 3382 | + |
| 3383 | + if ( isPartStr && !/\W/.test( part ) ) { |
2958 | 3384 | part = part.toLowerCase(); |
2959 | 3385 | |
2960 | | - for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
2961 | | - var elem = checkSet[i]; |
| 3386 | + for ( ; i < l; i++ ) { |
| 3387 | + elem = checkSet[i]; |
| 3388 | + |
2962 | 3389 | if ( elem ) { |
2963 | 3390 | var parent = elem.parentNode; |
2964 | 3391 | checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; |
2965 | 3392 | } |
2966 | 3393 | } |
| 3394 | + |
2967 | 3395 | } else { |
2968 | | - for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
2969 | | - var elem = checkSet[i]; |
| 3396 | + for ( ; i < l; i++ ) { |
| 3397 | + elem = checkSet[i]; |
| 3398 | + |
2970 | 3399 | if ( elem ) { |
2971 | 3400 | checkSet[i] = isPartStr ? |
2972 | 3401 | elem.parentNode : |
— | — | @@ -2978,37 +3407,50 @@ |
2979 | 3408 | } |
2980 | 3409 | } |
2981 | 3410 | }, |
| 3411 | + |
2982 | 3412 | "": function(checkSet, part, isXML){ |
2983 | | - var doneName = done++, checkFn = dirCheck; |
| 3413 | + var nodeCheck, |
| 3414 | + doneName = done++, |
| 3415 | + checkFn = dirCheck; |
2984 | 3416 | |
2985 | 3417 | if ( typeof part === "string" && !/\W/.test(part) ) { |
2986 | | - var nodeCheck = part = part.toLowerCase(); |
| 3418 | + part = part.toLowerCase(); |
| 3419 | + nodeCheck = part; |
2987 | 3420 | checkFn = dirNodeCheck; |
2988 | 3421 | } |
2989 | 3422 | |
2990 | | - checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML); |
| 3423 | + checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); |
2991 | 3424 | }, |
2992 | | - "~": function(checkSet, part, isXML){ |
2993 | | - var doneName = done++, checkFn = dirCheck; |
2994 | 3425 | |
2995 | | - if ( typeof part === "string" && !/\W/.test(part) ) { |
2996 | | - var nodeCheck = part = part.toLowerCase(); |
| 3426 | + "~": function( checkSet, part, isXML ) { |
| 3427 | + var nodeCheck, |
| 3428 | + doneName = done++, |
| 3429 | + checkFn = dirCheck; |
| 3430 | + |
| 3431 | + if ( typeof part === "string" && !/\W/.test( part ) ) { |
| 3432 | + part = part.toLowerCase(); |
| 3433 | + nodeCheck = part; |
2997 | 3434 | checkFn = dirNodeCheck; |
2998 | 3435 | } |
2999 | 3436 | |
3000 | | - checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML); |
| 3437 | + checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); |
3001 | 3438 | } |
3002 | 3439 | }, |
| 3440 | + |
3003 | 3441 | find: { |
3004 | | - ID: function(match, context, isXML){ |
| 3442 | + ID: function( match, context, isXML ) { |
3005 | 3443 | if ( typeof context.getElementById !== "undefined" && !isXML ) { |
3006 | 3444 | var m = context.getElementById(match[1]); |
3007 | | - return m ? [m] : []; |
| 3445 | + // Check parentNode to catch when Blackberry 4.6 returns |
| 3446 | + // nodes that are no longer in the document #6963 |
| 3447 | + return m && m.parentNode ? [m] : []; |
3008 | 3448 | } |
3009 | 3449 | }, |
3010 | | - NAME: function(match, context){ |
| 3450 | + |
| 3451 | + NAME: function( match, context ) { |
3011 | 3452 | if ( typeof context.getElementsByName !== "undefined" ) { |
3012 | | - var ret = [], results = context.getElementsByName(match[1]); |
| 3453 | + var ret = [], |
| 3454 | + results = context.getElementsByName( match[1] ); |
3013 | 3455 | |
3014 | 3456 | for ( var i = 0, l = results.length; i < l; i++ ) { |
3015 | 3457 | if ( results[i].getAttribute("name") === match[1] ) { |
— | — | @@ -3019,12 +3461,13 @@ |
3020 | 3462 | return ret.length === 0 ? null : ret; |
3021 | 3463 | } |
3022 | 3464 | }, |
3023 | | - TAG: function(match, context){ |
3024 | | - return context.getElementsByTagName(match[1]); |
| 3465 | + |
| 3466 | + TAG: function( match, context ) { |
| 3467 | + return context.getElementsByTagName( match[1] ); |
3025 | 3468 | } |
3026 | 3469 | }, |
3027 | 3470 | preFilter: { |
3028 | | - CLASS: function(match, curLoop, inplace, result, not, isXML){ |
| 3471 | + CLASS: function( match, curLoop, inplace, result, not, isXML ) { |
3029 | 3472 | match = " " + match[1].replace(/\\/g, "") + " "; |
3030 | 3473 | |
3031 | 3474 | if ( isXML ) { |
— | — | @@ -3037,6 +3480,7 @@ |
3038 | 3481 | if ( !inplace ) { |
3039 | 3482 | result.push( elem ); |
3040 | 3483 | } |
| 3484 | + |
3041 | 3485 | } else if ( inplace ) { |
3042 | 3486 | curLoop[i] = false; |
3043 | 3487 | } |
— | — | @@ -3045,13 +3489,16 @@ |
3046 | 3490 | |
3047 | 3491 | return false; |
3048 | 3492 | }, |
3049 | | - ID: function(match){ |
| 3493 | + |
| 3494 | + ID: function( match ) { |
3050 | 3495 | return match[1].replace(/\\/g, ""); |
3051 | 3496 | }, |
3052 | | - TAG: function(match, curLoop){ |
| 3497 | + |
| 3498 | + TAG: function( match, curLoop ) { |
3053 | 3499 | return match[1].toLowerCase(); |
3054 | 3500 | }, |
3055 | | - CHILD: function(match){ |
| 3501 | + |
| 3502 | + CHILD: function( match ) { |
3056 | 3503 | if ( match[1] === "nth" ) { |
3057 | 3504 | // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' |
3058 | 3505 | var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec( |
— | — | @@ -3068,7 +3515,8 @@ |
3069 | 3516 | |
3070 | 3517 | return match; |
3071 | 3518 | }, |
3072 | | - ATTR: function(match, curLoop, inplace, result, not, isXML){ |
| 3519 | + |
| 3520 | + ATTR: function( match, curLoop, inplace, result, not, isXML ) { |
3073 | 3521 | var name = match[1].replace(/\\/g, ""); |
3074 | 3522 | |
3075 | 3523 | if ( !isXML && Expr.attrMap[name] ) { |
— | — | @@ -3081,160 +3529,204 @@ |
3082 | 3530 | |
3083 | 3531 | return match; |
3084 | 3532 | }, |
3085 | | - PSEUDO: function(match, curLoop, inplace, result, not){ |
| 3533 | + |
| 3534 | + PSEUDO: function( match, curLoop, inplace, result, not ) { |
3086 | 3535 | if ( match[1] === "not" ) { |
3087 | 3536 | // If we're dealing with a complex expression, or a simple one |
3088 | 3537 | if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { |
3089 | 3538 | match[3] = Sizzle(match[3], null, null, curLoop); |
| 3539 | + |
3090 | 3540 | } else { |
3091 | 3541 | var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); |
| 3542 | + |
3092 | 3543 | if ( !inplace ) { |
3093 | 3544 | result.push.apply( result, ret ); |
3094 | 3545 | } |
| 3546 | + |
3095 | 3547 | return false; |
3096 | 3548 | } |
| 3549 | + |
3097 | 3550 | } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { |
3098 | 3551 | return true; |
3099 | 3552 | } |
3100 | 3553 | |
3101 | 3554 | return match; |
3102 | 3555 | }, |
3103 | | - POS: function(match){ |
| 3556 | + |
| 3557 | + POS: function( match ) { |
3104 | 3558 | match.unshift( true ); |
| 3559 | + |
3105 | 3560 | return match; |
3106 | 3561 | } |
3107 | 3562 | }, |
| 3563 | + |
3108 | 3564 | filters: { |
3109 | | - enabled: function(elem){ |
| 3565 | + enabled: function( elem ) { |
3110 | 3566 | return elem.disabled === false && elem.type !== "hidden"; |
3111 | 3567 | }, |
3112 | | - disabled: function(elem){ |
| 3568 | + |
| 3569 | + disabled: function( elem ) { |
3113 | 3570 | return elem.disabled === true; |
3114 | 3571 | }, |
3115 | | - checked: function(elem){ |
| 3572 | + |
| 3573 | + checked: function( elem ) { |
3116 | 3574 | return elem.checked === true; |
3117 | 3575 | }, |
3118 | | - selected: function(elem){ |
| 3576 | + |
| 3577 | + selected: function( elem ) { |
3119 | 3578 | // Accessing this property makes selected-by-default |
3120 | 3579 | // options in Safari work properly |
3121 | 3580 | elem.parentNode.selectedIndex; |
| 3581 | + |
3122 | 3582 | return elem.selected === true; |
3123 | 3583 | }, |
3124 | | - parent: function(elem){ |
| 3584 | + |
| 3585 | + parent: function( elem ) { |
3125 | 3586 | return !!elem.firstChild; |
3126 | 3587 | }, |
3127 | | - empty: function(elem){ |
| 3588 | + |
| 3589 | + empty: function( elem ) { |
3128 | 3590 | return !elem.firstChild; |
3129 | 3591 | }, |
3130 | | - has: function(elem, i, match){ |
| 3592 | + |
| 3593 | + has: function( elem, i, match ) { |
3131 | 3594 | return !!Sizzle( match[3], elem ).length; |
3132 | 3595 | }, |
3133 | | - header: function(elem){ |
3134 | | - return /h\d/i.test( elem.nodeName ); |
| 3596 | + |
| 3597 | + header: function( elem ) { |
| 3598 | + return (/h\d/i).test( elem.nodeName ); |
3135 | 3599 | }, |
3136 | | - text: function(elem){ |
| 3600 | + |
| 3601 | + text: function( elem ) { |
3137 | 3602 | return "text" === elem.type; |
3138 | 3603 | }, |
3139 | | - radio: function(elem){ |
| 3604 | + radio: function( elem ) { |
3140 | 3605 | return "radio" === elem.type; |
3141 | 3606 | }, |
3142 | | - checkbox: function(elem){ |
| 3607 | + |
| 3608 | + checkbox: function( elem ) { |
3143 | 3609 | return "checkbox" === elem.type; |
3144 | 3610 | }, |
3145 | | - file: function(elem){ |
| 3611 | + |
| 3612 | + file: function( elem ) { |
3146 | 3613 | return "file" === elem.type; |
3147 | 3614 | }, |
3148 | | - password: function(elem){ |
| 3615 | + password: function( elem ) { |
3149 | 3616 | return "password" === elem.type; |
3150 | 3617 | }, |
3151 | | - submit: function(elem){ |
| 3618 | + |
| 3619 | + submit: function( elem ) { |
3152 | 3620 | return "submit" === elem.type; |
3153 | 3621 | }, |
3154 | | - image: function(elem){ |
| 3622 | + |
| 3623 | + image: function( elem ) { |
3155 | 3624 | return "image" === elem.type; |
3156 | 3625 | }, |
3157 | | - reset: function(elem){ |
| 3626 | + |
| 3627 | + reset: function( elem ) { |
3158 | 3628 | return "reset" === elem.type; |
3159 | 3629 | }, |
3160 | | - button: function(elem){ |
| 3630 | + |
| 3631 | + button: function( elem ) { |
3161 | 3632 | return "button" === elem.type || elem.nodeName.toLowerCase() === "button"; |
3162 | 3633 | }, |
3163 | | - input: function(elem){ |
3164 | | - return /input|select|textarea|button/i.test(elem.nodeName); |
| 3634 | + |
| 3635 | + input: function( elem ) { |
| 3636 | + return (/input|select|textarea|button/i).test( elem.nodeName ); |
3165 | 3637 | } |
3166 | 3638 | }, |
3167 | 3639 | setFilters: { |
3168 | | - first: function(elem, i){ |
| 3640 | + first: function( elem, i ) { |
3169 | 3641 | return i === 0; |
3170 | 3642 | }, |
3171 | | - last: function(elem, i, match, array){ |
| 3643 | + |
| 3644 | + last: function( elem, i, match, array ) { |
3172 | 3645 | return i === array.length - 1; |
3173 | 3646 | }, |
3174 | | - even: function(elem, i){ |
| 3647 | + |
| 3648 | + even: function( elem, i ) { |
3175 | 3649 | return i % 2 === 0; |
3176 | 3650 | }, |
3177 | | - odd: function(elem, i){ |
| 3651 | + |
| 3652 | + odd: function( elem, i ) { |
3178 | 3653 | return i % 2 === 1; |
3179 | 3654 | }, |
3180 | | - lt: function(elem, i, match){ |
| 3655 | + |
| 3656 | + lt: function( elem, i, match ) { |
3181 | 3657 | return i < match[3] - 0; |
3182 | 3658 | }, |
3183 | | - gt: function(elem, i, match){ |
| 3659 | + |
| 3660 | + gt: function( elem, i, match ) { |
3184 | 3661 | return i > match[3] - 0; |
3185 | 3662 | }, |
3186 | | - nth: function(elem, i, match){ |
| 3663 | + |
| 3664 | + nth: function( elem, i, match ) { |
3187 | 3665 | return match[3] - 0 === i; |
3188 | 3666 | }, |
3189 | | - eq: function(elem, i, match){ |
| 3667 | + |
| 3668 | + eq: function( elem, i, match ) { |
3190 | 3669 | return match[3] - 0 === i; |
3191 | 3670 | } |
3192 | 3671 | }, |
3193 | 3672 | filter: { |
3194 | | - PSEUDO: function(elem, match, i, array){ |
3195 | | - var name = match[1], filter = Expr.filters[ name ]; |
| 3673 | + PSEUDO: function( elem, match, i, array ) { |
| 3674 | + var name = match[1], |
| 3675 | + filter = Expr.filters[ name ]; |
3196 | 3676 | |
3197 | 3677 | if ( filter ) { |
3198 | 3678 | return filter( elem, i, match, array ); |
| 3679 | + |
3199 | 3680 | } else if ( name === "contains" ) { |
3200 | | - return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; |
| 3681 | + return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0; |
| 3682 | + |
3201 | 3683 | } else if ( name === "not" ) { |
3202 | 3684 | var not = match[3]; |
3203 | 3685 | |
3204 | | - for ( var i = 0, l = not.length; i < l; i++ ) { |
3205 | | - if ( not[i] === elem ) { |
| 3686 | + for ( var j = 0, l = not.length; j < l; j++ ) { |
| 3687 | + if ( not[j] === elem ) { |
3206 | 3688 | return false; |
3207 | 3689 | } |
3208 | 3690 | } |
3209 | 3691 | |
3210 | 3692 | return true; |
| 3693 | + |
3211 | 3694 | } else { |
3212 | 3695 | Sizzle.error( "Syntax error, unrecognized expression: " + name ); |
3213 | 3696 | } |
3214 | 3697 | }, |
3215 | | - CHILD: function(elem, match){ |
3216 | | - var type = match[1], node = elem; |
3217 | | - switch (type) { |
3218 | | - case 'only': |
3219 | | - case 'first': |
| 3698 | + |
| 3699 | + CHILD: function( elem, match ) { |
| 3700 | + var type = match[1], |
| 3701 | + node = elem; |
| 3702 | + |
| 3703 | + switch ( type ) { |
| 3704 | + case "only": |
| 3705 | + case "first": |
3220 | 3706 | while ( (node = node.previousSibling) ) { |
3221 | 3707 | if ( node.nodeType === 1 ) { |
3222 | 3708 | return false; |
3223 | 3709 | } |
3224 | 3710 | } |
| 3711 | + |
3225 | 3712 | if ( type === "first" ) { |
3226 | 3713 | return true; |
3227 | 3714 | } |
| 3715 | + |
3228 | 3716 | node = elem; |
3229 | | - case 'last': |
| 3717 | + |
| 3718 | + case "last": |
3230 | 3719 | while ( (node = node.nextSibling) ) { |
3231 | 3720 | if ( node.nodeType === 1 ) { |
3232 | 3721 | return false; |
3233 | 3722 | } |
3234 | 3723 | } |
| 3724 | + |
3235 | 3725 | return true; |
3236 | | - case 'nth': |
3237 | | - var first = match[2], last = match[3]; |
3238 | 3726 | |
| 3727 | + case "nth": |
| 3728 | + var first = match[2], |
| 3729 | + last = match[3]; |
| 3730 | + |
3239 | 3731 | if ( first === 1 && last === 0 ) { |
3240 | 3732 | return true; |
3241 | 3733 | } |
— | — | @@ -3244,33 +3736,41 @@ |
3245 | 3737 | |
3246 | 3738 | if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { |
3247 | 3739 | var count = 0; |
| 3740 | + |
3248 | 3741 | for ( node = parent.firstChild; node; node = node.nextSibling ) { |
3249 | 3742 | if ( node.nodeType === 1 ) { |
3250 | 3743 | node.nodeIndex = ++count; |
3251 | 3744 | } |
3252 | 3745 | } |
| 3746 | + |
3253 | 3747 | parent.sizcache = doneName; |
3254 | 3748 | } |
3255 | 3749 | |
3256 | 3750 | var diff = elem.nodeIndex - last; |
| 3751 | + |
3257 | 3752 | if ( first === 0 ) { |
3258 | 3753 | return diff === 0; |
| 3754 | + |
3259 | 3755 | } else { |
3260 | 3756 | return ( diff % first === 0 && diff / first >= 0 ); |
3261 | 3757 | } |
3262 | 3758 | } |
3263 | 3759 | }, |
3264 | | - ID: function(elem, match){ |
| 3760 | + |
| 3761 | + ID: function( elem, match ) { |
3265 | 3762 | return elem.nodeType === 1 && elem.getAttribute("id") === match; |
3266 | 3763 | }, |
3267 | | - TAG: function(elem, match){ |
| 3764 | + |
| 3765 | + TAG: function( elem, match ) { |
3268 | 3766 | return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; |
3269 | 3767 | }, |
3270 | | - CLASS: function(elem, match){ |
| 3768 | + |
| 3769 | + CLASS: function( elem, match ) { |
3271 | 3770 | return (" " + (elem.className || elem.getAttribute("class")) + " ") |
3272 | 3771 | .indexOf( match ) > -1; |
3273 | 3772 | }, |
3274 | | - ATTR: function(elem, match){ |
| 3773 | + |
| 3774 | + ATTR: function( elem, match ) { |
3275 | 3775 | var name = match[1], |
3276 | 3776 | result = Expr.attrHandle[ name ] ? |
3277 | 3777 | Expr.attrHandle[ name ]( elem ) : |
— | — | @@ -3301,9 +3801,11 @@ |
3302 | 3802 | value === check || value.substr(0, check.length + 1) === check + "-" : |
3303 | 3803 | false; |
3304 | 3804 | }, |
3305 | | - POS: function(elem, match, i, array){ |
3306 | | - var name = match[2], filter = Expr.setFilters[ name ]; |
3307 | 3805 | |
| 3806 | + POS: function( elem, match, i, array ) { |
| 3807 | + var name = match[2], |
| 3808 | + filter = Expr.setFilters[ name ]; |
| 3809 | + |
3308 | 3810 | if ( filter ) { |
3309 | 3811 | return filter( elem, i, match, array ); |
3310 | 3812 | } |
— | — | @@ -3311,16 +3813,17 @@ |
3312 | 3814 | } |
3313 | 3815 | }; |
3314 | 3816 | |
3315 | | -var origPOS = Expr.match.POS; |
| 3817 | +var origPOS = Expr.match.POS, |
| 3818 | + fescape = function(all, num){ |
| 3819 | + return "\\" + (num - 0 + 1); |
| 3820 | + }; |
3316 | 3821 | |
3317 | 3822 | for ( var type in Expr.match ) { |
3318 | | - Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source ); |
3319 | | - Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){ |
3320 | | - return "\\" + (num - 0 + 1); |
3321 | | - })); |
| 3823 | + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); |
| 3824 | + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); |
3322 | 3825 | } |
3323 | 3826 | |
3324 | | -var makeArray = function(array, results) { |
| 3827 | +var makeArray = function( array, results ) { |
3325 | 3828 | array = Array.prototype.slice.call( array, 0 ); |
3326 | 3829 | |
3327 | 3830 | if ( results ) { |
— | — | @@ -3339,19 +3842,22 @@ |
3340 | 3843 | Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; |
3341 | 3844 | |
3342 | 3845 | // Provide a fallback method if it does not work |
3343 | | -} catch(e){ |
3344 | | - makeArray = function(array, results) { |
3345 | | - var ret = results || []; |
| 3846 | +} catch( e ) { |
| 3847 | + makeArray = function( array, results ) { |
| 3848 | + var i = 0, |
| 3849 | + ret = results || []; |
3346 | 3850 | |
3347 | 3851 | if ( toString.call(array) === "[object Array]" ) { |
3348 | 3852 | Array.prototype.push.apply( ret, array ); |
| 3853 | + |
3349 | 3854 | } else { |
3350 | 3855 | if ( typeof array.length === "number" ) { |
3351 | | - for ( var i = 0, l = array.length; i < l; i++ ) { |
| 3856 | + for ( var l = array.length; i < l; i++ ) { |
3352 | 3857 | ret.push( array[i] ); |
3353 | 3858 | } |
| 3859 | + |
3354 | 3860 | } else { |
3355 | | - for ( var i = 0; array[i]; i++ ) { |
| 3861 | + for ( ; array[i]; i++ ) { |
3356 | 3862 | ret.push( array[i] ); |
3357 | 3863 | } |
3358 | 3864 | } |
— | — | @@ -3361,62 +3867,99 @@ |
3362 | 3868 | }; |
3363 | 3869 | } |
3364 | 3870 | |
3365 | | -var sortOrder; |
| 3871 | +var sortOrder, siblingCheck; |
3366 | 3872 | |
3367 | 3873 | if ( document.documentElement.compareDocumentPosition ) { |
3368 | 3874 | sortOrder = function( a, b ) { |
| 3875 | + if ( a === b ) { |
| 3876 | + hasDuplicate = true; |
| 3877 | + return 0; |
| 3878 | + } |
| 3879 | + |
3369 | 3880 | if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { |
3370 | | - if ( a == b ) { |
3371 | | - hasDuplicate = true; |
3372 | | - } |
3373 | 3881 | return a.compareDocumentPosition ? -1 : 1; |
3374 | 3882 | } |
3375 | 3883 | |
3376 | | - var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; |
3377 | | - if ( ret === 0 ) { |
| 3884 | + return a.compareDocumentPosition(b) & 4 ? -1 : 1; |
| 3885 | + }; |
| 3886 | + |
| 3887 | +} else { |
| 3888 | + sortOrder = function( a, b ) { |
| 3889 | + var al, bl, |
| 3890 | + ap = [], |
| 3891 | + bp = [], |
| 3892 | + aup = a.parentNode, |
| 3893 | + bup = b.parentNode, |
| 3894 | + cur = aup; |
| 3895 | + |
| 3896 | + // The nodes are identical, we can exit early |
| 3897 | + if ( a === b ) { |
3378 | 3898 | hasDuplicate = true; |
| 3899 | + return 0; |
| 3900 | + |
| 3901 | + // If the nodes are siblings (or identical) we can do a quick check |
| 3902 | + } else if ( aup === bup ) { |
| 3903 | + return siblingCheck( a, b ); |
| 3904 | + |
| 3905 | + // If no parents were found then the nodes are disconnected |
| 3906 | + } else if ( !aup ) { |
| 3907 | + return -1; |
| 3908 | + |
| 3909 | + } else if ( !bup ) { |
| 3910 | + return 1; |
3379 | 3911 | } |
3380 | | - return ret; |
3381 | | - }; |
3382 | | -} else if ( "sourceIndex" in document.documentElement ) { |
3383 | | - sortOrder = function( a, b ) { |
3384 | | - if ( !a.sourceIndex || !b.sourceIndex ) { |
3385 | | - if ( a == b ) { |
3386 | | - hasDuplicate = true; |
| 3912 | + |
| 3913 | + // Otherwise they're somewhere else in the tree so we need |
| 3914 | + // to build up a full list of the parentNodes for comparison |
| 3915 | + while ( cur ) { |
| 3916 | + ap.unshift( cur ); |
| 3917 | + cur = cur.parentNode; |
| 3918 | + } |
| 3919 | + |
| 3920 | + cur = bup; |
| 3921 | + |
| 3922 | + while ( cur ) { |
| 3923 | + bp.unshift( cur ); |
| 3924 | + cur = cur.parentNode; |
| 3925 | + } |
| 3926 | + |
| 3927 | + al = ap.length; |
| 3928 | + bl = bp.length; |
| 3929 | + |
| 3930 | + // Start walking down the tree looking for a discrepancy |
| 3931 | + for ( var i = 0; i < al && i < bl; i++ ) { |
| 3932 | + if ( ap[i] !== bp[i] ) { |
| 3933 | + return siblingCheck( ap[i], bp[i] ); |
3387 | 3934 | } |
3388 | | - return a.sourceIndex ? -1 : 1; |
3389 | 3935 | } |
3390 | 3936 | |
3391 | | - var ret = a.sourceIndex - b.sourceIndex; |
3392 | | - if ( ret === 0 ) { |
3393 | | - hasDuplicate = true; |
| 3937 | + // We ended someplace up the tree so do a sibling check |
| 3938 | + return i === al ? |
| 3939 | + siblingCheck( a, bp[i], -1 ) : |
| 3940 | + siblingCheck( ap[i], b, 1 ); |
| 3941 | + }; |
| 3942 | + |
| 3943 | + siblingCheck = function( a, b, ret ) { |
| 3944 | + if ( a === b ) { |
| 3945 | + return ret; |
3394 | 3946 | } |
3395 | | - return ret; |
3396 | | - }; |
3397 | | -} else if ( document.createRange ) { |
3398 | | - sortOrder = function( a, b ) { |
3399 | | - if ( !a.ownerDocument || !b.ownerDocument ) { |
3400 | | - if ( a == b ) { |
3401 | | - hasDuplicate = true; |
| 3947 | + |
| 3948 | + var cur = a.nextSibling; |
| 3949 | + |
| 3950 | + while ( cur ) { |
| 3951 | + if ( cur === b ) { |
| 3952 | + return -1; |
3402 | 3953 | } |
3403 | | - return a.ownerDocument ? -1 : 1; |
| 3954 | + |
| 3955 | + cur = cur.nextSibling; |
3404 | 3956 | } |
3405 | 3957 | |
3406 | | - var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); |
3407 | | - aRange.setStart(a, 0); |
3408 | | - aRange.setEnd(a, 0); |
3409 | | - bRange.setStart(b, 0); |
3410 | | - bRange.setEnd(b, 0); |
3411 | | - var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange); |
3412 | | - if ( ret === 0 ) { |
3413 | | - hasDuplicate = true; |
3414 | | - } |
3415 | | - return ret; |
| 3958 | + return 1; |
3416 | 3959 | }; |
3417 | 3960 | } |
3418 | 3961 | |
3419 | 3962 | // Utility function for retreiving the text value of an array of DOM nodes |
3420 | | -function getText( elems ) { |
| 3963 | +Sizzle.getText = function( elems ) { |
3421 | 3964 | var ret = "", elem; |
3422 | 3965 | |
3423 | 3966 | for ( var i = 0; elems[i]; i++ ) { |
— | — | @@ -3428,43 +3971,52 @@ |
3429 | 3972 | |
3430 | 3973 | // Traverse everything else, except comment nodes |
3431 | 3974 | } else if ( elem.nodeType !== 8 ) { |
3432 | | - ret += getText( elem.childNodes ); |
| 3975 | + ret += Sizzle.getText( elem.childNodes ); |
3433 | 3976 | } |
3434 | 3977 | } |
3435 | 3978 | |
3436 | 3979 | return ret; |
3437 | | -} |
| 3980 | +}; |
3438 | 3981 | |
3439 | 3982 | // Check to see if the browser returns elements by name when |
3440 | 3983 | // querying by getElementById (and provide a workaround) |
3441 | 3984 | (function(){ |
3442 | 3985 | // We're going to inject a fake input element with a specified name |
3443 | 3986 | var form = document.createElement("div"), |
3444 | | - id = "script" + (new Date).getTime(); |
| 3987 | + id = "script" + (new Date()).getTime(), |
| 3988 | + root = document.documentElement; |
| 3989 | + |
3445 | 3990 | form.innerHTML = "<a name='" + id + "'/>"; |
3446 | 3991 | |
3447 | 3992 | // Inject it into the root element, check its status, and remove it quickly |
3448 | | - var root = document.documentElement; |
3449 | 3993 | root.insertBefore( form, root.firstChild ); |
3450 | 3994 | |
3451 | 3995 | // The workaround has to do additional checks after a getElementById |
3452 | 3996 | // Which slows things down for other browsers (hence the branching) |
3453 | 3997 | if ( document.getElementById( id ) ) { |
3454 | | - Expr.find.ID = function(match, context, isXML){ |
| 3998 | + Expr.find.ID = function( match, context, isXML ) { |
3455 | 3999 | if ( typeof context.getElementById !== "undefined" && !isXML ) { |
3456 | 4000 | var m = context.getElementById(match[1]); |
3457 | | - return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : []; |
| 4001 | + |
| 4002 | + return m ? |
| 4003 | + m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? |
| 4004 | + [m] : |
| 4005 | + undefined : |
| 4006 | + []; |
3458 | 4007 | } |
3459 | 4008 | }; |
3460 | 4009 | |
3461 | | - Expr.filter.ID = function(elem, match){ |
| 4010 | + Expr.filter.ID = function( elem, match ) { |
3462 | 4011 | var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); |
| 4012 | + |
3463 | 4013 | return elem.nodeType === 1 && node && node.nodeValue === match; |
3464 | 4014 | }; |
3465 | 4015 | } |
3466 | 4016 | |
3467 | 4017 | root.removeChild( form ); |
3468 | | - root = form = null; // release memory in IE |
| 4018 | + |
| 4019 | + // release memory in IE |
| 4020 | + root = form = null; |
3469 | 4021 | })(); |
3470 | 4022 | |
3471 | 4023 | (function(){ |
— | — | @@ -3477,8 +4029,8 @@ |
3478 | 4030 | |
3479 | 4031 | // Make sure no comments are found |
3480 | 4032 | if ( div.getElementsByTagName("*").length > 0 ) { |
3481 | | - Expr.find.TAG = function(match, context){ |
3482 | | - var results = context.getElementsByTagName(match[1]); |
| 4033 | + Expr.find.TAG = function( match, context ) { |
| 4034 | + var results = context.getElementsByTagName( match[1] ); |
3483 | 4035 | |
3484 | 4036 | // Filter out possible comments |
3485 | 4037 | if ( match[1] === "*" ) { |
— | — | @@ -3499,19 +4051,25 @@ |
3500 | 4052 | |
3501 | 4053 | // Check to see if an attribute returns normalized href attributes |
3502 | 4054 | div.innerHTML = "<a href='#'></a>"; |
| 4055 | + |
3503 | 4056 | if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && |
3504 | 4057 | div.firstChild.getAttribute("href") !== "#" ) { |
3505 | | - Expr.attrHandle.href = function(elem){ |
3506 | | - return elem.getAttribute("href", 2); |
| 4058 | + |
| 4059 | + Expr.attrHandle.href = function( elem ) { |
| 4060 | + return elem.getAttribute( "href", 2 ); |
3507 | 4061 | }; |
3508 | 4062 | } |
3509 | 4063 | |
3510 | | - div = null; // release memory in IE |
| 4064 | + // release memory in IE |
| 4065 | + div = null; |
3511 | 4066 | })(); |
3512 | 4067 | |
3513 | 4068 | if ( document.querySelectorAll ) { |
3514 | 4069 | (function(){ |
3515 | | - var oldSizzle = Sizzle, div = document.createElement("div"); |
| 4070 | + var oldSizzle = Sizzle, |
| 4071 | + div = document.createElement("div"), |
| 4072 | + id = "__sizzle__"; |
| 4073 | + |
3516 | 4074 | div.innerHTML = "<p class='TEST'></p>"; |
3517 | 4075 | |
3518 | 4076 | // Safari can't handle uppercase or unicode characters when |
— | — | @@ -3520,15 +4078,42 @@ |
3521 | 4079 | return; |
3522 | 4080 | } |
3523 | 4081 | |
3524 | | - Sizzle = function(query, context, extra, seed){ |
| 4082 | + Sizzle = function( query, context, extra, seed ) { |
3525 | 4083 | context = context || document; |
3526 | 4084 | |
| 4085 | + // Make sure that attribute selectors are quoted |
| 4086 | + query = query.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); |
| 4087 | + |
3527 | 4088 | // Only use querySelectorAll on non-XML documents |
3528 | 4089 | // (ID selectors don't work in non-HTML documents) |
3529 | | - if ( !seed && context.nodeType === 9 && !isXML(context) ) { |
3530 | | - try { |
3531 | | - return makeArray( context.querySelectorAll(query), extra ); |
3532 | | - } catch(e){} |
| 4090 | + if ( !seed && !Sizzle.isXML(context) ) { |
| 4091 | + if ( context.nodeType === 9 ) { |
| 4092 | + try { |
| 4093 | + return makeArray( context.querySelectorAll(query), extra ); |
| 4094 | + } catch(qsaError) {} |
| 4095 | + |
| 4096 | + // qSA works strangely on Element-rooted queries |
| 4097 | + // We can work around this by specifying an extra ID on the root |
| 4098 | + // and working up from there (Thanks to Andrew Dupont for the technique) |
| 4099 | + // IE 8 doesn't work on object elements |
| 4100 | + } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { |
| 4101 | + var old = context.getAttribute( "id" ), |
| 4102 | + nid = old || id; |
| 4103 | + |
| 4104 | + if ( !old ) { |
| 4105 | + context.setAttribute( "id", nid ); |
| 4106 | + } |
| 4107 | + |
| 4108 | + try { |
| 4109 | + return makeArray( context.querySelectorAll( "#" + nid + " " + query ), extra ); |
| 4110 | + |
| 4111 | + } catch(pseudoError) { |
| 4112 | + } finally { |
| 4113 | + if ( !old ) { |
| 4114 | + context.removeAttribute( "id" ); |
| 4115 | + } |
| 4116 | + } |
| 4117 | + } |
3533 | 4118 | } |
3534 | 4119 | |
3535 | 4120 | return oldSizzle(query, context, extra, seed); |
— | — | @@ -3538,11 +4123,44 @@ |
3539 | 4124 | Sizzle[ prop ] = oldSizzle[ prop ]; |
3540 | 4125 | } |
3541 | 4126 | |
3542 | | - div = null; // release memory in IE |
| 4127 | + // release memory in IE |
| 4128 | + div = null; |
3543 | 4129 | })(); |
3544 | 4130 | } |
3545 | 4131 | |
3546 | 4132 | (function(){ |
| 4133 | + var html = document.documentElement, |
| 4134 | + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector, |
| 4135 | + pseudoWorks = false; |
| 4136 | + |
| 4137 | + try { |
| 4138 | + // This should fail with an exception |
| 4139 | + // Gecko does not error, returns false instead |
| 4140 | + matches.call( document.documentElement, "[test!='']:sizzle" ); |
| 4141 | + |
| 4142 | + } catch( pseudoError ) { |
| 4143 | + pseudoWorks = true; |
| 4144 | + } |
| 4145 | + |
| 4146 | + if ( matches ) { |
| 4147 | + Sizzle.matchesSelector = function( node, expr ) { |
| 4148 | + // Make sure that attribute selectors are quoted |
| 4149 | + expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); |
| 4150 | + |
| 4151 | + if ( !Sizzle.isXML( node ) ) { |
| 4152 | + try { |
| 4153 | + if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { |
| 4154 | + return matches.call( node, expr ); |
| 4155 | + } |
| 4156 | + } catch(e) {} |
| 4157 | + } |
| 4158 | + |
| 4159 | + return Sizzle(expr, null, null, [node]).length > 0; |
| 4160 | + }; |
| 4161 | + } |
| 4162 | +})(); |
| 4163 | + |
| 4164 | +(function(){ |
3547 | 4165 | var div = document.createElement("div"); |
3548 | 4166 | |
3549 | 4167 | div.innerHTML = "<div class='test e'></div><div class='test'></div>"; |
— | — | @@ -3561,22 +4179,25 @@ |
3562 | 4180 | } |
3563 | 4181 | |
3564 | 4182 | Expr.order.splice(1, 0, "CLASS"); |
3565 | | - Expr.find.CLASS = function(match, context, isXML) { |
| 4183 | + Expr.find.CLASS = function( match, context, isXML ) { |
3566 | 4184 | if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { |
3567 | 4185 | return context.getElementsByClassName(match[1]); |
3568 | 4186 | } |
3569 | 4187 | }; |
3570 | 4188 | |
3571 | | - div = null; // release memory in IE |
| 4189 | + // release memory in IE |
| 4190 | + div = null; |
3572 | 4191 | })(); |
3573 | 4192 | |
3574 | 4193 | function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
3575 | 4194 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
3576 | 4195 | var elem = checkSet[i]; |
| 4196 | + |
3577 | 4197 | if ( elem ) { |
3578 | | - elem = elem[dir]; |
3579 | 4198 | var match = false; |
3580 | 4199 | |
| 4200 | + elem = elem[dir]; |
| 4201 | + |
3581 | 4202 | while ( elem ) { |
3582 | 4203 | if ( elem.sizcache === doneName ) { |
3583 | 4204 | match = checkSet[elem.sizset]; |
— | — | @@ -3604,9 +4225,11 @@ |
3605 | 4226 | function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { |
3606 | 4227 | for ( var i = 0, l = checkSet.length; i < l; i++ ) { |
3607 | 4228 | var elem = checkSet[i]; |
| 4229 | + |
3608 | 4230 | if ( elem ) { |
| 4231 | + var match = false; |
| 4232 | + |
3609 | 4233 | elem = elem[dir]; |
3610 | | - var match = false; |
3611 | 4234 | |
3612 | 4235 | while ( elem ) { |
3613 | 4236 | if ( elem.sizcache === doneName ) { |
— | — | @@ -3619,6 +4242,7 @@ |
3620 | 4243 | elem.sizcache = doneName; |
3621 | 4244 | elem.sizset = i; |
3622 | 4245 | } |
| 4246 | + |
3623 | 4247 | if ( typeof cur !== "string" ) { |
3624 | 4248 | if ( elem === cur ) { |
3625 | 4249 | match = true; |
— | — | @@ -3639,21 +4263,34 @@ |
3640 | 4264 | } |
3641 | 4265 | } |
3642 | 4266 | |
3643 | | -var contains = document.compareDocumentPosition ? function(a, b){ |
3644 | | - return !!(a.compareDocumentPosition(b) & 16); |
3645 | | -} : function(a, b){ |
3646 | | - return a !== b && (a.contains ? a.contains(b) : true); |
3647 | | -}; |
| 4267 | +if ( document.documentElement.contains ) { |
| 4268 | + Sizzle.contains = function( a, b ) { |
| 4269 | + return a !== b && (a.contains ? a.contains(b) : true); |
| 4270 | + }; |
3648 | 4271 | |
3649 | | -var isXML = function(elem){ |
| 4272 | +} else if ( document.documentElement.compareDocumentPosition ) { |
| 4273 | + Sizzle.contains = function( a, b ) { |
| 4274 | + return !!(a.compareDocumentPosition(b) & 16); |
| 4275 | + }; |
| 4276 | + |
| 4277 | +} else { |
| 4278 | + Sizzle.contains = function() { |
| 4279 | + return false; |
| 4280 | + }; |
| 4281 | +} |
| 4282 | + |
| 4283 | +Sizzle.isXML = function( elem ) { |
3650 | 4284 | // documentElement is verified for cases where it doesn't yet exist |
3651 | 4285 | // (such as loading iframes in IE - #4833) |
3652 | 4286 | var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; |
| 4287 | + |
3653 | 4288 | return documentElement ? documentElement.nodeName !== "HTML" : false; |
3654 | 4289 | }; |
3655 | 4290 | |
3656 | | -var posProcess = function(selector, context){ |
3657 | | - var tmpSet = [], later = "", match, |
| 4291 | +var posProcess = function( selector, context ) { |
| 4292 | + var match, |
| 4293 | + tmpSet = [], |
| 4294 | + later = "", |
3658 | 4295 | root = context.nodeType ? [context] : context; |
3659 | 4296 | |
3660 | 4297 | // Position selectors must be done after the filter |
— | — | @@ -3677,53 +4314,26 @@ |
3678 | 4315 | jQuery.expr = Sizzle.selectors; |
3679 | 4316 | jQuery.expr[":"] = jQuery.expr.filters; |
3680 | 4317 | jQuery.unique = Sizzle.uniqueSort; |
3681 | | -jQuery.text = getText; |
3682 | | -jQuery.isXMLDoc = isXML; |
3683 | | -jQuery.contains = contains; |
| 4318 | +jQuery.text = Sizzle.getText; |
| 4319 | +jQuery.isXMLDoc = Sizzle.isXML; |
| 4320 | +jQuery.contains = Sizzle.contains; |
3684 | 4321 | |
3685 | | -return; |
3686 | 4322 | |
3687 | | -window.Sizzle = Sizzle; |
| 4323 | +})(); |
3688 | 4324 | |
3689 | | -})(); |
| 4325 | + |
3690 | 4326 | var runtil = /Until$/, |
3691 | 4327 | rparentsprev = /^(?:parents|prevUntil|prevAll)/, |
3692 | 4328 | // Note: This RegExp should be improved, or likely pulled from Sizzle |
3693 | 4329 | rmultiselector = /,/, |
3694 | | - slice = Array.prototype.slice; |
| 4330 | + isSimple = /^.[^:#\[\.,]*$/, |
| 4331 | + slice = Array.prototype.slice, |
| 4332 | + POS = jQuery.expr.match.POS; |
3695 | 4333 | |
3696 | | -// Implement the identical functionality for filter and not |
3697 | | -var winnow = function( elements, qualifier, keep ) { |
3698 | | - if ( jQuery.isFunction( qualifier ) ) { |
3699 | | - return jQuery.grep(elements, function( elem, i ) { |
3700 | | - return !!qualifier.call( elem, i, elem ) === keep; |
3701 | | - }); |
3702 | | - |
3703 | | - } else if ( qualifier.nodeType ) { |
3704 | | - return jQuery.grep(elements, function( elem, i ) { |
3705 | | - return (elem === qualifier) === keep; |
3706 | | - }); |
3707 | | - |
3708 | | - } else if ( typeof qualifier === "string" ) { |
3709 | | - var filtered = jQuery.grep(elements, function( elem ) { |
3710 | | - return elem.nodeType === 1; |
3711 | | - }); |
3712 | | - |
3713 | | - if ( isSimple.test( qualifier ) ) { |
3714 | | - return jQuery.filter(qualifier, filtered, !keep); |
3715 | | - } else { |
3716 | | - qualifier = jQuery.filter( qualifier, filtered ); |
3717 | | - } |
3718 | | - } |
3719 | | - |
3720 | | - return jQuery.grep(elements, function( elem, i ) { |
3721 | | - return (jQuery.inArray( elem, qualifier ) >= 0) === keep; |
3722 | | - }); |
3723 | | -}; |
3724 | | - |
3725 | 4334 | jQuery.fn.extend({ |
3726 | 4335 | find: function( selector ) { |
3727 | | - var ret = this.pushStack( "", "find", selector ), length = 0; |
| 4336 | + var ret = this.pushStack( "", "find", selector ), |
| 4337 | + length = 0; |
3728 | 4338 | |
3729 | 4339 | for ( var i = 0, l = this.length; i < l; i++ ) { |
3730 | 4340 | length = ret.length; |
— | — | @@ -3769,11 +4379,15 @@ |
3770 | 4380 | }, |
3771 | 4381 | |
3772 | 4382 | closest: function( selectors, context ) { |
| 4383 | + var ret = [], i, l, cur = this[0]; |
| 4384 | + |
3773 | 4385 | if ( jQuery.isArray( selectors ) ) { |
3774 | | - var ret = [], cur = this[0], match, matches = {}, selector; |
| 4386 | + var match, selector, |
| 4387 | + matches = {}, |
| 4388 | + level = 1; |
3775 | 4389 | |
3776 | 4390 | if ( cur && selectors.length ) { |
3777 | | - for ( var i = 0, l = selectors.length; i < l; i++ ) { |
| 4391 | + for ( i = 0, l = selectors.length; i < l; i++ ) { |
3778 | 4392 | selector = selectors[i]; |
3779 | 4393 | |
3780 | 4394 | if ( !matches[selector] ) { |
— | — | @@ -3788,29 +4402,41 @@ |
3789 | 4403 | match = matches[selector]; |
3790 | 4404 | |
3791 | 4405 | if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) { |
3792 | | - ret.push({ selector: selector, elem: cur }); |
3793 | | - delete matches[selector]; |
| 4406 | + ret.push({ selector: selector, elem: cur, level: level }); |
3794 | 4407 | } |
3795 | 4408 | } |
| 4409 | + |
3796 | 4410 | cur = cur.parentNode; |
| 4411 | + level++; |
3797 | 4412 | } |
3798 | 4413 | } |
3799 | 4414 | |
3800 | 4415 | return ret; |
3801 | 4416 | } |
3802 | 4417 | |
3803 | | - var pos = jQuery.expr.match.POS.test( selectors ) ? |
| 4418 | + var pos = POS.test( selectors ) ? |
3804 | 4419 | jQuery( selectors, context || this.context ) : null; |
3805 | 4420 | |
3806 | | - return this.map(function( i, cur ) { |
3807 | | - while ( cur && cur.ownerDocument && cur !== context ) { |
3808 | | - if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) { |
3809 | | - return cur; |
| 4421 | + for ( i = 0, l = this.length; i < l; i++ ) { |
| 4422 | + cur = this[i]; |
| 4423 | + |
| 4424 | + while ( cur ) { |
| 4425 | + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { |
| 4426 | + ret.push( cur ); |
| 4427 | + break; |
| 4428 | + |
| 4429 | + } else { |
| 4430 | + cur = cur.parentNode; |
| 4431 | + if ( !cur || !cur.ownerDocument || cur === context ) { |
| 4432 | + break; |
| 4433 | + } |
3810 | 4434 | } |
3811 | | - cur = cur.parentNode; |
3812 | 4435 | } |
3813 | | - return null; |
3814 | | - }); |
| 4436 | + } |
| 4437 | + |
| 4438 | + ret = ret.length > 1 ? jQuery.unique(ret) : ret; |
| 4439 | + |
| 4440 | + return this.pushStack( ret, "closest", selectors ); |
3815 | 4441 | }, |
3816 | 4442 | |
3817 | 4443 | // Determine the position of an element within |
— | — | @@ -3918,11 +4544,15 @@ |
3919 | 4545 | expr = ":not(" + expr + ")"; |
3920 | 4546 | } |
3921 | 4547 | |
3922 | | - return jQuery.find.matches(expr, elems); |
| 4548 | + return elems.length === 1 ? |
| 4549 | + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : |
| 4550 | + jQuery.find.matches(expr, elems); |
3923 | 4551 | }, |
3924 | 4552 | |
3925 | 4553 | dir: function( elem, dir, until ) { |
3926 | | - var matched = [], cur = elem[dir]; |
| 4554 | + var matched = [], |
| 4555 | + cur = elem[ dir ]; |
| 4556 | + |
3927 | 4557 | while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { |
3928 | 4558 | if ( cur.nodeType === 1 ) { |
3929 | 4559 | matched.push( cur ); |
— | — | @@ -3957,20 +4587,50 @@ |
3958 | 4588 | return r; |
3959 | 4589 | } |
3960 | 4590 | }); |
| 4591 | + |
| 4592 | +// Implement the identical functionality for filter and not |
| 4593 | +function winnow( elements, qualifier, keep ) { |
| 4594 | + if ( jQuery.isFunction( qualifier ) ) { |
| 4595 | + return jQuery.grep(elements, function( elem, i ) { |
| 4596 | + var retVal = !!qualifier.call( elem, i, elem ); |
| 4597 | + return retVal === keep; |
| 4598 | + }); |
| 4599 | + |
| 4600 | + } else if ( qualifier.nodeType ) { |
| 4601 | + return jQuery.grep(elements, function( elem, i ) { |
| 4602 | + return (elem === qualifier) === keep; |
| 4603 | + }); |
| 4604 | + |
| 4605 | + } else if ( typeof qualifier === "string" ) { |
| 4606 | + var filtered = jQuery.grep(elements, function( elem ) { |
| 4607 | + return elem.nodeType === 1; |
| 4608 | + }); |
| 4609 | + |
| 4610 | + if ( isSimple.test( qualifier ) ) { |
| 4611 | + return jQuery.filter(qualifier, filtered, !keep); |
| 4612 | + } else { |
| 4613 | + qualifier = jQuery.filter( qualifier, filtered ); |
| 4614 | + } |
| 4615 | + } |
| 4616 | + |
| 4617 | + return jQuery.grep(elements, function( elem, i ) { |
| 4618 | + return (jQuery.inArray( elem, qualifier ) >= 0) === keep; |
| 4619 | + }); |
| 4620 | +} |
| 4621 | + |
| 4622 | + |
| 4623 | + |
| 4624 | + |
3961 | 4625 | var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, |
3962 | 4626 | rleadingWhitespace = /^\s+/, |
3963 | | - rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g, |
3964 | | - rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i, |
| 4627 | + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, |
3965 | 4628 | rtagName = /<([\w:]+)/, |
3966 | 4629 | rtbody = /<tbody/i, |
3967 | 4630 | rhtml = /<|&#?\w+;/, |
3968 | | - rnocache = /<script|<object|<embed|<option|<style/i, |
3969 | | - rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, // checked="checked" or checked (html5) |
3970 | | - fcloseTag = function( all, front, tag ) { |
3971 | | - return rselfClosing.test( tag ) ? |
3972 | | - all : |
3973 | | - front + "></" + tag + ">"; |
3974 | | - }, |
| 4631 | + rnocache = /<(?:script|object|embed|option|style)/i, |
| 4632 | + // checked="checked" or checked (html5) |
| 4633 | + rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, |
| 4634 | + raction = /\=([^="'>\s]+\/)>/g, |
3975 | 4635 | wrapMap = { |
3976 | 4636 | option: [ 1, "<select multiple='multiple'>", "</select>" ], |
3977 | 4637 | legend: [ 1, "<fieldset>", "</fieldset>" ], |
— | — | @@ -3995,7 +4655,8 @@ |
3996 | 4656 | text: function( text ) { |
3997 | 4657 | if ( jQuery.isFunction(text) ) { |
3998 | 4658 | return this.each(function(i) { |
3999 | | - var self = jQuery(this); |
| 4659 | + var self = jQuery( this ); |
| 4660 | + |
4000 | 4661 | self.text( text.call(this, i, self.text()) ); |
4001 | 4662 | }); |
4002 | 4663 | } |
— | — | @@ -4044,7 +4705,8 @@ |
4045 | 4706 | } |
4046 | 4707 | |
4047 | 4708 | return this.each(function() { |
4048 | | - var self = jQuery( this ), contents = self.contents(); |
| 4709 | + var self = jQuery( this ), |
| 4710 | + contents = self.contents(); |
4049 | 4711 | |
4050 | 4712 | if ( contents.length ) { |
4051 | 4713 | contents.wrapAll( html ); |
— | — | @@ -4155,7 +4817,9 @@ |
4156 | 4818 | // attributes in IE that are actually only stored |
4157 | 4819 | // as properties will not be copied (such as the |
4158 | 4820 | // the name attribute on an input). |
4159 | | - var html = this.outerHTML, ownerDocument = this.ownerDocument; |
| 4821 | + var html = this.outerHTML, |
| 4822 | + ownerDocument = this.ownerDocument; |
| 4823 | + |
4160 | 4824 | if ( !html ) { |
4161 | 4825 | var div = ownerDocument.createElement("div"); |
4162 | 4826 | div.appendChild( this.cloneNode(true) ); |
— | — | @@ -4164,7 +4828,7 @@ |
4165 | 4829 | |
4166 | 4830 | return jQuery.clean([html.replace(rinlinejQuery, "") |
4167 | 4831 | // Handle the case in IE 8 where action=/test/> self-closes a tag |
4168 | | - .replace(/=([^="'>\s]+\/)>/g, '="$1">') |
| 4832 | + .replace(raction, '="$1">') |
4169 | 4833 | .replace(rleadingWhitespace, "")], ownerDocument)[0]; |
4170 | 4834 | } else { |
4171 | 4835 | return this.cloneNode(true); |
— | — | @@ -4192,7 +4856,7 @@ |
4193 | 4857 | (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && |
4194 | 4858 | !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { |
4195 | 4859 | |
4196 | | - value = value.replace(rxhtmlTag, fcloseTag); |
| 4860 | + value = value.replace(rxhtmlTag, "<$1></$2>"); |
4197 | 4861 | |
4198 | 4862 | try { |
4199 | 4863 | for ( var i = 0, l = this.length; i < l; i++ ) { |
— | — | @@ -4210,10 +4874,9 @@ |
4211 | 4875 | |
4212 | 4876 | } else if ( jQuery.isFunction( value ) ) { |
4213 | 4877 | this.each(function(i){ |
4214 | | - var self = jQuery(this), old = self.html(); |
4215 | | - self.empty().append(function(){ |
4216 | | - return value.call( this, i, old ); |
4217 | | - }); |
| 4878 | + var self = jQuery( this ); |
| 4879 | + |
| 4880 | + self.html( value.call(this, i, self.html()) ); |
4218 | 4881 | }); |
4219 | 4882 | |
4220 | 4883 | } else { |
— | — | @@ -4235,13 +4898,14 @@ |
4236 | 4899 | } |
4237 | 4900 | |
4238 | 4901 | if ( typeof value !== "string" ) { |
4239 | | - value = jQuery(value).detach(); |
| 4902 | + value = jQuery( value ).detach(); |
4240 | 4903 | } |
4241 | 4904 | |
4242 | 4905 | return this.each(function() { |
4243 | | - var next = this.nextSibling, parent = this.parentNode; |
| 4906 | + var next = this.nextSibling, |
| 4907 | + parent = this.parentNode; |
4244 | 4908 | |
4245 | | - jQuery(this).remove(); |
| 4909 | + jQuery( this ).remove(); |
4246 | 4910 | |
4247 | 4911 | if ( next ) { |
4248 | 4912 | jQuery(next).before( value ); |
— | — | @@ -4259,7 +4923,9 @@ |
4260 | 4924 | }, |
4261 | 4925 | |
4262 | 4926 | domManip: function( args, table, callback ) { |
4263 | | - var results, first, value = args[0], scripts = [], fragment, parent; |
| 4927 | + var results, first, fragment, parent, |
| 4928 | + value = args[0], |
| 4929 | + scripts = []; |
4264 | 4930 | |
4265 | 4931 | // We can't cloneNode fragments that contain checked, in WebKit |
4266 | 4932 | if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) { |
— | — | @@ -4284,7 +4950,7 @@ |
4285 | 4951 | results = { fragment: parent }; |
4286 | 4952 | |
4287 | 4953 | } else { |
4288 | | - results = buildFragment( args, this, scripts ); |
| 4954 | + results = jQuery.buildFragment( args, this, scripts ); |
4289 | 4955 | } |
4290 | 4956 | |
4291 | 4957 | fragment = results.fragment; |
— | — | @@ -4316,16 +4982,16 @@ |
4317 | 4983 | } |
4318 | 4984 | |
4319 | 4985 | return this; |
4320 | | - |
4321 | | - function root( elem, cur ) { |
4322 | | - return jQuery.nodeName(elem, "table") ? |
4323 | | - (elem.getElementsByTagName("tbody")[0] || |
4324 | | - elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
4325 | | - elem; |
4326 | | - } |
4327 | 4986 | } |
4328 | 4987 | }); |
4329 | 4988 | |
| 4989 | +function root( elem, cur ) { |
| 4990 | + return jQuery.nodeName(elem, "table") ? |
| 4991 | + (elem.getElementsByTagName("tbody")[0] || |
| 4992 | + elem.appendChild(elem.ownerDocument.createElement("tbody"))) : |
| 4993 | + elem; |
| 4994 | +} |
| 4995 | + |
4330 | 4996 | function cloneCopyEvent(orig, ret) { |
4331 | 4997 | var i = 0; |
4332 | 4998 | |
— | — | @@ -4334,7 +5000,9 @@ |
4335 | 5001 | return; |
4336 | 5002 | } |
4337 | 5003 | |
4338 | | - var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events; |
| 5004 | + var oldData = jQuery.data( orig[i++] ), |
| 5005 | + curData = jQuery.data( this, oldData ), |
| 5006 | + events = oldData && oldData.events; |
4339 | 5007 | |
4340 | 5008 | if ( events ) { |
4341 | 5009 | delete curData.handle; |
— | — | @@ -4349,7 +5017,7 @@ |
4350 | 5018 | }); |
4351 | 5019 | } |
4352 | 5020 | |
4353 | | -function buildFragment( args, nodes, scripts ) { |
| 5021 | +jQuery.buildFragment = function( args, nodes, scripts ) { |
4354 | 5022 | var fragment, cacheable, cacheresults, |
4355 | 5023 | doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document); |
4356 | 5024 | |
— | — | @@ -4379,7 +5047,7 @@ |
4380 | 5048 | } |
4381 | 5049 | |
4382 | 5050 | return { fragment: fragment, cacheable: cacheable }; |
4383 | | -} |
| 5051 | +}; |
4384 | 5052 | |
4385 | 5053 | jQuery.fragments = {}; |
4386 | 5054 | |
— | — | @@ -4391,7 +5059,8 @@ |
4392 | 5060 | replaceAll: "replaceWith" |
4393 | 5061 | }, function( name, original ) { |
4394 | 5062 | jQuery.fn[ name ] = function( selector ) { |
4395 | | - var ret = [], insert = jQuery( selector ), |
| 5063 | + var ret = [], |
| 5064 | + insert = jQuery( selector ), |
4396 | 5065 | parent = this.length === 1 && this[0].parentNode; |
4397 | 5066 | |
4398 | 5067 | if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) { |
— | — | @@ -4401,7 +5070,7 @@ |
4402 | 5071 | } else { |
4403 | 5072 | for ( var i = 0, l = insert.length; i < l; i++ ) { |
4404 | 5073 | var elems = (i > 0 ? this.clone(true) : this).get(); |
4405 | | - jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); |
| 5074 | + jQuery( insert[i] )[ original ]( elems ); |
4406 | 5075 | ret = ret.concat( elems ); |
4407 | 5076 | } |
4408 | 5077 | |
— | — | @@ -4436,7 +5105,7 @@ |
4437 | 5106 | |
4438 | 5107 | } else if ( typeof elem === "string" ) { |
4439 | 5108 | // Fix "XHTML"-style tags in all browsers |
4440 | | - elem = elem.replace(rxhtmlTag, fcloseTag); |
| 5109 | + elem = elem.replace(rxhtmlTag, "<$1></$2>"); |
4441 | 5110 | |
4442 | 5111 | // Trim whitespace, otherwise indexOf won't work as expected |
4443 | 5112 | var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), |
— | — | @@ -4489,7 +5158,7 @@ |
4490 | 5159 | } |
4491 | 5160 | |
4492 | 5161 | if ( fragment ) { |
4493 | | - for ( var i = 0; ret[i]; i++ ) { |
| 5162 | + for ( i = 0; ret[i]; i++ ) { |
4494 | 5163 | if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
4495 | 5164 | scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
4496 | 5165 | |
— | — | @@ -4511,18 +5180,22 @@ |
4512 | 5181 | deleteExpando = jQuery.support.deleteExpando; |
4513 | 5182 | |
4514 | 5183 | for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
| 5184 | + if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { |
| 5185 | + continue; |
| 5186 | + } |
| 5187 | + |
4515 | 5188 | id = elem[ jQuery.expando ]; |
4516 | 5189 | |
4517 | 5190 | if ( id ) { |
4518 | 5191 | data = cache[ id ]; |
4519 | 5192 | |
4520 | | - if ( data.events ) { |
| 5193 | + if ( data && data.events ) { |
4521 | 5194 | for ( var type in data.events ) { |
4522 | 5195 | if ( special[ type ] ) { |
4523 | 5196 | jQuery.event.remove( elem, type ); |
4524 | 5197 | |
4525 | 5198 | } else { |
4526 | | - removeEvent( elem, type, data.handle ); |
| 5199 | + jQuery.removeEvent( elem, type, data.handle ); |
4527 | 5200 | } |
4528 | 5201 | } |
4529 | 5202 | } |
— | — | @@ -4539,252 +5212,379 @@ |
4540 | 5213 | } |
4541 | 5214 | } |
4542 | 5215 | }); |
4543 | | -// exclude the following css properties to add px |
4544 | | -var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
4545 | | - ralpha = /alpha\([^)]*\)/, |
| 5216 | + |
| 5217 | +function evalScript( i, elem ) { |
| 5218 | + if ( elem.src ) { |
| 5219 | + jQuery.ajax({ |
| 5220 | + url: elem.src, |
| 5221 | + async: false, |
| 5222 | + dataType: "script" |
| 5223 | + }); |
| 5224 | + } else { |
| 5225 | + jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" ); |
| 5226 | + } |
| 5227 | + |
| 5228 | + if ( elem.parentNode ) { |
| 5229 | + elem.parentNode.removeChild( elem ); |
| 5230 | + } |
| 5231 | +} |
| 5232 | + |
| 5233 | + |
| 5234 | + |
| 5235 | + |
| 5236 | +var ralpha = /alpha\([^)]*\)/i, |
4546 | 5237 | ropacity = /opacity=([^)]*)/, |
4547 | | - rfloat = /float/i, |
4548 | 5238 | rdashAlpha = /-([a-z])/ig, |
4549 | 5239 | rupper = /([A-Z])/g, |
4550 | 5240 | rnumpx = /^-?\d+(?:px)?$/i, |
4551 | 5241 | rnum = /^-?\d/, |
4552 | 5242 | |
4553 | | - cssShow = { position: "absolute", visibility: "hidden", display:"block" }, |
| 5243 | + cssShow = { position: "absolute", visibility: "hidden", display: "block" }, |
4554 | 5244 | cssWidth = [ "Left", "Right" ], |
4555 | 5245 | cssHeight = [ "Top", "Bottom" ], |
| 5246 | + curCSS, |
4556 | 5247 | |
4557 | | - // cache check for defaultView.getComputedStyle |
4558 | | - getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, |
4559 | | - // normalize float css property |
4560 | | - styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat", |
| 5248 | + getComputedStyle, |
| 5249 | + currentStyle, |
| 5250 | + |
4561 | 5251 | fcamelCase = function( all, letter ) { |
4562 | 5252 | return letter.toUpperCase(); |
4563 | 5253 | }; |
4564 | 5254 | |
4565 | 5255 | jQuery.fn.css = function( name, value ) { |
4566 | | - return access( this, name, value, true, function( elem, name, value ) { |
4567 | | - if ( value === undefined ) { |
4568 | | - return jQuery.curCSS( elem, name ); |
4569 | | - } |
4570 | | - |
4571 | | - if ( typeof value === "number" && !rexclude.test(name) ) { |
4572 | | - value += "px"; |
4573 | | - } |
| 5256 | + // Setting 'undefined' is a no-op |
| 5257 | + if ( arguments.length === 2 && value === undefined ) { |
| 5258 | + return this; |
| 5259 | + } |
4574 | 5260 | |
4575 | | - jQuery.style( elem, name, value ); |
| 5261 | + return jQuery.access( this, name, value, true, function( elem, name, value ) { |
| 5262 | + return value !== undefined ? |
| 5263 | + jQuery.style( elem, name, value ) : |
| 5264 | + jQuery.css( elem, name ); |
4576 | 5265 | }); |
4577 | 5266 | }; |
4578 | 5267 | |
4579 | 5268 | jQuery.extend({ |
4580 | | - style: function( elem, name, value ) { |
4581 | | - // don't set styles on text and comment nodes |
4582 | | - if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { |
4583 | | - return undefined; |
| 5269 | + // Add in style property hooks for overriding the default |
| 5270 | + // behavior of getting and setting a style property |
| 5271 | + cssHooks: { |
| 5272 | + opacity: { |
| 5273 | + get: function( elem, computed ) { |
| 5274 | + if ( computed ) { |
| 5275 | + // We should always get a number back from opacity |
| 5276 | + var ret = curCSS( elem, "opacity", "opacity" ); |
| 5277 | + return ret === "" ? "1" : ret; |
| 5278 | + |
| 5279 | + } else { |
| 5280 | + return elem.style.opacity; |
| 5281 | + } |
| 5282 | + } |
4584 | 5283 | } |
| 5284 | + }, |
4585 | 5285 | |
4586 | | - // ignore negative width and height values #1599 |
4587 | | - if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) { |
4588 | | - value = undefined; |
| 5286 | + // Exclude the following css properties to add px |
| 5287 | + cssNumber: { |
| 5288 | + "zIndex": true, |
| 5289 | + "fontWeight": true, |
| 5290 | + "opacity": true, |
| 5291 | + "zoom": true, |
| 5292 | + "lineHeight": true |
| 5293 | + }, |
| 5294 | + |
| 5295 | + // Add in properties whose names you wish to fix before |
| 5296 | + // setting or getting the value |
| 5297 | + cssProps: { |
| 5298 | + // normalize float css property |
| 5299 | + "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat" |
| 5300 | + }, |
| 5301 | + |
| 5302 | + // Get and set the style property on a DOM Node |
| 5303 | + style: function( elem, name, value, extra ) { |
| 5304 | + // Don't set styles on text and comment nodes |
| 5305 | + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { |
| 5306 | + return; |
4589 | 5307 | } |
4590 | 5308 | |
4591 | | - var style = elem.style || elem, set = value !== undefined; |
| 5309 | + // Make sure that we're working with the right name |
| 5310 | + var ret, origName = jQuery.camelCase( name ), |
| 5311 | + style = elem.style, hooks = jQuery.cssHooks[ origName ]; |
4592 | 5312 | |
4593 | | - // IE uses filters for opacity |
4594 | | - if ( !jQuery.support.opacity && name === "opacity" ) { |
4595 | | - if ( set ) { |
4596 | | - // IE has trouble with opacity if it does not have layout |
4597 | | - // Force it by setting the zoom level |
4598 | | - style.zoom = 1; |
| 5313 | + name = jQuery.cssProps[ origName ] || origName; |
4599 | 5314 | |
4600 | | - // Set the alpha filter to set the opacity |
4601 | | - var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")"; |
4602 | | - var filter = style.filter || jQuery.curCSS( elem, "filter" ) || ""; |
4603 | | - style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity; |
| 5315 | + // Check if we're setting a value |
| 5316 | + if ( value !== undefined ) { |
| 5317 | + // Make sure that NaN and null values aren't set. See: #7116 |
| 5318 | + if ( typeof value === "number" && isNaN( value ) || value == null ) { |
| 5319 | + return; |
4604 | 5320 | } |
4605 | 5321 | |
4606 | | - return style.filter && style.filter.indexOf("opacity=") >= 0 ? |
4607 | | - (parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "": |
4608 | | - ""; |
| 5322 | + // If a number was passed in, add 'px' to the (except for certain CSS properties) |
| 5323 | + if ( typeof value === "number" && !jQuery.cssNumber[ origName ] ) { |
| 5324 | + value += "px"; |
| 5325 | + } |
| 5326 | + |
| 5327 | + // If a hook was provided, use that value, otherwise just set the specified value |
| 5328 | + if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) { |
| 5329 | + // Wrapped to prevent IE from throwing errors when 'invalid' values are provided |
| 5330 | + // Fixes bug #5509 |
| 5331 | + try { |
| 5332 | + style[ name ] = value; |
| 5333 | + } catch(e) {} |
| 5334 | + } |
| 5335 | + |
| 5336 | + } else { |
| 5337 | + // If a hook was provided get the non-computed value from there |
| 5338 | + if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { |
| 5339 | + return ret; |
| 5340 | + } |
| 5341 | + |
| 5342 | + // Otherwise just get the value from the style object |
| 5343 | + return style[ name ]; |
4609 | 5344 | } |
| 5345 | + }, |
4610 | 5346 | |
4611 | | - // Make sure we're using the right name for getting the float value |
4612 | | - if ( rfloat.test( name ) ) { |
4613 | | - name = styleFloat; |
| 5347 | + css: function( elem, name, extra ) { |
| 5348 | + // Make sure that we're working with the right name |
| 5349 | + var ret, origName = jQuery.camelCase( name ), |
| 5350 | + hooks = jQuery.cssHooks[ origName ]; |
| 5351 | + |
| 5352 | + name = jQuery.cssProps[ origName ] || origName; |
| 5353 | + |
| 5354 | + // If a hook was provided get the computed value from there |
| 5355 | + if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) { |
| 5356 | + return ret; |
| 5357 | + |
| 5358 | + // Otherwise, if a way to get the computed value exists, use that |
| 5359 | + } else if ( curCSS ) { |
| 5360 | + return curCSS( elem, name, origName ); |
4614 | 5361 | } |
| 5362 | + }, |
4615 | 5363 | |
4616 | | - name = name.replace(rdashAlpha, fcamelCase); |
| 5364 | + // A method for quickly swapping in/out CSS properties to get correct calculations |
| 5365 | + swap: function( elem, options, callback ) { |
| 5366 | + var old = {}; |
4617 | 5367 | |
4618 | | - if ( set ) { |
4619 | | - style[ name ] = value; |
| 5368 | + // Remember the old values, and insert the new ones |
| 5369 | + for ( var name in options ) { |
| 5370 | + old[ name ] = elem.style[ name ]; |
| 5371 | + elem.style[ name ] = options[ name ]; |
4620 | 5372 | } |
4621 | 5373 | |
4622 | | - return style[ name ]; |
| 5374 | + callback.call( elem ); |
| 5375 | + |
| 5376 | + // Revert the old values |
| 5377 | + for ( name in options ) { |
| 5378 | + elem.style[ name ] = old[ name ]; |
| 5379 | + } |
4623 | 5380 | }, |
4624 | 5381 | |
4625 | | - css: function( elem, name, force, extra ) { |
4626 | | - if ( name === "width" || name === "height" ) { |
4627 | | - var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight; |
| 5382 | + camelCase: function( string ) { |
| 5383 | + return string.replace( rdashAlpha, fcamelCase ); |
| 5384 | + } |
| 5385 | +}); |
4628 | 5386 | |
4629 | | - function getWH() { |
4630 | | - val = name === "width" ? elem.offsetWidth : elem.offsetHeight; |
| 5387 | +// DEPRECATED, Use jQuery.css() instead |
| 5388 | +jQuery.curCSS = jQuery.css; |
4631 | 5389 | |
4632 | | - if ( extra === "border" ) { |
4633 | | - return; |
| 5390 | +jQuery.each(["height", "width"], function( i, name ) { |
| 5391 | + jQuery.cssHooks[ name ] = { |
| 5392 | + get: function( elem, computed, extra ) { |
| 5393 | + var val; |
| 5394 | + |
| 5395 | + if ( computed ) { |
| 5396 | + if ( elem.offsetWidth !== 0 ) { |
| 5397 | + val = getWH( elem, name, extra ); |
| 5398 | + |
| 5399 | + } else { |
| 5400 | + jQuery.swap( elem, cssShow, function() { |
| 5401 | + val = getWH( elem, name, extra ); |
| 5402 | + }); |
4634 | 5403 | } |
4635 | 5404 | |
4636 | | - jQuery.each( which, function() { |
4637 | | - if ( !extra ) { |
4638 | | - val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0; |
| 5405 | + if ( val <= 0 ) { |
| 5406 | + val = curCSS( elem, name, name ); |
| 5407 | + |
| 5408 | + if ( val === "0px" && currentStyle ) { |
| 5409 | + val = currentStyle( elem, name, name ); |
4639 | 5410 | } |
4640 | 5411 | |
4641 | | - if ( extra === "margin" ) { |
4642 | | - val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0; |
4643 | | - } else { |
4644 | | - val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0; |
| 5412 | + if ( val != null ) { |
| 5413 | + // Should return "auto" instead of 0, use 0 for |
| 5414 | + // temporary backwards-compat |
| 5415 | + return val === "" || val === "auto" ? "0px" : val; |
4645 | 5416 | } |
4646 | | - }); |
| 5417 | + } |
| 5418 | + |
| 5419 | + if ( val < 0 || val == null ) { |
| 5420 | + val = elem.style[ name ]; |
| 5421 | + |
| 5422 | + // Should return "auto" instead of 0, use 0 for |
| 5423 | + // temporary backwards-compat |
| 5424 | + return val === "" || val === "auto" ? "0px" : val; |
| 5425 | + } |
| 5426 | + |
| 5427 | + return typeof val === "string" ? val : val + "px"; |
4647 | 5428 | } |
| 5429 | + }, |
4648 | 5430 | |
4649 | | - if ( elem.offsetWidth !== 0 ) { |
4650 | | - getWH(); |
| 5431 | + set: function( elem, value ) { |
| 5432 | + if ( rnumpx.test( value ) ) { |
| 5433 | + // ignore negative width and height values #1599 |
| 5434 | + value = parseFloat(value); |
| 5435 | + |
| 5436 | + if ( value >= 0 ) { |
| 5437 | + return value + "px"; |
| 5438 | + } |
| 5439 | + |
4651 | 5440 | } else { |
4652 | | - jQuery.swap( elem, props, getWH ); |
| 5441 | + return value; |
4653 | 5442 | } |
4654 | | - |
4655 | | - return Math.max(0, Math.round(val)); |
4656 | 5443 | } |
| 5444 | + }; |
| 5445 | +}); |
4657 | 5446 | |
4658 | | - return jQuery.curCSS( elem, name, force ); |
4659 | | - }, |
| 5447 | +if ( !jQuery.support.opacity ) { |
| 5448 | + jQuery.cssHooks.opacity = { |
| 5449 | + get: function( elem, computed ) { |
| 5450 | + // IE uses filters for opacity |
| 5451 | + return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ? |
| 5452 | + (parseFloat(RegExp.$1) / 100) + "" : |
| 5453 | + computed ? "1" : ""; |
| 5454 | + }, |
4660 | 5455 | |
4661 | | - curCSS: function( elem, name, force ) { |
4662 | | - var ret, style = elem.style, filter; |
| 5456 | + set: function( elem, value ) { |
| 5457 | + var style = elem.style; |
4663 | 5458 | |
4664 | | - // IE uses filters for opacity |
4665 | | - if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) { |
4666 | | - ret = ropacity.test(elem.currentStyle.filter || "") ? |
4667 | | - (parseFloat(RegExp.$1) / 100) + "" : |
4668 | | - ""; |
| 5459 | + // IE has trouble with opacity if it does not have layout |
| 5460 | + // Force it by setting the zoom level |
| 5461 | + style.zoom = 1; |
4669 | 5462 | |
4670 | | - return ret === "" ? |
4671 | | - "1" : |
4672 | | - ret; |
4673 | | - } |
| 5463 | + // Set the alpha filter to set the opacity |
| 5464 | + var opacity = jQuery.isNaN(value) ? |
| 5465 | + "" : |
| 5466 | + "alpha(opacity=" + value * 100 + ")", |
| 5467 | + filter = style.filter || ""; |
4674 | 5468 | |
4675 | | - // Make sure we're using the right name for getting the float value |
4676 | | - if ( rfloat.test( name ) ) { |
4677 | | - name = styleFloat; |
| 5469 | + style.filter = ralpha.test(filter) ? |
| 5470 | + filter.replace(ralpha, opacity) : |
| 5471 | + style.filter + ' ' + opacity; |
4678 | 5472 | } |
| 5473 | + }; |
| 5474 | +} |
4679 | 5475 | |
4680 | | - if ( !force && style && style[ name ] ) { |
4681 | | - ret = style[ name ]; |
| 5476 | +if ( document.defaultView && document.defaultView.getComputedStyle ) { |
| 5477 | + getComputedStyle = function( elem, newName, name ) { |
| 5478 | + var ret, defaultView, computedStyle; |
4682 | 5479 | |
4683 | | - } else if ( getComputedStyle ) { |
| 5480 | + name = name.replace( rupper, "-$1" ).toLowerCase(); |
4684 | 5481 | |
4685 | | - // Only "float" is needed here |
4686 | | - if ( rfloat.test( name ) ) { |
4687 | | - name = "float"; |
| 5482 | + if ( !(defaultView = elem.ownerDocument.defaultView) ) { |
| 5483 | + return undefined; |
| 5484 | + } |
| 5485 | + |
| 5486 | + if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) { |
| 5487 | + ret = computedStyle.getPropertyValue( name ); |
| 5488 | + if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) { |
| 5489 | + ret = jQuery.style( elem, name ); |
4688 | 5490 | } |
| 5491 | + } |
4689 | 5492 | |
4690 | | - name = name.replace( rupper, "-$1" ).toLowerCase(); |
| 5493 | + return ret; |
| 5494 | + }; |
| 5495 | +} |
4691 | 5496 | |
4692 | | - var defaultView = elem.ownerDocument.defaultView; |
| 5497 | +if ( document.documentElement.currentStyle ) { |
| 5498 | + currentStyle = function( elem, name ) { |
| 5499 | + var left, rsLeft, |
| 5500 | + ret = elem.currentStyle && elem.currentStyle[ name ], |
| 5501 | + style = elem.style; |
4693 | 5502 | |
4694 | | - if ( !defaultView ) { |
4695 | | - return null; |
4696 | | - } |
| 5503 | + // From the awesome hack by Dean Edwards |
| 5504 | + // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 |
4697 | 5505 | |
4698 | | - var computedStyle = defaultView.getComputedStyle( elem, null ); |
| 5506 | + // If we're not dealing with a regular pixel number |
| 5507 | + // but a number that has a weird ending, we need to convert it to pixels |
| 5508 | + if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { |
| 5509 | + // Remember the original values |
| 5510 | + left = style.left; |
| 5511 | + rsLeft = elem.runtimeStyle.left; |
4699 | 5512 | |
4700 | | - if ( computedStyle ) { |
4701 | | - ret = computedStyle.getPropertyValue( name ); |
4702 | | - } |
| 5513 | + // Put in the new values to get a computed value out |
| 5514 | + elem.runtimeStyle.left = elem.currentStyle.left; |
| 5515 | + style.left = name === "fontSize" ? "1em" : (ret || 0); |
| 5516 | + ret = style.pixelLeft + "px"; |
4703 | 5517 | |
4704 | | - // We should always get a number back from opacity |
4705 | | - if ( name === "opacity" && ret === "" ) { |
4706 | | - ret = "1"; |
4707 | | - } |
| 5518 | + // Revert the changed values |
| 5519 | + style.left = left; |
| 5520 | + elem.runtimeStyle.left = rsLeft; |
| 5521 | + } |
4708 | 5522 | |
4709 | | - } else if ( elem.currentStyle ) { |
4710 | | - var camelCase = name.replace(rdashAlpha, fcamelCase); |
| 5523 | + return ret === "" ? "auto" : ret; |
| 5524 | + }; |
| 5525 | +} |
4711 | 5526 | |
4712 | | - ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; |
| 5527 | +curCSS = getComputedStyle || currentStyle; |
4713 | 5528 | |
4714 | | - // From the awesome hack by Dean Edwards |
4715 | | - // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 |
| 5529 | +function getWH( elem, name, extra ) { |
| 5530 | + var which = name === "width" ? cssWidth : cssHeight, |
| 5531 | + val = name === "width" ? elem.offsetWidth : elem.offsetHeight; |
4716 | 5532 | |
4717 | | - // If we're not dealing with a regular pixel number |
4718 | | - // but a number that has a weird ending, we need to convert it to pixels |
4719 | | - if ( !rnumpx.test( ret ) && rnum.test( ret ) ) { |
4720 | | - // Remember the original values |
4721 | | - var left = style.left, rsLeft = elem.runtimeStyle.left; |
| 5533 | + if ( extra === "border" ) { |
| 5534 | + return val; |
| 5535 | + } |
4722 | 5536 | |
4723 | | - // Put in the new values to get a computed value out |
4724 | | - elem.runtimeStyle.left = elem.currentStyle.left; |
4725 | | - style.left = camelCase === "fontSize" ? "1em" : (ret || 0); |
4726 | | - ret = style.pixelLeft + "px"; |
4727 | | - |
4728 | | - // Revert the changed values |
4729 | | - style.left = left; |
4730 | | - elem.runtimeStyle.left = rsLeft; |
4731 | | - } |
| 5537 | + jQuery.each( which, function() { |
| 5538 | + if ( !extra ) { |
| 5539 | + val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0; |
4732 | 5540 | } |
4733 | 5541 | |
4734 | | - return ret; |
4735 | | - }, |
| 5542 | + if ( extra === "margin" ) { |
| 5543 | + val += parseFloat(jQuery.css( elem, "margin" + this )) || 0; |
4736 | 5544 | |
4737 | | - // A method for quickly swapping in/out CSS properties to get correct calculations |
4738 | | - swap: function( elem, options, callback ) { |
4739 | | - var old = {}; |
4740 | | - |
4741 | | - // Remember the old values, and insert the new ones |
4742 | | - for ( var name in options ) { |
4743 | | - old[ name ] = elem.style[ name ]; |
4744 | | - elem.style[ name ] = options[ name ]; |
| 5545 | + } else { |
| 5546 | + val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0; |
4745 | 5547 | } |
| 5548 | + }); |
4746 | 5549 | |
4747 | | - callback.call( elem ); |
| 5550 | + return val; |
| 5551 | +} |
4748 | 5552 | |
4749 | | - // Revert the old values |
4750 | | - for ( var name in options ) { |
4751 | | - elem.style[ name ] = old[ name ]; |
4752 | | - } |
4753 | | - } |
4754 | | -}); |
4755 | | - |
4756 | 5553 | if ( jQuery.expr && jQuery.expr.filters ) { |
4757 | 5554 | jQuery.expr.filters.hidden = function( elem ) { |
4758 | | - var width = elem.offsetWidth, height = elem.offsetHeight, |
4759 | | - skip = elem.nodeName.toLowerCase() === "tr"; |
| 5555 | + var width = elem.offsetWidth, |
| 5556 | + height = elem.offsetHeight; |
4760 | 5557 | |
4761 | | - return width === 0 && height === 0 && !skip ? |
4762 | | - true : |
4763 | | - width > 0 && height > 0 && !skip ? |
4764 | | - false : |
4765 | | - jQuery.curCSS(elem, "display") === "none"; |
| 5558 | + return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none"); |
4766 | 5559 | }; |
4767 | 5560 | |
4768 | 5561 | jQuery.expr.filters.visible = function( elem ) { |
4769 | 5562 | return !jQuery.expr.filters.hidden( elem ); |
4770 | 5563 | }; |
4771 | 5564 | } |
4772 | | -var jsc = now(), |
4773 | | - rscript = /<script(.|\s)*?\/script>/gi, |
4774 | | - rselectTextarea = /select|textarea/i, |
4775 | | - rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i, |
4776 | | - jsre = /=\?(&|$)/, |
| 5565 | + |
| 5566 | + |
| 5567 | + |
| 5568 | + |
| 5569 | +var jsc = jQuery.now(), |
| 5570 | + rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, |
| 5571 | + rselectTextarea = /^(?:select|textarea)/i, |
| 5572 | + rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, |
| 5573 | + rnoContent = /^(?:GET|HEAD)$/, |
| 5574 | + rbracket = /\[\]$/, |
| 5575 | + jsre = /\=\?(&|$)/, |
4777 | 5576 | rquery = /\?/, |
4778 | | - rts = /(\?|&)_=.*?(&|$)/, |
| 5577 | + rts = /([?&])_=[^&]*/, |
4779 | 5578 | rurl = /^(\w+:)?\/\/([^\/?#]+)/, |
4780 | 5579 | r20 = /%20/g, |
| 5580 | + rhash = /#.*$/, |
4781 | 5581 | |
4782 | 5582 | // Keep a copy of the old load method |
4783 | 5583 | _load = jQuery.fn.load; |
4784 | 5584 | |
4785 | 5585 | jQuery.fn.extend({ |
4786 | 5586 | load: function( url, params, callback ) { |
4787 | | - if ( typeof url !== "string" ) { |
4788 | | - return _load.call( this, url ); |
| 5587 | + if ( typeof url !== "string" && _load ) { |
| 5588 | + return _load.apply( this, arguments ); |
4789 | 5589 | |
4790 | 5590 | // Don't do a request if no elements are being requested |
4791 | 5591 | } else if ( !this.length ) { |
— | — | @@ -4829,7 +5629,7 @@ |
4830 | 5630 | // See if a selector was specified |
4831 | 5631 | self.html( selector ? |
4832 | 5632 | // Create a dummy div to hold the results |
4833 | | - jQuery("<div />") |
| 5633 | + jQuery("<div>") |
4834 | 5634 | // inject the contents of the document in, removing the scripts |
4835 | 5635 | // to avoid any 'Permission Denied' errors in IE |
4836 | 5636 | .append(res.responseText.replace(rscript, "")) |
— | — | @@ -4853,6 +5653,7 @@ |
4854 | 5654 | serialize: function() { |
4855 | 5655 | return jQuery.param(this.serializeArray()); |
4856 | 5656 | }, |
| 5657 | + |
4857 | 5658 | serializeArray: function() { |
4858 | 5659 | return this.map(function() { |
4859 | 5660 | return this.elements ? jQuery.makeArray(this.elements) : this; |
— | — | @@ -4884,7 +5685,6 @@ |
4885 | 5686 | }); |
4886 | 5687 | |
4887 | 5688 | jQuery.extend({ |
4888 | | - |
4889 | 5689 | get: function( url, data, callback, type ) { |
4890 | 5690 | // shift arguments if data argument was omited |
4891 | 5691 | if ( jQuery.isFunction( data ) ) { |
— | — | @@ -4945,19 +5745,10 @@ |
4946 | 5746 | password: null, |
4947 | 5747 | traditional: false, |
4948 | 5748 | */ |
4949 | | - // Create the request object; Microsoft failed to properly |
4950 | | - // implement the XMLHttpRequest in IE7 (can't request local files), |
4951 | | - // so we use the ActiveXObject when it is available |
4952 | 5749 | // This function can be overriden by calling jQuery.ajaxSetup |
4953 | | - xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ? |
4954 | | - function() { |
4955 | | - return new window.XMLHttpRequest(); |
4956 | | - } : |
4957 | | - function() { |
4958 | | - try { |
4959 | | - return new window.ActiveXObject("Microsoft.XMLHTTP"); |
4960 | | - } catch(e) {} |
4961 | | - }, |
| 5750 | + xhr: function() { |
| 5751 | + return new window.XMLHttpRequest(); |
| 5752 | + }, |
4962 | 5753 | accepts: { |
4963 | 5754 | xml: "application/xml, text/xml", |
4964 | 5755 | html: "text/html", |
— | — | @@ -4968,17 +5759,15 @@ |
4969 | 5760 | } |
4970 | 5761 | }, |
4971 | 5762 | |
4972 | | - // Last-Modified header cache for next request |
4973 | | - lastModified: {}, |
4974 | | - etag: {}, |
4975 | | - |
4976 | 5763 | ajax: function( origSettings ) { |
4977 | | - var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings); |
4978 | | - |
4979 | | - var jsonp, status, data, |
4980 | | - callbackContext = origSettings && origSettings.context || s, |
4981 | | - type = s.type.toUpperCase(); |
| 5764 | + var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings), |
| 5765 | + jsonp, status, data, type = s.type.toUpperCase(), noContent = rnoContent.test(type); |
4982 | 5766 | |
| 5767 | + s.url = s.url.replace( rhash, "" ); |
| 5768 | + |
| 5769 | + // Use original (not extended) context object if it was provided |
| 5770 | + s.context = origSettings && origSettings.context != null ? origSettings.context : s; |
| 5771 | + |
4983 | 5772 | // convert data if not already a string |
4984 | 5773 | if ( s.data && s.processData && typeof s.data !== "string" ) { |
4985 | 5774 | s.data = jQuery.param( s.data, s.traditional ); |
— | — | @@ -5012,17 +5801,25 @@ |
5013 | 5802 | s.dataType = "script"; |
5014 | 5803 | |
5015 | 5804 | // Handle JSONP-style loading |
5016 | | - window[ jsonp ] = window[ jsonp ] || function( tmp ) { |
5017 | | - data = tmp; |
5018 | | - success(); |
5019 | | - complete(); |
5020 | | - // Garbage collect |
5021 | | - window[ jsonp ] = undefined; |
| 5805 | + var customJsonp = window[ jsonp ]; |
5022 | 5806 | |
5023 | | - try { |
5024 | | - delete window[ jsonp ]; |
5025 | | - } catch(e) {} |
| 5807 | + window[ jsonp ] = function( tmp ) { |
| 5808 | + if ( jQuery.isFunction( customJsonp ) ) { |
| 5809 | + customJsonp( tmp ); |
5026 | 5810 | |
| 5811 | + } else { |
| 5812 | + // Garbage collect |
| 5813 | + window[ jsonp ] = undefined; |
| 5814 | + |
| 5815 | + try { |
| 5816 | + delete window[ jsonp ]; |
| 5817 | + } catch( jsonpError ) {} |
| 5818 | + } |
| 5819 | + |
| 5820 | + data = tmp; |
| 5821 | + jQuery.handleSuccess( s, xhr, status, data ); |
| 5822 | + jQuery.handleComplete( s, xhr, status, data ); |
| 5823 | + |
5027 | 5824 | if ( head ) { |
5028 | 5825 | head.removeChild( script ); |
5029 | 5826 | } |
— | — | @@ -5033,39 +5830,39 @@ |
5034 | 5831 | s.cache = false; |
5035 | 5832 | } |
5036 | 5833 | |
5037 | | - if ( s.cache === false && type === "GET" ) { |
5038 | | - var ts = now(); |
| 5834 | + if ( s.cache === false && noContent ) { |
| 5835 | + var ts = jQuery.now(); |
5039 | 5836 | |
5040 | 5837 | // try replacing _= if it is there |
5041 | | - var ret = s.url.replace(rts, "$1_=" + ts + "$2"); |
| 5838 | + var ret = s.url.replace(rts, "$1_=" + ts); |
5042 | 5839 | |
5043 | 5840 | // if nothing was replaced, add timestamp to the end |
5044 | 5841 | s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : ""); |
5045 | 5842 | } |
5046 | 5843 | |
5047 | | - // If data is available, append data to url for get requests |
5048 | | - if ( s.data && type === "GET" ) { |
| 5844 | + // If data is available, append data to url for GET/HEAD requests |
| 5845 | + if ( s.data && noContent ) { |
5049 | 5846 | s.url += (rquery.test(s.url) ? "&" : "?") + s.data; |
5050 | 5847 | } |
5051 | 5848 | |
5052 | 5849 | // Watch for a new set of requests |
5053 | | - if ( s.global && ! jQuery.active++ ) { |
| 5850 | + if ( s.global && jQuery.active++ === 0 ) { |
5054 | 5851 | jQuery.event.trigger( "ajaxStart" ); |
5055 | 5852 | } |
5056 | 5853 | |
5057 | 5854 | // Matches an absolute URL, and saves the domain |
5058 | 5855 | var parts = rurl.exec( s.url ), |
5059 | | - remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host); |
| 5856 | + remote = parts && (parts[1] && parts[1].toLowerCase() !== location.protocol || parts[2].toLowerCase() !== location.host); |
5060 | 5857 | |
5061 | 5858 | // If we're requesting a remote document |
5062 | 5859 | // and trying to load JSON or Script with a GET |
5063 | 5860 | if ( s.dataType === "script" && type === "GET" && remote ) { |
5064 | 5861 | var head = document.getElementsByTagName("head")[0] || document.documentElement; |
5065 | 5862 | var script = document.createElement("script"); |
5066 | | - script.src = s.url; |
5067 | 5863 | if ( s.scriptCharset ) { |
5068 | 5864 | script.charset = s.scriptCharset; |
5069 | 5865 | } |
| 5866 | + script.src = s.url; |
5070 | 5867 | |
5071 | 5868 | // Handle Script loading |
5072 | 5869 | if ( !jsonp ) { |
— | — | @@ -5076,8 +5873,8 @@ |
5077 | 5874 | if ( !done && (!this.readyState || |
5078 | 5875 | this.readyState === "loaded" || this.readyState === "complete") ) { |
5079 | 5876 | done = true; |
5080 | | - success(); |
5081 | | - complete(); |
| 5877 | + jQuery.handleSuccess( s, xhr, status, data ); |
| 5878 | + jQuery.handleComplete( s, xhr, status, data ); |
5082 | 5879 | |
5083 | 5880 | // Handle memory leak in IE |
5084 | 5881 | script.onload = script.onreadystatechange = null; |
— | — | @@ -5115,8 +5912,8 @@ |
5116 | 5913 | |
5117 | 5914 | // Need an extra try/catch for cross domain requests in Firefox 3 |
5118 | 5915 | try { |
5119 | | - // Set the correct header, if data is being sent |
5120 | | - if ( s.data || origSettings && origSettings.contentType ) { |
| 5916 | + // Set content-type if data specified and content-body is valid for this type |
| 5917 | + if ( (s.data != null && !noContent) || (origSettings && origSettings.contentType) ) { |
5121 | 5918 | xhr.setRequestHeader("Content-Type", s.contentType); |
5122 | 5919 | } |
5123 | 5920 | |
— | — | @@ -5139,14 +5936,14 @@ |
5140 | 5937 | |
5141 | 5938 | // Set the Accepts header for the server, depending on the dataType |
5142 | 5939 | xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ? |
5143 | | - s.accepts[ s.dataType ] + ", */*" : |
| 5940 | + s.accepts[ s.dataType ] + ", */*; q=0.01" : |
5144 | 5941 | s.accepts._default ); |
5145 | | - } catch(e) {} |
| 5942 | + } catch( headerError ) {} |
5146 | 5943 | |
5147 | 5944 | // Allow custom headers/mimetypes and early abort |
5148 | | - if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) { |
| 5945 | + if ( s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false ) { |
5149 | 5946 | // Handle the global AJAX counter |
5150 | | - if ( s.global && ! --jQuery.active ) { |
| 5947 | + if ( s.global && jQuery.active-- === 1 ) { |
5151 | 5948 | jQuery.event.trigger( "ajaxStop" ); |
5152 | 5949 | } |
5153 | 5950 | |
— | — | @@ -5156,7 +5953,7 @@ |
5157 | 5954 | } |
5158 | 5955 | |
5159 | 5956 | if ( s.global ) { |
5160 | | - trigger("ajaxSend", [xhr, s]); |
| 5957 | + jQuery.triggerGlobal( s, "ajaxSend", [xhr, s] ); |
5161 | 5958 | } |
5162 | 5959 | |
5163 | 5960 | // Wait for a response to come back |
— | — | @@ -5166,7 +5963,7 @@ |
5167 | 5964 | // Opera doesn't call onreadystatechange before this point |
5168 | 5965 | // so we simulate the call |
5169 | 5966 | if ( !requestDone ) { |
5170 | | - complete(); |
| 5967 | + jQuery.handleComplete( s, xhr, status, data ); |
5171 | 5968 | } |
5172 | 5969 | |
5173 | 5970 | requestDone = true; |
— | — | @@ -5194,9 +5991,9 @@ |
5195 | 5992 | try { |
5196 | 5993 | // process the data (runs the xml through httpData regardless of callback) |
5197 | 5994 | data = jQuery.httpData( xhr, s.dataType, s ); |
5198 | | - } catch(err) { |
| 5995 | + } catch( parserError ) { |
5199 | 5996 | status = "parsererror"; |
5200 | | - errMsg = err; |
| 5997 | + errMsg = parserError; |
5201 | 5998 | } |
5202 | 5999 | } |
5203 | 6000 | |
— | — | @@ -5204,14 +6001,16 @@ |
5205 | 6002 | if ( status === "success" || status === "notmodified" ) { |
5206 | 6003 | // JSONP handles its own success callback |
5207 | 6004 | if ( !jsonp ) { |
5208 | | - success(); |
| 6005 | + jQuery.handleSuccess( s, xhr, status, data ); |
5209 | 6006 | } |
5210 | 6007 | } else { |
5211 | | - jQuery.handleError(s, xhr, status, errMsg); |
| 6008 | + jQuery.handleError( s, xhr, status, errMsg ); |
5212 | 6009 | } |
5213 | 6010 | |
5214 | 6011 | // Fire the complete handlers |
5215 | | - complete(); |
| 6012 | + if ( !jsonp ) { |
| 6013 | + jQuery.handleComplete( s, xhr, status, data ); |
| 6014 | + } |
5216 | 6015 | |
5217 | 6016 | if ( isTimeout === "timeout" ) { |
5218 | 6017 | xhr.abort(); |
— | — | @@ -5224,18 +6023,21 @@ |
5225 | 6024 | } |
5226 | 6025 | }; |
5227 | 6026 | |
5228 | | - // Override the abort handler, if we can (IE doesn't allow it, but that's OK) |
| 6027 | + // Override the abort handler, if we can (IE 6 doesn't allow it, but that's OK) |
5229 | 6028 | // Opera doesn't fire onreadystatechange at all on abort |
5230 | 6029 | try { |
5231 | 6030 | var oldAbort = xhr.abort; |
5232 | 6031 | xhr.abort = function() { |
5233 | 6032 | if ( xhr ) { |
5234 | | - oldAbort.call( 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 ); |
5235 | 6037 | } |
5236 | 6038 | |
5237 | 6039 | onreadystatechange( "abort" ); |
5238 | 6040 | }; |
5239 | | - } catch(e) { } |
| 6041 | + } catch( abortError ) {} |
5240 | 6042 | |
5241 | 6043 | // Timeout checker |
5242 | 6044 | if ( s.async && s.timeout > 0 ) { |
— | — | @@ -5249,11 +6051,13 @@ |
5250 | 6052 | |
5251 | 6053 | // Send the data |
5252 | 6054 | try { |
5253 | | - xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null ); |
5254 | | - } catch(e) { |
5255 | | - jQuery.handleError(s, xhr, null, e); |
| 6055 | + xhr.send( noContent || s.data == null ? null : s.data ); |
| 6056 | + |
| 6057 | + } catch( sendError ) { |
| 6058 | + jQuery.handleError( s, xhr, null, sendError ); |
| 6059 | + |
5256 | 6060 | // Fire the complete handlers |
5257 | | - complete(); |
| 6061 | + jQuery.handleComplete( s, xhr, status, data ); |
5258 | 6062 | } |
5259 | 6063 | |
5260 | 6064 | // firefox 1.5 doesn't fire statechange for sync requests |
— | — | @@ -5261,66 +6065,145 @@ |
5262 | 6066 | onreadystatechange(); |
5263 | 6067 | } |
5264 | 6068 | |
5265 | | - function success() { |
5266 | | - // If a local callback was specified, fire it and pass it the data |
5267 | | - if ( s.success ) { |
5268 | | - s.success.call( callbackContext, data, status, xhr ); |
5269 | | - } |
| 6069 | + // return XMLHttpRequest to allow aborting the request etc. |
| 6070 | + return xhr; |
| 6071 | + }, |
5270 | 6072 | |
5271 | | - // Fire the global callback |
5272 | | - if ( s.global ) { |
5273 | | - trigger( "ajaxSuccess", [xhr, s] ); |
| 6073 | + // Serialize an array of form elements or a set of |
| 6074 | + // key/values into a query string |
| 6075 | + param: function( a, traditional ) { |
| 6076 | + var s = [], |
| 6077 | + add = function( key, value ) { |
| 6078 | + // If value is a function, invoke it and return its value |
| 6079 | + value = jQuery.isFunction(value) ? value() : value; |
| 6080 | + s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value); |
| 6081 | + }; |
| 6082 | + |
| 6083 | + // Set traditional to true for jQuery <= 1.3.2 behavior. |
| 6084 | + if ( traditional === undefined ) { |
| 6085 | + traditional = jQuery.ajaxSettings.traditional; |
| 6086 | + } |
| 6087 | + |
| 6088 | + // If an array was passed in, assume that it is an array of form elements. |
| 6089 | + if ( jQuery.isArray(a) || a.jquery ) { |
| 6090 | + // Serialize the form elements |
| 6091 | + jQuery.each( a, function() { |
| 6092 | + add( this.name, this.value ); |
| 6093 | + }); |
| 6094 | + |
| 6095 | + } else { |
| 6096 | + // If traditional, encode the "old" way (the way 1.3.2 or older |
| 6097 | + // did it), otherwise encode params recursively. |
| 6098 | + for ( var prefix in a ) { |
| 6099 | + buildParams( prefix, a[prefix], traditional, add ); |
5274 | 6100 | } |
5275 | 6101 | } |
5276 | 6102 | |
5277 | | - function complete() { |
5278 | | - // Process result |
5279 | | - if ( s.complete ) { |
5280 | | - s.complete.call( callbackContext, xhr, status); |
5281 | | - } |
| 6103 | + // Return the resulting serialization |
| 6104 | + return s.join("&").replace(r20, "+"); |
| 6105 | + } |
| 6106 | +}); |
5282 | 6107 | |
5283 | | - // The request was completed |
5284 | | - if ( s.global ) { |
5285 | | - trigger( "ajaxComplete", [xhr, s] ); |
| 6108 | +function buildParams( prefix, obj, traditional, add ) { |
| 6109 | + if ( jQuery.isArray(obj) && obj.length ) { |
| 6110 | + // Serialize array item. |
| 6111 | + jQuery.each( obj, function( i, v ) { |
| 6112 | + if ( traditional || rbracket.test( prefix ) ) { |
| 6113 | + // Treat each array item as a scalar. |
| 6114 | + add( prefix, v ); |
| 6115 | + |
| 6116 | + } else { |
| 6117 | + // If array item is non-scalar (array or object), encode its |
| 6118 | + // numeric index to resolve deserialization ambiguity issues. |
| 6119 | + // Note that rack (as of 1.0.0) can't currently deserialize |
| 6120 | + // nested arrays properly, and attempting to do so may cause |
| 6121 | + // a server error. Possible fixes are to modify rack's |
| 6122 | + // deserialization algorithm or to provide an option or flag |
| 6123 | + // to force array serialization to be shallow. |
| 6124 | + buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add ); |
5286 | 6125 | } |
| 6126 | + }); |
| 6127 | + |
| 6128 | + } else if ( !traditional && obj != null && typeof obj === "object" ) { |
| 6129 | + if ( jQuery.isEmptyObject( obj ) ) { |
| 6130 | + add( prefix, "" ); |
5287 | 6131 | |
5288 | | - // Handle the global AJAX counter |
5289 | | - if ( s.global && ! --jQuery.active ) { |
5290 | | - jQuery.event.trigger( "ajaxStop" ); |
5291 | | - } |
| 6132 | + // Serialize object item. |
| 6133 | + } else { |
| 6134 | + jQuery.each( obj, function( k, v ) { |
| 6135 | + buildParams( prefix + "[" + k + "]", v, traditional, add ); |
| 6136 | + }); |
5292 | 6137 | } |
5293 | | - |
5294 | | - function trigger(type, args) { |
5295 | | - (s.context ? jQuery(s.context) : jQuery.event).trigger(type, args); |
5296 | | - } |
| 6138 | + |
| 6139 | + } else { |
| 6140 | + // Serialize scalar item. |
| 6141 | + add( prefix, obj ); |
| 6142 | + } |
| 6143 | +} |
5297 | 6144 | |
5298 | | - // return XMLHttpRequest to allow aborting the request etc. |
5299 | | - return xhr; |
5300 | | - }, |
| 6145 | +// This is still on the jQuery object... for now |
| 6146 | +// Want to move this to jQuery.ajax some day |
| 6147 | +jQuery.extend({ |
5301 | 6148 | |
| 6149 | + // Counter for holding the number of active queries |
| 6150 | + active: 0, |
| 6151 | + |
| 6152 | + // Last-Modified header cache for next request |
| 6153 | + lastModified: {}, |
| 6154 | + etag: {}, |
| 6155 | + |
5302 | 6156 | handleError: function( s, xhr, status, e ) { |
5303 | 6157 | // If a local callback was specified, fire it |
5304 | 6158 | if ( s.error ) { |
5305 | | - s.error.call( s.context || s, xhr, status, e ); |
| 6159 | + s.error.call( s.context, xhr, status, e ); |
5306 | 6160 | } |
5307 | 6161 | |
5308 | 6162 | // Fire the global callback |
5309 | 6163 | if ( s.global ) { |
5310 | | - (s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] ); |
| 6164 | + jQuery.triggerGlobal( s, "ajaxError", [xhr, s, e] ); |
5311 | 6165 | } |
5312 | 6166 | }, |
5313 | 6167 | |
5314 | | - // Counter for holding the number of active queries |
5315 | | - active: 0, |
| 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 ); |
| 6172 | + } |
5316 | 6173 | |
| 6174 | + // Fire the global callback |
| 6175 | + if ( s.global ) { |
| 6176 | + jQuery.triggerGlobal( s, "ajaxSuccess", [xhr, s] ); |
| 6177 | + } |
| 6178 | + }, |
| 6179 | + |
| 6180 | + handleComplete: function( s, xhr, status ) { |
| 6181 | + // Process result |
| 6182 | + if ( s.complete ) { |
| 6183 | + s.complete.call( s.context, xhr, status ); |
| 6184 | + } |
| 6185 | + |
| 6186 | + // The request was completed |
| 6187 | + if ( s.global ) { |
| 6188 | + jQuery.triggerGlobal( s, "ajaxComplete", [xhr, s] ); |
| 6189 | + } |
| 6190 | + |
| 6191 | + // Handle the global AJAX counter |
| 6192 | + if ( s.global && jQuery.active-- === 1 ) { |
| 6193 | + jQuery.event.trigger( "ajaxStop" ); |
| 6194 | + } |
| 6195 | + }, |
| 6196 | + |
| 6197 | + triggerGlobal: function( s, type, args ) { |
| 6198 | + (s.context && s.context.url == null ? jQuery(s.context) : jQuery.event).trigger(type, args); |
| 6199 | + }, |
| 6200 | + |
5317 | 6201 | // Determines if an XMLHttpRequest was successful or not |
5318 | 6202 | httpSuccess: function( xhr ) { |
5319 | 6203 | try { |
5320 | 6204 | // IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450 |
5321 | 6205 | return !xhr.status && location.protocol === "file:" || |
5322 | | - // Opera returns 0 when status is 304 |
5323 | | - ( xhr.status >= 200 && xhr.status < 300 ) || |
5324 | | - xhr.status === 304 || xhr.status === 1223 || xhr.status === 0; |
| 6206 | + xhr.status >= 200 && xhr.status < 300 || |
| 6207 | + xhr.status === 304 || xhr.status === 1223; |
5325 | 6208 | } catch(e) {} |
5326 | 6209 | |
5327 | 6210 | return false; |
— | — | @@ -5339,8 +6222,7 @@ |
5340 | 6223 | jQuery.etag[url] = etag; |
5341 | 6224 | } |
5342 | 6225 | |
5343 | | - // Opera returns 0 when status is 304 |
5344 | | - return xhr.status === 304 || xhr.status === 0; |
| 6226 | + return xhr.status === 304; |
5345 | 6227 | }, |
5346 | 6228 | |
5347 | 6229 | httpData: function( xhr, type, s ) { |
— | — | @@ -5371,77 +6253,40 @@ |
5372 | 6254 | } |
5373 | 6255 | |
5374 | 6256 | return data; |
5375 | | - }, |
| 6257 | + } |
5376 | 6258 | |
5377 | | - // Serialize an array of form elements or a set of |
5378 | | - // key/values into a query string |
5379 | | - param: function( a, traditional ) { |
5380 | | - var s = []; |
5381 | | - |
5382 | | - // Set traditional to true for jQuery <= 1.3.2 behavior. |
5383 | | - if ( traditional === undefined ) { |
5384 | | - traditional = jQuery.ajaxSettings.traditional; |
| 6259 | +}); |
| 6260 | + |
| 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) {} |
5385 | 6274 | } |
5386 | | - |
5387 | | - // If an array was passed in, assume that it is an array of form elements. |
5388 | | - if ( jQuery.isArray(a) || a.jquery ) { |
5389 | | - // Serialize the form elements |
5390 | | - jQuery.each( a, function() { |
5391 | | - add( this.name, this.value ); |
5392 | | - }); |
5393 | | - |
5394 | | - } else { |
5395 | | - // If traditional, encode the "old" way (the way 1.3.2 or older |
5396 | | - // did it), otherwise encode params recursively. |
5397 | | - for ( var prefix in a ) { |
5398 | | - buildParams( prefix, a[prefix] ); |
5399 | | - } |
5400 | | - } |
5401 | 6275 | |
5402 | | - // Return the resulting serialization |
5403 | | - return s.join("&").replace(r20, "+"); |
| 6276 | + try { |
| 6277 | + return new window.ActiveXObject("Microsoft.XMLHTTP"); |
| 6278 | + } catch(activeError) {} |
| 6279 | + }; |
| 6280 | +} |
5404 | 6281 | |
5405 | | - function buildParams( prefix, obj ) { |
5406 | | - if ( jQuery.isArray(obj) ) { |
5407 | | - // Serialize array item. |
5408 | | - jQuery.each( obj, function( i, v ) { |
5409 | | - if ( traditional || /\[\]$/.test( prefix ) ) { |
5410 | | - // Treat each array item as a scalar. |
5411 | | - add( prefix, v ); |
5412 | | - } else { |
5413 | | - // If array item is non-scalar (array or object), encode its |
5414 | | - // numeric index to resolve deserialization ambiguity issues. |
5415 | | - // Note that rack (as of 1.0.0) can't currently deserialize |
5416 | | - // nested arrays properly, and attempting to do so may cause |
5417 | | - // a server error. Possible fixes are to modify rack's |
5418 | | - // deserialization algorithm or to provide an option or flag |
5419 | | - // to force array serialization to be shallow. |
5420 | | - buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v ); |
5421 | | - } |
5422 | | - }); |
5423 | | - |
5424 | | - } else if ( !traditional && obj != null && typeof obj === "object" ) { |
5425 | | - // Serialize object item. |
5426 | | - jQuery.each( obj, function( k, v ) { |
5427 | | - buildParams( prefix + "[" + k + "]", v ); |
5428 | | - }); |
5429 | | - |
5430 | | - } else { |
5431 | | - // Serialize scalar item. |
5432 | | - add( prefix, obj ); |
5433 | | - } |
5434 | | - } |
| 6282 | +// Does this browser support XHR requests? |
| 6283 | +jQuery.support.ajax = !!jQuery.ajaxSettings.xhr(); |
5435 | 6284 | |
5436 | | - function add( key, value ) { |
5437 | | - // If value is a function, invoke it and return its value |
5438 | | - value = jQuery.isFunction(value) ? value() : value; |
5439 | | - s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value); |
5440 | | - } |
5441 | | - } |
5442 | | -}); |
| 6285 | + |
| 6286 | + |
| 6287 | + |
5443 | 6288 | var elemdisplay = {}, |
5444 | | - rfxtypes = /toggle|show|hide/, |
5445 | | - rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/, |
| 6289 | + rfxtypes = /^(?:toggle|show|hide)$/, |
| 6290 | + rfxnum = /^([+\-]=)?([\d+.\-]+)(.*)$/, |
5446 | 6291 | timerId, |
5447 | 6292 | fxAttrs = [ |
5448 | 6293 | // height animations |
— | — | @@ -5453,66 +6298,63 @@ |
5454 | 6299 | ]; |
5455 | 6300 | |
5456 | 6301 | jQuery.fn.extend({ |
5457 | | - show: function( speed, callback ) { |
5458 | | - if ( speed || speed === 0) { |
5459 | | - return this.animate( genFx("show", 3), speed, callback); |
| 6302 | + show: function( speed, easing, callback ) { |
| 6303 | + var elem, display; |
5460 | 6304 | |
| 6305 | + if ( speed || speed === 0 ) { |
| 6306 | + return this.animate( genFx("show", 3), speed, easing, callback); |
| 6307 | + |
5461 | 6308 | } else { |
5462 | | - for ( var i = 0, l = this.length; i < l; i++ ) { |
5463 | | - var old = jQuery.data(this[i], "olddisplay"); |
| 6309 | + for ( var i = 0, j = this.length; i < j; i++ ) { |
| 6310 | + elem = this[i]; |
| 6311 | + display = elem.style.display; |
5464 | 6312 | |
5465 | | - this[i].style.display = old || ""; |
| 6313 | + // Reset the inline display of this element to learn if it is |
| 6314 | + // being hidden by cascaded rules or not |
| 6315 | + if ( !jQuery.data(elem, "olddisplay") && display === "none" ) { |
| 6316 | + display = elem.style.display = ""; |
| 6317 | + } |
5466 | 6318 | |
5467 | | - if ( jQuery.css(this[i], "display") === "none" ) { |
5468 | | - var nodeName = this[i].nodeName, display; |
5469 | | - |
5470 | | - if ( elemdisplay[ nodeName ] ) { |
5471 | | - display = elemdisplay[ nodeName ]; |
5472 | | - |
5473 | | - } else { |
5474 | | - var elem = jQuery("<" + nodeName + " />").appendTo("body"); |
5475 | | - |
5476 | | - display = elem.css("display"); |
5477 | | - |
5478 | | - if ( display === "none" ) { |
5479 | | - display = "block"; |
5480 | | - } |
5481 | | - |
5482 | | - elem.remove(); |
5483 | | - |
5484 | | - elemdisplay[ nodeName ] = display; |
5485 | | - } |
5486 | | - |
5487 | | - jQuery.data(this[i], "olddisplay", display); |
| 6319 | + // Set elements which have been overridden with display: none |
| 6320 | + // in a stylesheet to whatever the default browser style is |
| 6321 | + // for such an element |
| 6322 | + if ( display === "" && jQuery.css( elem, "display" ) === "none" ) { |
| 6323 | + jQuery.data(elem, "olddisplay", defaultDisplay(elem.nodeName)); |
5488 | 6324 | } |
5489 | 6325 | } |
5490 | 6326 | |
5491 | | - // Set the display of the elements in a second loop |
| 6327 | + // Set the display of most of the elements in a second loop |
5492 | 6328 | // to avoid the constant reflow |
5493 | | - for ( var j = 0, k = this.length; j < k; j++ ) { |
5494 | | - this[j].style.display = jQuery.data(this[j], "olddisplay") || ""; |
| 6329 | + for ( i = 0; i < j; i++ ) { |
| 6330 | + elem = this[i]; |
| 6331 | + display = elem.style.display; |
| 6332 | + |
| 6333 | + if ( display === "" || display === "none" ) { |
| 6334 | + elem.style.display = jQuery.data(elem, "olddisplay") || ""; |
| 6335 | + } |
5495 | 6336 | } |
5496 | 6337 | |
5497 | 6338 | return this; |
5498 | 6339 | } |
5499 | 6340 | }, |
5500 | 6341 | |
5501 | | - hide: function( speed, callback ) { |
| 6342 | + hide: function( speed, easing, callback ) { |
5502 | 6343 | if ( speed || speed === 0 ) { |
5503 | | - return this.animate( genFx("hide", 3), speed, callback); |
| 6344 | + return this.animate( genFx("hide", 3), speed, easing, callback); |
5504 | 6345 | |
5505 | 6346 | } else { |
5506 | | - for ( var i = 0, l = this.length; i < l; i++ ) { |
5507 | | - var old = jQuery.data(this[i], "olddisplay"); |
5508 | | - if ( !old && old !== "none" ) { |
5509 | | - jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display")); |
| 6347 | + for ( var i = 0, j = this.length; i < j; i++ ) { |
| 6348 | + var display = jQuery.css( this[i], "display" ); |
| 6349 | + |
| 6350 | + if ( display !== "none" ) { |
| 6351 | + jQuery.data( this[i], "olddisplay", display ); |
5510 | 6352 | } |
5511 | 6353 | } |
5512 | 6354 | |
5513 | 6355 | // Set the display of the elements in a second loop |
5514 | 6356 | // to avoid the constant reflow |
5515 | | - for ( var j = 0, k = this.length; j < k; j++ ) { |
5516 | | - this[j].style.display = "none"; |
| 6357 | + for ( i = 0; i < j; i++ ) { |
| 6358 | + this[i].style.display = "none"; |
5517 | 6359 | } |
5518 | 6360 | |
5519 | 6361 | return this; |
— | — | @@ -5522,7 +6364,7 @@ |
5523 | 6365 | // Save the old toggle function |
5524 | 6366 | _toggle: jQuery.fn.toggle, |
5525 | 6367 | |
5526 | | - toggle: function( fn, fn2 ) { |
| 6368 | + toggle: function( fn, fn2, callback ) { |
5527 | 6369 | var bool = typeof fn === "boolean"; |
5528 | 6370 | |
5529 | 6371 | if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) { |
— | — | @@ -5535,15 +6377,15 @@ |
5536 | 6378 | }); |
5537 | 6379 | |
5538 | 6380 | } else { |
5539 | | - this.animate(genFx("toggle", 3), fn, fn2); |
| 6381 | + this.animate(genFx("toggle", 3), fn, fn2, callback); |
5540 | 6382 | } |
5541 | 6383 | |
5542 | 6384 | return this; |
5543 | 6385 | }, |
5544 | 6386 | |
5545 | | - fadeTo: function( speed, to, callback ) { |
| 6387 | + fadeTo: function( speed, to, easing, callback ) { |
5546 | 6388 | return this.filter(":hidden").css("opacity", 0).show().end() |
5547 | | - .animate({opacity: to}, speed, callback); |
| 6389 | + .animate({opacity: to}, speed, easing, callback); |
5548 | 6390 | }, |
5549 | 6391 | |
5550 | 6392 | animate: function( prop, speed, easing, callback ) { |
— | — | @@ -5554,12 +6396,16 @@ |
5555 | 6397 | } |
5556 | 6398 | |
5557 | 6399 | return this[ optall.queue === false ? "each" : "queue" ](function() { |
| 6400 | + // XXX 'this' does not always have a nodeName when running the |
| 6401 | + // test suite |
| 6402 | + |
5558 | 6403 | var opt = jQuery.extend({}, optall), p, |
5559 | | - hidden = this.nodeType === 1 && jQuery(this).is(":hidden"), |
| 6404 | + isElement = this.nodeType === 1, |
| 6405 | + hidden = isElement && jQuery(this).is(":hidden"), |
5560 | 6406 | self = this; |
5561 | 6407 | |
5562 | 6408 | for ( p in prop ) { |
5563 | | - var name = p.replace(rdashAlpha, fcamelCase); |
| 6409 | + var name = jQuery.camelCase( p ); |
5564 | 6410 | |
5565 | 6411 | if ( p !== name ) { |
5566 | 6412 | prop[ name ] = prop[ p ]; |
— | — | @@ -5571,12 +6417,35 @@ |
5572 | 6418 | return opt.complete.call(this); |
5573 | 6419 | } |
5574 | 6420 | |
5575 | | - if ( ( p === "height" || p === "width" ) && this.style ) { |
5576 | | - // Store display property |
5577 | | - opt.display = jQuery.css(this, "display"); |
| 6421 | + if ( isElement && ( p === "height" || p === "width" ) ) { |
| 6422 | + // Make sure that nothing sneaks out |
| 6423 | + // Record all 3 overflow attributes because IE does not |
| 6424 | + // change the overflow attribute when overflowX and |
| 6425 | + // overflowY are set to the same value |
| 6426 | + opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ]; |
5578 | 6427 | |
5579 | | - // Make sure that nothing sneaks out |
5580 | | - opt.overflow = this.style.overflow; |
| 6428 | + // Set display property to inline-block for height/width |
| 6429 | + // animations on inline elements that are having width/height |
| 6430 | + // animated |
| 6431 | + if ( jQuery.css( this, "display" ) === "inline" && |
| 6432 | + jQuery.css( this, "float" ) === "none" ) { |
| 6433 | + if ( !jQuery.support.inlineBlockNeedsLayout ) { |
| 6434 | + this.style.display = "inline-block"; |
| 6435 | + |
| 6436 | + } else { |
| 6437 | + var display = defaultDisplay(this.nodeName); |
| 6438 | + |
| 6439 | + // inline-level elements accept inline-block; |
| 6440 | + // block-level elements need to be inline with layout |
| 6441 | + if ( display === "inline" ) { |
| 6442 | + this.style.display = "inline-block"; |
| 6443 | + |
| 6444 | + } else { |
| 6445 | + this.style.display = "inline"; |
| 6446 | + this.style.zoom = 1; |
| 6447 | + } |
| 6448 | + } |
| 6449 | + } |
5581 | 6450 | } |
5582 | 6451 | |
5583 | 6452 | if ( jQuery.isArray( prop[p] ) ) { |
— | — | @@ -5600,7 +6469,7 @@ |
5601 | 6470 | |
5602 | 6471 | } else { |
5603 | 6472 | var parts = rfxnum.exec(val), |
5604 | | - start = e.cur(true) || 0; |
| 6473 | + start = e.cur() || 0; |
5605 | 6474 | |
5606 | 6475 | if ( parts ) { |
5607 | 6476 | var end = parseFloat( parts[2] ), |
— | — | @@ -5608,9 +6477,9 @@ |
5609 | 6478 | |
5610 | 6479 | // We need to compute starting value |
5611 | 6480 | if ( unit !== "px" ) { |
5612 | | - self.style[ name ] = (end || 1) + unit; |
5613 | | - start = ((end || 1) / e.cur(true)) * start; |
5614 | | - self.style[ name ] = start + unit; |
| 6481 | + jQuery.style( self, name, (end || 1) + unit); |
| 6482 | + start = ((end || 1) / e.cur()) * start; |
| 6483 | + jQuery.style( self, name, start + unit); |
5615 | 6484 | } |
5616 | 6485 | |
5617 | 6486 | // If a +=/-= token was provided, we're doing a relative animation |
— | — | @@ -5662,22 +6531,33 @@ |
5663 | 6532 | |
5664 | 6533 | }); |
5665 | 6534 | |
| 6535 | +function genFx( type, num ) { |
| 6536 | + var obj = {}; |
| 6537 | + |
| 6538 | + jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() { |
| 6539 | + obj[ this ] = type; |
| 6540 | + }); |
| 6541 | + |
| 6542 | + return obj; |
| 6543 | +} |
| 6544 | + |
5666 | 6545 | // Generate shortcuts for custom animations |
5667 | 6546 | jQuery.each({ |
5668 | 6547 | slideDown: genFx("show", 1), |
5669 | 6548 | slideUp: genFx("hide", 1), |
5670 | 6549 | slideToggle: genFx("toggle", 1), |
5671 | 6550 | fadeIn: { opacity: "show" }, |
5672 | | - fadeOut: { opacity: "hide" } |
| 6551 | + fadeOut: { opacity: "hide" }, |
| 6552 | + fadeToggle: { opacity: "toggle" } |
5673 | 6553 | }, function( name, props ) { |
5674 | | - jQuery.fn[ name ] = function( speed, callback ) { |
5675 | | - return this.animate( props, speed, callback ); |
| 6554 | + jQuery.fn[ name ] = function( speed, easing, callback ) { |
| 6555 | + return this.animate( props, speed, easing, callback ); |
5676 | 6556 | }; |
5677 | 6557 | }); |
5678 | 6558 | |
5679 | 6559 | jQuery.extend({ |
5680 | 6560 | speed: function( speed, easing, fn ) { |
5681 | | - var opt = speed && typeof speed === "object" ? speed : { |
| 6561 | + var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : { |
5682 | 6562 | complete: fn || !fn && easing || |
5683 | 6563 | jQuery.isFunction( speed ) && speed, |
5684 | 6564 | duration: speed, |
— | — | @@ -5685,7 +6565,7 @@ |
5686 | 6566 | }; |
5687 | 6567 | |
5688 | 6568 | opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : |
5689 | | - jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default; |
| 6569 | + opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default; |
5690 | 6570 | |
5691 | 6571 | // Queueing |
5692 | 6572 | opt.old = opt.complete; |
— | — | @@ -5732,33 +6612,30 @@ |
5733 | 6613 | } |
5734 | 6614 | |
5735 | 6615 | (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this ); |
5736 | | - |
5737 | | - // Set display property to block for height/width animations |
5738 | | - if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) { |
5739 | | - this.elem.style.display = "block"; |
5740 | | - } |
5741 | 6616 | }, |
5742 | 6617 | |
5743 | 6618 | // Get the current size |
5744 | | - cur: function( force ) { |
| 6619 | + cur: function() { |
5745 | 6620 | if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) { |
5746 | 6621 | return this.elem[ this.prop ]; |
5747 | 6622 | } |
5748 | 6623 | |
5749 | | - var r = parseFloat(jQuery.css(this.elem, this.prop, force)); |
5750 | | - return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0; |
| 6624 | + var r = parseFloat( jQuery.css( this.elem, this.prop ) ); |
| 6625 | + return r && r > -10000 ? r : 0; |
5751 | 6626 | }, |
5752 | 6627 | |
5753 | 6628 | // Start an animation from one number to another |
5754 | 6629 | custom: function( from, to, unit ) { |
5755 | | - this.startTime = now(); |
| 6630 | + var self = this, |
| 6631 | + fx = jQuery.fx; |
| 6632 | + |
| 6633 | + this.startTime = jQuery.now(); |
5756 | 6634 | this.start = from; |
5757 | 6635 | this.end = to; |
5758 | 6636 | this.unit = unit || this.unit || "px"; |
5759 | 6637 | this.now = this.start; |
5760 | 6638 | this.pos = this.state = 0; |
5761 | 6639 | |
5762 | | - var self = this; |
5763 | 6640 | function t( gotoEnd ) { |
5764 | 6641 | return self.step(gotoEnd); |
5765 | 6642 | } |
— | — | @@ -5766,7 +6643,7 @@ |
5767 | 6644 | t.elem = this.elem; |
5768 | 6645 | |
5769 | 6646 | if ( t() && jQuery.timers.push(t) && !timerId ) { |
5770 | | - timerId = setInterval(jQuery.fx.tick, 13); |
| 6647 | + timerId = setInterval(fx.tick, fx.interval); |
5771 | 6648 | } |
5772 | 6649 | }, |
5773 | 6650 | |
— | — | @@ -5797,7 +6674,7 @@ |
5798 | 6675 | |
5799 | 6676 | // Each step of an animation |
5800 | 6677 | step: function( gotoEnd ) { |
5801 | | - var t = now(), done = true; |
| 6678 | + var t = jQuery.now(), done = true; |
5802 | 6679 | |
5803 | 6680 | if ( gotoEnd || t >= this.options.duration + this.startTime ) { |
5804 | 6681 | this.now = this.end; |
— | — | @@ -5813,17 +6690,14 @@ |
5814 | 6691 | } |
5815 | 6692 | |
5816 | 6693 | if ( done ) { |
5817 | | - if ( this.options.display != null ) { |
5818 | | - // Reset the overflow |
5819 | | - this.elem.style.overflow = this.options.overflow; |
| 6694 | + // Reset the overflow |
| 6695 | + if ( this.options.overflow != null && !jQuery.support.shrinkWrapBlocks ) { |
| 6696 | + var elem = this.elem, |
| 6697 | + options = this.options; |
5820 | 6698 | |
5821 | | - // Reset the display |
5822 | | - var old = jQuery.data(this.elem, "olddisplay"); |
5823 | | - this.elem.style.display = old ? old : this.options.display; |
5824 | | - |
5825 | | - if ( jQuery.css(this.elem, "display") === "none" ) { |
5826 | | - this.elem.style.display = "block"; |
5827 | | - } |
| 6699 | + jQuery.each( [ "", "X", "Y" ], function (index, value) { |
| 6700 | + elem.style[ "overflow" + value ] = options.overflow[index]; |
| 6701 | + } ); |
5828 | 6702 | } |
5829 | 6703 | |
5830 | 6704 | // Hide the element if the "hide" operation was done |
— | — | @@ -5834,7 +6708,7 @@ |
5835 | 6709 | // Reset the properties, if the item has been hidden or shown |
5836 | 6710 | if ( this.options.hide || this.options.show ) { |
5837 | 6711 | for ( var p in this.options.curAnim ) { |
5838 | | - jQuery.style(this.elem, p, this.options.orig[p]); |
| 6712 | + jQuery.style( this.elem, p, this.options.orig[p] ); |
5839 | 6713 | } |
5840 | 6714 | } |
5841 | 6715 | |
— | — | @@ -5876,22 +6750,24 @@ |
5877 | 6751 | jQuery.fx.stop(); |
5878 | 6752 | } |
5879 | 6753 | }, |
5880 | | - |
| 6754 | + |
| 6755 | + interval: 13, |
| 6756 | + |
5881 | 6757 | stop: function() { |
5882 | 6758 | clearInterval( timerId ); |
5883 | 6759 | timerId = null; |
5884 | 6760 | }, |
5885 | | - |
| 6761 | + |
5886 | 6762 | speeds: { |
5887 | 6763 | slow: 600, |
5888 | | - fast: 200, |
5889 | | - // Default speed |
5890 | | - _default: 400 |
| 6764 | + fast: 200, |
| 6765 | + // Default speed |
| 6766 | + _default: 400 |
5891 | 6767 | }, |
5892 | 6768 | |
5893 | 6769 | step: { |
5894 | 6770 | opacity: function( fx ) { |
5895 | | - jQuery.style(fx.elem, "opacity", fx.now); |
| 6771 | + jQuery.style( fx.elem, "opacity", fx.now ); |
5896 | 6772 | }, |
5897 | 6773 | |
5898 | 6774 | _default: function( fx ) { |
— | — | @@ -5912,18 +6788,32 @@ |
5913 | 6789 | }; |
5914 | 6790 | } |
5915 | 6791 | |
5916 | | -function genFx( type, num ) { |
5917 | | - var obj = {}; |
| 6792 | +function defaultDisplay( nodeName ) { |
| 6793 | + if ( !elemdisplay[ nodeName ] ) { |
| 6794 | + var elem = jQuery("<" + nodeName + ">").appendTo("body"), |
| 6795 | + display = elem.css("display"); |
5918 | 6796 | |
5919 | | - jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() { |
5920 | | - obj[ this ] = type; |
5921 | | - }); |
| 6797 | + elem.remove(); |
5922 | 6798 | |
5923 | | - return obj; |
| 6799 | + if ( display === "none" || display === "" ) { |
| 6800 | + display = "block"; |
| 6801 | + } |
| 6802 | + |
| 6803 | + elemdisplay[ nodeName ] = display; |
| 6804 | + } |
| 6805 | + |
| 6806 | + return elemdisplay[ nodeName ]; |
5924 | 6807 | } |
| 6808 | + |
| 6809 | + |
| 6810 | + |
| 6811 | + |
| 6812 | +var rtable = /^t(?:able|d|h)$/i, |
| 6813 | + rroot = /^(?:body|html)$/i; |
| 6814 | + |
5925 | 6815 | if ( "getBoundingClientRect" in document.documentElement ) { |
5926 | 6816 | jQuery.fn.offset = function( options ) { |
5927 | | - var elem = this[0]; |
| 6817 | + var elem = this[0], box; |
5928 | 6818 | |
5929 | 6819 | if ( options ) { |
5930 | 6820 | return this.each(function( i ) { |
— | — | @@ -5939,11 +6829,27 @@ |
5940 | 6830 | return jQuery.offset.bodyOffset( elem ); |
5941 | 6831 | } |
5942 | 6832 | |
5943 | | - var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, |
5944 | | - clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, |
5945 | | - top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, |
5946 | | - left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; |
| 6833 | + try { |
| 6834 | + box = elem.getBoundingClientRect(); |
| 6835 | + } catch(e) {} |
5947 | 6836 | |
| 6837 | + var doc = elem.ownerDocument, |
| 6838 | + docElem = doc.documentElement; |
| 6839 | + |
| 6840 | + // Make sure we're not dealing with a disconnected DOM node |
| 6841 | + if ( !box || !jQuery.contains( docElem, elem ) ) { |
| 6842 | + return box || { top: 0, left: 0 }; |
| 6843 | + } |
| 6844 | + |
| 6845 | + var body = doc.body, |
| 6846 | + win = getWindow(doc), |
| 6847 | + clientTop = docElem.clientTop || body.clientTop || 0, |
| 6848 | + clientLeft = docElem.clientLeft || body.clientLeft || 0, |
| 6849 | + scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ), |
| 6850 | + scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft), |
| 6851 | + top = box.top + scrollTop - clientTop, |
| 6852 | + left = box.left + scrollLeft - clientLeft; |
| 6853 | + |
5948 | 6854 | return { top: top, left: left }; |
5949 | 6855 | }; |
5950 | 6856 | |
— | — | @@ -5967,11 +6873,16 @@ |
5968 | 6874 | |
5969 | 6875 | jQuery.offset.initialize(); |
5970 | 6876 | |
5971 | | - var offsetParent = elem.offsetParent, prevOffsetParent = elem, |
5972 | | - doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement, |
5973 | | - body = doc.body, defaultView = doc.defaultView, |
| 6877 | + var computedStyle, |
| 6878 | + offsetParent = elem.offsetParent, |
| 6879 | + prevOffsetParent = elem, |
| 6880 | + doc = elem.ownerDocument, |
| 6881 | + docElem = doc.documentElement, |
| 6882 | + body = doc.body, |
| 6883 | + defaultView = doc.defaultView, |
5974 | 6884 | prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle, |
5975 | | - top = elem.offsetTop, left = elem.offsetLeft; |
| 6885 | + top = elem.offsetTop, |
| 6886 | + left = elem.offsetLeft; |
5976 | 6887 | |
5977 | 6888 | while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { |
5978 | 6889 | if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) { |
— | — | @@ -5986,12 +6897,13 @@ |
5987 | 6898 | top += elem.offsetTop; |
5988 | 6899 | left += elem.offsetLeft; |
5989 | 6900 | |
5990 | | - if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) { |
| 6901 | + if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) { |
5991 | 6902 | top += parseFloat( computedStyle.borderTopWidth ) || 0; |
5992 | 6903 | left += parseFloat( computedStyle.borderLeftWidth ) || 0; |
5993 | 6904 | } |
5994 | 6905 | |
5995 | | - prevOffsetParent = offsetParent, offsetParent = elem.offsetParent; |
| 6906 | + prevOffsetParent = offsetParent; |
| 6907 | + offsetParent = elem.offsetParent; |
5996 | 6908 | } |
5997 | 6909 | |
5998 | 6910 | if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) { |
— | — | @@ -6018,7 +6930,7 @@ |
6019 | 6931 | |
6020 | 6932 | jQuery.offset = { |
6021 | 6933 | initialize: function() { |
6022 | | - var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0, |
| 6934 | + var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0, |
6023 | 6935 | html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>"; |
6024 | 6936 | |
6025 | 6937 | jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } ); |
— | — | @@ -6032,12 +6944,16 @@ |
6033 | 6945 | this.doesNotAddBorder = (checkDiv.offsetTop !== 5); |
6034 | 6946 | this.doesAddBorderForTableAndCells = (td.offsetTop === 5); |
6035 | 6947 | |
6036 | | - checkDiv.style.position = "fixed", checkDiv.style.top = "20px"; |
| 6948 | + checkDiv.style.position = "fixed"; |
| 6949 | + checkDiv.style.top = "20px"; |
| 6950 | + |
6037 | 6951 | // safari subtracts parent border width here which is 5px |
6038 | 6952 | this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); |
6039 | 6953 | checkDiv.style.position = checkDiv.style.top = ""; |
6040 | 6954 | |
6041 | | - innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative"; |
| 6955 | + innerDiv.style.overflow = "hidden"; |
| 6956 | + innerDiv.style.position = "relative"; |
| 6957 | + |
6042 | 6958 | this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5); |
6043 | 6959 | |
6044 | 6960 | this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop); |
— | — | @@ -6048,36 +6964,52 @@ |
6049 | 6965 | }, |
6050 | 6966 | |
6051 | 6967 | bodyOffset: function( body ) { |
6052 | | - var top = body.offsetTop, left = body.offsetLeft; |
| 6968 | + var top = body.offsetTop, |
| 6969 | + left = body.offsetLeft; |
6053 | 6970 | |
6054 | 6971 | jQuery.offset.initialize(); |
6055 | 6972 | |
6056 | 6973 | if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) { |
6057 | | - top += parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0; |
6058 | | - left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0; |
| 6974 | + top += parseFloat( jQuery.css(body, "marginTop") ) || 0; |
| 6975 | + left += parseFloat( jQuery.css(body, "marginLeft") ) || 0; |
6059 | 6976 | } |
6060 | 6977 | |
6061 | 6978 | return { top: top, left: left }; |
6062 | 6979 | }, |
6063 | 6980 | |
6064 | 6981 | setOffset: function( elem, options, i ) { |
| 6982 | + var position = jQuery.css( elem, "position" ); |
| 6983 | + |
6065 | 6984 | // set position first, in-case top/left are set even on static elem |
6066 | | - if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) { |
| 6985 | + if ( position === "static" ) { |
6067 | 6986 | elem.style.position = "relative"; |
6068 | 6987 | } |
6069 | | - var curElem = jQuery( elem ), |
| 6988 | + |
| 6989 | + var curElem = jQuery( elem ), |
6070 | 6990 | curOffset = curElem.offset(), |
6071 | | - curTop = parseInt( jQuery.curCSS( elem, "top", true ), 10 ) || 0, |
6072 | | - curLeft = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0; |
| 6991 | + curCSSTop = jQuery.css( elem, "top" ), |
| 6992 | + curCSSLeft = jQuery.css( elem, "left" ), |
| 6993 | + calculatePosition = (position === "absolute" && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1), |
| 6994 | + props = {}, curPosition = {}, curTop, curLeft; |
6073 | 6995 | |
| 6996 | + // need to be able to calculate position if either top or left is auto and position is absolute |
| 6997 | + if ( calculatePosition ) { |
| 6998 | + curPosition = curElem.position(); |
| 6999 | + } |
| 7000 | + |
| 7001 | + curTop = calculatePosition ? curPosition.top : parseInt( curCSSTop, 10 ) || 0; |
| 7002 | + curLeft = calculatePosition ? curPosition.left : parseInt( curCSSLeft, 10 ) || 0; |
| 7003 | + |
6074 | 7004 | if ( jQuery.isFunction( options ) ) { |
6075 | 7005 | options = options.call( elem, i, curOffset ); |
6076 | 7006 | } |
6077 | 7007 | |
6078 | | - var props = { |
6079 | | - top: (options.top - curOffset.top) + curTop, |
6080 | | - left: (options.left - curOffset.left) + curLeft |
6081 | | - }; |
| 7008 | + if (options.top != null) { |
| 7009 | + props.top = (options.top - curOffset.top) + curTop; |
| 7010 | + } |
| 7011 | + if (options.left != null) { |
| 7012 | + props.left = (options.left - curOffset.left) + curLeft; |
| 7013 | + } |
6082 | 7014 | |
6083 | 7015 | if ( "using" in options ) { |
6084 | 7016 | options.using.call( elem, props ); |
— | — | @@ -6101,17 +7033,17 @@ |
6102 | 7034 | |
6103 | 7035 | // Get correct offsets |
6104 | 7036 | offset = this.offset(), |
6105 | | - parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); |
| 7037 | + parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); |
6106 | 7038 | |
6107 | 7039 | // Subtract element margins |
6108 | 7040 | // note: when an element has margin: auto the offsetLeft and marginLeft |
6109 | 7041 | // are the same in Safari causing offset.left to incorrectly be 0 |
6110 | | - offset.top -= parseFloat( jQuery.curCSS(elem, "marginTop", true) ) || 0; |
6111 | | - offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0; |
| 7042 | + offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0; |
| 7043 | + offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0; |
6112 | 7044 | |
6113 | 7045 | // Add offsetParent borders |
6114 | | - parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth", true) ) || 0; |
6115 | | - parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0; |
| 7046 | + parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0; |
| 7047 | + parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0; |
6116 | 7048 | |
6117 | 7049 | // Subtract the two offsets |
6118 | 7050 | return { |
— | — | @@ -6123,7 +7055,7 @@ |
6124 | 7056 | offsetParent: function() { |
6125 | 7057 | return this.map(function() { |
6126 | 7058 | var offsetParent = this.offsetParent || document.body; |
6127 | | - while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) { |
| 7059 | + while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) { |
6128 | 7060 | offsetParent = offsetParent.offsetParent; |
6129 | 7061 | } |
6130 | 7062 | return offsetParent; |
— | — | @@ -6171,12 +7103,16 @@ |
6172 | 7104 | }); |
6173 | 7105 | |
6174 | 7106 | function getWindow( elem ) { |
6175 | | - return ("scrollTo" in elem && elem.document) ? |
| 7107 | + return jQuery.isWindow( elem ) ? |
6176 | 7108 | elem : |
6177 | 7109 | elem.nodeType === 9 ? |
6178 | 7110 | elem.defaultView || elem.parentWindow : |
6179 | 7111 | false; |
6180 | 7112 | } |
| 7113 | + |
| 7114 | + |
| 7115 | + |
| 7116 | + |
6181 | 7117 | // Create innerHeight, innerWidth, outerHeight and outerWidth methods |
6182 | 7118 | jQuery.each([ "Height", "Width" ], function( i, name ) { |
6183 | 7119 | |
— | — | @@ -6185,14 +7121,14 @@ |
6186 | 7122 | // innerHeight and innerWidth |
6187 | 7123 | jQuery.fn["inner" + name] = function() { |
6188 | 7124 | return this[0] ? |
6189 | | - jQuery.css( this[0], type, false, "padding" ) : |
| 7125 | + parseFloat( jQuery.css( this[0], type, "padding" ) ) : |
6190 | 7126 | null; |
6191 | 7127 | }; |
6192 | 7128 | |
6193 | 7129 | // outerHeight and outerWidth |
6194 | 7130 | jQuery.fn["outer" + name] = function( margin ) { |
6195 | 7131 | return this[0] ? |
6196 | | - jQuery.css( this[0], type, false, margin ? "margin" : "border" ) : |
| 7132 | + parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) : |
6197 | 7133 | null; |
6198 | 7134 | }; |
6199 | 7135 | |
— | — | @@ -6210,31 +7146,34 @@ |
6211 | 7147 | }); |
6212 | 7148 | } |
6213 | 7149 | |
6214 | | - return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window? |
| 7150 | + if ( jQuery.isWindow( elem ) ) { |
6215 | 7151 | // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode |
6216 | | - elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || |
6217 | | - elem.document.body[ "client" + name ] : |
| 7152 | + return elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] || |
| 7153 | + elem.document.body[ "client" + name ]; |
6218 | 7154 | |
6219 | | - // Get document width or height |
6220 | | - (elem.nodeType === 9) ? // is it a document |
6221 | | - // Either scroll[Width/Height] or offset[Width/Height], whichever is greater |
6222 | | - Math.max( |
6223 | | - elem.documentElement["client" + name], |
6224 | | - elem.body["scroll" + name], elem.documentElement["scroll" + name], |
6225 | | - elem.body["offset" + name], elem.documentElement["offset" + name] |
6226 | | - ) : |
| 7155 | + // Get document width or height |
| 7156 | + } else if ( elem.nodeType === 9 ) { |
| 7157 | + // Either scroll[Width/Height] or offset[Width/Height], whichever is greater |
| 7158 | + return Math.max( |
| 7159 | + elem.documentElement["client" + name], |
| 7160 | + elem.body["scroll" + name], elem.documentElement["scroll" + name], |
| 7161 | + elem.body["offset" + name], elem.documentElement["offset" + name] |
| 7162 | + ); |
6227 | 7163 | |
6228 | | - // Get or set width or height on the element |
6229 | | - size === undefined ? |
6230 | | - // Get width or height on the element |
6231 | | - jQuery.css( elem, type ) : |
| 7164 | + // Get or set width or height on the element |
| 7165 | + } else if ( size === undefined ) { |
| 7166 | + var orig = jQuery.css( elem, type ), |
| 7167 | + ret = parseFloat( orig ); |
6232 | 7168 | |
6233 | | - // Set the width or height on the element (default to pixels if value is unitless) |
6234 | | - this.css( type, typeof size === "string" ? size : ( parseInt( size ) || 0 ) + "px" ); |
| 7169 | + return jQuery.isNaN( ret ) ? orig : ret; |
| 7170 | + |
| 7171 | + // Set the width or height on the element (default to pixels if value is unitless) |
| 7172 | + } else { |
| 7173 | + return this.css( type, typeof size === "string" ? size : size + "px" ); |
| 7174 | + } |
6235 | 7175 | }; |
6236 | 7176 | |
6237 | 7177 | }); |
6238 | | -// Expose jQuery to the global object |
6239 | | -window.jQuery = window.$ = jQuery; |
6240 | 7178 | |
| 7179 | + |
6241 | 7180 | })(window); |