Changeset 9553 for trunk/themes/default/js/jquery.js
- Timestamp:
- Mar 6, 2011, 10:46:00 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/themes/default/js/jquery.js
r9172 r9553 1 1 /*! 2 * jQuery JavaScript Library v1.5 2 * jQuery JavaScript Library v1.5.1 3 3 * http://jquery.com/ 4 4 * … … 12 12 * Released under the MIT, BSD, and GPL Licenses. 13 13 * 14 * Date: Mon Jan 31 08:31:29 2011 -050014 * Date: Wed Feb 23 13:55:29 2011 -0500 15 15 */ 16 16 (function( window, undefined ) { … … 203 203 204 204 // The current version of jQuery being used 205 jquery: "1.5 ",205 jquery: "1.5.1", 206 206 207 207 // The default length of a jQuery object is 0 … … 314 314 315 315 jQuery.extend = jQuery.fn.extend = function() { 316 316 var options, name, src, copy, copyIsArray, clone, 317 317 target = arguments[0] || {}, 318 318 i = 1, … … 586 586 // Inspired by code by Andrea Giammarchi 587 587 // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html 588 var head = document.getElementsByTagName("head")[0] || document.documentElement, 589 script = document.createElement("script"); 590 591 script.type = "text/javascript"; 588 var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement, 589 script = document.createElement( "script" ); 592 590 593 591 if ( jQuery.support.scriptEval() ) { … … 865 863 } 866 864 } 865 // We have to add a catch block for 866 // IE prior to 8 or else the finally 867 // block will never get executed 868 catch (e) { 869 throw e; 870 } 867 871 finally { 868 872 fired = [ context, args ]; … … 912 916 // Get a promise for this deferred 913 917 // If obj is provided, the promise aspect is added to the object 914 promise: function( obj , i /* internal */) {918 promise: function( obj ) { 915 919 if ( obj == null ) { 916 920 if ( promise ) { … … 919 923 promise = obj = {}; 920 924 } 921 i = promiseMethods.length;925 var i = promiseMethods.length; 922 926 while( i-- ) { 923 obj[ promiseMethods[ i ] ] = deferred[ promiseMethods[ i] ];927 obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ]; 924 928 } 925 929 return obj; … … 927 931 } ); 928 932 // Make sure only one callback list will be used 929 deferred. then( failDeferred.cancel,deferred.cancel );933 deferred.done( failDeferred.cancel ).fail( deferred.cancel ); 930 934 // Unexpose cancel 931 935 delete deferred.cancel; … … 939 943 // Deferred helper 940 944 when: function( object ) { 941 var args = arguments, 942 length = args.length, 943 deferred = length <= 1 && object && jQuery.isFunction( object.promise ) ? 945 var lastIndex = arguments.length, 946 deferred = lastIndex <= 1 && object && jQuery.isFunction( object.promise ) ? 944 947 object : 945 948 jQuery.Deferred(), 946 promise = deferred.promise(), 947 resolveArray; 948 949 if ( length > 1 ) { 950 resolveArray = new Array( length ); 951 jQuery.each( args, function( index, element ) { 952 jQuery.when( element ).then( function( value ) { 953 resolveArray[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value; 954 if( ! --length ) { 955 deferred.resolveWith( promise, resolveArray ); 956 } 957 }, deferred.reject ); 958 } ); 949 promise = deferred.promise(); 950 951 if ( lastIndex > 1 ) { 952 var array = slice.call( arguments, 0 ), 953 count = lastIndex, 954 iCallback = function( index ) { 955 return function( value ) { 956 array[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value; 957 if ( !( --count ) ) { 958 deferred.resolveWith( promise, array ); 959 } 960 }; 961 }; 962 while( ( lastIndex-- ) ) { 963 object = array[ lastIndex ]; 964 if ( object && jQuery.isFunction( object.promise ) ) { 965 object.promise().then( iCallback(lastIndex), deferred.reject ); 966 } else { 967 --count; 968 } 969 } 970 if ( !count ) { 971 deferred.resolveWith( promise, array ); 972 } 959 973 } else if ( deferred !== object ) { 960 974 deferred.resolve( object ); … … 1072 1086 1073 1087 // Expose jQuery to the global object 1074 return (window.jQuery = window.$ = jQuery);1088 return jQuery; 1075 1089 1076 1090 })(); … … 1089 1103 a = div.getElementsByTagName("a")[0], 1090 1104 select = document.createElement("select"), 1091 opt = select.appendChild( document.createElement("option") ); 1105 opt = select.appendChild( document.createElement("option") ), 1106 input = div.getElementsByTagName("input")[0]; 1092 1107 1093 1108 // Can't get basic test support … … 1128 1143 // that it defaults to "on". 1129 1144 // (WebKit defaults to "" instead) 1130 checkOn: div.getElementsByTagName("input")[0].value === "on",1145 checkOn: input.value === "on", 1131 1146 1132 1147 // Make sure that a selected-by-default option has a working selected property. … … 1138 1153 optDisabled: false, 1139 1154 checkClone: false, 1140 _scriptEval: null,1141 1155 noCloneEvent: true, 1156 noCloneChecked: true, 1142 1157 boxModel: null, 1143 1158 inlineBlockNeedsLayout: false, … … 1146 1161 }; 1147 1162 1163 input.checked = true; 1164 jQuery.support.noCloneChecked = input.cloneNode( true ).checked; 1165 1148 1166 // Make sure that the options inside disabled selects aren't marked as disabled 1149 1167 // (WebKit marks them as diabled) … … 1151 1169 jQuery.support.optDisabled = !opt.disabled; 1152 1170 1171 var _scriptEval = null; 1153 1172 jQuery.support.scriptEval = function() { 1154 if ( jQuery.support._scriptEval === null ) {1173 if ( _scriptEval === null ) { 1155 1174 var root = document.documentElement, 1156 1175 script = document.createElement("script"), 1157 1176 id = "script" + jQuery.now(); 1158 1177 1159 script.type = "text/javascript";1160 1178 try { 1161 1179 script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); … … 1168 1186 // (IE doesn't support this, fails, and uses .text instead) 1169 1187 if ( window[ id ] ) { 1170 jQuery.support._scriptEval = true;1188 _scriptEval = true; 1171 1189 delete window[ id ]; 1172 1190 } else { 1173 jQuery.support._scriptEval = false;1191 _scriptEval = false; 1174 1192 } 1175 1193 … … 1179 1197 } 1180 1198 1181 return jQuery.support._scriptEval;1199 return _scriptEval; 1182 1200 }; 1183 1201 … … 1191 1209 } 1192 1210 1193 if ( div.attachEvent && div.fireEvent ) {1211 if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { 1194 1212 div.attachEvent("onclick", function click() { 1195 1213 // Cloning a node shouldn't copy over any … … 1322 1340 elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; 1323 1341 1324 return !!elem && ! jQuery.isEmptyObject(elem);1342 return !!elem && !isEmptyDataObject( elem ); 1325 1343 }, 1326 1344 … … 1362 1380 if ( !cache[ id ] ) { 1363 1381 cache[ id ] = {}; 1382 1383 // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery 1384 // metadata on plain JS objects when the object is serialized using 1385 // JSON.stringify 1386 if ( !isNode ) { 1387 cache[ id ].toJSON = jQuery.noop; 1388 } 1364 1389 } 1365 1390 1366 1391 // An object can be passed to jQuery.data instead of a key/value pair; this gets 1367 1392 // shallow copied over onto the existing cache 1368 if ( typeof name === "object" ) {1393 if ( typeof name === "object" || typeof name === "function" ) { 1369 1394 if ( pvt ) { 1370 1395 cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name); … … 1428 1453 // If there is no data left in the cache, we want to continue 1429 1454 // and let the cache object itself get destroyed 1430 if ( ! jQuery.isEmptyObject(thisCache) ) {1455 if ( !isEmptyDataObject(thisCache) ) { 1431 1456 return; 1432 1457 } … … 1440 1465 // Don't destroy the parent cache unless the internal data object 1441 1466 // had been the only thing left in it 1442 if ( ! jQuery.isEmptyObject(cache[ id ]) ) {1467 if ( !isEmptyDataObject(cache[ id ]) ) { 1443 1468 return; 1444 1469 } … … 1461 1486 if ( internalCache ) { 1462 1487 cache[ id ] = {}; 1488 // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery 1489 // metadata on plain JS objects when the object is serialized using 1490 // JSON.stringify 1491 if ( !isNode ) { 1492 cache[ id ].toJSON = jQuery.noop; 1493 } 1494 1463 1495 cache[ id ][ internalKey ] = internalCache; 1464 1496 … … 1589 1621 } 1590 1622 1623 // TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON 1624 // property to be considered empty objects; this property always exists in 1625 // order to make sure JSON.stringify does not expose internal metadata 1626 function isEmptyDataObject( obj ) { 1627 for ( var name in obj ) { 1628 if ( name !== "toJSON" ) { 1629 return false; 1630 } 1631 } 1632 1633 return true; 1634 } 1635 1591 1636 1592 1637 … … 1889 1934 } 1890 1935 1936 // Fixes Bug #2551 -- select.val() broken in IE after form.reset() 1937 if ( one && !values.length && options.length ) { 1938 return jQuery( options[ index ] ).val(); 1939 } 1940 1891 1941 return values; 1892 1942 } … … 2082 2132 fcleanup = function( nm ) { 2083 2133 return nm.replace(rescape, "\\$&"); 2084 }, 2085 eventKey = "events"; 2134 }; 2086 2135 2087 2136 /* … … 2099 2148 } 2100 2149 2101 // For whatever reason, IE has trouble passing the window object 2102 // around, causing it to be cloned in the process 2103 if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) { 2104 elem = window; 2105 } 2150 // TODO :: Use a try/catch until it's safe to pull this out (likely 1.6) 2151 // Minor release fix for bug #8018 2152 try { 2153 // For whatever reason, IE has trouble passing the window object 2154 // around, causing it to be cloned in the process 2155 if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) { 2156 elem = window; 2157 } 2158 } 2159 catch ( e ) {} 2106 2160 2107 2161 if ( handler === false ) { … … 2109 2163 } else if ( !handler ) { 2110 2164 // Fixes bug #7229. Fix recommended by jdalton 2111 2165 return; 2112 2166 } 2113 2167 … … 2133 2187 } 2134 2188 2135 var events = elemData [ eventKey ],2189 var events = elemData.events, 2136 2190 eventHandle = elemData.handle; 2137 2191 2138 if ( typeof events === "function" ) { 2139 // On plain objects events is a fn that holds the the data 2140 // which prevents this data from being JSON serialized 2141 // the function does not need to be called, it just contains the data 2142 eventHandle = events.handle; 2143 events = events.events; 2144 2145 } else if ( !events ) { 2146 if ( !elem.nodeType ) { 2147 // On plain objects, create a fn that acts as the holder 2148 // of the values to avoid JSON serialization of event data 2149 elemData[ eventKey ] = elemData = function(){}; 2150 } 2151 2192 if ( !events ) { 2152 2193 elemData.events = events = {}; 2153 2194 } … … 2250 2291 var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, 2251 2292 elemData = jQuery.hasData( elem ) && jQuery._data( elem ), 2252 events = elemData && elemData [ eventKey ];2293 events = elemData && elemData.events; 2253 2294 2254 2295 if ( !elemData || !events ) { 2255 2296 return; 2256 }2257 2258 if ( typeof events === "function" ) {2259 elemData = events;2260 events = events.events;2261 2297 } 2262 2298 … … 2360 2396 delete elemData.handle; 2361 2397 2362 if ( typeof elemData === "function" ) { 2363 jQuery.removeData( elem, eventKey, true ); 2364 2365 } else if ( jQuery.isEmptyObject( elemData ) ) { 2398 if ( jQuery.isEmptyObject( elemData ) ) { 2366 2399 jQuery.removeData( elem, undefined, true ); 2367 2400 } … … 2404 2437 var internalKey = jQuery.expando, 2405 2438 internalCache = this[ internalKey ]; 2406 if ( internalCache && internalCache.events && internalCache.events[ type] ) {2439 if ( internalCache && internalCache.events && internalCache.events[ type ] ) { 2407 2440 jQuery.event.trigger( event, data, internalCache.handle.elem ); 2408 2441 } … … 2430 2463 2431 2464 // Trigger the event, it is assumed that "handle" is a function 2432 var handle = elem.nodeType ? 2433 jQuery._data( elem, "handle" ) : 2434 (jQuery._data( elem, eventKey ) || {}).handle; 2465 var handle = jQuery._data( elem, "handle" ); 2435 2466 2436 2467 if ( handle ) { … … 2510 2541 event.namespace = event.namespace || namespace_sort.join("."); 2511 2542 2512 events = jQuery._data(this, eventKey); 2513 2514 if ( typeof events === "function" ) { 2515 events = events.events; 2516 } 2543 events = jQuery._data(this, "events"); 2517 2544 2518 2545 handlers = (events || {})[ event.type ]; … … 2681 2708 // Events bubbling up the document may have been marked as prevented 2682 2709 // by a handler lower down the tree; reflect the correct value. 2683 this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || 2710 this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || 2684 2711 src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse; 2685 2712 … … 2756 2783 // which we cannot access the parentNode property of 2757 2784 try { 2785 2786 // Chrome does something similar, the parentNode property 2787 // can be accessed but is null. 2788 if ( parent !== document && !parent.parentNode ) { 2789 return; 2790 } 2758 2791 // Traverse up the tree 2759 2792 while ( parent && parent !== this ) { … … 2806 2839 2807 2840 if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { 2808 e.liveFired = undefined; 2809 return trigger( "submit", this, arguments ); 2841 trigger( "submit", this, arguments ); 2810 2842 } 2811 2843 }); … … 2816 2848 2817 2849 if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { 2818 e.liveFired = undefined; 2819 return trigger( "submit", this, arguments ); 2850 trigger( "submit", this, arguments ); 2820 2851 } 2821 2852 }); … … 2880 2911 e.type = "change"; 2881 2912 e.liveFired = undefined; 2882 returnjQuery.event.trigger( e, arguments[1], elem );2913 jQuery.event.trigger( e, arguments[1], elem ); 2883 2914 } 2884 2915 }; … … 2894 2925 2895 2926 if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) { 2896 returntestChange.call( this, e );2927 testChange.call( this, e ); 2897 2928 } 2898 2929 }, … … 2906 2937 (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || 2907 2938 type === "select-multiple" ) { 2908 returntestChange.call( this, e );2939 testChange.call( this, e ); 2909 2940 } 2910 2941 }, … … 2945 2976 2946 2977 function trigger( type, elem, args ) { 2947 args[0].type = type; 2948 return jQuery.event.handle.apply( elem, args ); 2978 // Piggyback on a donor event to simulate a different one. 2979 // Fake originalEvent to avoid donor's stopPropagation, but if the 2980 // simulated event prevents default then we do the same on the donor. 2981 // Don't pass args or remember liveFired; they apply to the donor event. 2982 var event = jQuery.extend( {}, args[ 0 ] ); 2983 event.type = type; 2984 event.originalEvent = {}; 2985 event.liveFired = undefined; 2986 jQuery.event.handle.call( elem, event ); 2987 if ( event.isDefaultPrevented() ) { 2988 args[ 0 ].preventDefault(); 2989 } 2949 2990 } 2950 2991 … … 2955 2996 setup: function() { 2956 2997 this.addEventListener( orig, handler, true ); 2957 }, 2958 teardown: function() { 2998 }, 2999 teardown: function() { 2959 3000 this.removeEventListener( orig, handler, true ); 2960 3001 } … … 3149 3190 elems = [], 3150 3191 selectors = [], 3151 events = jQuery._data( this, eventKey ); 3152 3153 if ( typeof events === "function" ) { 3154 events = events.events; 3155 } 3192 events = jQuery._data( this, "events" ); 3156 3193 3157 3194 // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911) … … 3187 3224 handleObj = live[j]; 3188 3225 3189 if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) {3226 if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) { 3190 3227 elem = close.elem; 3191 3228 related = null; … … 3270 3307 toString = Object.prototype.toString, 3271 3308 hasDuplicate = false, 3272 baseHasDuplicate = true; 3309 baseHasDuplicate = true, 3310 rBackslash = /\\/g, 3311 rNonWord = /\W/; 3273 3312 3274 3313 // Here we check if the JavaScript engine is using some sort of … … 3469 3508 3470 3509 if ( left.substr( left.length - 1 ) !== "\\" ) { 3471 match[1] = (match[1] || "").replace( /\\/g, "");3510 match[1] = (match[1] || "").replace( rBackslash, "" ); 3472 3511 set = Expr.find[ type ]( match, context, isXML ); 3473 3512 … … 3608 3647 href: function( elem ) { 3609 3648 return elem.getAttribute( "href" ); 3649 }, 3650 type: function( elem ) { 3651 return elem.getAttribute( "type" ); 3610 3652 } 3611 3653 }, … … 3614 3656 "+": function(checkSet, part){ 3615 3657 var isPartStr = typeof part === "string", 3616 isTag = isPartStr && ! /\W/.test( part ),3658 isTag = isPartStr && !rNonWord.test( part ), 3617 3659 isPartStrNotTag = isPartStr && !isTag; 3618 3660 … … 3642 3684 l = checkSet.length; 3643 3685 3644 if ( isPartStr && ! /\W/.test( part ) ) {3686 if ( isPartStr && !rNonWord.test( part ) ) { 3645 3687 part = part.toLowerCase(); 3646 3688 … … 3676 3718 checkFn = dirCheck; 3677 3719 3678 if ( typeof part === "string" && ! /\W/.test(part) ) {3720 if ( typeof part === "string" && !rNonWord.test( part ) ) { 3679 3721 part = part.toLowerCase(); 3680 3722 nodeCheck = part; … … 3690 3732 checkFn = dirCheck; 3691 3733 3692 if ( typeof part === "string" && ! /\W/.test( part ) ) {3734 if ( typeof part === "string" && !rNonWord.test( part ) ) { 3693 3735 part = part.toLowerCase(); 3694 3736 nodeCheck = part; … … 3733 3775 preFilter: { 3734 3776 CLASS: function( match, curLoop, inplace, result, not, isXML ) { 3735 match = " " + match[1].replace( /\\/g, "") + " ";3777 match = " " + match[1].replace( rBackslash, "" ) + " "; 3736 3778 3737 3779 if ( isXML ) { … … 3756 3798 3757 3799 ID: function( match ) { 3758 return match[1].replace( /\\/g, "");3800 return match[1].replace( rBackslash, "" ); 3759 3801 }, 3760 3802 3761 3803 TAG: function( match, curLoop ) { 3762 return match[1]. toLowerCase();3804 return match[1].replace( rBackslash, "" ).toLowerCase(); 3763 3805 }, 3764 3806 … … 3791 3833 3792 3834 ATTR: function( match, curLoop, inplace, result, not, isXML ) { 3793 var name = match[1] = match[1].replace( /\\/g, "");3835 var name = match[1] = match[1].replace( rBackslash, "" ); 3794 3836 3795 3837 if ( !isXML && Expr.attrMap[name] ) { … … 3798 3840 3799 3841 // Handle if an un-quoted value was used 3800 match[4] = ( match[4] || match[5] || "" ).replace( /\\/g, "");3842 match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); 3801 3843 3802 3844 if ( match[2] === "~=" ) { … … 3853 3895 // Accessing this property makes selected-by-default 3854 3896 // options in Safari work properly 3855 elem.parentNode.selectedIndex; 3897 if ( elem.parentNode ) { 3898 elem.parentNode.selectedIndex; 3899 } 3856 3900 3857 3901 return elem.selected === true; … … 3875 3919 3876 3920 text: function( elem ) { 3877 return "text" === elem.type; 3921 // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) 3922 // use getAttribute instead to test this case 3923 return "text" === elem.getAttribute( 'type' ); 3878 3924 }, 3879 3925 radio: function( elem ) { … … 4408 4454 // IE 8 doesn't work on object elements 4409 4455 } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { 4410 var old = context.getAttribute( "id" ), 4456 var oldContext = context, 4457 old = context.getAttribute( "id" ), 4411 4458 nid = old || id, 4412 4459 hasParent = context.parentNode, … … 4430 4477 } finally { 4431 4478 if ( !old ) { 4432 context.removeAttribute( "id" );4479 oldContext.removeAttribute( "id" ); 4433 4480 } 4434 4481 } … … 4846 4893 jQuery.fn[ name ] = function( until, selector ) { 4847 4894 var ret = jQuery.map( this, fn, until ), 4848 4849 4850 4851 4852 4895 // The variable 'args' was introduced in 4896 // https://github.com/jquery/jquery/commit/52a0238 4897 // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. 4898 // http://code.google.com/p/v8/issues/detail?id=1050 4899 args = slice.call(arguments); 4853 4900 4854 4901 if ( !runtil.test( name ) ) { … … 4960 5007 rhtml = /<|&#?\w+;/, 4961 5008 rnocache = /<(?:script|object|embed|option|style)/i, 4962 // checked="checked" or checked (html5)5009 // checked="checked" or checked 4963 5010 rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, 4964 5011 wrapMap = { … … 5112 5159 5113 5160 if ( elem.parentNode ) { 5114 5161 elem.parentNode.removeChild( elem ); 5115 5162 } 5116 5163 } … … 5137 5184 5138 5185 clone: function( dataAndEvents, deepDataAndEvents ) { 5139 dataAndEvents = dataAndEvents == null ? true : dataAndEvents;5186 dataAndEvents = dataAndEvents == null ? false : dataAndEvents; 5140 5187 deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; 5141 5188 … … 5306 5353 5307 5354 var internalKey = jQuery.expando, 5308 5309 5355 oldData = jQuery.data( src ), 5356 curData = jQuery.data( dest, oldData ); 5310 5357 5311 5358 // Switch to use the internal data object, if it exists, for the next … … 5321 5368 for ( var type in events ) { 5322 5369 for ( var i = 0, l = events[ type ].length; i < l; i++ ) { 5323 jQuery.event.add( dest, type , events[ type ][ i ], events[ type ][ i ].data );5370 jQuery.event.add( dest, type + ( events[ type ][ i ].namespace ? "." : "" ) + events[ type ][ i ].namespace, events[ type ][ i ], events[ type ][ i ].data ); 5324 5371 } 5325 5372 } … … 5442 5489 }); 5443 5490 5491 function getAll( elem ) { 5492 if ( "getElementsByTagName" in elem ) { 5493 return elem.getElementsByTagName( "*" ); 5494 5495 } else if ( "querySelectorAll" in elem ) { 5496 return elem.querySelectorAll( "*" ); 5497 5498 } else { 5499 return []; 5500 } 5501 } 5502 5444 5503 jQuery.extend({ 5445 5504 clone: function( elem, dataAndEvents, deepDataAndEvents ) { … … 5449 5508 i; 5450 5509 5451 if ( !jQuery.support.noCloneEvent && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { 5510 if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && 5511 (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { 5452 5512 // IE copies events bound via attachEvent when using cloneNode. 5453 5513 // Calling detachEvent on the clone will also remove the events … … 5456 5516 // guys for this hotness. 5457 5517 5518 cloneFixAttributes( elem, clone ); 5519 5458 5520 // Using Sizzle here is crazy slow, so we use getElementsByTagName 5459 5521 // instead 5460 srcElements = elem.getElementsByTagName("*");5461 destElements = clone.getElementsByTagName("*");5522 srcElements = getAll( elem ); 5523 destElements = getAll( clone ); 5462 5524 5463 5525 // Weird iteration because IE will replace the length property … … 5467 5529 cloneFixAttributes( srcElements[i], destElements[i] ); 5468 5530 } 5469 5470 cloneFixAttributes( elem, clone );5471 5531 } 5472 5532 5473 5533 // Copy the events from the original to the clone 5474 5534 if ( dataAndEvents ) { 5475 5476 5535 cloneCopyEvent( elem, clone ); 5477 5536 5478 if ( deepDataAndEvents && "getElementsByTagName" in elem ) { 5479 5480 srcElements = elem.getElementsByTagName("*"); 5481 destElements = clone.getElementsByTagName("*"); 5482 5483 if ( srcElements.length ) { 5484 for ( i = 0; srcElements[i]; ++i ) { 5485 cloneCopyEvent( srcElements[i], destElements[i] ); 5486 } 5487 } 5488 } 5489 } 5537 if ( deepDataAndEvents ) { 5538 srcElements = getAll( elem ); 5539 destElements = getAll( clone ); 5540 5541 for ( i = 0; srcElements[i]; ++i ) { 5542 cloneCopyEvent( srcElements[i], destElements[i] ); 5543 } 5544 } 5545 } 5546 5490 5547 // Return the cloned set 5491 5548 return clone; 5492 5549 }, 5493 5550 clean: function( elems, context, fragment, scripts ) { 5494 5551 context = context || document; … … 5911 5968 if ( document.documentElement.currentStyle ) { 5912 5969 currentStyle = function( elem, name ) { 5913 var left, 5970 var left, 5914 5971 ret = elem.currentStyle && elem.currentStyle[ name ], 5915 5972 rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ], … … 5989 6046 rCRLF = /\r?\n/g, 5990 6047 rhash = /#.*$/, 5991 rheaders = /^(.*?): \s*(.*?)\r?$/mg, // IE leaves an \r character at EOL6048 rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL 5992 6049 rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, 6050 // #7653, #8125, #8152: local protocol detection 6051 rlocalProtocol = /(?:^file|^widget|\-extension):$/, 5993 6052 rnoContent = /^(?:GET|HEAD)$/, 5994 6053 rprotocol = /^\/\//, … … 5998 6057 rspacesAjax = /\s+/, 5999 6058 rts = /([?&])_=[^&]*/, 6000 rurl = /^(\w+:)\/\/([^\/?#:]+)(?::(\d+))?/, 6059 rucHeaders = /(^|\-)([a-z])/g, 6060 rucHeadersFunc = function( _, $1, $2 ) { 6061 return $1 + $2.toUpperCase(); 6062 }, 6063 rurl = /^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/, 6001 6064 6002 6065 // Keep a copy of the old load method … … 6019 6082 * 3) selection will start with transport dataType and THEN go to "*" if needed 6020 6083 */ 6021 transports = {}; 6084 transports = {}, 6085 6086 // Document location 6087 ajaxLocation, 6088 6089 // Document location segments 6090 ajaxLocParts; 6091 6092 // #8138, IE may throw an exception when accessing 6093 // a field from document.location if document.domain has been set 6094 try { 6095 ajaxLocation = document.location.href; 6096 } catch( e ) { 6097 // Use the href attribute of an A element 6098 // since IE will modify it given document.location 6099 ajaxLocation = document.createElement( "a" ); 6100 ajaxLocation.href = ""; 6101 ajaxLocation = ajaxLocation.href; 6102 } 6103 6104 // Segment location into parts 6105 ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ); 6022 6106 6023 6107 // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport … … 6058 6142 6059 6143 //Base inspection function for prefilters and transports 6060 function inspectPrefiltersOrTransports( structure, options, originalOptions, j XHR,6144 function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR, 6061 6145 dataType /* internal */, inspected /* internal */ ) { 6062 6146 … … 6073 6157 6074 6158 for(; i < length && ( executeOnly || !selection ); i++ ) { 6075 selection = list[ i ]( options, originalOptions, j XHR );6159 selection = list[ i ]( options, originalOptions, jqXHR ); 6076 6160 // If we got redirected to another dataType 6077 // we try there if not done already6161 // we try there if executing only and not done already 6078 6162 if ( typeof selection === "string" ) { 6079 if ( inspected[ selection ] ) {6163 if ( !executeOnly || inspected[ selection ] ) { 6080 6164 selection = undefined; 6081 6165 } else { 6082 6166 options.dataTypes.unshift( selection ); 6083 6167 selection = inspectPrefiltersOrTransports( 6084 structure, options, originalOptions, j XHR, selection, inspected );6168 structure, options, originalOptions, jqXHR, selection, inspected ); 6085 6169 } 6086 6170 } … … 6090 6174 if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) { 6091 6175 selection = inspectPrefiltersOrTransports( 6092 structure, options, originalOptions, j XHR, "*", inspected );6176 structure, options, originalOptions, jqXHR, "*", inspected ); 6093 6177 } 6094 6178 // unnecessary when only executing (prefilters) … … 6122 6206 // We assume that it's the callback 6123 6207 callback = params; 6124 params = null;6208 params = undefined; 6125 6209 6126 6210 // Otherwise, build a param string … … 6140 6224 data: params, 6141 6225 // Complete callback (responseText is used internally) 6142 complete: function( j XHR, status, responseText ) {6143 // Store the response as specified by the j XHR object6144 responseText = j XHR.responseText;6226 complete: function( jqXHR, status, responseText ) { 6227 // Store the response as specified by the jqXHR object 6228 responseText = jqXHR.responseText; 6145 6229 // If successful, inject the HTML into all the matched elements 6146 if ( j XHR.isResolved() ) {6230 if ( jqXHR.isResolved() ) { 6147 6231 // #4825: Get the actual response in case 6148 6232 // a dataFilter is present in ajaxSettings 6149 j XHR.done(function( r ) {6233 jqXHR.done(function( r ) { 6150 6234 responseText = r; 6151 6235 }); … … 6166 6250 6167 6251 if ( callback ) { 6168 self.each( callback, [ responseText, status, j XHR ] );6252 self.each( callback, [ responseText, status, jqXHR ] ); 6169 6253 } 6170 6254 } … … 6214 6298 type = type || callback; 6215 6299 callback = data; 6216 data = null;6300 data = undefined; 6217 6301 } 6218 6302 … … 6230 6314 6231 6315 getScript: function( url, callback ) { 6232 return jQuery.get( url, null, callback, "script" );6316 return jQuery.get( url, undefined, callback, "script" ); 6233 6317 }, 6234 6318 … … 6237 6321 }, 6238 6322 6239 ajaxSetup: function( settings ) { 6240 jQuery.extend( true, jQuery.ajaxSettings, settings ); 6241 if ( settings.context ) { 6242 jQuery.ajaxSettings.context = settings.context; 6243 } 6323 // Creates a full fledged settings object into target 6324 // with both ajaxSettings and settings fields. 6325 // If target is omitted, writes into ajaxSettings. 6326 ajaxSetup: function ( target, settings ) { 6327 if ( !settings ) { 6328 // Only one parameter, we extend ajaxSettings 6329 settings = target; 6330 target = jQuery.extend( true, jQuery.ajaxSettings, settings ); 6331 } else { 6332 // target was provided, we extend into it 6333 jQuery.extend( true, target, jQuery.ajaxSettings, settings ); 6334 } 6335 // Flatten fields we don't want deep extended 6336 for( var field in { context: 1, url: 1 } ) { 6337 if ( field in settings ) { 6338 target[ field ] = settings[ field ]; 6339 } else if( field in jQuery.ajaxSettings ) { 6340 target[ field ] = jQuery.ajaxSettings[ field ]; 6341 } 6342 } 6343 return target; 6244 6344 }, 6245 6345 6246 6346 ajaxSettings: { 6247 url: location.href, 6347 url: ajaxLocation, 6348 isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), 6248 6349 global: true, 6249 6350 type: "GET", … … 6307 6408 ajax: function( url, options ) { 6308 6409 6309 // If options is not an object, 6310 // we simulate pre-1.5 signature 6311 if ( typeof options !== "object" ) { 6410 // If url is an object, simulate pre-1.5 signature 6411 if ( typeof url === "object" ) { 6312 6412 options = url; 6313 6413 url = undefined; … … 6318 6418 6319 6419 var // Create the final options object 6320 s = jQuery.extend( true, {}, jQuery.ajaxSettings, options ), 6321 // Callbacks contexts 6322 // We force the original context if it exists 6323 // or take it from jQuery.ajaxSettings otherwise 6324 // (plain objects used as context get extended) 6325 callbackContext = 6326 ( s.context = ( "context" in options ? options : jQuery.ajaxSettings ).context ) || s, 6327 globalEventContext = callbackContext === s ? jQuery.event : jQuery( callbackContext ), 6420 s = jQuery.ajaxSetup( {}, options ), 6421 // Callbacks context 6422 callbackContext = s.context || s, 6423 // Context for global events 6424 // It's the callbackContext if one was provided in the options 6425 // and if it's a DOM node or a jQuery collection 6426 globalEventContext = callbackContext !== s && 6427 ( callbackContext.nodeType || callbackContext instanceof jQuery ) ? 6428 jQuery( callbackContext ) : jQuery.event, 6328 6429 // Deferreds 6329 6430 deferred = jQuery.Deferred(), … … 6331 6432 // Status-dependent callbacks 6332 6433 statusCode = s.statusCode || {}, 6434 // ifModified key 6435 ifModifiedKey, 6333 6436 // Headers (they are sent all at once) 6334 6437 requestHeaders = {}, … … 6341 6444 timeoutTimer, 6342 6445 // Cross-domain detection vars 6343 loc = document.location,6344 protocol = loc.protocol || "http:",6345 6446 parts, 6346 // The j XHR state6447 // The jqXHR state 6347 6448 state = 0, 6449 // To know if global events are to be dispatched 6450 fireGlobals, 6348 6451 // Loop variable 6349 6452 i, 6350 6453 // Fake xhr 6351 j XHR = {6454 jqXHR = { 6352 6455 6353 6456 readyState: 0, … … 6355 6458 // Caches the header 6356 6459 setRequestHeader: function( name, value ) { 6357 if ( state === 0) {6358 requestHeaders[ name.toLowerCase() ] = value;6460 if ( !state ) { 6461 requestHeaders[ name.toLowerCase().replace( rucHeaders, rucHeadersFunc ) ] = value; 6359 6462 } 6360 6463 return this; … … 6378 6481 match = responseHeaders[ key.toLowerCase() ]; 6379 6482 } 6380 return match || null; 6483 return match === undefined ? null : match; 6484 }, 6485 6486 // Overrides response content-type header 6487 overrideMimeType: function( type ) { 6488 if ( !state ) { 6489 s.mimeType = type; 6490 } 6491 return this; 6381 6492 }, 6382 6493 … … 6395 6506 // It is defined here because jslint complains if it is declared 6396 6507 // at the end of the function (which would be more logical and readable) 6397 function done( status, statusText, responses, headers ) {6508 function done( status, statusText, responses, headers ) { 6398 6509 6399 6510 // Called once … … 6411 6522 6412 6523 // Dereference transport for early garbage collection 6413 // (no matter how long the j XHR object will be used)6524 // (no matter how long the jqXHR object will be used) 6414 6525 transport = undefined; 6415 6526 … … 6418 6529 6419 6530 // Set readyState 6420 j XHR.readyState = status ? 4 : 0;6531 jqXHR.readyState = status ? 4 : 0; 6421 6532 6422 6533 var isSuccess, 6423 6534 success, 6424 6535 error, 6425 response = responses ? ajaxHandleResponses( s, j XHR, responses ) : undefined,6536 response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined, 6426 6537 lastModified, 6427 6538 etag; … … 6433 6544 if ( s.ifModified ) { 6434 6545 6435 if ( ( lastModified = j XHR.getResponseHeader( "Last-Modified" ) ) ) {6436 jQuery.lastModified[ s.url] = lastModified;6546 if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) { 6547 jQuery.lastModified[ ifModifiedKey ] = lastModified; 6437 6548 } 6438 if ( ( etag = j XHR.getResponseHeader( "Etag" ) ) ) {6439 jQuery.etag[ s.url] = etag;6549 if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) { 6550 jQuery.etag[ ifModifiedKey ] = etag; 6440 6551 } 6441 6552 } … … 6464 6575 // then normalize statusText and status for non-aborts 6465 6576 error = statusText; 6466 if( status ) {6577 if( !statusText || status ) { 6467 6578 statusText = "error"; 6468 6579 if ( status < 0 ) { … … 6473 6584 6474 6585 // Set data for the fake xhr object 6475 j XHR.status = status;6476 j XHR.statusText = statusText;6586 jqXHR.status = status; 6587 jqXHR.statusText = statusText; 6477 6588 6478 6589 // Success/Error 6479 6590 if ( isSuccess ) { 6480 deferred.resolveWith( callbackContext, [ success, statusText, j XHR ] );6591 deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); 6481 6592 } else { 6482 deferred.rejectWith( callbackContext, [ j XHR, statusText, error ] );6593 deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); 6483 6594 } 6484 6595 6485 6596 // Status-dependent callbacks 6486 j XHR.statusCode( statusCode );6597 jqXHR.statusCode( statusCode ); 6487 6598 statusCode = undefined; 6488 6599 6489 if ( s.global) {6600 if ( fireGlobals ) { 6490 6601 globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ), 6491 [ j XHR, s, isSuccess ? success : error ] );6602 [ jqXHR, s, isSuccess ? success : error ] ); 6492 6603 } 6493 6604 6494 6605 // Complete 6495 completeDeferred.resolveWith( callbackContext, [ j XHR, statusText ] );6496 6497 if ( s.global) {6498 globalEventContext.trigger( "ajaxComplete", [ j XHR, s] );6606 completeDeferred.resolveWith( callbackContext, [ jqXHR, statusText ] ); 6607 6608 if ( fireGlobals ) { 6609 globalEventContext.trigger( "ajaxComplete", [ jqXHR, s] ); 6499 6610 // Handle the global AJAX counter 6500 6611 if ( !( --jQuery.active ) ) { … … 6505 6616 6506 6617 // Attach deferreds 6507 deferred.promise( j XHR );6508 j XHR.success = jXHR.done;6509 j XHR.error = jXHR.fail;6510 j XHR.complete = completeDeferred.done;6618 deferred.promise( jqXHR ); 6619 jqXHR.success = jqXHR.done; 6620 jqXHR.error = jqXHR.fail; 6621 jqXHR.complete = completeDeferred.done; 6511 6622 6512 6623 // Status-dependent callbacks 6513 j XHR.statusCode = function( map ) {6624 jqXHR.statusCode = function( map ) { 6514 6625 if ( map ) { 6515 6626 var tmp; … … 6519 6630 } 6520 6631 } else { 6521 tmp = map[ j XHR.status ];6522 j XHR.then( tmp, tmp );6632 tmp = map[ jqXHR.status ]; 6633 jqXHR.then( tmp, tmp ); 6523 6634 } 6524 6635 } … … 6529 6640 // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) 6530 6641 // We also use the url parameter if available 6531 s.url = ( "" + ( url || s.url ) ).replace( rhash, "" ).replace( rprotocol, protocol+ "//" );6642 s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); 6532 6643 6533 6644 // Extract dataTypes list … … 6538 6649 parts = rurl.exec( s.url.toLowerCase() ); 6539 6650 s.crossDomain = !!( parts && 6540 ( parts[ 1 ] != protocol || parts[ 2 ] != loc.hostname||6651 ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] || 6541 6652 ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) != 6542 ( loc.port || ( protocol=== "http:" ? 80 : 443 ) ) )6653 ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) ) 6543 6654 ); 6544 6655 } … … 6550 6661 6551 6662 // Apply prefilters 6552 inspectPrefiltersOrTransports( prefilters, s, options, jXHR ); 6663 inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); 6664 6665 // If request was aborted inside a prefiler, stop there 6666 if ( state === 2 ) { 6667 return false; 6668 } 6669 6670 // We can fire global events as of now if asked to 6671 fireGlobals = s.global; 6553 6672 6554 6673 // Uppercase the type … … 6559 6678 6560 6679 // Watch for a new set of requests 6561 if ( s.global&& jQuery.active++ === 0 ) {6680 if ( fireGlobals && jQuery.active++ === 0 ) { 6562 6681 jQuery.event.trigger( "ajaxStart" ); 6563 6682 } … … 6571 6690 } 6572 6691 6692 // Get ifModifiedKey before adding the anti-cache parameter 6693 ifModifiedKey = s.url; 6694 6573 6695 // Add anti-cache in url if needed 6574 6696 if ( s.cache === false ) { … … 6585 6707 // Set the correct header, if data is being sent 6586 6708 if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { 6587 requestHeaders[ " content-type" ] = s.contentType;6709 requestHeaders[ "Content-Type" ] = s.contentType; 6588 6710 } 6589 6711 6590 6712 // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. 6591 6713 if ( s.ifModified ) { 6592 if ( jQuery.lastModified[ s.url ] ) { 6593 requestHeaders[ "if-modified-since" ] = jQuery.lastModified[ s.url ]; 6594 } 6595 if ( jQuery.etag[ s.url ] ) { 6596 requestHeaders[ "if-none-match" ] = jQuery.etag[ s.url ]; 6714 ifModifiedKey = ifModifiedKey || s.url; 6715 if ( jQuery.lastModified[ ifModifiedKey ] ) { 6716 requestHeaders[ "If-Modified-Since" ] = jQuery.lastModified[ ifModifiedKey ]; 6717 } 6718 if ( jQuery.etag[ ifModifiedKey ] ) { 6719 requestHeaders[ "If-None-Match" ] = jQuery.etag[ ifModifiedKey ]; 6597 6720 } 6598 6721 } 6599 6722 6600 6723 // Set the Accepts header for the server, depending on the dataType 6601 requestHeaders. accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?6724 requestHeaders.Accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? 6602 6725 s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) : 6603 6726 s.accepts[ "*" ]; … … 6605 6728 // Check for headers option 6606 6729 for ( i in s.headers ) { 6607 requestHeaders[ i.toLowerCase() ] = s.headers[ i ];6730 jqXHR.setRequestHeader( i, s.headers[ i ] ); 6608 6731 } 6609 6732 6610 6733 // Allow custom headers/mimetypes and early abort 6611 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, j XHR, s ) === false || state === 2 ) ) {6734 if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { 6612 6735 // Abort if not done already 6613 done( 0, "abort" ); 6614 // Return false 6615 jXHR = false; 6616 6736 jqXHR.abort(); 6737 return false; 6738 6739 } 6740 6741 // Install callbacks on deferreds 6742 for ( i in { success: 1, error: 1, complete: 1 } ) { 6743 jqXHR[ i ]( s[ i ] ); 6744 } 6745 6746 // Get transport 6747 transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); 6748 6749 // If no transport, we auto-abort 6750 if ( !transport ) { 6751 done( -1, "No Transport" ); 6617 6752 } else { 6618 6619 // Install callbacks on deferreds 6620 for ( i in { success: 1, error: 1, complete: 1 } ) { 6621 jXHR[ i ]( s[ i ] ); 6622 } 6623 6624 // Get transport 6625 transport = inspectPrefiltersOrTransports( transports, s, options, jXHR ); 6626 6627 // If no transport, we auto-abort 6628 if ( !transport ) { 6629 done( -1, "No Transport" ); 6630 } else { 6631 // Set state as sending 6632 state = jXHR.readyState = 1; 6633 // Send global event 6634 if ( s.global ) { 6635 globalEventContext.trigger( "ajaxSend", [ jXHR, s ] ); 6636 } 6637 // Timeout 6638 if ( s.async && s.timeout > 0 ) { 6639 timeoutTimer = setTimeout( function(){ 6640 jXHR.abort( "timeout" ); 6641 }, s.timeout ); 6642 } 6643 6644 try { 6645 transport.send( requestHeaders, done ); 6646 } catch (e) { 6647 // Propagate exception as error if not done 6648 if ( status < 2 ) { 6649 done( -1, e ); 6650 // Simply rethrow otherwise 6651 } else { 6652 jQuery.error( e ); 6653 } 6654 } 6655 } 6656 } 6657 return jXHR; 6753 jqXHR.readyState = 1; 6754 // Send global event 6755 if ( fireGlobals ) { 6756 globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); 6757 } 6758 // Timeout 6759 if ( s.async && s.timeout > 0 ) { 6760 timeoutTimer = setTimeout( function(){ 6761 jqXHR.abort( "timeout" ); 6762 }, s.timeout ); 6763 } 6764 6765 try { 6766 state = 1; 6767 transport.send( requestHeaders, done ); 6768 } catch (e) { 6769 // Propagate exception as error if not done 6770 if ( status < 2 ) { 6771 done( -1, e ); 6772 // Simply rethrow otherwise 6773 } else { 6774 jQuery.error( e ); 6775 } 6776 } 6777 } 6778 6779 return jqXHR; 6658 6780 }, 6659 6781 … … 6674 6796 6675 6797 // If an array was passed in, assume that it is an array of form elements. 6676 if ( jQuery.isArray( a ) || a.jquery) {6798 if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { 6677 6799 // Serialize the form elements 6678 6800 jQuery.each( a, function() { … … 6721 6843 // Serialize object item. 6722 6844 } else { 6723 jQuery.each( obj, function( k, v) {6724 buildParams( prefix + "[" + k + "]", v, traditional, add );6725 } );6845 for ( var name in obj ) { 6846 buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); 6847 } 6726 6848 } 6727 6849 … … 6750 6872 * - returns the corresponding response 6751 6873 */ 6752 function ajaxHandleResponses( s, j XHR, responses ) {6874 function ajaxHandleResponses( s, jqXHR, responses ) { 6753 6875 6754 6876 var contents = s.contents, … … 6763 6885 for( type in responseFields ) { 6764 6886 if ( type in responses ) { 6765 j XHR[ responseFields[type] ] = responses[ type ];6887 jqXHR[ responseFields[type] ] = responses[ type ]; 6766 6888 } 6767 6889 } … … 6771 6893 dataTypes.shift(); 6772 6894 if ( ct === undefined ) { 6773 ct = jXHR.getResponseHeader( "content-type" );6895 ct = s.mimeType || jqXHR.getResponseHeader( "content-type" ); 6774 6896 } 6775 6897 } … … 6823 6945 6824 6946 var dataTypes = s.dataTypes, 6825 converters = s.converters,6947 converters = {}, 6826 6948 i, 6949 key, 6827 6950 length = dataTypes.length, 6828 6951 tmp, … … 6840 6963 // For each dataType in the chain 6841 6964 for( i = 1; i < length; i++ ) { 6965 6966 // Create converters map 6967 // with lowercased keys 6968 if ( i === 1 ) { 6969 for( key in s.converters ) { 6970 if( typeof key === "string" ) { 6971 converters[ key.toLowerCase() ] = s.converters[ key ]; 6972 } 6973 } 6974 } 6842 6975 6843 6976 // Get the dataTypes … … 6903 7036 6904 7037 // Detect, normalize options and install callbacks for jsonp requests 6905 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString /* internal */) {6906 6907 dataIsString = ( typeof s.data === "string" );7038 jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { 7039 7040 var dataIsString = ( typeof s.data === "string" ); 6908 7041 6909 7042 if ( s.dataTypes[ 0 ] === "jsonp" || … … 6919 7052 url = s.url, 6920 7053 data = s.data, 6921 replace = "$1" + jsonpCallback + "$2"; 7054 replace = "$1" + jsonpCallback + "$2", 7055 cleanUp = function() { 7056 // Set callback back to previous value 7057 window[ jsonpCallback ] = previous; 7058 // Call if it was a function and we have a response 7059 if ( responseContainer && jQuery.isFunction( previous ) ) { 7060 window[ jsonpCallback ]( responseContainer[ 0 ] ); 7061 } 7062 }; 6922 7063 6923 7064 if ( s.jsonp !== false ) { … … 6937 7078 s.data = data; 6938 7079 7080 // Install callback 6939 7081 window[ jsonpCallback ] = function( response ) { 6940 7082 responseContainer = [ response ]; 6941 7083 }; 6942 7084 6943 s.complete = [ function() { 6944 6945 // Set callback back to previous value 6946 window[ jsonpCallback ] = previous; 6947 6948 // Call if it was a function and we have a response 6949 if ( previous) { 6950 if ( responseContainer && jQuery.isFunction( previous ) ) { 6951 window[ jsonpCallback ] ( responseContainer[ 0 ] ); 6952 } 6953 } else { 6954 // else, more memory leak avoidance 6955 try{ 6956 delete window[ jsonpCallback ]; 6957 } catch( e ) {} 6958 } 6959 6960 }, s.complete ]; 7085 // Install cleanUp function 7086 jqXHR.then( cleanUp, cleanUp ); 6961 7087 6962 7088 // Use data converter to retrieve json after script execution 6963 7089 s.converters["script json"] = function() { 6964 if ( ! 7090 if ( !responseContainer ) { 6965 7091 jQuery.error( jsonpCallback + " was not called" ); 6966 7092 } … … 6982 7108 jQuery.ajaxSetup({ 6983 7109 accepts: { 6984 script: "text/javascript, application/javascript "7110 script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" 6985 7111 }, 6986 7112 contents: { 6987 script: /javascript /7113 script: /javascript|ecmascript/ 6988 7114 }, 6989 7115 converters: { … … 7013 7139 7014 7140 var script, 7015 head = document. getElementsByTagName( "head" )[ 0] || document.documentElement;7141 head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; 7016 7142 7017 7143 return { … … 7068 7194 7069 7195 7070 var // Next active xhr id7196 var // #5280: next active xhr id and list of active xhrs' callbacks 7071 7197 xhrId = jQuery.now(), 7072 7073 // active xhrs 7074 xhrs = {}, 7075 7076 // #5280: see below 7077 xhrUnloadAbortInstalled, 7198 xhrCallbacks, 7078 7199 7079 7200 // XHR used to determine supports properties 7080 7201 testXHR; 7202 7203 // #5280: Internet Explorer will keep connections alive if we don't abort on unload 7204 function xhrOnUnloadAbort() { 7205 jQuery( window ).unload(function() { 7206 // Abort all pending requests 7207 for ( var key in xhrCallbacks ) { 7208 xhrCallbacks[ key ]( 0, 1 ); 7209 } 7210 }); 7211 } 7212 7213 // Functions to create xhrs 7214 function createStandardXHR() { 7215 try { 7216 return new window.XMLHttpRequest(); 7217 } catch( e ) {} 7218 } 7219 7220 function createActiveXHR() { 7221 try { 7222 return new window.ActiveXObject( "Microsoft.XMLHTTP" ); 7223 } catch( e ) {} 7224 } 7081 7225 7082 7226 // Create the request object … … 7090 7234 */ 7091 7235 function() { 7092 if ( window.location.protocol !== "file:" ) { 7093 try { 7094 return new window.XMLHttpRequest(); 7095 } catch( xhrError ) {} 7096 } 7097 7098 try { 7099 return new window.ActiveXObject("Microsoft.XMLHTTP"); 7100 } catch( activeError ) {} 7236 return !this.isLocal && createStandardXHR() || createActiveXHR(); 7101 7237 } : 7102 7238 // For all other browsers, use the standard XMLHttpRequest object 7103 function() { 7104 return new window.XMLHttpRequest(); 7105 }; 7239 createStandardXHR; 7106 7240 7107 7241 // Test if we can create an xhr object 7108 try { 7109 testXHR = jQuery.ajaxSettings.xhr(); 7110 } catch( xhrCreationException ) {} 7111 7112 //Does this browser support XHR requests? 7242 testXHR = jQuery.ajaxSettings.xhr(); 7113 7243 jQuery.support.ajax = !!testXHR; 7114 7244 … … 7131 7261 send: function( headers, complete ) { 7132 7262 7133 // #5280: we need to abort on unload or IE will keep connections alive7134 if ( !xhrUnloadAbortInstalled ) {7135 7136 xhrUnloadAbortInstalled = 1;7137 7138 jQuery(window).bind( "unload", function() {7139 7140 // Abort all pending requests7141 jQuery.each( xhrs, function( _, xhr ) {7142 if ( xhr.onreadystatechange ) {7143 xhr.onreadystatechange( 1 );7144 }7145 } );7146 7147 } );7148 }7149 7150 7263 // Get a new xhr 7151 7264 var xhr = s.xhr(), 7152 handle; 7265 handle, 7266 i; 7153 7267 7154 7268 // Open the socket … … 7160 7274 } 7161 7275 7276 // Apply custom fields if provided 7277 if ( s.xhrFields ) { 7278 for ( i in s.xhrFields ) { 7279 xhr[ i ] = s.xhrFields[ i ]; 7280 } 7281 } 7282 7283 // Override mime type if needed 7284 if ( s.mimeType && xhr.overrideMimeType ) { 7285 xhr.overrideMimeType( s.mimeType ); 7286 } 7287 7162 7288 // Requested-With header 7163 7289 // Not set for crossDomain requests with no content 7164 7290 // (see why at http://trac.dojotoolkit.org/ticket/9486) 7165 7291 // Won't change header if already provided 7166 if ( !( s.crossDomain && !s.hasContent ) && !headers[" x-requested-with"] ) {7167 headers[ " x-requested-with" ] = "XMLHttpRequest";7292 if ( !( s.crossDomain && !s.hasContent ) && !headers["X-Requested-With"] ) { 7293 headers[ "X-Requested-With" ] = "XMLHttpRequest"; 7168 7294 } 7169 7295 7170 7296 // Need an extra try/catch for cross domain requests in Firefox 3 7171 7297 try { 7172 jQuery.each( headers, function( key, value) {7173 xhr.setRequestHeader( key, value);7174 } );7298 for ( i in headers ) { 7299 xhr.setRequestHeader( i, headers[ i ] ); 7300 } 7175 7301 } catch( _ ) {} 7176 7302 … … 7183 7309 callback = function( _, isAbort ) { 7184 7310 7185 // Was never called and is aborted or complete 7186 if ( callback && ( isAbort || xhr.readyState === 4 ) ) { 7187 7188 // Only called once 7189 callback = 0; 7190 7191 // Do not keep as active anymore 7192 if ( handle ) { 7193 xhr.onreadystatechange = jQuery.noop; 7194 delete xhrs[ handle ]; 7311 var status, 7312 statusText, 7313 responseHeaders, 7314 responses, 7315 xml; 7316 7317 // Firefox throws exceptions when accessing properties 7318 // of an xhr when a network error occured 7319 // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) 7320 try { 7321 7322 // Was never called and is aborted or complete 7323 if ( callback && ( isAbort || xhr.readyState === 4 ) ) { 7324 7325 // Only called once 7326 callback = undefined; 7327 7328 // Do not keep as active anymore 7329 if ( handle ) { 7330 xhr.onreadystatechange = jQuery.noop; 7331 delete xhrCallbacks[ handle ]; 7332 } 7333 7334 // If it's an abort 7335 if ( isAbort ) { 7336 // Abort it manually if needed 7337 if ( xhr.readyState !== 4 ) { 7338 xhr.abort(); 7339 } 7340 } else { 7341 status = xhr.status; 7342 responseHeaders = xhr.getAllResponseHeaders(); 7343 responses = {}; 7344 xml = xhr.responseXML; 7345 7346 // Construct response list 7347 if ( xml && xml.documentElement /* #4958 */ ) { 7348 responses.xml = xml; 7349 } 7350 responses.text = xhr.responseText; 7351 7352 // Firefox throws an exception when accessing 7353 // statusText for faulty cross-domain requests 7354 try { 7355 statusText = xhr.statusText; 7356 } catch( e ) { 7357 // We normalize with Webkit giving an empty statusText 7358 statusText = ""; 7359 } 7360 7361 // Filter status for non standard behaviors 7362 7363 // If the request is local and we have data: assume a success 7364 // (success with no data won't get notified, that's the best we 7365 // can do given current implementations) 7366 if ( !status && s.isLocal && !s.crossDomain ) { 7367 status = responses.text ? 200 : 404; 7368 // IE - #1450: sometimes returns 1223 when it should be 204 7369 } else if ( status === 1223 ) { 7370 status = 204; 7371 } 7372 } 7195 7373 } 7196 7197 // If it's an abort 7198 if ( isAbort ) { 7199 // Abort it manually if needed 7200 if ( xhr.readyState !== 4 ) { 7201 xhr.abort(); 7202 } 7203 } else { 7204 // Get info 7205 var status = xhr.status, 7206 statusText, 7207 responseHeaders = xhr.getAllResponseHeaders(), 7208 responses = {}, 7209 xml = xhr.responseXML; 7210 7211 // Construct response list 7212 if ( xml && xml.documentElement /* #4958 */ ) { 7213 responses.xml = xml; 7214 } 7215 responses.text = xhr.responseText; 7216 7217 // Firefox throws an exception when accessing 7218 // statusText for faulty cross-domain requests 7219 try { 7220 statusText = xhr.statusText; 7221 } catch( e ) { 7222 // We normalize with Webkit giving an empty statusText 7223 statusText = ""; 7224 } 7225 7226 // Filter status for non standard behaviours 7227 status = 7228 // Opera returns 0 when it should be 304 7229 // Webkit returns 0 for failing cross-domain no matter the real status 7230 status === 0 ? 7231 ( 7232 // Webkit, Firefox: filter out faulty cross-domain requests 7233 !s.crossDomain || statusText ? 7234 ( 7235 // Opera: filter out real aborts #6060 7236 responseHeaders ? 7237 304 : 7238 0 7239 ) : 7240 // We assume 302 but could be anything cross-domain related 7241 302 7242 ) : 7243 ( 7244 // IE sometimes returns 1223 when it should be 204 (see #1450) 7245 status == 1223 ? 7246 204 : 7247 status 7248 ); 7249 7250 // Call complete 7251 complete( status, statusText, responses, responseHeaders ); 7374 } catch( firefoxAccessException ) { 7375 if ( !isAbort ) { 7376 complete( -1, firefoxAccessException ); 7252 7377 } 7378 } 7379 7380 // Call complete if needed 7381 if ( responses ) { 7382 complete( status, statusText, responses, responseHeaders ); 7253 7383 } 7254 7384 }; … … 7260 7390 callback(); 7261 7391 } else { 7262 // Add to list of active xhrs 7392 // Create the active xhrs callbacks list if needed 7393 // and attach the unload handler 7394 if ( !xhrCallbacks ) { 7395 xhrCallbacks = {}; 7396 xhrOnUnloadAbort(); 7397 } 7398 // Add to list of active xhrs callbacks 7263 7399 handle = xhrId++; 7264 xhrs[ handle ] = xhr; 7265 xhr.onreadystatechange = callback; 7400 xhr.onreadystatechange = xhrCallbacks[ handle ] = callback; 7266 7401 } 7267 7402 }, … … 7465 7600 } else { 7466 7601 var parts = rfxnum.exec(val), 7467 start = e.cur() || 0;7602 start = e.cur(); 7468 7603 7469 7604 if ( parts ) { 7470 7605 var end = parseFloat( parts[2] ), 7471 unit = parts[3] || "px";7606 unit = parts[3] || ( jQuery.cssNumber[ name ] ? "" : "px" ); 7472 7607 7473 7608 // We need to compute starting value … … 7616 7751 } 7617 7752 7618 var r = parseFloat( jQuery.css( this.elem, this.prop ) ); 7619 return r || 0; 7753 var parsed, 7754 r = jQuery.css( this.elem, this.prop ); 7755 // Empty strings, null, undefined and "auto" are converted to 0, 7756 // complex values such as "rotate(1rad)" are returned as is, 7757 // simple values such as "10px" are parsed to Float. 7758 return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed; 7620 7759 }, 7621 7760 … … 7628 7767 this.start = from; 7629 7768 this.end = to; 7630 this.unit = unit || this.unit || "px";7769 this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" ); 7631 7770 this.now = this.start; 7632 7771 this.pos = this.state = 0; … … 8079 8218 win.scrollTo( 8080 8219 !i ? val : jQuery(win).scrollLeft(), 8081 8220 i ? val : jQuery(win).scrollTop() 8082 8221 ); 8083 8222 … … 8174 8313 8175 8314 8315 window.jQuery = window.$ = jQuery; 8176 8316 })(window);
Note: See TracChangeset
for help on using the changeset viewer.