Skip to content
Snippets Groups Projects
jquery.js 242 KiB
Newer Older
  • Learn to ignore specific revisions
  • Martin Poirier's avatar
    Martin Poirier committed
    2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000
    
    	_mark: function( elem, type ) {
    		if ( elem ) {
    			type = ( type || "fx" ) + "mark";
    			jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 );
    		}
    	},
    
    	_unmark: function( force, elem, type ) {
    		if ( force !== true ) {
    			type = elem;
    			elem = force;
    			force = false;
    		}
    		if ( elem ) {
    			type = type || "fx";
    			var key = type + "mark",
    				count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 );
    			if ( count ) {
    				jQuery._data( elem, key, count );
    			} else {
    				jQuery.removeData( elem, key, true );
    				handleQueueMarkDefer( elem, type, "mark" );
    			}
    		}
    	},
    
    	queue: function( elem, type, data ) {
    		var q;
    		if ( elem ) {
    			type = ( type || "fx" ) + "queue";
    			q = jQuery._data( elem, type );
    
    			// Speed up dequeue by getting out quickly if this is just a lookup
    			if ( data ) {
    				if ( !q || jQuery.isArray(data) ) {
    					q = jQuery._data( elem, type, jQuery.makeArray(data) );
    				} else {
    					q.push( data );
    				}
    			}
    			return q || [];
    		}
    	},
    
    	dequeue: function( elem, type ) {
    		type = type || "fx";
    
    		var queue = jQuery.queue( elem, type ),
    			fn = queue.shift(),
    			hooks = {};
    
    		// If the fx queue is dequeued, always remove the progress sentinel
    		if ( fn === "inprogress" ) {
    			fn = queue.shift();
    		}
    
    		if ( fn ) {
    			// Add a progress sentinel to prevent the fx queue from being
    			// automatically dequeued
    			if ( type === "fx" ) {
    				queue.unshift( "inprogress" );
    			}
    
    			jQuery._data( elem, type + ".run", hooks );
    			fn.call( elem, function() {
    				jQuery.dequeue( elem, type );
    			}, hooks );
    		}
    
    		if ( !queue.length ) {
    			jQuery.removeData( elem, type + "queue " + type + ".run", true );
    			handleQueueMarkDefer( elem, type, "queue" );
    		}
    	}
    });
    
    jQuery.fn.extend({
    	queue: function( type, data ) {
    		if ( typeof type !== "string" ) {
    			data = type;
    			type = "fx";
    		}
    
    		if ( data === undefined ) {
    			return jQuery.queue( this[0], type );
    		}
    		return this.each(function() {
    			var queue = jQuery.queue( this, type, data );
    
    			if ( type === "fx" && queue[0] !== "inprogress" ) {
    				jQuery.dequeue( this, type );
    			}
    		});
    	},
    	dequeue: function( type ) {
    		return this.each(function() {
    			jQuery.dequeue( this, type );
    		});
    	},
    	// Based off of the plugin by Clint Helfers, with permission.
    	// http://blindsignals.com/index.php/2009/07/jquery-delay/
    	delay: function( time, type ) {
    		time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
    		type = type || "fx";
    
    		return this.queue( type, function( next, hooks ) {
    			var timeout = setTimeout( next, time );
    			hooks.stop = function() {
    				clearTimeout( timeout );
    			};
    		});
    	},
    	clearQueue: function( type ) {
    		return this.queue( type || "fx", [] );
    	},
    	// Get a promise resolved when queues of a certain type
    	// are emptied (fx is the type by default)
    	promise: function( type, object ) {
    		if ( typeof type !== "string" ) {
    			object = type;
    			type = undefined;
    		}
    		type = type || "fx";
    		var defer = jQuery.Deferred(),
    			elements = this,
    			i = elements.length,
    			count = 1,
    			deferDataKey = type + "defer",
    			queueDataKey = type + "queue",
    			markDataKey = type + "mark",
    			tmp;
    		function resolve() {
    			if ( !( --count ) ) {
    				defer.resolveWith( elements, [ elements ] );
    			}
    		}
    		while( i-- ) {
    			if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) ||
    					( jQuery.data( elements[ i ], queueDataKey, undefined, true ) ||
    						jQuery.data( elements[ i ], markDataKey, undefined, true ) ) &&
    					jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) {
    				count++;
    				tmp.add( resolve );
    			}
    		}
    		resolve();
    		return defer.promise();
    	}
    });
    
    
    
    
    var rclass = /[\n\t\r]/g,
    	rspace = /\s+/,
    	rreturn = /\r/g,
    	rtype = /^(?:button|input)$/i,
    	rfocusable = /^(?:button|input|object|select|textarea)$/i,
    	rclickable = /^a(?:rea)?$/i,
    	rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,
    	getSetAttribute = jQuery.support.getSetAttribute,
    	nodeHook, boolHook, fixSpecified;
    
    jQuery.fn.extend({
    	attr: function( name, value ) {
    		return jQuery.access( this, name, value, true, jQuery.attr );
    	},
    
    	removeAttr: function( name ) {
    		return this.each(function() {
    			jQuery.removeAttr( this, name );
    		});
    	},
    
    	prop: function( name, value ) {
    		return jQuery.access( this, name, value, true, jQuery.prop );
    	},
    
    	removeProp: function( name ) {
    		name = jQuery.propFix[ name ] || name;
    		return this.each(function() {
    			// try/catch handles cases where IE balks (such as removing a property on window)
    			try {
    				this[ name ] = undefined;
    				delete this[ name ];
    			} catch( e ) {}
    		});
    	},
    
    	addClass: function( value ) {
    		var classNames, i, l, elem,
    			setClass, c, cl;
    
    		if ( jQuery.isFunction( value ) ) {
    			return this.each(function( j ) {
    				jQuery( this ).addClass( value.call(this, j, this.className) );
    			});
    		}
    
    		if ( value && typeof value === "string" ) {
    			classNames = value.split( rspace );
    
    			for ( i = 0, l = this.length; i < l; i++ ) {
    				elem = this[ i ];
    
    				if ( elem.nodeType === 1 ) {
    					if ( !elem.className && classNames.length === 1 ) {
    						elem.className = value;
    
    					} else {
    						setClass = " " + elem.className + " ";
    
    						for ( c = 0, cl = classNames.length; c < cl; c++ ) {
    							if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
    								setClass += classNames[ c ] + " ";
    							}
    						}
    						elem.className = jQuery.trim( setClass );
    					}
    				}
    			}
    		}
    
    		return this;
    	},
    
    	removeClass: function( value ) {
    		var classNames, i, l, elem, className, c, cl;
    
    		if ( jQuery.isFunction( value ) ) {
    			return this.each(function( j ) {
    				jQuery( this ).removeClass( value.call(this, j, this.className) );
    			});
    		}
    
    		if ( (value && typeof value === "string") || value === undefined ) {
    			classNames = ( value || "" ).split( rspace );
    
    			for ( i = 0, l = this.length; i < l; i++ ) {
    				elem = this[ i ];
    
    				if ( elem.nodeType === 1 && elem.className ) {
    					if ( value ) {
    						className = (" " + elem.className + " ").replace( rclass, " " );
    						for ( c = 0, cl = classNames.length; c < cl; c++ ) {
    							className = className.replace(" " + classNames[ c ] + " ", " ");
    						}
    						elem.className = jQuery.trim( className );
    
    					} else {
    						elem.className = "";
    					}
    				}
    			}
    		}
    
    		return this;
    	},
    
    	toggleClass: function( value, stateVal ) {
    		var type = typeof value,
    			isBool = typeof stateVal === "boolean";
    
    		if ( jQuery.isFunction( value ) ) {
    			return this.each(function( i ) {
    				jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal );
    			});
    		}
    
    		return this.each(function() {
    			if ( type === "string" ) {
    				// toggle individual class names
    				var className,
    					i = 0,
    					self = jQuery( this ),
    					state = stateVal,
    					classNames = value.split( rspace );
    
    				while ( (className = classNames[ i++ ]) ) {
    					// check each className given, space seperated list
    					state = isBool ? state : !self.hasClass( className );
    					self[ state ? "addClass" : "removeClass" ]( className );
    				}
    
    			} else if ( type === "undefined" || type === "boolean" ) {
    				if ( this.className ) {
    					// store className if set
    					jQuery._data( this, "__className__", this.className );
    				}
    
    				// toggle whole className
    				this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
    			}
    		});
    	},
    
    	hasClass: function( selector ) {
    		var className = " " + selector + " ",
    			i = 0,
    			l = this.length;
    		for ( ; i < l; i++ ) {
    			if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
    				return true;
    			}
    		}
    
    		return false;
    	},
    
    	val: function( value ) {
    		var hooks, ret, isFunction,
    			elem = this[0];
    
    		if ( !arguments.length ) {
    			if ( elem ) {
    				hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ];
    
    				if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) {
    					return ret;
    				}
    
    				ret = elem.value;
    
    				return typeof ret === "string" ?
    					// handle most common string cases
    					ret.replace(rreturn, "") :
    					// handle cases where value is null/undef or number
    					ret == null ? "" : ret;
    			}
    
    			return;
    		}
    
    		isFunction = jQuery.isFunction( value );
    
    		return this.each(function( i ) {
    			var self = jQuery(this), val;
    
    			if ( this.nodeType !== 1 ) {
    				return;
    			}
    
    			if ( isFunction ) {
    				val = value.call( this, i, self.val() );
    			} else {
    				val = value;
    			}
    
    			// Treat null/undefined as ""; convert numbers to string
    			if ( val == null ) {
    				val = "";
    			} else if ( typeof val === "number" ) {
    				val += "";
    			} else if ( jQuery.isArray( val ) ) {
    				val = jQuery.map(val, function ( value ) {
    					return value == null ? "" : value + "";
    				});
    			}
    
    			hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ];
    
    			// If set returns undefined, fall back to normal setting
    			if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) {
    				this.value = val;
    			}
    		});
    	}
    });
    
    jQuery.extend({
    	valHooks: {
    		option: {
    			get: function( elem ) {
    				// attributes.value is undefined in Blackberry 4.7 but
    				// uses .value. See #6932
    				var val = elem.attributes.value;
    				return !val || val.specified ? elem.value : elem.text;
    			}
    		},
    		select: {
    			get: function( elem ) {
    				var value, i, max, option,
    					index = elem.selectedIndex,
    					values = [],
    					options = elem.options,
    					one = elem.type === "select-one";
    
    				// Nothing was selected
    				if ( index < 0 ) {
    					return null;
    				}
    
    				// Loop through all the selected options
    				i = one ? index : 0;
    				max = one ? index + 1 : options.length;
    				for ( ; i < max; i++ ) {
    					option = options[ i ];
    
    					// Don't return options that are disabled or in a disabled optgroup
    					if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
    							(!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
    
    						// Get the specific value for the option
    						value = jQuery( option ).val();
    
    						// We don't need an array for one selects
    						if ( one ) {
    							return value;
    						}
    
    						// Multi-Selects return an array
    						values.push( value );
    					}
    				}
    
    				// Fixes Bug #2551 -- select.val() broken in IE after form.reset()
    				if ( one && !values.length && options.length ) {
    					return jQuery( options[ index ] ).val();
    				}
    
    				return values;
    			},
    
    			set: function( elem, value ) {
    				var values = jQuery.makeArray( value );
    
    				jQuery(elem).find("option").each(function() {
    					this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
    				});
    
    				if ( !values.length ) {
    					elem.selectedIndex = -1;
    				}
    				return values;
    			}
    		}
    	},
    
    	attrFn: {
    		val: true,
    		css: true,
    		html: true,
    		text: true,
    		data: true,
    		width: true,
    		height: true,
    		offset: true
    	},
    
    	attr: function( elem, name, value, pass ) {
    		var ret, hooks, notxml,
    			nType = elem.nodeType;
    
    		// don't get/set attributes on text, comment and attribute nodes
    		if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
    			return;
    		}
    
    		if ( pass && name in jQuery.attrFn ) {
    			return jQuery( elem )[ name ]( value );
    		}
    
    		// Fallback to prop when attributes are not supported
    		if ( typeof elem.getAttribute === "undefined" ) {
    			return jQuery.prop( elem, name, value );
    		}
    
    		notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
    
    		// All attributes are lowercase
    		// Grab necessary hook if one is defined
    		if ( notxml ) {
    			name = name.toLowerCase();
    			hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
    		}
    
    		if ( value !== undefined ) {
    
    			if ( value === null ) {
    				jQuery.removeAttr( elem, name );
    				return;
    
    			} else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
    				return ret;
    
    			} else {
    				elem.setAttribute( name, "" + value );
    				return value;
    			}
    
    		} else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
    			return ret;
    
    		} else {
    
    			ret = elem.getAttribute( name );
    
    			// Non-existent attributes return null, we normalize to undefined
    			return ret === null ?
    				undefined :
    				ret;
    		}
    	},
    
    	removeAttr: function( elem, value ) {
    		var propName, attrNames, name, l,
    			i = 0;
    
    		if ( value && elem.nodeType === 1 ) {
    			attrNames = value.toLowerCase().split( rspace );
    			l = attrNames.length;
    
    			for ( ; i < l; i++ ) {
    				name = attrNames[ i ];
    
    				if ( name ) {
    					propName = jQuery.propFix[ name ] || name;
    
    					// See #9699 for explanation of this approach (setting first, then removal)
    					jQuery.attr( elem, name, "" );
    					elem.removeAttribute( getSetAttribute ? name : propName );
    
    					// Set corresponding property to false for boolean attributes
    					if ( rboolean.test( name ) && propName in elem ) {
    						elem[ propName ] = false;
    					}
    				}
    			}
    		}
    	},
    
    	attrHooks: {
    		type: {
    			set: function( elem, value ) {
    				// We can't allow the type property to be changed (since it causes problems in IE)
    				if ( rtype.test( elem.nodeName ) && elem.parentNode ) {
    					jQuery.error( "type property can't be changed" );
    				} else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) {
    					// Setting the type on a radio button after the value resets the value in IE6-9
    					// Reset value to it's default in case type is set after value
    					// This is for element creation
    					var val = elem.value;
    					elem.setAttribute( "type", value );
    					if ( val ) {
    						elem.value = val;
    					}
    					return value;
    				}
    			}
    		},
    		// Use the value property for back compat
    		// Use the nodeHook for button elements in IE6/7 (#1954)
    		value: {
    			get: function( elem, name ) {
    				if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
    					return nodeHook.get( elem, name );
    				}
    				return name in elem ?
    					elem.value :
    					null;
    			},
    			set: function( elem, value, name ) {
    				if ( nodeHook && jQuery.nodeName( elem, "button" ) ) {
    					return nodeHook.set( elem, value, name );
    				}
    				// Does not return so that setAttribute is also used
    				elem.value = value;
    			}
    		}
    	},
    
    	propFix: {
    		tabindex: "tabIndex",
    		readonly: "readOnly",
    		"for": "htmlFor",
    		"class": "className",
    		maxlength: "maxLength",
    		cellspacing: "cellSpacing",
    		cellpadding: "cellPadding",
    		rowspan: "rowSpan",
    		colspan: "colSpan",
    		usemap: "useMap",
    		frameborder: "frameBorder",
    		contenteditable: "contentEditable"
    	},
    
    	prop: function( elem, name, value ) {
    		var ret, hooks, notxml,
    			nType = elem.nodeType;
    
    		// don't get/set properties on text, comment and attribute nodes
    		if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
    			return;
    		}
    
    		notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
    
    		if ( notxml ) {
    			// Fix name and attach hooks
    			name = jQuery.propFix[ name ] || name;
    			hooks = jQuery.propHooks[ name ];
    		}
    
    		if ( value !== undefined ) {
    			if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) {
    				return ret;
    
    			} else {
    				return ( elem[ name ] = value );
    			}
    
    		} else {
    			if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) {
    				return ret;
    
    			} else {
    				return elem[ name ];
    			}
    		}
    	},
    
    	propHooks: {
    		tabIndex: {
    			get: function( elem ) {
    				// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
    				// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
    				var attributeNode = elem.getAttributeNode("tabindex");
    
    				return attributeNode && attributeNode.specified ?
    					parseInt( attributeNode.value, 10 ) :
    					rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
    						0 :
    						undefined;
    			}
    		}
    	}
    });
    
    // Add the tabIndex propHook to attrHooks for back-compat (different case is intentional)
    jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex;
    
    // Hook for boolean attributes
    boolHook = {
    	get: function( elem, name ) {
    		// Align boolean attributes with corresponding properties
    		// Fall back to attribute presence where some booleans are not supported
    		var attrNode,
    			property = jQuery.prop( elem, name );
    		return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?
    			name.toLowerCase() :
    			undefined;
    	},
    	set: function( elem, value, name ) {
    		var propName;
    		if ( value === false ) {
    			// Remove boolean attributes when set to false
    			jQuery.removeAttr( elem, name );
    		} else {
    			// value is true since we know at this point it's type boolean and not false
    			// Set boolean attributes to the same name and set the DOM property
    			propName = jQuery.propFix[ name ] || name;
    			if ( propName in elem ) {
    				// Only set the IDL specifically if it already exists on the element
    				elem[ propName ] = true;
    			}
    
    			elem.setAttribute( name, name.toLowerCase() );
    		}
    		return name;
    	}
    };
    
    // IE6/7 do not support getting/setting some attributes with get/setAttribute
    if ( !getSetAttribute ) {
    
    	fixSpecified = {
    		name: true,
    		id: true
    	};
    
    	// Use this for any attribute in IE6/7
    	// This fixes almost every IE6/7 issue
    	nodeHook = jQuery.valHooks.button = {
    		get: function( elem, name ) {
    			var ret;
    			ret = elem.getAttributeNode( name );
    			return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ?
    				ret.nodeValue :
    				undefined;
    		},
    		set: function( elem, value, name ) {
    			// Set the existing or create a new attribute node
    			var ret = elem.getAttributeNode( name );
    			if ( !ret ) {
    				ret = document.createAttribute( name );
    				elem.setAttributeNode( ret );
    			}
    			return ( ret.nodeValue = value + "" );
    		}
    	};
    
    	// Apply the nodeHook to tabindex
    	jQuery.attrHooks.tabindex.set = nodeHook.set;
    
    	// Set width and height to auto instead of 0 on empty string( Bug #8150 )
    	// This is for removals
    	jQuery.each([ "width", "height" ], function( i, name ) {
    		jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
    			set: function( elem, value ) {
    				if ( value === "" ) {
    					elem.setAttribute( name, "auto" );
    					return value;
    				}
    			}
    		});
    	});
    
    	// Set contenteditable to false on removals(#10429)
    	// Setting to empty string throws an error as an invalid value
    	jQuery.attrHooks.contenteditable = {
    		get: nodeHook.get,
    		set: function( elem, value, name ) {
    			if ( value === "" ) {
    				value = "false";
    			}
    			nodeHook.set( elem, value, name );
    		}
    	};
    }
    
    
    // Some attributes require a special call on IE
    if ( !jQuery.support.hrefNormalized ) {
    	jQuery.each([ "href", "src", "width", "height" ], function( i, name ) {
    		jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], {
    			get: function( elem ) {
    				var ret = elem.getAttribute( name, 2 );
    				return ret === null ? undefined : ret;
    			}
    		});
    	});
    }
    
    if ( !jQuery.support.style ) {
    	jQuery.attrHooks.style = {
    		get: function( elem ) {
    			// Return undefined in the case of empty string
    			// Normalize to lowercase since IE uppercases css property names
    			return elem.style.cssText.toLowerCase() || undefined;
    		},
    		set: function( elem, value ) {
    			return ( elem.style.cssText = "" + value );
    		}
    	};
    }
    
    // Safari mis-reports the default selected property of an option
    // Accessing the parent's selectedIndex property fixes it
    if ( !jQuery.support.optSelected ) {
    	jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, {
    		get: function( elem ) {
    			var parent = elem.parentNode;
    
    			if ( parent ) {
    				parent.selectedIndex;
    
    				// Make sure that it also works with optgroups, see #5701
    				if ( parent.parentNode ) {
    					parent.parentNode.selectedIndex;
    				}
    			}
    			return null;
    		}
    	});
    }
    
    // IE6/7 call enctype encoding
    if ( !jQuery.support.enctype ) {
    	jQuery.propFix.enctype = "encoding";
    }
    
    // Radios and checkboxes getter/setter
    if ( !jQuery.support.checkOn ) {
    	jQuery.each([ "radio", "checkbox" ], function() {
    		jQuery.valHooks[ this ] = {
    			get: function( elem ) {
    				// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
    				return elem.getAttribute("value") === null ? "on" : elem.value;
    			}
    		};
    	});
    }
    jQuery.each([ "radio", "checkbox" ], function() {
    	jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], {
    		set: function( elem, value ) {
    			if ( jQuery.isArray( value ) ) {
    				return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 );
    			}
    		}
    	});
    });
    
    
    
    
    var rformElems = /^(?:textarea|input|select)$/i,
    	rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/,
    	rhoverHack = /\bhover(\.\S+)?\b/,
    	rkeyEvent = /^key/,
    	rmouseEvent = /^(?:mouse|contextmenu)|click/,
    	rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
    	rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,
    	quickParse = function( selector ) {
    		var quick = rquickIs.exec( selector );
    		if ( quick ) {
    			//   0  1    2   3
    			// [ _, tag, id, class ]
    			quick[1] = ( quick[1] || "" ).toLowerCase();
    			quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" );
    		}
    		return quick;
    	},
    	quickIs = function( elem, m ) {
    		var attrs = elem.attributes || {};
    		return (
    			(!m[1] || elem.nodeName.toLowerCase() === m[1]) &&
    			(!m[2] || (attrs.id || {}).value === m[2]) &&
    			(!m[3] || m[3].test( (attrs[ "class" ] || {}).value ))
    		);
    	},
    	hoverHack = function( events ) {
    		return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" );
    	};
    
    /*
     * Helper functions for managing events -- not part of the public interface.
     * Props to Dean Edwards' addEvent library for many of the ideas.
     */
    jQuery.event = {
    
    	add: function( elem, types, handler, data, selector ) {
    
    		var elemData, eventHandle, events,
    			t, tns, type, namespaces, handleObj,
    			handleObjIn, quick, handlers, special;
    
    		// Don't attach events to noData or text/comment nodes (allow plain objects tho)
    		if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) {
    			return;
    		}
    
    		// Caller can pass in an object of custom data in lieu of the handler
    		if ( handler.handler ) {
    			handleObjIn = handler;
    			handler = handleObjIn.handler;
    		}
    
    		// Make sure that the handler has a unique ID, used to find/remove it later
    		if ( !handler.guid ) {
    			handler.guid = jQuery.guid++;
    		}
    
    		// Init the element's event structure and main handler, if this is the first
    		events = elemData.events;
    		if ( !events ) {
    			elemData.events = events = {};
    		}
    		eventHandle = elemData.handle;
    		if ( !eventHandle ) {
    			elemData.handle = eventHandle = function( e ) {
    				// Discard the second event of a jQuery.event.trigger() and
    				// when an event is called after a page has unloaded
    				return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ?
    					jQuery.event.dispatch.apply( eventHandle.elem, arguments ) :
    					undefined;
    			};
    			// Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
    			eventHandle.elem = elem;
    		}
    
    		// Handle multiple events separated by a space
    		// jQuery(...).bind("mouseover mouseout", fn);
    		types = jQuery.trim( hoverHack(types) ).split( " " );
    		for ( t = 0; t < types.length; t++ ) {
    
    			tns = rtypenamespace.exec( types[t] ) || [];
    			type = tns[1];
    			namespaces = ( tns[2] || "" ).split( "." ).sort();
    
    			// If event changes its type, use the special event handlers for the changed type
    			special = jQuery.event.special[ type ] || {};
    
    			// If selector defined, determine special event api type, otherwise given type
    			type = ( selector ? special.delegateType : special.bindType ) || type;
    
    			// Update special based on newly reset type
    			special = jQuery.event.special[ type ] || {};
    
    			// handleObj is passed to all event handlers
    			handleObj = jQuery.extend({
    				type: type,
    				origType: tns[1],
    				data: data,
    				handler: handler,
    				guid: handler.guid,
    				selector: selector,
    				quick: quickParse( selector ),
    				namespace: namespaces.join(".")
    			}, handleObjIn );
    
    			// Init the event handler queue if we're the first
    			handlers = events[ type ];
    			if ( !handlers ) {
    				handlers = events[ type ] = [];
    				handlers.delegateCount = 0;
    
    				// Only use addEventListener/attachEvent if the special events handler returns false
    				if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
    					// Bind the global event handler to the element
    					if ( elem.addEventListener ) {
    						elem.addEventListener( type, eventHandle, false );
    
    					} else if ( elem.attachEvent ) {
    						elem.attachEvent( "on" + type, eventHandle );
    					}
    				}
    			}
    
    			if ( special.add ) {
    				special.add.call( elem, handleObj );
    
    				if ( !handleObj.handler.guid ) {
    					handleObj.handler.guid = handler.guid;
    				}
    			}
    
    			// Add to the element's handler list, delegates in front
    			if ( selector ) {
    				handlers.splice( handlers.delegateCount++, 0, handleObj );
    			} else {
    				handlers.push( handleObj );
    			}
    
    			// Keep track of which events have ever been used, for event optimization
    			jQuery.event.global[ type ] = true;
    		}
    
    		// Nullify elem to prevent memory leaks in IE
    		elem = null;
    	},
    
    	global: {},
    
    	// Detach an event or set of events from an element
    	remove: function( elem, types, handler, selector, mappedTypes ) {
    
    		var elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
    			t, tns, type, origType, namespaces, origCount,
    			j, events, special, handle, eventType, handleObj;
    
    		if ( !elemData || !(events = elemData.events) ) {
    			return;
    		}
    
    		// Once for each type.namespace in types; type may be omitted
    		types = jQuery.trim( hoverHack( types || "" ) ).split(" ");
    		for ( t = 0; t < types.length; t++ ) {
    			tns = rtypenamespace.exec( types[t] ) || [];
    			type = origType = tns[1];
    			namespaces = tns[2];
    
    			// Unbind all events (on this namespace, if provided) for the element
    			if ( !type ) {
    				for ( type in events ) {
    					jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
    				}
    				continue;
    			}
    
    			special = jQuery.event.special[ type ] || {};
    			type = ( selector? special.delegateType : special.bindType ) || type;
    			eventType = events[ type ] || [];
    			origCount = eventType.length;
    			namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null;
    
    			// Remove matching events
    			for ( j = 0; j < eventType.length; j++ ) {
    				handleObj = eventType[ j ];
    
    				if ( ( mappedTypes || origType === handleObj.origType ) &&
    					 ( !handler || handler.guid === handleObj.guid ) &&
    					 ( !namespaces || namespaces.test( handleObj.namespace ) ) &&
    					 ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
    					eventType.splice( j--, 1 );
    
    					if ( handleObj.selector ) {
    						eventType.delegateCount--;
    					}
    					if ( special.remove ) {