moel@348: /*! moel@348: * jQuery JavaScript Library v1.7.2 moel@348: * http://jquery.com/ moel@348: * moel@348: * Copyright 2011, John Resig moel@348: * Dual licensed under the MIT or GPL Version 2 licenses. moel@348: * http://jquery.org/license moel@348: * moel@348: * Includes Sizzle.js moel@348: * http://sizzlejs.com/ moel@348: * Copyright 2011, The Dojo Foundation moel@348: * Released under the MIT, BSD, and GPL Licenses. moel@348: * moel@348: * Date: Wed Mar 21 12:46:34 2012 -0700 moel@348: */ moel@348: (function( window, undefined ) { moel@348: moel@348: // Use the correct document accordingly with window argument (sandbox) moel@348: var document = window.document, moel@348: navigator = window.navigator, moel@348: location = window.location; moel@348: var jQuery = (function() { moel@348: moel@348: // Define a local copy of jQuery moel@348: var jQuery = function( selector, context ) { moel@348: // The jQuery object is actually just the init constructor 'enhanced' moel@348: return new jQuery.fn.init( selector, context, rootjQuery ); moel@348: }, moel@348: moel@348: // Map over jQuery in case of overwrite moel@348: _jQuery = window.jQuery, moel@348: moel@348: // Map over the $ in case of overwrite moel@348: _$ = window.$, moel@348: moel@348: // A central reference to the root jQuery(document) moel@348: rootjQuery, moel@348: moel@348: // A simple way to check for HTML strings or ID strings moel@348: // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) moel@348: quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, moel@348: moel@348: // Check if a string has a non-whitespace character in it moel@348: rnotwhite = /\S/, moel@348: moel@348: // Used for trimming whitespace moel@348: trimLeft = /^\s+/, moel@348: trimRight = /\s+$/, moel@348: moel@348: // Match a standalone tag moel@348: rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, moel@348: moel@348: // JSON RegExp moel@348: rvalidchars = /^[\],:{}\s]*$/, moel@348: rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, moel@348: rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, moel@348: rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, moel@348: moel@348: // Useragent RegExp moel@348: rwebkit = /(webkit)[ \/]([\w.]+)/, moel@348: ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, moel@348: rmsie = /(msie) ([\w.]+)/, moel@348: rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, moel@348: moel@348: // Matches dashed string for camelizing moel@348: rdashAlpha = /-([a-z]|[0-9])/ig, moel@348: rmsPrefix = /^-ms-/, moel@348: moel@348: // Used by jQuery.camelCase as callback to replace() moel@348: fcamelCase = function( all, letter ) { moel@348: return ( letter + "" ).toUpperCase(); moel@348: }, moel@348: moel@348: // Keep a UserAgent string for use with jQuery.browser moel@348: userAgent = navigator.userAgent, moel@348: moel@348: // For matching the engine and version of the browser moel@348: browserMatch, moel@348: moel@348: // The deferred used on DOM ready moel@348: readyList, moel@348: moel@348: // The ready event handler moel@348: DOMContentLoaded, moel@348: moel@348: // Save a reference to some core methods moel@348: toString = Object.prototype.toString, moel@348: hasOwn = Object.prototype.hasOwnProperty, moel@348: push = Array.prototype.push, moel@348: slice = Array.prototype.slice, moel@348: trim = String.prototype.trim, moel@348: indexOf = Array.prototype.indexOf, moel@348: moel@348: // [[Class]] -> type pairs moel@348: class2type = {}; moel@348: moel@348: jQuery.fn = jQuery.prototype = { moel@348: constructor: jQuery, moel@348: init: function( selector, context, rootjQuery ) { moel@348: var match, elem, ret, doc; moel@348: moel@348: // Handle $(""), $(null), or $(undefined) moel@348: if ( !selector ) { moel@348: return this; moel@348: } moel@348: moel@348: // Handle $(DOMElement) moel@348: if ( selector.nodeType ) { moel@348: this.context = this[0] = selector; moel@348: this.length = 1; moel@348: return this; moel@348: } moel@348: moel@348: // The body element only exists once, optimize finding it moel@348: if ( selector === "body" && !context && document.body ) { moel@348: this.context = document; moel@348: this[0] = document.body; moel@348: this.selector = selector; moel@348: this.length = 1; moel@348: return this; moel@348: } moel@348: moel@348: // Handle HTML strings moel@348: if ( typeof selector === "string" ) { moel@348: // Are we dealing with HTML string or an ID? moel@348: if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { moel@348: // Assume that strings that start and end with <> are HTML and skip the regex check moel@348: match = [ null, selector, null ]; moel@348: moel@348: } else { moel@348: match = quickExpr.exec( selector ); moel@348: } moel@348: moel@348: // Verify a match, and that no context was specified for #id moel@348: if ( match && (match[1] || !context) ) { moel@348: moel@348: // HANDLE: $(html) -> $(array) moel@348: if ( match[1] ) { moel@348: context = context instanceof jQuery ? context[0] : context; moel@348: doc = ( context ? context.ownerDocument || context : document ); moel@348: moel@348: // If a single string is passed in and it's a single tag moel@348: // just do a createElement and skip the rest moel@348: ret = rsingleTag.exec( selector ); moel@348: moel@348: if ( ret ) { moel@348: if ( jQuery.isPlainObject( context ) ) { moel@348: selector = [ document.createElement( ret[1] ) ]; moel@348: jQuery.fn.attr.call( selector, context, true ); moel@348: moel@348: } else { moel@348: selector = [ doc.createElement( ret[1] ) ]; moel@348: } moel@348: moel@348: } else { moel@348: ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); moel@348: selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes; moel@348: } moel@348: moel@348: return jQuery.merge( this, selector ); moel@348: moel@348: // HANDLE: $("#id") moel@348: } else { moel@348: elem = document.getElementById( match[2] ); moel@348: moel@348: // Check parentNode to catch when Blackberry 4.6 returns moel@348: // nodes that are no longer in the document #6963 moel@348: if ( elem && elem.parentNode ) { moel@348: // Handle the case where IE and Opera return items moel@348: // by name instead of ID moel@348: if ( elem.id !== match[2] ) { moel@348: return rootjQuery.find( selector ); moel@348: } moel@348: moel@348: // Otherwise, we inject the element directly into the jQuery object moel@348: this.length = 1; moel@348: this[0] = elem; moel@348: } moel@348: moel@348: this.context = document; moel@348: this.selector = selector; moel@348: return this; moel@348: } moel@348: moel@348: // HANDLE: $(expr, $(...)) moel@348: } else if ( !context || context.jquery ) { moel@348: return ( context || rootjQuery ).find( selector ); moel@348: moel@348: // HANDLE: $(expr, context) moel@348: // (which is just equivalent to: $(context).find(expr) moel@348: } else { moel@348: return this.constructor( context ).find( selector ); moel@348: } moel@348: moel@348: // HANDLE: $(function) moel@348: // Shortcut for document ready moel@348: } else if ( jQuery.isFunction( selector ) ) { moel@348: return rootjQuery.ready( selector ); moel@348: } moel@348: moel@348: if ( selector.selector !== undefined ) { moel@348: this.selector = selector.selector; moel@348: this.context = selector.context; moel@348: } moel@348: moel@348: return jQuery.makeArray( selector, this ); moel@348: }, moel@348: moel@348: // Start with an empty selector moel@348: selector: "", moel@348: moel@348: // The current version of jQuery being used moel@348: jquery: "1.7.2", moel@348: moel@348: // The default length of a jQuery object is 0 moel@348: length: 0, moel@348: moel@348: // The number of elements contained in the matched element set moel@348: size: function() { moel@348: return this.length; moel@348: }, moel@348: moel@348: toArray: function() { moel@348: return slice.call( this, 0 ); moel@348: }, moel@348: moel@348: // Get the Nth element in the matched element set OR moel@348: // Get the whole matched element set as a clean array moel@348: get: function( num ) { moel@348: return num == null ? moel@348: moel@348: // Return a 'clean' array moel@348: this.toArray() : moel@348: moel@348: // Return just the object moel@348: ( num < 0 ? this[ this.length + num ] : this[ num ] ); moel@348: }, moel@348: moel@348: // Take an array of elements and push it onto the stack moel@348: // (returning the new matched element set) moel@348: pushStack: function( elems, name, selector ) { moel@348: // Build a new jQuery matched element set moel@348: var ret = this.constructor(); moel@348: moel@348: if ( jQuery.isArray( elems ) ) { moel@348: push.apply( ret, elems ); moel@348: moel@348: } else { moel@348: jQuery.merge( ret, elems ); moel@348: } moel@348: moel@348: // Add the old object onto the stack (as a reference) moel@348: ret.prevObject = this; moel@348: moel@348: ret.context = this.context; moel@348: moel@348: if ( name === "find" ) { moel@348: ret.selector = this.selector + ( this.selector ? " " : "" ) + selector; moel@348: } else if ( name ) { moel@348: ret.selector = this.selector + "." + name + "(" + selector + ")"; moel@348: } moel@348: moel@348: // Return the newly-formed element set moel@348: return ret; moel@348: }, moel@348: moel@348: // Execute a callback for every element in the matched set. moel@348: // (You can seed the arguments with an array of args, but this is moel@348: // only used internally.) moel@348: each: function( callback, args ) { moel@348: return jQuery.each( this, callback, args ); moel@348: }, moel@348: moel@348: ready: function( fn ) { moel@348: // Attach the listeners moel@348: jQuery.bindReady(); moel@348: moel@348: // Add the callback moel@348: readyList.add( fn ); moel@348: moel@348: return this; moel@348: }, moel@348: moel@348: eq: function( i ) { moel@348: i = +i; moel@348: return i === -1 ? moel@348: this.slice( i ) : moel@348: this.slice( i, i + 1 ); moel@348: }, moel@348: moel@348: first: function() { moel@348: return this.eq( 0 ); moel@348: }, moel@348: moel@348: last: function() { moel@348: return this.eq( -1 ); moel@348: }, moel@348: moel@348: slice: function() { moel@348: return this.pushStack( slice.apply( this, arguments ), moel@348: "slice", slice.call(arguments).join(",") ); moel@348: }, moel@348: moel@348: map: function( callback ) { moel@348: return this.pushStack( jQuery.map(this, function( elem, i ) { moel@348: return callback.call( elem, i, elem ); moel@348: })); moel@348: }, moel@348: moel@348: end: function() { moel@348: return this.prevObject || this.constructor(null); moel@348: }, moel@348: moel@348: // For internal use only. moel@348: // Behaves like an Array's method, not like a jQuery method. moel@348: push: push, moel@348: sort: [].sort, moel@348: splice: [].splice moel@348: }; moel@348: moel@348: // Give the init function the jQuery prototype for later instantiation moel@348: jQuery.fn.init.prototype = jQuery.fn; moel@348: moel@348: jQuery.extend = jQuery.fn.extend = function() { moel@348: var options, name, src, copy, copyIsArray, clone, moel@348: target = arguments[0] || {}, moel@348: i = 1, moel@348: length = arguments.length, moel@348: deep = false; moel@348: moel@348: // Handle a deep copy situation moel@348: if ( typeof target === "boolean" ) { moel@348: deep = target; moel@348: target = arguments[1] || {}; moel@348: // skip the boolean and the target moel@348: i = 2; moel@348: } moel@348: moel@348: // Handle case when target is a string or something (possible in deep copy) moel@348: if ( typeof target !== "object" && !jQuery.isFunction(target) ) { moel@348: target = {}; moel@348: } moel@348: moel@348: // extend jQuery itself if only one argument is passed moel@348: if ( length === i ) { moel@348: target = this; moel@348: --i; moel@348: } moel@348: moel@348: for ( ; i < length; i++ ) { moel@348: // Only deal with non-null/undefined values moel@348: if ( (options = arguments[ i ]) != null ) { moel@348: // Extend the base object moel@348: for ( name in options ) { moel@348: src = target[ name ]; moel@348: copy = options[ name ]; moel@348: moel@348: // Prevent never-ending loop moel@348: if ( target === copy ) { moel@348: continue; moel@348: } moel@348: moel@348: // Recurse if we're merging plain objects or arrays moel@348: if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { moel@348: if ( copyIsArray ) { moel@348: copyIsArray = false; moel@348: clone = src && jQuery.isArray(src) ? src : []; moel@348: moel@348: } else { moel@348: clone = src && jQuery.isPlainObject(src) ? src : {}; moel@348: } moel@348: moel@348: // Never move original objects, clone them moel@348: target[ name ] = jQuery.extend( deep, clone, copy ); moel@348: moel@348: // Don't bring in undefined values moel@348: } else if ( copy !== undefined ) { moel@348: target[ name ] = copy; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Return the modified object moel@348: return target; moel@348: }; moel@348: moel@348: jQuery.extend({ moel@348: noConflict: function( deep ) { moel@348: if ( window.$ === jQuery ) { moel@348: window.$ = _$; moel@348: } moel@348: moel@348: if ( deep && window.jQuery === jQuery ) { moel@348: window.jQuery = _jQuery; moel@348: } moel@348: moel@348: return jQuery; moel@348: }, moel@348: moel@348: // Is the DOM ready to be used? Set to true once it occurs. moel@348: isReady: false, moel@348: moel@348: // A counter to track how many items to wait for before moel@348: // the ready event fires. See #6781 moel@348: readyWait: 1, moel@348: moel@348: // Hold (or release) the ready event moel@348: holdReady: function( hold ) { moel@348: if ( hold ) { moel@348: jQuery.readyWait++; moel@348: } else { moel@348: jQuery.ready( true ); moel@348: } moel@348: }, moel@348: moel@348: // Handle when the DOM is ready moel@348: ready: function( wait ) { moel@348: // Either a released hold or an DOMready/load event and not yet ready moel@348: if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { moel@348: // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). moel@348: if ( !document.body ) { moel@348: return setTimeout( jQuery.ready, 1 ); moel@348: } moel@348: moel@348: // Remember that the DOM is ready moel@348: jQuery.isReady = true; moel@348: moel@348: // If a normal DOM Ready event fired, decrement, and wait if need be moel@348: if ( wait !== true && --jQuery.readyWait > 0 ) { moel@348: return; moel@348: } moel@348: moel@348: // If there are functions bound, to execute moel@348: readyList.fireWith( document, [ jQuery ] ); moel@348: moel@348: // Trigger any bound ready events moel@348: if ( jQuery.fn.trigger ) { moel@348: jQuery( document ).trigger( "ready" ).off( "ready" ); moel@348: } moel@348: } moel@348: }, moel@348: moel@348: bindReady: function() { moel@348: if ( readyList ) { moel@348: return; moel@348: } moel@348: moel@348: readyList = jQuery.Callbacks( "once memory" ); moel@348: moel@348: // Catch cases where $(document).ready() is called after the moel@348: // browser event has already occurred. moel@348: if ( document.readyState === "complete" ) { moel@348: // Handle it asynchronously to allow scripts the opportunity to delay ready moel@348: return setTimeout( jQuery.ready, 1 ); moel@348: } moel@348: moel@348: // Mozilla, Opera and webkit nightlies currently support this event moel@348: if ( document.addEventListener ) { moel@348: // Use the handy event callback moel@348: document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); moel@348: moel@348: // A fallback to window.onload, that will always work moel@348: window.addEventListener( "load", jQuery.ready, false ); moel@348: moel@348: // If IE event model is used moel@348: } else if ( document.attachEvent ) { moel@348: // ensure firing before onload, moel@348: // maybe late but safe also for iframes moel@348: document.attachEvent( "onreadystatechange", DOMContentLoaded ); moel@348: moel@348: // A fallback to window.onload, that will always work moel@348: window.attachEvent( "onload", jQuery.ready ); moel@348: moel@348: // If IE and not a frame moel@348: // continually check to see if the document is ready moel@348: var toplevel = false; moel@348: moel@348: try { moel@348: toplevel = window.frameElement == null; moel@348: } catch(e) {} moel@348: moel@348: if ( document.documentElement.doScroll && toplevel ) { moel@348: doScrollCheck(); moel@348: } moel@348: } moel@348: }, moel@348: moel@348: // See test/unit/core.js for details concerning isFunction. moel@348: // Since version 1.3, DOM methods and functions like alert moel@348: // aren't supported. They return false on IE (#2968). moel@348: isFunction: function( obj ) { moel@348: return jQuery.type(obj) === "function"; moel@348: }, moel@348: moel@348: isArray: Array.isArray || function( obj ) { moel@348: return jQuery.type(obj) === "array"; moel@348: }, moel@348: moel@348: isWindow: function( obj ) { moel@348: return obj != null && obj == obj.window; moel@348: }, moel@348: moel@348: isNumeric: function( obj ) { moel@348: return !isNaN( parseFloat(obj) ) && isFinite( obj ); moel@348: }, moel@348: moel@348: type: function( obj ) { moel@348: return obj == null ? moel@348: String( obj ) : moel@348: class2type[ toString.call(obj) ] || "object"; moel@348: }, moel@348: moel@348: isPlainObject: function( obj ) { moel@348: // Must be an Object. moel@348: // Because of IE, we also have to check the presence of the constructor property. moel@348: // Make sure that DOM nodes and window objects don't pass through, as well moel@348: if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { moel@348: return false; moel@348: } moel@348: moel@348: try { moel@348: // Not own constructor property must be Object moel@348: if ( obj.constructor && moel@348: !hasOwn.call(obj, "constructor") && moel@348: !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { moel@348: return false; moel@348: } moel@348: } catch ( e ) { moel@348: // IE8,9 Will throw exceptions on certain host objects #9897 moel@348: return false; moel@348: } moel@348: moel@348: // Own properties are enumerated firstly, so to speed up, moel@348: // if last one is own, then all properties are own. moel@348: moel@348: var key; moel@348: for ( key in obj ) {} moel@348: moel@348: return key === undefined || hasOwn.call( obj, key ); moel@348: }, moel@348: moel@348: isEmptyObject: function( obj ) { moel@348: for ( var name in obj ) { moel@348: return false; moel@348: } moel@348: return true; moel@348: }, moel@348: moel@348: error: function( msg ) { moel@348: throw new Error( msg ); moel@348: }, moel@348: moel@348: parseJSON: function( data ) { moel@348: if ( typeof data !== "string" || !data ) { moel@348: return null; moel@348: } moel@348: moel@348: // Make sure leading/trailing whitespace is removed (IE can't handle it) moel@348: data = jQuery.trim( data ); moel@348: moel@348: // Attempt to parse using the native JSON parser first moel@348: if ( window.JSON && window.JSON.parse ) { moel@348: return window.JSON.parse( data ); moel@348: } moel@348: moel@348: // Make sure the incoming data is actual JSON moel@348: // Logic borrowed from http://json.org/json2.js moel@348: if ( rvalidchars.test( data.replace( rvalidescape, "@" ) moel@348: .replace( rvalidtokens, "]" ) moel@348: .replace( rvalidbraces, "")) ) { moel@348: moel@348: return ( new Function( "return " + data ) )(); moel@348: moel@348: } moel@348: jQuery.error( "Invalid JSON: " + data ); moel@348: }, moel@348: moel@348: // Cross-browser xml parsing moel@348: parseXML: function( data ) { moel@348: if ( typeof data !== "string" || !data ) { moel@348: return null; moel@348: } moel@348: var xml, tmp; moel@348: try { moel@348: if ( window.DOMParser ) { // Standard moel@348: tmp = new DOMParser(); moel@348: xml = tmp.parseFromString( data , "text/xml" ); moel@348: } else { // IE moel@348: xml = new ActiveXObject( "Microsoft.XMLDOM" ); moel@348: xml.async = "false"; moel@348: xml.loadXML( data ); moel@348: } moel@348: } catch( e ) { moel@348: xml = undefined; moel@348: } moel@348: if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { moel@348: jQuery.error( "Invalid XML: " + data ); moel@348: } moel@348: return xml; moel@348: }, moel@348: moel@348: noop: function() {}, moel@348: moel@348: // Evaluates a script in a global context moel@348: // Workarounds based on findings by Jim Driscoll moel@348: // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context moel@348: globalEval: function( data ) { moel@348: if ( data && rnotwhite.test( data ) ) { moel@348: // We use execScript on Internet Explorer moel@348: // We use an anonymous function so that context is window moel@348: // rather than jQuery in Firefox moel@348: ( window.execScript || function( data ) { moel@348: window[ "eval" ].call( window, data ); moel@348: } )( data ); moel@348: } moel@348: }, moel@348: moel@348: // Convert dashed to camelCase; used by the css and data modules moel@348: // Microsoft forgot to hump their vendor prefix (#9572) moel@348: camelCase: function( string ) { moel@348: return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); moel@348: }, moel@348: moel@348: nodeName: function( elem, name ) { moel@348: return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); moel@348: }, moel@348: moel@348: // args is for internal usage only moel@348: each: function( object, callback, args ) { moel@348: var name, i = 0, moel@348: length = object.length, moel@348: isObj = length === undefined || jQuery.isFunction( object ); moel@348: moel@348: if ( args ) { moel@348: if ( isObj ) { moel@348: for ( name in object ) { moel@348: if ( callback.apply( object[ name ], args ) === false ) { moel@348: break; moel@348: } moel@348: } moel@348: } else { moel@348: for ( ; i < length; ) { moel@348: if ( callback.apply( object[ i++ ], args ) === false ) { moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: moel@348: // A special, fast, case for the most common use of each moel@348: } else { moel@348: if ( isObj ) { moel@348: for ( name in object ) { moel@348: if ( callback.call( object[ name ], name, object[ name ] ) === false ) { moel@348: break; moel@348: } moel@348: } moel@348: } else { moel@348: for ( ; i < length; ) { moel@348: if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return object; moel@348: }, moel@348: moel@348: // Use native String.trim function wherever possible moel@348: trim: trim ? moel@348: function( text ) { moel@348: return text == null ? moel@348: "" : moel@348: trim.call( text ); moel@348: } : moel@348: moel@348: // Otherwise use our own trimming functionality moel@348: function( text ) { moel@348: return text == null ? moel@348: "" : moel@348: text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); moel@348: }, moel@348: moel@348: // results is for internal usage only moel@348: makeArray: function( array, results ) { moel@348: var ret = results || []; moel@348: moel@348: if ( array != null ) { moel@348: // The window, strings (and functions) also have 'length' moel@348: // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 moel@348: var type = jQuery.type( array ); moel@348: moel@348: if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { moel@348: push.call( ret, array ); moel@348: } else { moel@348: jQuery.merge( ret, array ); moel@348: } moel@348: } moel@348: moel@348: return ret; moel@348: }, moel@348: moel@348: inArray: function( elem, array, i ) { moel@348: var len; moel@348: moel@348: if ( array ) { moel@348: if ( indexOf ) { moel@348: return indexOf.call( array, elem, i ); moel@348: } moel@348: moel@348: len = array.length; moel@348: i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0; moel@348: moel@348: for ( ; i < len; i++ ) { moel@348: // Skip accessing in sparse arrays moel@348: if ( i in array && array[ i ] === elem ) { moel@348: return i; moel@348: } moel@348: } moel@348: } moel@348: moel@348: return -1; moel@348: }, moel@348: moel@348: merge: function( first, second ) { moel@348: var i = first.length, moel@348: j = 0; moel@348: moel@348: if ( typeof second.length === "number" ) { moel@348: for ( var l = second.length; j < l; j++ ) { moel@348: first[ i++ ] = second[ j ]; moel@348: } moel@348: moel@348: } else { moel@348: while ( second[j] !== undefined ) { moel@348: first[ i++ ] = second[ j++ ]; moel@348: } moel@348: } moel@348: moel@348: first.length = i; moel@348: moel@348: return first; moel@348: }, moel@348: moel@348: grep: function( elems, callback, inv ) { moel@348: var ret = [], retVal; moel@348: inv = !!inv; moel@348: moel@348: // Go through the array, only saving the items moel@348: // that pass the validator function moel@348: for ( var i = 0, length = elems.length; i < length; i++ ) { moel@348: retVal = !!callback( elems[ i ], i ); moel@348: if ( inv !== retVal ) { moel@348: ret.push( elems[ i ] ); moel@348: } moel@348: } moel@348: moel@348: return ret; moel@348: }, moel@348: moel@348: // arg is for internal usage only moel@348: map: function( elems, callback, arg ) { moel@348: var value, key, ret = [], moel@348: i = 0, moel@348: length = elems.length, moel@348: // jquery objects are treated as arrays moel@348: isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; moel@348: moel@348: // Go through the array, translating each of the items to their moel@348: if ( isArray ) { moel@348: for ( ; i < length; i++ ) { moel@348: value = callback( elems[ i ], i, arg ); moel@348: moel@348: if ( value != null ) { moel@348: ret[ ret.length ] = value; moel@348: } moel@348: } moel@348: moel@348: // Go through every key on the object, moel@348: } else { moel@348: for ( key in elems ) { moel@348: value = callback( elems[ key ], key, arg ); moel@348: moel@348: if ( value != null ) { moel@348: ret[ ret.length ] = value; moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Flatten any nested arrays moel@348: return ret.concat.apply( [], ret ); moel@348: }, moel@348: moel@348: // A global GUID counter for objects moel@348: guid: 1, moel@348: moel@348: // Bind a function to a context, optionally partially applying any moel@348: // arguments. moel@348: proxy: function( fn, context ) { moel@348: if ( typeof context === "string" ) { moel@348: var tmp = fn[ context ]; moel@348: context = fn; moel@348: fn = tmp; moel@348: } moel@348: moel@348: // Quick check to determine if target is callable, in the spec moel@348: // this throws a TypeError, but we will just return undefined. moel@348: if ( !jQuery.isFunction( fn ) ) { moel@348: return undefined; moel@348: } moel@348: moel@348: // Simulated bind moel@348: var args = slice.call( arguments, 2 ), moel@348: proxy = function() { moel@348: return fn.apply( context, args.concat( slice.call( arguments ) ) ); moel@348: }; moel@348: moel@348: // Set the guid of unique handler to the same of original handler, so it can be removed moel@348: proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; moel@348: moel@348: return proxy; moel@348: }, moel@348: moel@348: // Mutifunctional method to get and set values to a collection moel@348: // The value/s can optionally be executed if it's a function moel@348: access: function( elems, fn, key, value, chainable, emptyGet, pass ) { moel@348: var exec, moel@348: bulk = key == null, moel@348: i = 0, moel@348: length = elems.length; moel@348: moel@348: // Sets many values moel@348: if ( key && typeof key === "object" ) { moel@348: for ( i in key ) { moel@348: jQuery.access( elems, fn, i, key[i], 1, emptyGet, value ); moel@348: } moel@348: chainable = 1; moel@348: moel@348: // Sets one value moel@348: } else if ( value !== undefined ) { moel@348: // Optionally, function values get executed if exec is true moel@348: exec = pass === undefined && jQuery.isFunction( value ); moel@348: moel@348: if ( bulk ) { moel@348: // Bulk operations only iterate when executing function values moel@348: if ( exec ) { moel@348: exec = fn; moel@348: fn = function( elem, key, value ) { moel@348: return exec.call( jQuery( elem ), value ); moel@348: }; moel@348: moel@348: // Otherwise they run against the entire set moel@348: } else { moel@348: fn.call( elems, value ); moel@348: fn = null; moel@348: } moel@348: } moel@348: moel@348: if ( fn ) { moel@348: for (; i < length; i++ ) { moel@348: fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); moel@348: } moel@348: } moel@348: moel@348: chainable = 1; moel@348: } moel@348: moel@348: return chainable ? moel@348: elems : moel@348: moel@348: // Gets moel@348: bulk ? moel@348: fn.call( elems ) : moel@348: length ? fn( elems[0], key ) : emptyGet; moel@348: }, moel@348: moel@348: now: function() { moel@348: return ( new Date() ).getTime(); moel@348: }, moel@348: moel@348: // Use of jQuery.browser is frowned upon. moel@348: // More details: http://docs.jquery.com/Utilities/jQuery.browser moel@348: uaMatch: function( ua ) { moel@348: ua = ua.toLowerCase(); moel@348: moel@348: var match = rwebkit.exec( ua ) || moel@348: ropera.exec( ua ) || moel@348: rmsie.exec( ua ) || moel@348: ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || moel@348: []; moel@348: moel@348: return { browser: match[1] || "", version: match[2] || "0" }; moel@348: }, moel@348: moel@348: sub: function() { moel@348: function jQuerySub( selector, context ) { moel@348: return new jQuerySub.fn.init( selector, context ); moel@348: } moel@348: jQuery.extend( true, jQuerySub, this ); moel@348: jQuerySub.superclass = this; moel@348: jQuerySub.fn = jQuerySub.prototype = this(); moel@348: jQuerySub.fn.constructor = jQuerySub; moel@348: jQuerySub.sub = this.sub; moel@348: jQuerySub.fn.init = function init( selector, context ) { moel@348: if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { moel@348: context = jQuerySub( context ); moel@348: } moel@348: moel@348: return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); moel@348: }; moel@348: jQuerySub.fn.init.prototype = jQuerySub.fn; moel@348: var rootjQuerySub = jQuerySub(document); moel@348: return jQuerySub; moel@348: }, moel@348: moel@348: browser: {} moel@348: }); moel@348: moel@348: // Populate the class2type map moel@348: jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { moel@348: class2type[ "[object " + name + "]" ] = name.toLowerCase(); moel@348: }); moel@348: moel@348: browserMatch = jQuery.uaMatch( userAgent ); moel@348: if ( browserMatch.browser ) { moel@348: jQuery.browser[ browserMatch.browser ] = true; moel@348: jQuery.browser.version = browserMatch.version; moel@348: } moel@348: moel@348: // Deprecated, use jQuery.browser.webkit instead moel@348: if ( jQuery.browser.webkit ) { moel@348: jQuery.browser.safari = true; moel@348: } moel@348: moel@348: // IE doesn't match non-breaking spaces with \s moel@348: if ( rnotwhite.test( "\xA0" ) ) { moel@348: trimLeft = /^[\s\xA0]+/; moel@348: trimRight = /[\s\xA0]+$/; moel@348: } moel@348: moel@348: // All jQuery objects should point back to these moel@348: rootjQuery = jQuery(document); moel@348: moel@348: // Cleanup functions for the document ready method moel@348: if ( document.addEventListener ) { moel@348: DOMContentLoaded = function() { moel@348: document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); moel@348: jQuery.ready(); moel@348: }; moel@348: moel@348: } else if ( document.attachEvent ) { moel@348: DOMContentLoaded = function() { moel@348: // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). moel@348: if ( document.readyState === "complete" ) { moel@348: document.detachEvent( "onreadystatechange", DOMContentLoaded ); moel@348: jQuery.ready(); moel@348: } moel@348: }; moel@348: } moel@348: moel@348: // The DOM ready check for Internet Explorer moel@348: function doScrollCheck() { moel@348: if ( jQuery.isReady ) { moel@348: return; moel@348: } moel@348: moel@348: try { moel@348: // If IE is used, use the trick by Diego Perini moel@348: // http://javascript.nwbox.com/IEContentLoaded/ moel@348: document.documentElement.doScroll("left"); moel@348: } catch(e) { moel@348: setTimeout( doScrollCheck, 1 ); moel@348: return; moel@348: } moel@348: moel@348: // and execute any waiting functions moel@348: jQuery.ready(); moel@348: } moel@348: moel@348: return jQuery; moel@348: moel@348: })(); moel@348: moel@348: moel@348: // String to Object flags format cache moel@348: var flagsCache = {}; moel@348: moel@348: // Convert String-formatted flags into Object-formatted ones and store in cache moel@348: function createFlags( flags ) { moel@348: var object = flagsCache[ flags ] = {}, moel@348: i, length; moel@348: flags = flags.split( /\s+/ ); moel@348: for ( i = 0, length = flags.length; i < length; i++ ) { moel@348: object[ flags[i] ] = true; moel@348: } moel@348: return object; moel@348: } moel@348: moel@348: /* moel@348: * Create a callback list using the following parameters: moel@348: * moel@348: * flags: an optional list of space-separated flags that will change how moel@348: * the callback list behaves moel@348: * moel@348: * By default a callback list will act like an event callback list and can be moel@348: * "fired" multiple times. moel@348: * moel@348: * Possible flags: moel@348: * moel@348: * once: will ensure the callback list can only be fired once (like a Deferred) moel@348: * moel@348: * memory: will keep track of previous values and will call any callback added moel@348: * after the list has been fired right away with the latest "memorized" moel@348: * values (like a Deferred) moel@348: * moel@348: * unique: will ensure a callback can only be added once (no duplicate in the list) moel@348: * moel@348: * stopOnFalse: interrupt callings when a callback returns false moel@348: * moel@348: */ moel@348: jQuery.Callbacks = function( flags ) { moel@348: moel@348: // Convert flags from String-formatted to Object-formatted moel@348: // (we check in cache first) moel@348: flags = flags ? ( flagsCache[ flags ] || createFlags( flags ) ) : {}; moel@348: moel@348: var // Actual callback list moel@348: list = [], moel@348: // Stack of fire calls for repeatable lists moel@348: stack = [], moel@348: // Last fire value (for non-forgettable lists) moel@348: memory, moel@348: // Flag to know if list was already fired moel@348: fired, moel@348: // Flag to know if list is currently firing moel@348: firing, moel@348: // First callback to fire (used internally by add and fireWith) moel@348: firingStart, moel@348: // End of the loop when firing moel@348: firingLength, moel@348: // Index of currently firing callback (modified by remove if needed) moel@348: firingIndex, moel@348: // Add one or several callbacks to the list moel@348: add = function( args ) { moel@348: var i, moel@348: length, moel@348: elem, moel@348: type, moel@348: actual; moel@348: for ( i = 0, length = args.length; i < length; i++ ) { moel@348: elem = args[ i ]; moel@348: type = jQuery.type( elem ); moel@348: if ( type === "array" ) { moel@348: // Inspect recursively moel@348: add( elem ); moel@348: } else if ( type === "function" ) { moel@348: // Add if not in unique mode and callback is not in moel@348: if ( !flags.unique || !self.has( elem ) ) { moel@348: list.push( elem ); moel@348: } moel@348: } moel@348: } moel@348: }, moel@348: // Fire callbacks moel@348: fire = function( context, args ) { moel@348: args = args || []; moel@348: memory = !flags.memory || [ context, args ]; moel@348: fired = true; moel@348: firing = true; moel@348: firingIndex = firingStart || 0; moel@348: firingStart = 0; moel@348: firingLength = list.length; moel@348: for ( ; list && firingIndex < firingLength; firingIndex++ ) { moel@348: if ( list[ firingIndex ].apply( context, args ) === false && flags.stopOnFalse ) { moel@348: memory = true; // Mark as halted moel@348: break; moel@348: } moel@348: } moel@348: firing = false; moel@348: if ( list ) { moel@348: if ( !flags.once ) { moel@348: if ( stack && stack.length ) { moel@348: memory = stack.shift(); moel@348: self.fireWith( memory[ 0 ], memory[ 1 ] ); moel@348: } moel@348: } else if ( memory === true ) { moel@348: self.disable(); moel@348: } else { moel@348: list = []; moel@348: } moel@348: } moel@348: }, moel@348: // Actual Callbacks object moel@348: self = { moel@348: // Add a callback or a collection of callbacks to the list moel@348: add: function() { moel@348: if ( list ) { moel@348: var length = list.length; moel@348: add( arguments ); moel@348: // Do we need to add the callbacks to the moel@348: // current firing batch? moel@348: if ( firing ) { moel@348: firingLength = list.length; moel@348: // With memory, if we're not firing then moel@348: // we should call right away, unless previous moel@348: // firing was halted (stopOnFalse) moel@348: } else if ( memory && memory !== true ) { moel@348: firingStart = length; moel@348: fire( memory[ 0 ], memory[ 1 ] ); moel@348: } moel@348: } moel@348: return this; moel@348: }, moel@348: // Remove a callback from the list moel@348: remove: function() { moel@348: if ( list ) { moel@348: var args = arguments, moel@348: argIndex = 0, moel@348: argLength = args.length; moel@348: for ( ; argIndex < argLength ; argIndex++ ) { moel@348: for ( var i = 0; i < list.length; i++ ) { moel@348: if ( args[ argIndex ] === list[ i ] ) { moel@348: // Handle firingIndex and firingLength moel@348: if ( firing ) { moel@348: if ( i <= firingLength ) { moel@348: firingLength--; moel@348: if ( i <= firingIndex ) { moel@348: firingIndex--; moel@348: } moel@348: } moel@348: } moel@348: // Remove the element moel@348: list.splice( i--, 1 ); moel@348: // If we have some unicity property then moel@348: // we only need to do this once moel@348: if ( flags.unique ) { moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: } moel@348: return this; moel@348: }, moel@348: // Control if a given callback is in the list moel@348: has: function( fn ) { moel@348: if ( list ) { moel@348: var i = 0, moel@348: length = list.length; moel@348: for ( ; i < length; i++ ) { moel@348: if ( fn === list[ i ] ) { moel@348: return true; moel@348: } moel@348: } moel@348: } moel@348: return false; moel@348: }, moel@348: // Remove all callbacks from the list moel@348: empty: function() { moel@348: list = []; moel@348: return this; moel@348: }, moel@348: // Have the list do nothing anymore moel@348: disable: function() { moel@348: list = stack = memory = undefined; moel@348: return this; moel@348: }, moel@348: // Is it disabled? moel@348: disabled: function() { moel@348: return !list; moel@348: }, moel@348: // Lock the list in its current state moel@348: lock: function() { moel@348: stack = undefined; moel@348: if ( !memory || memory === true ) { moel@348: self.disable(); moel@348: } moel@348: return this; moel@348: }, moel@348: // Is it locked? moel@348: locked: function() { moel@348: return !stack; moel@348: }, moel@348: // Call all callbacks with the given context and arguments moel@348: fireWith: function( context, args ) { moel@348: if ( stack ) { moel@348: if ( firing ) { moel@348: if ( !flags.once ) { moel@348: stack.push( [ context, args ] ); moel@348: } moel@348: } else if ( !( flags.once && memory ) ) { moel@348: fire( context, args ); moel@348: } moel@348: } moel@348: return this; moel@348: }, moel@348: // Call all the callbacks with the given arguments moel@348: fire: function() { moel@348: self.fireWith( this, arguments ); moel@348: return this; moel@348: }, moel@348: // To know if the callbacks have already been called at least once moel@348: fired: function() { moel@348: return !!fired; moel@348: } moel@348: }; moel@348: moel@348: return self; moel@348: }; moel@348: moel@348: moel@348: moel@348: moel@348: var // Static reference to slice moel@348: sliceDeferred = [].slice; moel@348: moel@348: jQuery.extend({ moel@348: moel@348: Deferred: function( func ) { moel@348: var doneList = jQuery.Callbacks( "once memory" ), moel@348: failList = jQuery.Callbacks( "once memory" ), moel@348: progressList = jQuery.Callbacks( "memory" ), moel@348: state = "pending", moel@348: lists = { moel@348: resolve: doneList, moel@348: reject: failList, moel@348: notify: progressList moel@348: }, moel@348: promise = { moel@348: done: doneList.add, moel@348: fail: failList.add, moel@348: progress: progressList.add, moel@348: moel@348: state: function() { moel@348: return state; moel@348: }, moel@348: moel@348: // Deprecated moel@348: isResolved: doneList.fired, moel@348: isRejected: failList.fired, moel@348: moel@348: then: function( doneCallbacks, failCallbacks, progressCallbacks ) { moel@348: deferred.done( doneCallbacks ).fail( failCallbacks ).progress( progressCallbacks ); moel@348: return this; moel@348: }, moel@348: always: function() { moel@348: deferred.done.apply( deferred, arguments ).fail.apply( deferred, arguments ); moel@348: return this; moel@348: }, moel@348: pipe: function( fnDone, fnFail, fnProgress ) { moel@348: return jQuery.Deferred(function( newDefer ) { moel@348: jQuery.each( { moel@348: done: [ fnDone, "resolve" ], moel@348: fail: [ fnFail, "reject" ], moel@348: progress: [ fnProgress, "notify" ] moel@348: }, function( handler, data ) { moel@348: var fn = data[ 0 ], moel@348: action = data[ 1 ], moel@348: returned; moel@348: if ( jQuery.isFunction( fn ) ) { moel@348: deferred[ handler ](function() { moel@348: returned = fn.apply( this, arguments ); moel@348: if ( returned && jQuery.isFunction( returned.promise ) ) { moel@348: returned.promise().then( newDefer.resolve, newDefer.reject, newDefer.notify ); moel@348: } else { moel@348: newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); moel@348: } moel@348: }); moel@348: } else { moel@348: deferred[ handler ]( newDefer[ action ] ); moel@348: } moel@348: }); moel@348: }).promise(); moel@348: }, moel@348: // Get a promise for this deferred moel@348: // If obj is provided, the promise aspect is added to the object moel@348: promise: function( obj ) { moel@348: if ( obj == null ) { moel@348: obj = promise; moel@348: } else { moel@348: for ( var key in promise ) { moel@348: obj[ key ] = promise[ key ]; moel@348: } moel@348: } moel@348: return obj; moel@348: } moel@348: }, moel@348: deferred = promise.promise({}), moel@348: key; moel@348: moel@348: for ( key in lists ) { moel@348: deferred[ key ] = lists[ key ].fire; moel@348: deferred[ key + "With" ] = lists[ key ].fireWith; moel@348: } moel@348: moel@348: // Handle state moel@348: deferred.done( function() { moel@348: state = "resolved"; moel@348: }, failList.disable, progressList.lock ).fail( function() { moel@348: state = "rejected"; moel@348: }, doneList.disable, progressList.lock ); moel@348: moel@348: // Call given func if any moel@348: if ( func ) { moel@348: func.call( deferred, deferred ); moel@348: } moel@348: moel@348: // All done! moel@348: return deferred; moel@348: }, moel@348: moel@348: // Deferred helper moel@348: when: function( firstParam ) { moel@348: var args = sliceDeferred.call( arguments, 0 ), moel@348: i = 0, moel@348: length = args.length, moel@348: pValues = new Array( length ), moel@348: count = length, moel@348: pCount = length, moel@348: deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? moel@348: firstParam : moel@348: jQuery.Deferred(), moel@348: promise = deferred.promise(); moel@348: function resolveFunc( i ) { moel@348: return function( value ) { moel@348: args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; moel@348: if ( !( --count ) ) { moel@348: deferred.resolveWith( deferred, args ); moel@348: } moel@348: }; moel@348: } moel@348: function progressFunc( i ) { moel@348: return function( value ) { moel@348: pValues[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; moel@348: deferred.notifyWith( promise, pValues ); moel@348: }; moel@348: } moel@348: if ( length > 1 ) { moel@348: for ( ; i < length; i++ ) { moel@348: if ( args[ i ] && args[ i ].promise && jQuery.isFunction( args[ i ].promise ) ) { moel@348: args[ i ].promise().then( resolveFunc(i), deferred.reject, progressFunc(i) ); moel@348: } else { moel@348: --count; moel@348: } moel@348: } moel@348: if ( !count ) { moel@348: deferred.resolveWith( deferred, args ); moel@348: } moel@348: } else if ( deferred !== firstParam ) { moel@348: deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); moel@348: } moel@348: return promise; moel@348: } moel@348: }); moel@348: moel@348: moel@348: moel@348: moel@348: jQuery.support = (function() { moel@348: moel@348: var support, moel@348: all, moel@348: a, moel@348: select, moel@348: opt, moel@348: input, moel@348: fragment, moel@348: tds, moel@348: events, moel@348: eventName, moel@348: i, moel@348: isSupported, moel@348: div = document.createElement( "div" ), moel@348: documentElement = document.documentElement; moel@348: moel@348: // Preliminary tests moel@348: div.setAttribute("className", "t"); moel@348: div.innerHTML = " <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>"; moel@348: moel@348: all = div.getElementsByTagName( "*" ); moel@348: a = div.getElementsByTagName( "a" )[ 0 ]; moel@348: moel@348: // Can't get basic test support moel@348: if ( !all || !all.length || !a ) { moel@348: return {}; moel@348: } moel@348: moel@348: // First batch of supports tests moel@348: select = document.createElement( "select" ); moel@348: opt = select.appendChild( document.createElement("option") ); moel@348: input = div.getElementsByTagName( "input" )[ 0 ]; moel@348: moel@348: support = { moel@348: // IE strips leading whitespace when .innerHTML is used moel@348: leadingWhitespace: ( div.firstChild.nodeType === 3 ), moel@348: moel@348: // Make sure that tbody elements aren't automatically inserted moel@348: // IE will insert them into empty tables moel@348: tbody: !div.getElementsByTagName("tbody").length, moel@348: moel@348: // Make sure that link elements get serialized correctly by innerHTML moel@348: // This requires a wrapper element in IE moel@348: htmlSerialize: !!div.getElementsByTagName("link").length, moel@348: moel@348: // Get the style information from getAttribute moel@348: // (IE uses .cssText instead) moel@348: style: /top/.test( a.getAttribute("style") ), moel@348: moel@348: // Make sure that URLs aren't manipulated moel@348: // (IE normalizes it by default) moel@348: hrefNormalized: ( a.getAttribute("href") === "/a" ), moel@348: moel@348: // Make sure that element opacity exists moel@348: // (IE uses filter instead) moel@348: // Use a regex to work around a WebKit issue. See #5145 moel@348: opacity: /^0.55/.test( a.style.opacity ), moel@348: moel@348: // Verify style float existence moel@348: // (IE uses styleFloat instead of cssFloat) moel@348: cssFloat: !!a.style.cssFloat, moel@348: moel@348: // Make sure that if no value is specified for a checkbox moel@348: // that it defaults to "on". moel@348: // (WebKit defaults to "" instead) moel@348: checkOn: ( input.value === "on" ), moel@348: moel@348: // Make sure that a selected-by-default option has a working selected property. moel@348: // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) moel@348: optSelected: opt.selected, moel@348: moel@348: // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) moel@348: getSetAttribute: div.className !== "t", moel@348: moel@348: // Tests for enctype support on a form(#6743) moel@348: enctype: !!document.createElement("form").enctype, moel@348: moel@348: // Makes sure cloning an html5 element does not cause problems moel@348: // Where outerHTML is undefined, this still works moel@348: html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>", moel@348: moel@348: // Will be defined later moel@348: submitBubbles: true, moel@348: changeBubbles: true, moel@348: focusinBubbles: false, moel@348: deleteExpando: true, moel@348: noCloneEvent: true, moel@348: inlineBlockNeedsLayout: false, moel@348: shrinkWrapBlocks: false, moel@348: reliableMarginRight: true, moel@348: pixelMargin: true moel@348: }; moel@348: moel@348: // jQuery.boxModel DEPRECATED in 1.3, use jQuery.support.boxModel instead moel@348: jQuery.boxModel = support.boxModel = (document.compatMode === "CSS1Compat"); moel@348: moel@348: // Make sure checked status is properly cloned moel@348: input.checked = true; moel@348: support.noCloneChecked = input.cloneNode( true ).checked; moel@348: moel@348: // Make sure that the options inside disabled selects aren't marked as disabled moel@348: // (WebKit marks them as disabled) moel@348: select.disabled = true; moel@348: support.optDisabled = !opt.disabled; moel@348: moel@348: // Test to see if it's possible to delete an expando from an element moel@348: // Fails in Internet Explorer moel@348: try { moel@348: delete div.test; moel@348: } catch( e ) { moel@348: support.deleteExpando = false; moel@348: } moel@348: moel@348: if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { moel@348: div.attachEvent( "onclick", function() { moel@348: // Cloning a node shouldn't copy over any moel@348: // bound event handlers (IE does this) moel@348: support.noCloneEvent = false; moel@348: }); moel@348: div.cloneNode( true ).fireEvent( "onclick" ); moel@348: } moel@348: moel@348: // Check if a radio maintains its value moel@348: // after being appended to the DOM moel@348: input = document.createElement("input"); moel@348: input.value = "t"; moel@348: input.setAttribute("type", "radio"); moel@348: support.radioValue = input.value === "t"; moel@348: moel@348: input.setAttribute("checked", "checked"); moel@348: moel@348: // #11217 - WebKit loses check when the name is after the checked attribute moel@348: input.setAttribute( "name", "t" ); moel@348: moel@348: div.appendChild( input ); moel@348: fragment = document.createDocumentFragment(); moel@348: fragment.appendChild( div.lastChild ); moel@348: moel@348: // WebKit doesn't clone checked state correctly in fragments moel@348: support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; moel@348: moel@348: // Check if a disconnected checkbox will retain its checked moel@348: // value of true after appended to the DOM (IE6/7) moel@348: support.appendChecked = input.checked; moel@348: moel@348: fragment.removeChild( input ); moel@348: fragment.appendChild( div ); moel@348: moel@348: // Technique from Juriy Zaytsev moel@348: // http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ moel@348: // We only care about the case where non-standard event systems moel@348: // are used, namely in IE. Short-circuiting here helps us to moel@348: // avoid an eval call (in setAttribute) which can cause CSP moel@348: // to go haywire. See: https://developer.mozilla.org/en/Security/CSP moel@348: if ( div.attachEvent ) { moel@348: for ( i in { moel@348: submit: 1, moel@348: change: 1, moel@348: focusin: 1 moel@348: }) { moel@348: eventName = "on" + i; moel@348: isSupported = ( eventName in div ); moel@348: if ( !isSupported ) { moel@348: div.setAttribute( eventName, "return;" ); moel@348: isSupported = ( typeof div[ eventName ] === "function" ); moel@348: } moel@348: support[ i + "Bubbles" ] = isSupported; moel@348: } moel@348: } moel@348: moel@348: fragment.removeChild( div ); moel@348: moel@348: // Null elements to avoid leaks in IE moel@348: fragment = select = opt = div = input = null; moel@348: moel@348: // Run tests that need a body at doc ready moel@348: jQuery(function() { moel@348: var container, outer, inner, table, td, offsetSupport, moel@348: marginDiv, conMarginTop, style, html, positionTopLeftWidthHeight, moel@348: paddingMarginBorderVisibility, paddingMarginBorder, moel@348: body = document.getElementsByTagName("body")[0]; moel@348: moel@348: if ( !body ) { moel@348: // Return for frameset docs that don't have a body moel@348: return; moel@348: } moel@348: moel@348: conMarginTop = 1; moel@348: paddingMarginBorder = "padding:0;margin:0;border:"; moel@348: positionTopLeftWidthHeight = "position:absolute;top:0;left:0;width:1px;height:1px;"; moel@348: paddingMarginBorderVisibility = paddingMarginBorder + "0;visibility:hidden;"; moel@348: style = "style='" + positionTopLeftWidthHeight + paddingMarginBorder + "5px solid #000;"; moel@348: html = "<div " + style + "display:block;'><div style='" + paddingMarginBorder + "0;display:block;overflow:hidden;'></div></div>" + moel@348: "<table " + style + "' cellpadding='0' cellspacing='0'>" + moel@348: "<tr><td></td></tr></table>"; moel@348: moel@348: container = document.createElement("div"); moel@348: container.style.cssText = paddingMarginBorderVisibility + "width:0;height:0;position:static;top:0;margin-top:" + conMarginTop + "px"; moel@348: body.insertBefore( container, body.firstChild ); moel@348: moel@348: // Construct the test element moel@348: div = document.createElement("div"); moel@348: container.appendChild( div ); moel@348: moel@348: // Check if table cells still have offsetWidth/Height when they are set moel@348: // to display:none and there are still other visible table cells in a moel@348: // table row; if so, offsetWidth/Height are not reliable for use when moel@348: // determining if an element has been hidden directly using moel@348: // display:none (it is still safe to use offsets if a parent element is moel@348: // hidden; don safety goggles and see bug #4512 for more information). moel@348: // (only IE 8 fails this test) moel@348: div.innerHTML = "<table><tr><td style='" + paddingMarginBorder + "0;display:none'></td><td>t</td></tr></table>"; moel@348: tds = div.getElementsByTagName( "td" ); moel@348: isSupported = ( tds[ 0 ].offsetHeight === 0 ); moel@348: moel@348: tds[ 0 ].style.display = ""; moel@348: tds[ 1 ].style.display = "none"; moel@348: moel@348: // Check if empty table cells still have offsetWidth/Height moel@348: // (IE <= 8 fail this test) moel@348: support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); moel@348: moel@348: // Check if div with explicit width and no margin-right incorrectly moel@348: // gets computed margin-right based on width of container. For more moel@348: // info see bug #3333 moel@348: // Fails in WebKit before Feb 2011 nightlies moel@348: // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right moel@348: if ( window.getComputedStyle ) { moel@348: div.innerHTML = ""; moel@348: marginDiv = document.createElement( "div" ); moel@348: marginDiv.style.width = "0"; moel@348: marginDiv.style.marginRight = "0"; moel@348: div.style.width = "2px"; moel@348: div.appendChild( marginDiv ); moel@348: support.reliableMarginRight = moel@348: ( parseInt( ( window.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; moel@348: } moel@348: moel@348: if ( typeof div.style.zoom !== "undefined" ) { moel@348: // Check if natively block-level elements act like inline-block moel@348: // elements when setting their display to 'inline' and giving moel@348: // them layout moel@348: // (IE < 8 does this) moel@348: div.innerHTML = ""; moel@348: div.style.width = div.style.padding = "1px"; moel@348: div.style.border = 0; moel@348: div.style.overflow = "hidden"; moel@348: div.style.display = "inline"; moel@348: div.style.zoom = 1; moel@348: support.inlineBlockNeedsLayout = ( div.offsetWidth === 3 ); moel@348: moel@348: // Check if elements with layout shrink-wrap their children moel@348: // (IE 6 does this) moel@348: div.style.display = "block"; moel@348: div.style.overflow = "visible"; moel@348: div.innerHTML = "<div style='width:5px;'></div>"; moel@348: support.shrinkWrapBlocks = ( div.offsetWidth !== 3 ); moel@348: } moel@348: moel@348: div.style.cssText = positionTopLeftWidthHeight + paddingMarginBorderVisibility; moel@348: div.innerHTML = html; moel@348: moel@348: outer = div.firstChild; moel@348: inner = outer.firstChild; moel@348: td = outer.nextSibling.firstChild.firstChild; moel@348: moel@348: offsetSupport = { moel@348: doesNotAddBorder: ( inner.offsetTop !== 5 ), moel@348: doesAddBorderForTableAndCells: ( td.offsetTop === 5 ) moel@348: }; moel@348: moel@348: inner.style.position = "fixed"; moel@348: inner.style.top = "20px"; moel@348: moel@348: // safari subtracts parent border width here which is 5px moel@348: offsetSupport.fixedPosition = ( inner.offsetTop === 20 || inner.offsetTop === 15 ); moel@348: inner.style.position = inner.style.top = ""; moel@348: moel@348: outer.style.overflow = "hidden"; moel@348: outer.style.position = "relative"; moel@348: moel@348: offsetSupport.subtractsBorderForOverflowNotVisible = ( inner.offsetTop === -5 ); moel@348: offsetSupport.doesNotIncludeMarginInBodyOffset = ( body.offsetTop !== conMarginTop ); moel@348: moel@348: if ( window.getComputedStyle ) { moel@348: div.style.marginTop = "1%"; moel@348: support.pixelMargin = ( window.getComputedStyle( div, null ) || { marginTop: 0 } ).marginTop !== "1%"; moel@348: } moel@348: moel@348: if ( typeof container.style.zoom !== "undefined" ) { moel@348: container.style.zoom = 1; moel@348: } moel@348: moel@348: body.removeChild( container ); moel@348: marginDiv = div = container = null; moel@348: moel@348: jQuery.extend( support, offsetSupport ); moel@348: }); moel@348: moel@348: return support; moel@348: })(); moel@348: moel@348: moel@348: moel@348: moel@348: var rbrace = /^(?:\{.*\}|\[.*\])$/, moel@348: rmultiDash = /([A-Z])/g; moel@348: moel@348: jQuery.extend({ moel@348: cache: {}, moel@348: moel@348: // Please use with caution moel@348: uuid: 0, moel@348: moel@348: // Unique for each copy of jQuery on the page moel@348: // Non-digits removed to match rinlinejQuery moel@348: expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), moel@348: moel@348: // The following elements throw uncatchable exceptions if you moel@348: // attempt to add expando properties to them. moel@348: noData: { moel@348: "embed": true, moel@348: // Ban all objects except for Flash (which handle expandos) moel@348: "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", moel@348: "applet": true moel@348: }, moel@348: moel@348: hasData: function( elem ) { moel@348: elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; moel@348: return !!elem && !isEmptyDataObject( elem ); moel@348: }, moel@348: moel@348: data: function( elem, name, data, pvt /* Internal Use Only */ ) { moel@348: if ( !jQuery.acceptData( elem ) ) { moel@348: return; moel@348: } moel@348: moel@348: var privateCache, thisCache, ret, moel@348: internalKey = jQuery.expando, moel@348: getByName = typeof name === "string", moel@348: moel@348: // We have to handle DOM nodes and JS objects differently because IE6-7 moel@348: // can't GC object references properly across the DOM-JS boundary moel@348: isNode = elem.nodeType, moel@348: moel@348: // Only DOM nodes need the global jQuery cache; JS object data is moel@348: // attached directly to the object so GC can occur automatically moel@348: cache = isNode ? jQuery.cache : elem, moel@348: moel@348: // Only defining an ID for JS objects if its cache already exists allows moel@348: // the code to shortcut on the same path as a DOM node with no cache moel@348: id = isNode ? elem[ internalKey ] : elem[ internalKey ] && internalKey, moel@348: isEvents = name === "events"; moel@348: moel@348: // Avoid doing any more work than we need to when trying to get data on an moel@348: // object that has no data at all moel@348: if ( (!id || !cache[id] || (!isEvents && !pvt && !cache[id].data)) && getByName && data === undefined ) { moel@348: return; moel@348: } moel@348: moel@348: if ( !id ) { moel@348: // Only DOM nodes need a new unique ID for each element since their data moel@348: // ends up in the global cache moel@348: if ( isNode ) { moel@348: elem[ internalKey ] = id = ++jQuery.uuid; moel@348: } else { moel@348: id = internalKey; moel@348: } moel@348: } moel@348: moel@348: if ( !cache[ id ] ) { moel@348: cache[ id ] = {}; moel@348: moel@348: // Avoids exposing jQuery metadata on plain JS objects when the object moel@348: // is serialized using JSON.stringify moel@348: if ( !isNode ) { moel@348: cache[ id ].toJSON = jQuery.noop; moel@348: } moel@348: } moel@348: moel@348: // An object can be passed to jQuery.data instead of a key/value pair; this gets moel@348: // shallow copied over onto the existing cache moel@348: if ( typeof name === "object" || typeof name === "function" ) { moel@348: if ( pvt ) { moel@348: cache[ id ] = jQuery.extend( cache[ id ], name ); moel@348: } else { moel@348: cache[ id ].data = jQuery.extend( cache[ id ].data, name ); moel@348: } moel@348: } moel@348: moel@348: privateCache = thisCache = cache[ id ]; moel@348: moel@348: // jQuery data() is stored in a separate object inside the object's internal data moel@348: // cache in order to avoid key collisions between internal data and user-defined moel@348: // data. moel@348: if ( !pvt ) { moel@348: if ( !thisCache.data ) { moel@348: thisCache.data = {}; moel@348: } moel@348: moel@348: thisCache = thisCache.data; moel@348: } moel@348: moel@348: if ( data !== undefined ) { moel@348: thisCache[ jQuery.camelCase( name ) ] = data; moel@348: } moel@348: moel@348: // Users should not attempt to inspect the internal events object using jQuery.data, moel@348: // it is undocumented and subject to change. But does anyone listen? No. moel@348: if ( isEvents && !thisCache[ name ] ) { moel@348: return privateCache.events; moel@348: } moel@348: moel@348: // Check for both converted-to-camel and non-converted data property names moel@348: // If a data property was specified moel@348: if ( getByName ) { moel@348: moel@348: // First Try to find as-is property data moel@348: ret = thisCache[ name ]; moel@348: moel@348: // Test for null|undefined property data moel@348: if ( ret == null ) { moel@348: moel@348: // Try to find the camelCased property moel@348: ret = thisCache[ jQuery.camelCase( name ) ]; moel@348: } moel@348: } else { moel@348: ret = thisCache; moel@348: } moel@348: moel@348: return ret; moel@348: }, moel@348: moel@348: removeData: function( elem, name, pvt /* Internal Use Only */ ) { moel@348: if ( !jQuery.acceptData( elem ) ) { moel@348: return; moel@348: } moel@348: moel@348: var thisCache, i, l, moel@348: moel@348: // Reference to internal data cache key moel@348: internalKey = jQuery.expando, moel@348: moel@348: isNode = elem.nodeType, moel@348: moel@348: // See jQuery.data for more information moel@348: cache = isNode ? jQuery.cache : elem, moel@348: moel@348: // See jQuery.data for more information moel@348: id = isNode ? elem[ internalKey ] : internalKey; moel@348: moel@348: // If there is already no cache entry for this object, there is no moel@348: // purpose in continuing moel@348: if ( !cache[ id ] ) { moel@348: return; moel@348: } moel@348: moel@348: if ( name ) { moel@348: moel@348: thisCache = pvt ? cache[ id ] : cache[ id ].data; moel@348: moel@348: if ( thisCache ) { moel@348: moel@348: // Support array or space separated string names for data keys moel@348: if ( !jQuery.isArray( name ) ) { moel@348: moel@348: // try the string as a key before any manipulation moel@348: if ( name in thisCache ) { moel@348: name = [ name ]; moel@348: } else { moel@348: moel@348: // split the camel cased version by spaces unless a key with the spaces exists moel@348: name = jQuery.camelCase( name ); moel@348: if ( name in thisCache ) { moel@348: name = [ name ]; moel@348: } else { moel@348: name = name.split( " " ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: for ( i = 0, l = name.length; i < l; i++ ) { moel@348: delete thisCache[ name[i] ]; moel@348: } moel@348: moel@348: // If there is no data left in the cache, we want to continue moel@348: // and let the cache object itself get destroyed moel@348: if ( !( pvt ? isEmptyDataObject : jQuery.isEmptyObject )( thisCache ) ) { moel@348: return; moel@348: } moel@348: } moel@348: } moel@348: moel@348: // See jQuery.data for more information moel@348: if ( !pvt ) { moel@348: delete cache[ id ].data; moel@348: moel@348: // Don't destroy the parent cache unless the internal data object moel@348: // had been the only thing left in it moel@348: if ( !isEmptyDataObject(cache[ id ]) ) { moel@348: return; moel@348: } moel@348: } moel@348: moel@348: // Browsers that fail expando deletion also refuse to delete expandos on moel@348: // the window, but it will allow it on all other JS objects; other browsers moel@348: // don't care moel@348: // Ensure that `cache` is not a window object #10080 moel@348: if ( jQuery.support.deleteExpando || !cache.setInterval ) { moel@348: delete cache[ id ]; moel@348: } else { moel@348: cache[ id ] = null; moel@348: } moel@348: moel@348: // We destroyed the cache and need to eliminate the expando on the node to avoid moel@348: // false lookups in the cache for entries that no longer exist moel@348: if ( isNode ) { moel@348: // IE does not allow us to delete expando properties from nodes, moel@348: // nor does it have a removeAttribute function on Document nodes; moel@348: // we must handle all of these cases moel@348: if ( jQuery.support.deleteExpando ) { moel@348: delete elem[ internalKey ]; moel@348: } else if ( elem.removeAttribute ) { moel@348: elem.removeAttribute( internalKey ); moel@348: } else { moel@348: elem[ internalKey ] = null; moel@348: } moel@348: } moel@348: }, moel@348: moel@348: // For internal use only. moel@348: _data: function( elem, name, data ) { moel@348: return jQuery.data( elem, name, data, true ); moel@348: }, moel@348: moel@348: // A method for determining if a DOM node can handle the data expando moel@348: acceptData: function( elem ) { moel@348: if ( elem.nodeName ) { moel@348: var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; moel@348: moel@348: if ( match ) { moel@348: return !(match === true || elem.getAttribute("classid") !== match); moel@348: } moel@348: } moel@348: moel@348: return true; moel@348: } moel@348: }); moel@348: moel@348: jQuery.fn.extend({ moel@348: data: function( key, value ) { moel@348: var parts, part, attr, name, l, moel@348: elem = this[0], moel@348: i = 0, moel@348: data = null; moel@348: moel@348: // Gets all values moel@348: if ( key === undefined ) { moel@348: if ( this.length ) { moel@348: data = jQuery.data( elem ); moel@348: moel@348: if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) { moel@348: attr = elem.attributes; moel@348: for ( l = attr.length; i < l; i++ ) { moel@348: name = attr[i].name; moel@348: moel@348: if ( name.indexOf( "data-" ) === 0 ) { moel@348: name = jQuery.camelCase( name.substring(5) ); moel@348: moel@348: dataAttr( elem, name, data[ name ] ); moel@348: } moel@348: } moel@348: jQuery._data( elem, "parsedAttrs", true ); moel@348: } moel@348: } moel@348: moel@348: return data; moel@348: } moel@348: moel@348: // Sets multiple values moel@348: if ( typeof key === "object" ) { moel@348: return this.each(function() { moel@348: jQuery.data( this, key ); moel@348: }); moel@348: } moel@348: moel@348: parts = key.split( ".", 2 ); moel@348: parts[1] = parts[1] ? "." + parts[1] : ""; moel@348: part = parts[1] + "!"; moel@348: moel@348: return jQuery.access( this, function( value ) { moel@348: moel@348: if ( value === undefined ) { moel@348: data = this.triggerHandler( "getData" + part, [ parts[0] ] ); moel@348: moel@348: // Try to fetch any internally stored data first moel@348: if ( data === undefined && elem ) { moel@348: data = jQuery.data( elem, key ); moel@348: data = dataAttr( elem, key, data ); moel@348: } moel@348: moel@348: return data === undefined && parts[1] ? moel@348: this.data( parts[0] ) : moel@348: data; moel@348: } moel@348: moel@348: parts[1] = value; moel@348: this.each(function() { moel@348: var self = jQuery( this ); moel@348: moel@348: self.triggerHandler( "setData" + part, parts ); moel@348: jQuery.data( this, key, value ); moel@348: self.triggerHandler( "changeData" + part, parts ); moel@348: }); moel@348: }, null, value, arguments.length > 1, null, false ); moel@348: }, moel@348: moel@348: removeData: function( key ) { moel@348: return this.each(function() { moel@348: jQuery.removeData( this, key ); moel@348: }); moel@348: } moel@348: }); moel@348: moel@348: function dataAttr( elem, key, data ) { moel@348: // If nothing was found internally, try to fetch any moel@348: // data from the HTML5 data-* attribute moel@348: if ( data === undefined && elem.nodeType === 1 ) { moel@348: moel@348: var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); moel@348: moel@348: data = elem.getAttribute( name ); moel@348: moel@348: if ( typeof data === "string" ) { moel@348: try { moel@348: data = data === "true" ? true : moel@348: data === "false" ? false : moel@348: data === "null" ? null : moel@348: jQuery.isNumeric( data ) ? +data : moel@348: rbrace.test( data ) ? jQuery.parseJSON( data ) : moel@348: data; moel@348: } catch( e ) {} moel@348: moel@348: // Make sure we set the data so it isn't changed later moel@348: jQuery.data( elem, key, data ); moel@348: moel@348: } else { moel@348: data = undefined; moel@348: } moel@348: } moel@348: moel@348: return data; moel@348: } moel@348: moel@348: // checks a cache object for emptiness moel@348: function isEmptyDataObject( obj ) { moel@348: for ( var name in obj ) { moel@348: moel@348: // if the public data object is empty, the private is still empty moel@348: if ( name === "data" && jQuery.isEmptyObject( obj[name] ) ) { moel@348: continue; moel@348: } moel@348: if ( name !== "toJSON" ) { moel@348: return false; moel@348: } moel@348: } moel@348: moel@348: return true; moel@348: } moel@348: moel@348: moel@348: moel@348: moel@348: function handleQueueMarkDefer( elem, type, src ) { moel@348: var deferDataKey = type + "defer", moel@348: queueDataKey = type + "queue", moel@348: markDataKey = type + "mark", moel@348: defer = jQuery._data( elem, deferDataKey ); moel@348: if ( defer && moel@348: ( src === "queue" || !jQuery._data(elem, queueDataKey) ) && moel@348: ( src === "mark" || !jQuery._data(elem, markDataKey) ) ) { moel@348: // Give room for hard-coded callbacks to fire first moel@348: // and eventually mark/queue something else on the element moel@348: setTimeout( function() { moel@348: if ( !jQuery._data( elem, queueDataKey ) && moel@348: !jQuery._data( elem, markDataKey ) ) { moel@348: jQuery.removeData( elem, deferDataKey, true ); moel@348: defer.fire(); moel@348: } moel@348: }, 0 ); moel@348: } moel@348: } moel@348: moel@348: jQuery.extend({ moel@348: moel@348: _mark: function( elem, type ) { moel@348: if ( elem ) { moel@348: type = ( type || "fx" ) + "mark"; moel@348: jQuery._data( elem, type, (jQuery._data( elem, type ) || 0) + 1 ); moel@348: } moel@348: }, moel@348: moel@348: _unmark: function( force, elem, type ) { moel@348: if ( force !== true ) { moel@348: type = elem; moel@348: elem = force; moel@348: force = false; moel@348: } moel@348: if ( elem ) { moel@348: type = type || "fx"; moel@348: var key = type + "mark", moel@348: count = force ? 0 : ( (jQuery._data( elem, key ) || 1) - 1 ); moel@348: if ( count ) { moel@348: jQuery._data( elem, key, count ); moel@348: } else { moel@348: jQuery.removeData( elem, key, true ); moel@348: handleQueueMarkDefer( elem, type, "mark" ); moel@348: } moel@348: } moel@348: }, moel@348: moel@348: queue: function( elem, type, data ) { moel@348: var q; moel@348: if ( elem ) { moel@348: type = ( type || "fx" ) + "queue"; moel@348: q = jQuery._data( elem, type ); moel@348: moel@348: // Speed up dequeue by getting out quickly if this is just a lookup moel@348: if ( data ) { moel@348: if ( !q || jQuery.isArray(data) ) { moel@348: q = jQuery._data( elem, type, jQuery.makeArray(data) ); moel@348: } else { moel@348: q.push( data ); moel@348: } moel@348: } moel@348: return q || []; moel@348: } moel@348: }, moel@348: moel@348: dequeue: function( elem, type ) { moel@348: type = type || "fx"; moel@348: moel@348: var queue = jQuery.queue( elem, type ), moel@348: fn = queue.shift(), moel@348: hooks = {}; moel@348: moel@348: // If the fx queue is dequeued, always remove the progress sentinel moel@348: if ( fn === "inprogress" ) { moel@348: fn = queue.shift(); moel@348: } moel@348: moel@348: if ( fn ) { moel@348: // Add a progress sentinel to prevent the fx queue from being moel@348: // automatically dequeued moel@348: if ( type === "fx" ) { moel@348: queue.unshift( "inprogress" ); moel@348: } moel@348: moel@348: jQuery._data( elem, type + ".run", hooks ); moel@348: fn.call( elem, function() { moel@348: jQuery.dequeue( elem, type ); moel@348: }, hooks ); moel@348: } moel@348: moel@348: if ( !queue.length ) { moel@348: jQuery.removeData( elem, type + "queue " + type + ".run", true ); moel@348: handleQueueMarkDefer( elem, type, "queue" ); moel@348: } moel@348: } moel@348: }); moel@348: moel@348: jQuery.fn.extend({ moel@348: queue: function( type, data ) { moel@348: var setter = 2; moel@348: moel@348: if ( typeof type !== "string" ) { moel@348: data = type; moel@348: type = "fx"; moel@348: setter--; moel@348: } moel@348: moel@348: if ( arguments.length < setter ) { moel@348: return jQuery.queue( this[0], type ); moel@348: } moel@348: moel@348: return data === undefined ? moel@348: this : moel@348: this.each(function() { moel@348: var queue = jQuery.queue( this, type, data ); moel@348: moel@348: if ( type === "fx" && queue[0] !== "inprogress" ) { moel@348: jQuery.dequeue( this, type ); moel@348: } moel@348: }); moel@348: }, moel@348: dequeue: function( type ) { moel@348: return this.each(function() { moel@348: jQuery.dequeue( this, type ); moel@348: }); moel@348: }, moel@348: // Based off of the plugin by Clint Helfers, with permission. moel@348: // http://blindsignals.com/index.php/2009/07/jquery-delay/ moel@348: delay: function( time, type ) { moel@348: time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; moel@348: type = type || "fx"; moel@348: moel@348: return this.queue( type, function( next, hooks ) { moel@348: var timeout = setTimeout( next, time ); moel@348: hooks.stop = function() { moel@348: clearTimeout( timeout ); moel@348: }; moel@348: }); moel@348: }, moel@348: clearQueue: function( type ) { moel@348: return this.queue( type || "fx", [] ); moel@348: }, moel@348: // Get a promise resolved when queues of a certain type moel@348: // are emptied (fx is the type by default) moel@348: promise: function( type, object ) { moel@348: if ( typeof type !== "string" ) { moel@348: object = type; moel@348: type = undefined; moel@348: } moel@348: type = type || "fx"; moel@348: var defer = jQuery.Deferred(), moel@348: elements = this, moel@348: i = elements.length, moel@348: count = 1, moel@348: deferDataKey = type + "defer", moel@348: queueDataKey = type + "queue", moel@348: markDataKey = type + "mark", moel@348: tmp; moel@348: function resolve() { moel@348: if ( !( --count ) ) { moel@348: defer.resolveWith( elements, [ elements ] ); moel@348: } moel@348: } moel@348: while( i-- ) { moel@348: if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || moel@348: ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || moel@348: jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && moel@348: jQuery.data( elements[ i ], deferDataKey, jQuery.Callbacks( "once memory" ), true ) )) { moel@348: count++; moel@348: tmp.add( resolve ); moel@348: } moel@348: } moel@348: resolve(); moel@348: return defer.promise( object ); moel@348: } moel@348: }); moel@348: moel@348: moel@348: moel@348: moel@348: var rclass = /[\n\t\r]/g, moel@348: rspace = /\s+/, moel@348: rreturn = /\r/g, moel@348: rtype = /^(?:button|input)$/i, moel@348: rfocusable = /^(?:button|input|object|select|textarea)$/i, moel@348: rclickable = /^a(?:rea)?$/i, moel@348: rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, moel@348: getSetAttribute = jQuery.support.getSetAttribute, moel@348: nodeHook, boolHook, fixSpecified; moel@348: moel@348: jQuery.fn.extend({ moel@348: attr: function( name, value ) { moel@348: return jQuery.access( this, jQuery.attr, name, value, arguments.length > 1 ); moel@348: }, moel@348: moel@348: removeAttr: function( name ) { moel@348: return this.each(function() { moel@348: jQuery.removeAttr( this, name ); moel@348: }); moel@348: }, moel@348: moel@348: prop: function( name, value ) { moel@348: return jQuery.access( this, jQuery.prop, name, value, arguments.length > 1 ); moel@348: }, moel@348: moel@348: removeProp: function( name ) { moel@348: name = jQuery.propFix[ name ] || name; moel@348: return this.each(function() { moel@348: // try/catch handles cases where IE balks (such as removing a property on window) moel@348: try { moel@348: this[ name ] = undefined; moel@348: delete this[ name ]; moel@348: } catch( e ) {} moel@348: }); moel@348: }, moel@348: moel@348: addClass: function( value ) { moel@348: var classNames, i, l, elem, moel@348: setClass, c, cl; moel@348: moel@348: if ( jQuery.isFunction( value ) ) { moel@348: return this.each(function( j ) { moel@348: jQuery( this ).addClass( value.call(this, j, this.className) ); moel@348: }); moel@348: } moel@348: moel@348: if ( value && typeof value === "string" ) { moel@348: classNames = value.split( rspace ); moel@348: moel@348: for ( i = 0, l = this.length; i < l; i++ ) { moel@348: elem = this[ i ]; moel@348: moel@348: if ( elem.nodeType === 1 ) { moel@348: if ( !elem.className && classNames.length === 1 ) { moel@348: elem.className = value; moel@348: moel@348: } else { moel@348: setClass = " " + elem.className + " "; moel@348: moel@348: for ( c = 0, cl = classNames.length; c < cl; c++ ) { moel@348: if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { moel@348: setClass += classNames[ c ] + " "; moel@348: } moel@348: } moel@348: elem.className = jQuery.trim( setClass ); moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return this; moel@348: }, moel@348: moel@348: removeClass: function( value ) { moel@348: var classNames, i, l, elem, className, c, cl; moel@348: moel@348: if ( jQuery.isFunction( value ) ) { moel@348: return this.each(function( j ) { moel@348: jQuery( this ).removeClass( value.call(this, j, this.className) ); moel@348: }); moel@348: } moel@348: moel@348: if ( (value && typeof value === "string") || value === undefined ) { moel@348: classNames = ( value || "" ).split( rspace ); moel@348: moel@348: for ( i = 0, l = this.length; i < l; i++ ) { moel@348: elem = this[ i ]; moel@348: moel@348: if ( elem.nodeType === 1 && elem.className ) { moel@348: if ( value ) { moel@348: className = (" " + elem.className + " ").replace( rclass, " " ); moel@348: for ( c = 0, cl = classNames.length; c < cl; c++ ) { moel@348: className = className.replace(" " + classNames[ c ] + " ", " "); moel@348: } moel@348: elem.className = jQuery.trim( className ); moel@348: moel@348: } else { moel@348: elem.className = ""; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return this; moel@348: }, moel@348: moel@348: toggleClass: function( value, stateVal ) { moel@348: var type = typeof value, moel@348: isBool = typeof stateVal === "boolean"; moel@348: moel@348: if ( jQuery.isFunction( value ) ) { moel@348: return this.each(function( i ) { moel@348: jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); moel@348: }); moel@348: } moel@348: moel@348: return this.each(function() { moel@348: if ( type === "string" ) { moel@348: // toggle individual class names moel@348: var className, moel@348: i = 0, moel@348: self = jQuery( this ), moel@348: state = stateVal, moel@348: classNames = value.split( rspace ); moel@348: moel@348: while ( (className = classNames[ i++ ]) ) { moel@348: // check each className given, space seperated list moel@348: state = isBool ? state : !self.hasClass( className ); moel@348: self[ state ? "addClass" : "removeClass" ]( className ); moel@348: } moel@348: moel@348: } else if ( type === "undefined" || type === "boolean" ) { moel@348: if ( this.className ) { moel@348: // store className if set moel@348: jQuery._data( this, "__className__", this.className ); moel@348: } moel@348: moel@348: // toggle whole className moel@348: this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; moel@348: } moel@348: }); moel@348: }, moel@348: moel@348: hasClass: function( selector ) { moel@348: var className = " " + selector + " ", moel@348: i = 0, moel@348: l = this.length; moel@348: for ( ; i < l; i++ ) { moel@348: if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { moel@348: return true; moel@348: } moel@348: } moel@348: moel@348: return false; moel@348: }, moel@348: moel@348: val: function( value ) { moel@348: var hooks, ret, isFunction, moel@348: elem = this[0]; moel@348: moel@348: if ( !arguments.length ) { moel@348: if ( elem ) { moel@348: hooks = jQuery.valHooks[ elem.type ] || jQuery.valHooks[ elem.nodeName.toLowerCase() ]; moel@348: moel@348: if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { moel@348: return ret; moel@348: } moel@348: moel@348: ret = elem.value; moel@348: moel@348: return typeof ret === "string" ? moel@348: // handle most common string cases moel@348: ret.replace(rreturn, "") : moel@348: // handle cases where value is null/undef or number moel@348: ret == null ? "" : ret; moel@348: } moel@348: moel@348: return; moel@348: } moel@348: moel@348: isFunction = jQuery.isFunction( value ); moel@348: moel@348: return this.each(function( i ) { moel@348: var self = jQuery(this), val; moel@348: moel@348: if ( this.nodeType !== 1 ) { moel@348: return; moel@348: } moel@348: moel@348: if ( isFunction ) { moel@348: val = value.call( this, i, self.val() ); moel@348: } else { moel@348: val = value; moel@348: } moel@348: moel@348: // Treat null/undefined as ""; convert numbers to string moel@348: if ( val == null ) { moel@348: val = ""; moel@348: } else if ( typeof val === "number" ) { moel@348: val += ""; moel@348: } else if ( jQuery.isArray( val ) ) { moel@348: val = jQuery.map(val, function ( value ) { moel@348: return value == null ? "" : value + ""; moel@348: }); moel@348: } moel@348: moel@348: hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; moel@348: moel@348: // If set returns undefined, fall back to normal setting moel@348: if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { moel@348: this.value = val; moel@348: } moel@348: }); moel@348: } moel@348: }); moel@348: moel@348: jQuery.extend({ moel@348: valHooks: { moel@348: option: { moel@348: get: function( elem ) { moel@348: // attributes.value is undefined in Blackberry 4.7 but moel@348: // uses .value. See #6932 moel@348: var val = elem.attributes.value; moel@348: return !val || val.specified ? elem.value : elem.text; moel@348: } moel@348: }, moel@348: select: { moel@348: get: function( elem ) { moel@348: var value, i, max, option, moel@348: index = elem.selectedIndex, moel@348: values = [], moel@348: options = elem.options, moel@348: one = elem.type === "select-one"; moel@348: moel@348: // Nothing was selected moel@348: if ( index < 0 ) { moel@348: return null; moel@348: } moel@348: moel@348: // Loop through all the selected options moel@348: i = one ? index : 0; moel@348: max = one ? index + 1 : options.length; moel@348: for ( ; i < max; i++ ) { moel@348: option = options[ i ]; moel@348: moel@348: // Don't return options that are disabled or in a disabled optgroup moel@348: if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && moel@348: (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { moel@348: moel@348: // Get the specific value for the option moel@348: value = jQuery( option ).val(); moel@348: moel@348: // We don't need an array for one selects moel@348: if ( one ) { moel@348: return value; moel@348: } moel@348: moel@348: // Multi-Selects return an array moel@348: values.push( value ); moel@348: } moel@348: } moel@348: moel@348: // Fixes Bug #2551 -- select.val() broken in IE after form.reset() moel@348: if ( one && !values.length && options.length ) { moel@348: return jQuery( options[ index ] ).val(); moel@348: } moel@348: moel@348: return values; moel@348: }, moel@348: moel@348: set: function( elem, value ) { moel@348: var values = jQuery.makeArray( value ); moel@348: moel@348: jQuery(elem).find("option").each(function() { moel@348: this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; moel@348: }); moel@348: moel@348: if ( !values.length ) { moel@348: elem.selectedIndex = -1; moel@348: } moel@348: return values; moel@348: } moel@348: } moel@348: }, moel@348: moel@348: attrFn: { moel@348: val: true, moel@348: css: true, moel@348: html: true, moel@348: text: true, moel@348: data: true, moel@348: width: true, moel@348: height: true, moel@348: offset: true moel@348: }, moel@348: moel@348: attr: function( elem, name, value, pass ) { moel@348: var ret, hooks, notxml, moel@348: nType = elem.nodeType; moel@348: moel@348: // don't get/set attributes on text, comment and attribute nodes moel@348: if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { moel@348: return; moel@348: } moel@348: moel@348: if ( pass && name in jQuery.attrFn ) { moel@348: return jQuery( elem )[ name ]( value ); moel@348: } moel@348: moel@348: // Fallback to prop when attributes are not supported moel@348: if ( typeof elem.getAttribute === "undefined" ) { moel@348: return jQuery.prop( elem, name, value ); moel@348: } moel@348: moel@348: notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); moel@348: moel@348: // All attributes are lowercase moel@348: // Grab necessary hook if one is defined moel@348: if ( notxml ) { moel@348: name = name.toLowerCase(); moel@348: hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook ); moel@348: } moel@348: moel@348: if ( value !== undefined ) { moel@348: moel@348: if ( value === null ) { moel@348: jQuery.removeAttr( elem, name ); moel@348: return; moel@348: moel@348: } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { moel@348: return ret; moel@348: moel@348: } else { moel@348: elem.setAttribute( name, "" + value ); moel@348: return value; moel@348: } moel@348: moel@348: } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { moel@348: return ret; moel@348: moel@348: } else { moel@348: moel@348: ret = elem.getAttribute( name ); moel@348: moel@348: // Non-existent attributes return null, we normalize to undefined moel@348: return ret === null ? moel@348: undefined : moel@348: ret; moel@348: } moel@348: }, moel@348: moel@348: removeAttr: function( elem, value ) { moel@348: var propName, attrNames, name, l, isBool, moel@348: i = 0; moel@348: moel@348: if ( value && elem.nodeType === 1 ) { moel@348: attrNames = value.toLowerCase().split( rspace ); moel@348: l = attrNames.length; moel@348: moel@348: for ( ; i < l; i++ ) { moel@348: name = attrNames[ i ]; moel@348: moel@348: if ( name ) { moel@348: propName = jQuery.propFix[ name ] || name; moel@348: isBool = rboolean.test( name ); moel@348: moel@348: // See #9699 for explanation of this approach (setting first, then removal) moel@348: // Do not do this for boolean attributes (see #10870) moel@348: if ( !isBool ) { moel@348: jQuery.attr( elem, name, "" ); moel@348: } moel@348: elem.removeAttribute( getSetAttribute ? name : propName ); moel@348: moel@348: // Set corresponding property to false for boolean attributes moel@348: if ( isBool && propName in elem ) { moel@348: elem[ propName ] = false; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: }, moel@348: moel@348: attrHooks: { moel@348: type: { moel@348: set: function( elem, value ) { moel@348: // We can't allow the type property to be changed (since it causes problems in IE) moel@348: if ( rtype.test( elem.nodeName ) && elem.parentNode ) { moel@348: jQuery.error( "type property can't be changed" ); moel@348: } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { moel@348: // Setting the type on a radio button after the value resets the value in IE6-9 moel@348: // Reset value to it's default in case type is set after value moel@348: // This is for element creation moel@348: var val = elem.value; moel@348: elem.setAttribute( "type", value ); moel@348: if ( val ) { moel@348: elem.value = val; moel@348: } moel@348: return value; moel@348: } moel@348: } moel@348: }, moel@348: // Use the value property for back compat moel@348: // Use the nodeHook for button elements in IE6/7 (#1954) moel@348: value: { moel@348: get: function( elem, name ) { moel@348: if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { moel@348: return nodeHook.get( elem, name ); moel@348: } moel@348: return name in elem ? moel@348: elem.value : moel@348: null; moel@348: }, moel@348: set: function( elem, value, name ) { moel@348: if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { moel@348: return nodeHook.set( elem, value, name ); moel@348: } moel@348: // Does not return so that setAttribute is also used moel@348: elem.value = value; moel@348: } moel@348: } moel@348: }, moel@348: moel@348: propFix: { moel@348: tabindex: "tabIndex", moel@348: readonly: "readOnly", moel@348: "for": "htmlFor", moel@348: "class": "className", moel@348: maxlength: "maxLength", moel@348: cellspacing: "cellSpacing", moel@348: cellpadding: "cellPadding", moel@348: rowspan: "rowSpan", moel@348: colspan: "colSpan", moel@348: usemap: "useMap", moel@348: frameborder: "frameBorder", moel@348: contenteditable: "contentEditable" moel@348: }, moel@348: moel@348: prop: function( elem, name, value ) { moel@348: var ret, hooks, notxml, moel@348: nType = elem.nodeType; moel@348: moel@348: // don't get/set properties on text, comment and attribute nodes moel@348: if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { moel@348: return; moel@348: } moel@348: moel@348: notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); moel@348: moel@348: if ( notxml ) { moel@348: // Fix name and attach hooks moel@348: name = jQuery.propFix[ name ] || name; moel@348: hooks = jQuery.propHooks[ name ]; moel@348: } moel@348: moel@348: if ( value !== undefined ) { moel@348: if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { moel@348: return ret; moel@348: moel@348: } else { moel@348: return ( elem[ name ] = value ); moel@348: } moel@348: moel@348: } else { moel@348: if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { moel@348: return ret; moel@348: moel@348: } else { moel@348: return elem[ name ]; moel@348: } moel@348: } moel@348: }, moel@348: moel@348: propHooks: { moel@348: tabIndex: { moel@348: get: function( elem ) { moel@348: // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set moel@348: // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ moel@348: var attributeNode = elem.getAttributeNode("tabindex"); moel@348: moel@348: return attributeNode && attributeNode.specified ? moel@348: parseInt( attributeNode.value, 10 ) : moel@348: rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? moel@348: 0 : moel@348: undefined; moel@348: } moel@348: } moel@348: } moel@348: }); moel@348: moel@348: // Add the tabIndex propHook to attrHooks for back-compat (different case is intentional) moel@348: jQuery.attrHooks.tabindex = jQuery.propHooks.tabIndex; moel@348: moel@348: // Hook for boolean attributes moel@348: boolHook = { moel@348: get: function( elem, name ) { moel@348: // Align boolean attributes with corresponding properties moel@348: // Fall back to attribute presence where some booleans are not supported moel@348: var attrNode, moel@348: property = jQuery.prop( elem, name ); moel@348: return property === true || typeof property !== "boolean" && ( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ? moel@348: name.toLowerCase() : moel@348: undefined; moel@348: }, moel@348: set: function( elem, value, name ) { moel@348: var propName; moel@348: if ( value === false ) { moel@348: // Remove boolean attributes when set to false moel@348: jQuery.removeAttr( elem, name ); moel@348: } else { moel@348: // value is true since we know at this point it's type boolean and not false moel@348: // Set boolean attributes to the same name and set the DOM property moel@348: propName = jQuery.propFix[ name ] || name; moel@348: if ( propName in elem ) { moel@348: // Only set the IDL specifically if it already exists on the element moel@348: elem[ propName ] = true; moel@348: } moel@348: moel@348: elem.setAttribute( name, name.toLowerCase() ); moel@348: } moel@348: return name; moel@348: } moel@348: }; moel@348: moel@348: // IE6/7 do not support getting/setting some attributes with get/setAttribute moel@348: if ( !getSetAttribute ) { moel@348: moel@348: fixSpecified = { moel@348: name: true, moel@348: id: true, moel@348: coords: true moel@348: }; moel@348: moel@348: // Use this for any attribute in IE6/7 moel@348: // This fixes almost every IE6/7 issue moel@348: nodeHook = jQuery.valHooks.button = { moel@348: get: function( elem, name ) { moel@348: var ret; moel@348: ret = elem.getAttributeNode( name ); moel@348: return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ? moel@348: ret.nodeValue : moel@348: undefined; moel@348: }, moel@348: set: function( elem, value, name ) { moel@348: // Set the existing or create a new attribute node moel@348: var ret = elem.getAttributeNode( name ); moel@348: if ( !ret ) { moel@348: ret = document.createAttribute( name ); moel@348: elem.setAttributeNode( ret ); moel@348: } moel@348: return ( ret.nodeValue = value + "" ); moel@348: } moel@348: }; moel@348: moel@348: // Apply the nodeHook to tabindex moel@348: jQuery.attrHooks.tabindex.set = nodeHook.set; moel@348: moel@348: // Set width and height to auto instead of 0 on empty string( Bug #8150 ) moel@348: // This is for removals moel@348: jQuery.each([ "width", "height" ], function( i, name ) { moel@348: jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { moel@348: set: function( elem, value ) { moel@348: if ( value === "" ) { moel@348: elem.setAttribute( name, "auto" ); moel@348: return value; moel@348: } moel@348: } moel@348: }); moel@348: }); moel@348: moel@348: // Set contenteditable to false on removals(#10429) moel@348: // Setting to empty string throws an error as an invalid value moel@348: jQuery.attrHooks.contenteditable = { moel@348: get: nodeHook.get, moel@348: set: function( elem, value, name ) { moel@348: if ( value === "" ) { moel@348: value = "false"; moel@348: } moel@348: nodeHook.set( elem, value, name ); moel@348: } moel@348: }; moel@348: } moel@348: moel@348: moel@348: // Some attributes require a special call on IE moel@348: if ( !jQuery.support.hrefNormalized ) { moel@348: jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { moel@348: jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { moel@348: get: function( elem ) { moel@348: var ret = elem.getAttribute( name, 2 ); moel@348: return ret === null ? undefined : ret; moel@348: } moel@348: }); moel@348: }); moel@348: } moel@348: moel@348: if ( !jQuery.support.style ) { moel@348: jQuery.attrHooks.style = { moel@348: get: function( elem ) { moel@348: // Return undefined in the case of empty string moel@348: // Normalize to lowercase since IE uppercases css property names moel@348: return elem.style.cssText.toLowerCase() || undefined; moel@348: }, moel@348: set: function( elem, value ) { moel@348: return ( elem.style.cssText = "" + value ); moel@348: } moel@348: }; moel@348: } moel@348: moel@348: // Safari mis-reports the default selected property of an option moel@348: // Accessing the parent's selectedIndex property fixes it moel@348: if ( !jQuery.support.optSelected ) { moel@348: jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { moel@348: get: function( elem ) { moel@348: var parent = elem.parentNode; moel@348: moel@348: if ( parent ) { moel@348: parent.selectedIndex; moel@348: moel@348: // Make sure that it also works with optgroups, see #5701 moel@348: if ( parent.parentNode ) { moel@348: parent.parentNode.selectedIndex; moel@348: } moel@348: } moel@348: return null; moel@348: } moel@348: }); moel@348: } moel@348: moel@348: // IE6/7 call enctype encoding moel@348: if ( !jQuery.support.enctype ) { moel@348: jQuery.propFix.enctype = "encoding"; moel@348: } moel@348: moel@348: // Radios and checkboxes getter/setter moel@348: if ( !jQuery.support.checkOn ) { moel@348: jQuery.each([ "radio", "checkbox" ], function() { moel@348: jQuery.valHooks[ this ] = { moel@348: get: function( elem ) { moel@348: // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified moel@348: return elem.getAttribute("value") === null ? "on" : elem.value; moel@348: } moel@348: }; moel@348: }); moel@348: } moel@348: jQuery.each([ "radio", "checkbox" ], function() { moel@348: jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { moel@348: set: function( elem, value ) { moel@348: if ( jQuery.isArray( value ) ) { moel@348: return ( elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0 ); moel@348: } moel@348: } moel@348: }); moel@348: }); moel@348: moel@348: moel@348: moel@348: moel@348: var rformElems = /^(?:textarea|input|select)$/i, moel@348: rtypenamespace = /^([^\.]*)?(?:\.(.+))?$/, moel@348: rhoverHack = /(?:^|\s)hover(\.\S+)?\b/, moel@348: rkeyEvent = /^key/, moel@348: rmouseEvent = /^(?:mouse|contextmenu)|click/, moel@348: rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, moel@348: rquickIs = /^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/, moel@348: quickParse = function( selector ) { moel@348: var quick = rquickIs.exec( selector ); moel@348: if ( quick ) { moel@348: // 0 1 2 3 moel@348: // [ _, tag, id, class ] moel@348: quick[1] = ( quick[1] || "" ).toLowerCase(); moel@348: quick[3] = quick[3] && new RegExp( "(?:^|\\s)" + quick[3] + "(?:\\s|$)" ); moel@348: } moel@348: return quick; moel@348: }, moel@348: quickIs = function( elem, m ) { moel@348: var attrs = elem.attributes || {}; moel@348: return ( moel@348: (!m[1] || elem.nodeName.toLowerCase() === m[1]) && moel@348: (!m[2] || (attrs.id || {}).value === m[2]) && moel@348: (!m[3] || m[3].test( (attrs[ "class" ] || {}).value )) moel@348: ); moel@348: }, moel@348: hoverHack = function( events ) { moel@348: return jQuery.event.special.hover ? events : events.replace( rhoverHack, "mouseenter$1 mouseleave$1" ); moel@348: }; moel@348: moel@348: /* moel@348: * Helper functions for managing events -- not part of the public interface. moel@348: * Props to Dean Edwards' addEvent library for many of the ideas. moel@348: */ moel@348: jQuery.event = { moel@348: moel@348: add: function( elem, types, handler, data, selector ) { moel@348: moel@348: var elemData, eventHandle, events, moel@348: t, tns, type, namespaces, handleObj, moel@348: handleObjIn, quick, handlers, special; moel@348: moel@348: // Don't attach events to noData or text/comment nodes (allow plain objects tho) moel@348: if ( elem.nodeType === 3 || elem.nodeType === 8 || !types || !handler || !(elemData = jQuery._data( elem )) ) { moel@348: return; moel@348: } moel@348: moel@348: // Caller can pass in an object of custom data in lieu of the handler moel@348: if ( handler.handler ) { moel@348: handleObjIn = handler; moel@348: handler = handleObjIn.handler; moel@348: selector = handleObjIn.selector; moel@348: } moel@348: moel@348: // Make sure that the handler has a unique ID, used to find/remove it later moel@348: if ( !handler.guid ) { moel@348: handler.guid = jQuery.guid++; moel@348: } moel@348: moel@348: // Init the element's event structure and main handler, if this is the first moel@348: events = elemData.events; moel@348: if ( !events ) { moel@348: elemData.events = events = {}; moel@348: } moel@348: eventHandle = elemData.handle; moel@348: if ( !eventHandle ) { moel@348: elemData.handle = eventHandle = function( e ) { moel@348: // Discard the second event of a jQuery.event.trigger() and moel@348: // when an event is called after a page has unloaded moel@348: return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? moel@348: jQuery.event.dispatch.apply( eventHandle.elem, arguments ) : moel@348: undefined; moel@348: }; moel@348: // Add elem as a property of the handle fn to prevent a memory leak with IE non-native events moel@348: eventHandle.elem = elem; moel@348: } moel@348: moel@348: // Handle multiple events separated by a space moel@348: // jQuery(...).bind("mouseover mouseout", fn); moel@348: types = jQuery.trim( hoverHack(types) ).split( " " ); moel@348: for ( t = 0; t < types.length; t++ ) { moel@348: moel@348: tns = rtypenamespace.exec( types[t] ) || []; moel@348: type = tns[1]; moel@348: namespaces = ( tns[2] || "" ).split( "." ).sort(); moel@348: moel@348: // If event changes its type, use the special event handlers for the changed type moel@348: special = jQuery.event.special[ type ] || {}; moel@348: moel@348: // If selector defined, determine special event api type, otherwise given type moel@348: type = ( selector ? special.delegateType : special.bindType ) || type; moel@348: moel@348: // Update special based on newly reset type moel@348: special = jQuery.event.special[ type ] || {}; moel@348: moel@348: // handleObj is passed to all event handlers moel@348: handleObj = jQuery.extend({ moel@348: type: type, moel@348: origType: tns[1], moel@348: data: data, moel@348: handler: handler, moel@348: guid: handler.guid, moel@348: selector: selector, moel@348: quick: selector && quickParse( selector ), moel@348: namespace: namespaces.join(".") moel@348: }, handleObjIn ); moel@348: moel@348: // Init the event handler queue if we're the first moel@348: handlers = events[ type ]; moel@348: if ( !handlers ) { moel@348: handlers = events[ type ] = []; moel@348: handlers.delegateCount = 0; moel@348: moel@348: // Only use addEventListener/attachEvent if the special events handler returns false moel@348: if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { moel@348: // Bind the global event handler to the element moel@348: if ( elem.addEventListener ) { moel@348: elem.addEventListener( type, eventHandle, false ); moel@348: moel@348: } else if ( elem.attachEvent ) { moel@348: elem.attachEvent( "on" + type, eventHandle ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: if ( special.add ) { moel@348: special.add.call( elem, handleObj ); moel@348: moel@348: if ( !handleObj.handler.guid ) { moel@348: handleObj.handler.guid = handler.guid; moel@348: } moel@348: } moel@348: moel@348: // Add to the element's handler list, delegates in front moel@348: if ( selector ) { moel@348: handlers.splice( handlers.delegateCount++, 0, handleObj ); moel@348: } else { moel@348: handlers.push( handleObj ); moel@348: } moel@348: moel@348: // Keep track of which events have ever been used, for event optimization moel@348: jQuery.event.global[ type ] = true; moel@348: } moel@348: moel@348: // Nullify elem to prevent memory leaks in IE moel@348: elem = null; moel@348: }, moel@348: moel@348: global: {}, moel@348: moel@348: // Detach an event or set of events from an element moel@348: remove: function( elem, types, handler, selector, mappedTypes ) { moel@348: moel@348: var elemData = jQuery.hasData( elem ) && jQuery._data( elem ), moel@348: t, tns, type, origType, namespaces, origCount, moel@348: j, events, special, handle, eventType, handleObj; moel@348: moel@348: if ( !elemData || !(events = elemData.events) ) { moel@348: return; moel@348: } moel@348: moel@348: // Once for each type.namespace in types; type may be omitted moel@348: types = jQuery.trim( hoverHack( types || "" ) ).split(" "); moel@348: for ( t = 0; t < types.length; t++ ) { moel@348: tns = rtypenamespace.exec( types[t] ) || []; moel@348: type = origType = tns[1]; moel@348: namespaces = tns[2]; moel@348: moel@348: // Unbind all events (on this namespace, if provided) for the element moel@348: if ( !type ) { moel@348: for ( type in events ) { moel@348: jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); moel@348: } moel@348: continue; moel@348: } moel@348: moel@348: special = jQuery.event.special[ type ] || {}; moel@348: type = ( selector? special.delegateType : special.bindType ) || type; moel@348: eventType = events[ type ] || []; moel@348: origCount = eventType.length; moel@348: namespaces = namespaces ? new RegExp("(^|\\.)" + namespaces.split(".").sort().join("\\.(?:.*\\.)?") + "(\\.|$)") : null; moel@348: moel@348: // Remove matching events moel@348: for ( j = 0; j < eventType.length; j++ ) { moel@348: handleObj = eventType[ j ]; moel@348: moel@348: if ( ( mappedTypes || origType === handleObj.origType ) && moel@348: ( !handler || handler.guid === handleObj.guid ) && moel@348: ( !namespaces || namespaces.test( handleObj.namespace ) ) && moel@348: ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) { moel@348: eventType.splice( j--, 1 ); moel@348: moel@348: if ( handleObj.selector ) { moel@348: eventType.delegateCount--; moel@348: } moel@348: if ( special.remove ) { moel@348: special.remove.call( elem, handleObj ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Remove generic event handler if we removed something and no more handlers exist moel@348: // (avoids potential for endless recursion during removal of special event handlers) moel@348: if ( eventType.length === 0 && origCount !== eventType.length ) { moel@348: if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { moel@348: jQuery.removeEvent( elem, type, elemData.handle ); moel@348: } moel@348: moel@348: delete events[ type ]; moel@348: } moel@348: } moel@348: moel@348: // Remove the expando if it's no longer used moel@348: if ( jQuery.isEmptyObject( events ) ) { moel@348: handle = elemData.handle; moel@348: if ( handle ) { moel@348: handle.elem = null; moel@348: } moel@348: moel@348: // removeData also checks for emptiness and clears the expando if empty moel@348: // so use it instead of delete moel@348: jQuery.removeData( elem, [ "events", "handle" ], true ); moel@348: } moel@348: }, moel@348: moel@348: // Events that are safe to short-circuit if no handlers are attached. moel@348: // Native DOM events should not be added, they may have inline handlers. moel@348: customEvent: { moel@348: "getData": true, moel@348: "setData": true, moel@348: "changeData": true moel@348: }, moel@348: moel@348: trigger: function( event, data, elem, onlyHandlers ) { moel@348: // Don't do events on text and comment nodes moel@348: if ( elem && (elem.nodeType === 3 || elem.nodeType === 8) ) { moel@348: return; moel@348: } moel@348: moel@348: // Event object or event type moel@348: var type = event.type || event, moel@348: namespaces = [], moel@348: cache, exclusive, i, cur, old, ontype, special, handle, eventPath, bubbleType; moel@348: moel@348: // focus/blur morphs to focusin/out; ensure we're not firing them right now moel@348: if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { moel@348: return; moel@348: } moel@348: moel@348: if ( type.indexOf( "!" ) >= 0 ) { moel@348: // Exclusive events trigger only for the exact event (no namespaces) moel@348: type = type.slice(0, -1); moel@348: exclusive = true; moel@348: } moel@348: moel@348: if ( type.indexOf( "." ) >= 0 ) { moel@348: // Namespaced trigger; create a regexp to match event type in handle() moel@348: namespaces = type.split("."); moel@348: type = namespaces.shift(); moel@348: namespaces.sort(); moel@348: } moel@348: moel@348: if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { moel@348: // No jQuery handlers for this event type, and it can't have inline handlers moel@348: return; moel@348: } moel@348: moel@348: // Caller can pass in an Event, Object, or just an event type string moel@348: event = typeof event === "object" ? moel@348: // jQuery.Event object moel@348: event[ jQuery.expando ] ? event : moel@348: // Object literal moel@348: new jQuery.Event( type, event ) : moel@348: // Just the event type (string) moel@348: new jQuery.Event( type ); moel@348: moel@348: event.type = type; moel@348: event.isTrigger = true; moel@348: event.exclusive = exclusive; moel@348: event.namespace = namespaces.join( "." ); moel@348: event.namespace_re = event.namespace? new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)") : null; moel@348: ontype = type.indexOf( ":" ) < 0 ? "on" + type : ""; moel@348: moel@348: // Handle a global trigger moel@348: if ( !elem ) { moel@348: moel@348: // TODO: Stop taunting the data cache; remove global events and always attach to document moel@348: cache = jQuery.cache; moel@348: for ( i in cache ) { moel@348: if ( cache[ i ].events && cache[ i ].events[ type ] ) { moel@348: jQuery.event.trigger( event, data, cache[ i ].handle.elem, true ); moel@348: } moel@348: } moel@348: return; moel@348: } moel@348: moel@348: // Clean up the event in case it is being reused moel@348: event.result = undefined; moel@348: if ( !event.target ) { moel@348: event.target = elem; moel@348: } moel@348: moel@348: // Clone any incoming data and prepend the event, creating the handler arg list moel@348: data = data != null ? jQuery.makeArray( data ) : []; moel@348: data.unshift( event ); moel@348: moel@348: // Allow special events to draw outside the lines moel@348: special = jQuery.event.special[ type ] || {}; moel@348: if ( special.trigger && special.trigger.apply( elem, data ) === false ) { moel@348: return; moel@348: } moel@348: moel@348: // Determine event propagation path in advance, per W3C events spec (#9951) moel@348: // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) moel@348: eventPath = [[ elem, special.bindType || type ]]; moel@348: if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { moel@348: moel@348: bubbleType = special.delegateType || type; moel@348: cur = rfocusMorph.test( bubbleType + type ) ? elem : elem.parentNode; moel@348: old = null; moel@348: for ( ; cur; cur = cur.parentNode ) { moel@348: eventPath.push([ cur, bubbleType ]); moel@348: old = cur; moel@348: } moel@348: moel@348: // Only add window if we got to document (e.g., not plain obj or detached DOM) moel@348: if ( old && old === elem.ownerDocument ) { moel@348: eventPath.push([ old.defaultView || old.parentWindow || window, bubbleType ]); moel@348: } moel@348: } moel@348: moel@348: // Fire handlers on the event path moel@348: for ( i = 0; i < eventPath.length && !event.isPropagationStopped(); i++ ) { moel@348: moel@348: cur = eventPath[i][0]; moel@348: event.type = eventPath[i][1]; moel@348: moel@348: handle = ( jQuery._data( cur, "events" ) || {} )[ event.type ] && jQuery._data( cur, "handle" ); moel@348: if ( handle ) { moel@348: handle.apply( cur, data ); moel@348: } moel@348: // Note that this is a bare JS function and not a jQuery handler moel@348: handle = ontype && cur[ ontype ]; moel@348: if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) { moel@348: event.preventDefault(); moel@348: } moel@348: } moel@348: event.type = type; moel@348: moel@348: // If nobody prevented the default action, do it now moel@348: if ( !onlyHandlers && !event.isDefaultPrevented() ) { moel@348: moel@348: if ( (!special._default || special._default.apply( elem.ownerDocument, data ) === false) && moel@348: !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { moel@348: moel@348: // Call a native DOM method on the target with the same name name as the event. moel@348: // Can't use an .isFunction() check here because IE6/7 fails that test. moel@348: // Don't do default actions on window, that's where global variables be (#6170) moel@348: // IE<9 dies on focus/blur to hidden element (#1486) moel@348: if ( ontype && elem[ type ] && ((type !== "focus" && type !== "blur") || event.target.offsetWidth !== 0) && !jQuery.isWindow( elem ) ) { moel@348: moel@348: // Don't re-trigger an onFOO event when we call its FOO() method moel@348: old = elem[ ontype ]; moel@348: moel@348: if ( old ) { moel@348: elem[ ontype ] = null; moel@348: } moel@348: moel@348: // Prevent re-triggering of the same event, since we already bubbled it above moel@348: jQuery.event.triggered = type; moel@348: elem[ type ](); moel@348: jQuery.event.triggered = undefined; moel@348: moel@348: if ( old ) { moel@348: elem[ ontype ] = old; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return event.result; moel@348: }, moel@348: moel@348: dispatch: function( event ) { moel@348: moel@348: // Make a writable jQuery.Event from the native event object moel@348: event = jQuery.event.fix( event || window.event ); moel@348: moel@348: var handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []), moel@348: delegateCount = handlers.delegateCount, moel@348: args = [].slice.call( arguments, 0 ), moel@348: run_all = !event.exclusive && !event.namespace, moel@348: special = jQuery.event.special[ event.type ] || {}, moel@348: handlerQueue = [], moel@348: i, j, cur, jqcur, ret, selMatch, matched, matches, handleObj, sel, related; moel@348: moel@348: // Use the fix-ed jQuery.Event rather than the (read-only) native event moel@348: args[0] = event; moel@348: event.delegateTarget = this; moel@348: moel@348: // Call the preDispatch hook for the mapped type, and let it bail if desired moel@348: if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { moel@348: return; moel@348: } moel@348: moel@348: // Determine handlers that should run if there are delegated events moel@348: // Avoid non-left-click bubbling in Firefox (#3861) moel@348: if ( delegateCount && !(event.button && event.type === "click") ) { moel@348: moel@348: // Pregenerate a single jQuery object for reuse with .is() moel@348: jqcur = jQuery(this); moel@348: jqcur.context = this.ownerDocument || this; moel@348: moel@348: for ( cur = event.target; cur != this; cur = cur.parentNode || this ) { moel@348: moel@348: // Don't process events on disabled elements (#6911, #8165) moel@348: if ( cur.disabled !== true ) { moel@348: selMatch = {}; moel@348: matches = []; moel@348: jqcur[0] = cur; moel@348: for ( i = 0; i < delegateCount; i++ ) { moel@348: handleObj = handlers[ i ]; moel@348: sel = handleObj.selector; moel@348: moel@348: if ( selMatch[ sel ] === undefined ) { moel@348: selMatch[ sel ] = ( moel@348: handleObj.quick ? quickIs( cur, handleObj.quick ) : jqcur.is( sel ) moel@348: ); moel@348: } moel@348: if ( selMatch[ sel ] ) { moel@348: matches.push( handleObj ); moel@348: } moel@348: } moel@348: if ( matches.length ) { moel@348: handlerQueue.push({ elem: cur, matches: matches }); moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Add the remaining (directly-bound) handlers moel@348: if ( handlers.length > delegateCount ) { moel@348: handlerQueue.push({ elem: this, matches: handlers.slice( delegateCount ) }); moel@348: } moel@348: moel@348: // Run delegates first; they may want to stop propagation beneath us moel@348: for ( i = 0; i < handlerQueue.length && !event.isPropagationStopped(); i++ ) { moel@348: matched = handlerQueue[ i ]; moel@348: event.currentTarget = matched.elem; moel@348: moel@348: for ( j = 0; j < matched.matches.length && !event.isImmediatePropagationStopped(); j++ ) { moel@348: handleObj = matched.matches[ j ]; moel@348: moel@348: // Triggered event must either 1) be non-exclusive and have no namespace, or moel@348: // 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). moel@348: if ( run_all || (!event.namespace && !handleObj.namespace) || event.namespace_re && event.namespace_re.test( handleObj.namespace ) ) { moel@348: moel@348: event.data = handleObj.data; moel@348: event.handleObj = handleObj; moel@348: moel@348: ret = ( (jQuery.event.special[ handleObj.origType ] || {}).handle || handleObj.handler ) moel@348: .apply( matched.elem, args ); moel@348: moel@348: if ( ret !== undefined ) { moel@348: event.result = ret; moel@348: if ( ret === false ) { moel@348: event.preventDefault(); moel@348: event.stopPropagation(); moel@348: } moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Call the postDispatch hook for the mapped type moel@348: if ( special.postDispatch ) { moel@348: special.postDispatch.call( this, event ); moel@348: } moel@348: moel@348: return event.result; moel@348: }, moel@348: moel@348: // Includes some event props shared by KeyEvent and MouseEvent moel@348: // *** attrChange attrName relatedNode srcElement are not normalized, non-W3C, deprecated, will be removed in 1.8 *** moel@348: props: "attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "), moel@348: moel@348: fixHooks: {}, moel@348: moel@348: keyHooks: { moel@348: props: "char charCode key keyCode".split(" "), moel@348: filter: function( event, original ) { moel@348: moel@348: // Add which for key events moel@348: if ( event.which == null ) { moel@348: event.which = original.charCode != null ? original.charCode : original.keyCode; moel@348: } moel@348: moel@348: return event; moel@348: } moel@348: }, moel@348: moel@348: mouseHooks: { moel@348: props: "button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "), moel@348: filter: function( event, original ) { moel@348: var eventDoc, doc, body, moel@348: button = original.button, moel@348: fromElement = original.fromElement; moel@348: moel@348: // Calculate pageX/Y if missing and clientX/Y available moel@348: if ( event.pageX == null && original.clientX != null ) { moel@348: eventDoc = event.target.ownerDocument || document; moel@348: doc = eventDoc.documentElement; moel@348: body = eventDoc.body; moel@348: moel@348: event.pageX = original.clientX + ( doc && doc.scrollLeft || body && body.scrollLeft || 0 ) - ( doc && doc.clientLeft || body && body.clientLeft || 0 ); moel@348: event.pageY = original.clientY + ( doc && doc.scrollTop || body && body.scrollTop || 0 ) - ( doc && doc.clientTop || body && body.clientTop || 0 ); moel@348: } moel@348: moel@348: // Add relatedTarget, if necessary moel@348: if ( !event.relatedTarget && fromElement ) { moel@348: event.relatedTarget = fromElement === event.target ? original.toElement : fromElement; moel@348: } moel@348: moel@348: // Add which for click: 1 === left; 2 === middle; 3 === right moel@348: // Note: button is not normalized, so don't use it moel@348: if ( !event.which && button !== undefined ) { moel@348: event.which = ( button & 1 ? 1 : ( button & 2 ? 3 : ( button & 4 ? 2 : 0 ) ) ); moel@348: } moel@348: moel@348: return event; moel@348: } moel@348: }, moel@348: moel@348: fix: function( event ) { moel@348: if ( event[ jQuery.expando ] ) { moel@348: return event; moel@348: } moel@348: moel@348: // Create a writable copy of the event object and normalize some properties moel@348: var i, prop, moel@348: originalEvent = event, moel@348: fixHook = jQuery.event.fixHooks[ event.type ] || {}, moel@348: copy = fixHook.props ? this.props.concat( fixHook.props ) : this.props; moel@348: moel@348: event = jQuery.Event( originalEvent ); moel@348: moel@348: for ( i = copy.length; i; ) { moel@348: prop = copy[ --i ]; moel@348: event[ prop ] = originalEvent[ prop ]; moel@348: } moel@348: moel@348: // Fix target property, if necessary (#1925, IE 6/7/8 & Safari2) moel@348: if ( !event.target ) { moel@348: event.target = originalEvent.srcElement || document; moel@348: } moel@348: moel@348: // Target should not be a text node (#504, Safari) moel@348: if ( event.target.nodeType === 3 ) { moel@348: event.target = event.target.parentNode; moel@348: } moel@348: moel@348: // For mouse/key events; add metaKey if it's not there (#3368, IE6/7/8) moel@348: if ( event.metaKey === undefined ) { moel@348: event.metaKey = event.ctrlKey; moel@348: } moel@348: moel@348: return fixHook.filter? fixHook.filter( event, originalEvent ) : event; moel@348: }, moel@348: moel@348: special: { moel@348: ready: { moel@348: // Make sure the ready event is setup moel@348: setup: jQuery.bindReady moel@348: }, moel@348: moel@348: load: { moel@348: // Prevent triggered image.load events from bubbling to window.load moel@348: noBubble: true moel@348: }, moel@348: moel@348: focus: { moel@348: delegateType: "focusin" moel@348: }, moel@348: blur: { moel@348: delegateType: "focusout" moel@348: }, moel@348: moel@348: beforeunload: { moel@348: setup: function( data, namespaces, eventHandle ) { moel@348: // We only want to do this special case on windows moel@348: if ( jQuery.isWindow( this ) ) { moel@348: this.onbeforeunload = eventHandle; moel@348: } moel@348: }, moel@348: moel@348: teardown: function( namespaces, eventHandle ) { moel@348: if ( this.onbeforeunload === eventHandle ) { moel@348: this.onbeforeunload = null; moel@348: } moel@348: } moel@348: } moel@348: }, moel@348: moel@348: simulate: function( type, elem, event, bubble ) { moel@348: // Piggyback on a donor event to simulate a different one. moel@348: // Fake originalEvent to avoid donor's stopPropagation, but if the moel@348: // simulated event prevents default then we do the same on the donor. moel@348: var e = jQuery.extend( moel@348: new jQuery.Event(), moel@348: event, moel@348: { type: type, moel@348: isSimulated: true, moel@348: originalEvent: {} moel@348: } moel@348: ); moel@348: if ( bubble ) { moel@348: jQuery.event.trigger( e, null, elem ); moel@348: } else { moel@348: jQuery.event.dispatch.call( elem, e ); moel@348: } moel@348: if ( e.isDefaultPrevented() ) { moel@348: event.preventDefault(); moel@348: } moel@348: } moel@348: }; moel@348: moel@348: // Some plugins are using, but it's undocumented/deprecated and will be removed. moel@348: // The 1.7 special event interface should provide all the hooks needed now. moel@348: jQuery.event.handle = jQuery.event.dispatch; moel@348: moel@348: jQuery.removeEvent = document.removeEventListener ? moel@348: function( elem, type, handle ) { moel@348: if ( elem.removeEventListener ) { moel@348: elem.removeEventListener( type, handle, false ); moel@348: } moel@348: } : moel@348: function( elem, type, handle ) { moel@348: if ( elem.detachEvent ) { moel@348: elem.detachEvent( "on" + type, handle ); moel@348: } moel@348: }; moel@348: moel@348: jQuery.Event = function( src, props ) { moel@348: // Allow instantiation without the 'new' keyword moel@348: if ( !(this instanceof jQuery.Event) ) { moel@348: return new jQuery.Event( src, props ); moel@348: } moel@348: moel@348: // Event object moel@348: if ( src && src.type ) { moel@348: this.originalEvent = src; moel@348: this.type = src.type; moel@348: moel@348: // Events bubbling up the document may have been marked as prevented moel@348: // by a handler lower down the tree; reflect the correct value. moel@348: this.isDefaultPrevented = ( src.defaultPrevented || src.returnValue === false || moel@348: src.getPreventDefault && src.getPreventDefault() ) ? returnTrue : returnFalse; moel@348: moel@348: // Event type moel@348: } else { moel@348: this.type = src; moel@348: } moel@348: moel@348: // Put explicitly provided properties onto the event object moel@348: if ( props ) { moel@348: jQuery.extend( this, props ); moel@348: } moel@348: moel@348: // Create a timestamp if incoming event doesn't have one moel@348: this.timeStamp = src && src.timeStamp || jQuery.now(); moel@348: moel@348: // Mark it as fixed moel@348: this[ jQuery.expando ] = true; moel@348: }; moel@348: moel@348: function returnFalse() { moel@348: return false; moel@348: } moel@348: function returnTrue() { moel@348: return true; moel@348: } moel@348: moel@348: // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding moel@348: // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html moel@348: jQuery.Event.prototype = { moel@348: preventDefault: function() { moel@348: this.isDefaultPrevented = returnTrue; moel@348: moel@348: var e = this.originalEvent; moel@348: if ( !e ) { moel@348: return; moel@348: } moel@348: moel@348: // if preventDefault exists run it on the original event moel@348: if ( e.preventDefault ) { moel@348: e.preventDefault(); moel@348: moel@348: // otherwise set the returnValue property of the original event to false (IE) moel@348: } else { moel@348: e.returnValue = false; moel@348: } moel@348: }, moel@348: stopPropagation: function() { moel@348: this.isPropagationStopped = returnTrue; moel@348: moel@348: var e = this.originalEvent; moel@348: if ( !e ) { moel@348: return; moel@348: } moel@348: // if stopPropagation exists run it on the original event moel@348: if ( e.stopPropagation ) { moel@348: e.stopPropagation(); moel@348: } moel@348: // otherwise set the cancelBubble property of the original event to true (IE) moel@348: e.cancelBubble = true; moel@348: }, moel@348: stopImmediatePropagation: function() { moel@348: this.isImmediatePropagationStopped = returnTrue; moel@348: this.stopPropagation(); moel@348: }, moel@348: isDefaultPrevented: returnFalse, moel@348: isPropagationStopped: returnFalse, moel@348: isImmediatePropagationStopped: returnFalse moel@348: }; moel@348: moel@348: // Create mouseenter/leave events using mouseover/out and event-time checks moel@348: jQuery.each({ moel@348: mouseenter: "mouseover", moel@348: mouseleave: "mouseout" moel@348: }, function( orig, fix ) { moel@348: jQuery.event.special[ orig ] = { moel@348: delegateType: fix, moel@348: bindType: fix, moel@348: moel@348: handle: function( event ) { moel@348: var target = this, moel@348: related = event.relatedTarget, moel@348: handleObj = event.handleObj, moel@348: selector = handleObj.selector, moel@348: ret; moel@348: moel@348: // For mousenter/leave call the handler if related is outside the target. moel@348: // NB: No relatedTarget if the mouse left/entered the browser window moel@348: if ( !related || (related !== target && !jQuery.contains( target, related )) ) { moel@348: event.type = handleObj.origType; moel@348: ret = handleObj.handler.apply( this, arguments ); moel@348: event.type = fix; moel@348: } moel@348: return ret; moel@348: } moel@348: }; moel@348: }); moel@348: moel@348: // IE submit delegation moel@348: if ( !jQuery.support.submitBubbles ) { moel@348: moel@348: jQuery.event.special.submit = { moel@348: setup: function() { moel@348: // Only need this for delegated form submit events moel@348: if ( jQuery.nodeName( this, "form" ) ) { moel@348: return false; moel@348: } moel@348: moel@348: // Lazy-add a submit handler when a descendant form may potentially be submitted moel@348: jQuery.event.add( this, "click._submit keypress._submit", function( e ) { moel@348: // Node name check avoids a VML-related crash in IE (#9807) moel@348: var elem = e.target, moel@348: form = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.form : undefined; moel@348: if ( form && !form._submit_attached ) { moel@348: jQuery.event.add( form, "submit._submit", function( event ) { moel@348: event._submit_bubble = true; moel@348: }); moel@348: form._submit_attached = true; moel@348: } moel@348: }); moel@348: // return undefined since we don't need an event listener moel@348: }, moel@348: moel@348: postDispatch: function( event ) { moel@348: // If form was submitted by the user, bubble the event up the tree moel@348: if ( event._submit_bubble ) { moel@348: delete event._submit_bubble; moel@348: if ( this.parentNode && !event.isTrigger ) { moel@348: jQuery.event.simulate( "submit", this.parentNode, event, true ); moel@348: } moel@348: } moel@348: }, moel@348: moel@348: teardown: function() { moel@348: // Only need this for delegated form submit events moel@348: if ( jQuery.nodeName( this, "form" ) ) { moel@348: return false; moel@348: } moel@348: moel@348: // Remove delegated handlers; cleanData eventually reaps submit handlers attached above moel@348: jQuery.event.remove( this, "._submit" ); moel@348: } moel@348: }; moel@348: } moel@348: moel@348: // IE change delegation and checkbox/radio fix moel@348: if ( !jQuery.support.changeBubbles ) { moel@348: moel@348: jQuery.event.special.change = { moel@348: moel@348: setup: function() { moel@348: moel@348: if ( rformElems.test( this.nodeName ) ) { moel@348: // IE doesn't fire change on a check/radio until blur; trigger it on click moel@348: // after a propertychange. Eat the blur-change in special.change.handle. moel@348: // This still fires onchange a second time for check/radio after blur. moel@348: if ( this.type === "checkbox" || this.type === "radio" ) { moel@348: jQuery.event.add( this, "propertychange._change", function( event ) { moel@348: if ( event.originalEvent.propertyName === "checked" ) { moel@348: this._just_changed = true; moel@348: } moel@348: }); moel@348: jQuery.event.add( this, "click._change", function( event ) { moel@348: if ( this._just_changed && !event.isTrigger ) { moel@348: this._just_changed = false; moel@348: jQuery.event.simulate( "change", this, event, true ); moel@348: } moel@348: }); moel@348: } moel@348: return false; moel@348: } moel@348: // Delegated event; lazy-add a change handler on descendant inputs moel@348: jQuery.event.add( this, "beforeactivate._change", function( e ) { moel@348: var elem = e.target; moel@348: moel@348: if ( rformElems.test( elem.nodeName ) && !elem._change_attached ) { moel@348: jQuery.event.add( elem, "change._change", function( event ) { moel@348: if ( this.parentNode && !event.isSimulated && !event.isTrigger ) { moel@348: jQuery.event.simulate( "change", this.parentNode, event, true ); moel@348: } moel@348: }); moel@348: elem._change_attached = true; moel@348: } moel@348: }); moel@348: }, moel@348: moel@348: handle: function( event ) { moel@348: var elem = event.target; moel@348: moel@348: // Swallow native change events from checkbox/radio, we already triggered them above moel@348: if ( this !== elem || event.isSimulated || event.isTrigger || (elem.type !== "radio" && elem.type !== "checkbox") ) { moel@348: return event.handleObj.handler.apply( this, arguments ); moel@348: } moel@348: }, moel@348: moel@348: teardown: function() { moel@348: jQuery.event.remove( this, "._change" ); moel@348: moel@348: return rformElems.test( this.nodeName ); moel@348: } moel@348: }; moel@348: } moel@348: moel@348: // Create "bubbling" focus and blur events moel@348: if ( !jQuery.support.focusinBubbles ) { moel@348: jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { moel@348: moel@348: // Attach a single capturing handler while someone wants focusin/focusout moel@348: var attaches = 0, moel@348: handler = function( event ) { moel@348: jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ), true ); moel@348: }; moel@348: moel@348: jQuery.event.special[ fix ] = { moel@348: setup: function() { moel@348: if ( attaches++ === 0 ) { moel@348: document.addEventListener( orig, handler, true ); moel@348: } moel@348: }, moel@348: teardown: function() { moel@348: if ( --attaches === 0 ) { moel@348: document.removeEventListener( orig, handler, true ); moel@348: } moel@348: } moel@348: }; moel@348: }); moel@348: } moel@348: moel@348: jQuery.fn.extend({ moel@348: moel@348: on: function( types, selector, data, fn, /*INTERNAL*/ one ) { moel@348: var origFn, type; moel@348: moel@348: // Types can be a map of types/handlers moel@348: if ( typeof types === "object" ) { moel@348: // ( types-Object, selector, data ) moel@348: if ( typeof selector !== "string" ) { // && selector != null moel@348: // ( types-Object, data ) moel@348: data = data || selector; moel@348: selector = undefined; moel@348: } moel@348: for ( type in types ) { moel@348: this.on( type, selector, data, types[ type ], one ); moel@348: } moel@348: return this; moel@348: } moel@348: moel@348: if ( data == null && fn == null ) { moel@348: // ( types, fn ) moel@348: fn = selector; moel@348: data = selector = undefined; moel@348: } else if ( fn == null ) { moel@348: if ( typeof selector === "string" ) { moel@348: // ( types, selector, fn ) moel@348: fn = data; moel@348: data = undefined; moel@348: } else { moel@348: // ( types, data, fn ) moel@348: fn = data; moel@348: data = selector; moel@348: selector = undefined; moel@348: } moel@348: } moel@348: if ( fn === false ) { moel@348: fn = returnFalse; moel@348: } else if ( !fn ) { moel@348: return this; moel@348: } moel@348: moel@348: if ( one === 1 ) { moel@348: origFn = fn; moel@348: fn = function( event ) { moel@348: // Can use an empty set, since event contains the info moel@348: jQuery().off( event ); moel@348: return origFn.apply( this, arguments ); moel@348: }; moel@348: // Use same guid so caller can remove using origFn moel@348: fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); moel@348: } moel@348: return this.each( function() { moel@348: jQuery.event.add( this, types, fn, data, selector ); moel@348: }); moel@348: }, moel@348: one: function( types, selector, data, fn ) { moel@348: return this.on( types, selector, data, fn, 1 ); moel@348: }, moel@348: off: function( types, selector, fn ) { moel@348: if ( types && types.preventDefault && types.handleObj ) { moel@348: // ( event ) dispatched jQuery.Event moel@348: var handleObj = types.handleObj; moel@348: jQuery( types.delegateTarget ).off( moel@348: handleObj.namespace ? handleObj.origType + "." + handleObj.namespace : handleObj.origType, moel@348: handleObj.selector, moel@348: handleObj.handler moel@348: ); moel@348: return this; moel@348: } moel@348: if ( typeof types === "object" ) { moel@348: // ( types-object [, selector] ) moel@348: for ( var type in types ) { moel@348: this.off( type, selector, types[ type ] ); moel@348: } moel@348: return this; moel@348: } moel@348: if ( selector === false || typeof selector === "function" ) { moel@348: // ( types [, fn] ) moel@348: fn = selector; moel@348: selector = undefined; moel@348: } moel@348: if ( fn === false ) { moel@348: fn = returnFalse; moel@348: } moel@348: return this.each(function() { moel@348: jQuery.event.remove( this, types, fn, selector ); moel@348: }); moel@348: }, moel@348: moel@348: bind: function( types, data, fn ) { moel@348: return this.on( types, null, data, fn ); moel@348: }, moel@348: unbind: function( types, fn ) { moel@348: return this.off( types, null, fn ); moel@348: }, moel@348: moel@348: live: function( types, data, fn ) { moel@348: jQuery( this.context ).on( types, this.selector, data, fn ); moel@348: return this; moel@348: }, moel@348: die: function( types, fn ) { moel@348: jQuery( this.context ).off( types, this.selector || "**", fn ); moel@348: return this; moel@348: }, moel@348: moel@348: delegate: function( selector, types, data, fn ) { moel@348: return this.on( types, selector, data, fn ); moel@348: }, moel@348: undelegate: function( selector, types, fn ) { moel@348: // ( namespace ) or ( selector, types [, fn] ) moel@348: return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector, fn ); moel@348: }, moel@348: moel@348: trigger: function( type, data ) { moel@348: return this.each(function() { moel@348: jQuery.event.trigger( type, data, this ); moel@348: }); moel@348: }, moel@348: triggerHandler: function( type, data ) { moel@348: if ( this[0] ) { moel@348: return jQuery.event.trigger( type, data, this[0], true ); moel@348: } moel@348: }, moel@348: moel@348: toggle: function( fn ) { moel@348: // Save reference to arguments for access in closure moel@348: var args = arguments, moel@348: guid = fn.guid || jQuery.guid++, moel@348: i = 0, moel@348: toggler = function( event ) { moel@348: // Figure out which function to execute moel@348: var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i; moel@348: jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 ); moel@348: moel@348: // Make sure that clicks stop moel@348: event.preventDefault(); moel@348: moel@348: // and execute the function moel@348: return args[ lastToggle ].apply( this, arguments ) || false; moel@348: }; moel@348: moel@348: // link all the functions, so any of them can unbind this click handler moel@348: toggler.guid = guid; moel@348: while ( i < args.length ) { moel@348: args[ i++ ].guid = guid; moel@348: } moel@348: moel@348: return this.click( toggler ); moel@348: }, moel@348: moel@348: hover: function( fnOver, fnOut ) { moel@348: return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); moel@348: } moel@348: }); moel@348: moel@348: jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + moel@348: "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + moel@348: "change select submit keydown keypress keyup error contextmenu").split(" "), function( i, name ) { moel@348: moel@348: // Handle event binding moel@348: jQuery.fn[ name ] = function( data, fn ) { moel@348: if ( fn == null ) { moel@348: fn = data; moel@348: data = null; moel@348: } moel@348: moel@348: return arguments.length > 0 ? moel@348: this.on( name, null, data, fn ) : moel@348: this.trigger( name ); moel@348: }; moel@348: moel@348: if ( jQuery.attrFn ) { moel@348: jQuery.attrFn[ name ] = true; moel@348: } moel@348: moel@348: if ( rkeyEvent.test( name ) ) { moel@348: jQuery.event.fixHooks[ name ] = jQuery.event.keyHooks; moel@348: } moel@348: moel@348: if ( rmouseEvent.test( name ) ) { moel@348: jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks; moel@348: } moel@348: }); moel@348: moel@348: moel@348: moel@348: /*! moel@348: * Sizzle CSS Selector Engine moel@348: * Copyright 2011, The Dojo Foundation moel@348: * Released under the MIT, BSD, and GPL Licenses. moel@348: * More information: http://sizzlejs.com/ moel@348: */ moel@348: (function(){ moel@348: moel@348: var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, moel@348: expando = "sizcache" + (Math.random() + '').replace('.', ''), moel@348: done = 0, moel@348: toString = Object.prototype.toString, moel@348: hasDuplicate = false, moel@348: baseHasDuplicate = true, moel@348: rBackslash = /\\/g, moel@348: rReturn = /\r\n/g, moel@348: rNonWord = /\W/; moel@348: moel@348: // Here we check if the JavaScript engine is using some sort of moel@348: // optimization where it does not always call our comparision moel@348: // function. If that is the case, discard the hasDuplicate value. moel@348: // Thus far that includes Google Chrome. moel@348: [0, 0].sort(function() { moel@348: baseHasDuplicate = false; moel@348: return 0; moel@348: }); moel@348: moel@348: var Sizzle = function( selector, context, results, seed ) { moel@348: results = results || []; moel@348: context = context || document; moel@348: moel@348: var origContext = context; moel@348: moel@348: if ( context.nodeType !== 1 && context.nodeType !== 9 ) { moel@348: return []; moel@348: } moel@348: moel@348: if ( !selector || typeof selector !== "string" ) { moel@348: return results; moel@348: } moel@348: moel@348: var m, set, checkSet, extra, ret, cur, pop, i, moel@348: prune = true, moel@348: contextXML = Sizzle.isXML( context ), moel@348: parts = [], moel@348: soFar = selector; moel@348: moel@348: // Reset the position of the chunker regexp (start from head) moel@348: do { moel@348: chunker.exec( "" ); moel@348: m = chunker.exec( soFar ); moel@348: moel@348: if ( m ) { moel@348: soFar = m[3]; moel@348: moel@348: parts.push( m[1] ); moel@348: moel@348: if ( m[2] ) { moel@348: extra = m[3]; moel@348: break; moel@348: } moel@348: } moel@348: } while ( m ); moel@348: moel@348: if ( parts.length > 1 && origPOS.exec( selector ) ) { moel@348: moel@348: if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { moel@348: set = posProcess( parts[0] + parts[1], context, seed ); moel@348: moel@348: } else { moel@348: set = Expr.relative[ parts[0] ] ? moel@348: [ context ] : moel@348: Sizzle( parts.shift(), context ); moel@348: moel@348: while ( parts.length ) { moel@348: selector = parts.shift(); moel@348: moel@348: if ( Expr.relative[ selector ] ) { moel@348: selector += parts.shift(); moel@348: } moel@348: moel@348: set = posProcess( selector, set, seed ); moel@348: } moel@348: } moel@348: moel@348: } else { moel@348: // Take a shortcut and set the context if the root selector is an ID moel@348: // (but not if it'll be faster if the inner selector is an ID) moel@348: if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && moel@348: Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { moel@348: moel@348: ret = Sizzle.find( parts.shift(), context, contextXML ); moel@348: context = ret.expr ? moel@348: Sizzle.filter( ret.expr, ret.set )[0] : moel@348: ret.set[0]; moel@348: } moel@348: moel@348: if ( context ) { moel@348: ret = seed ? moel@348: { expr: parts.pop(), set: makeArray(seed) } : moel@348: Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); moel@348: moel@348: set = ret.expr ? moel@348: Sizzle.filter( ret.expr, ret.set ) : moel@348: ret.set; moel@348: moel@348: if ( parts.length > 0 ) { moel@348: checkSet = makeArray( set ); moel@348: moel@348: } else { moel@348: prune = false; moel@348: } moel@348: moel@348: while ( parts.length ) { moel@348: cur = parts.pop(); moel@348: pop = cur; moel@348: moel@348: if ( !Expr.relative[ cur ] ) { moel@348: cur = ""; moel@348: } else { moel@348: pop = parts.pop(); moel@348: } moel@348: moel@348: if ( pop == null ) { moel@348: pop = context; moel@348: } moel@348: moel@348: Expr.relative[ cur ]( checkSet, pop, contextXML ); moel@348: } moel@348: moel@348: } else { moel@348: checkSet = parts = []; moel@348: } moel@348: } moel@348: moel@348: if ( !checkSet ) { moel@348: checkSet = set; moel@348: } moel@348: moel@348: if ( !checkSet ) { moel@348: Sizzle.error( cur || selector ); moel@348: } moel@348: moel@348: if ( toString.call(checkSet) === "[object Array]" ) { moel@348: if ( !prune ) { moel@348: results.push.apply( results, checkSet ); moel@348: moel@348: } else if ( context && context.nodeType === 1 ) { moel@348: for ( i = 0; checkSet[i] != null; i++ ) { moel@348: if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { moel@348: results.push( set[i] ); moel@348: } moel@348: } moel@348: moel@348: } else { moel@348: for ( i = 0; checkSet[i] != null; i++ ) { moel@348: if ( checkSet[i] && checkSet[i].nodeType === 1 ) { moel@348: results.push( set[i] ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: } else { moel@348: makeArray( checkSet, results ); moel@348: } moel@348: moel@348: if ( extra ) { moel@348: Sizzle( extra, origContext, results, seed ); moel@348: Sizzle.uniqueSort( results ); moel@348: } moel@348: moel@348: return results; moel@348: }; moel@348: moel@348: Sizzle.uniqueSort = function( results ) { moel@348: if ( sortOrder ) { moel@348: hasDuplicate = baseHasDuplicate; moel@348: results.sort( sortOrder ); moel@348: moel@348: if ( hasDuplicate ) { moel@348: for ( var i = 1; i < results.length; i++ ) { moel@348: if ( results[i] === results[ i - 1 ] ) { moel@348: results.splice( i--, 1 ); moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return results; moel@348: }; moel@348: moel@348: Sizzle.matches = function( expr, set ) { moel@348: return Sizzle( expr, null, null, set ); moel@348: }; moel@348: moel@348: Sizzle.matchesSelector = function( node, expr ) { moel@348: return Sizzle( expr, null, null, [node] ).length > 0; moel@348: }; moel@348: moel@348: Sizzle.find = function( expr, context, isXML ) { moel@348: var set, i, len, match, type, left; moel@348: moel@348: if ( !expr ) { moel@348: return []; moel@348: } moel@348: moel@348: for ( i = 0, len = Expr.order.length; i < len; i++ ) { moel@348: type = Expr.order[i]; moel@348: moel@348: if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { moel@348: left = match[1]; moel@348: match.splice( 1, 1 ); moel@348: moel@348: if ( left.substr( left.length - 1 ) !== "\\" ) { moel@348: match[1] = (match[1] || "").replace( rBackslash, "" ); moel@348: set = Expr.find[ type ]( match, context, isXML ); moel@348: moel@348: if ( set != null ) { moel@348: expr = expr.replace( Expr.match[ type ], "" ); moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: if ( !set ) { moel@348: set = typeof context.getElementsByTagName !== "undefined" ? moel@348: context.getElementsByTagName( "*" ) : moel@348: []; moel@348: } moel@348: moel@348: return { set: set, expr: expr }; moel@348: }; moel@348: moel@348: Sizzle.filter = function( expr, set, inplace, not ) { moel@348: var match, anyFound, moel@348: type, found, item, filter, left, moel@348: i, pass, moel@348: old = expr, moel@348: result = [], moel@348: curLoop = set, moel@348: isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); moel@348: moel@348: while ( expr && set.length ) { moel@348: for ( type in Expr.filter ) { moel@348: if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { moel@348: filter = Expr.filter[ type ]; moel@348: left = match[1]; moel@348: moel@348: anyFound = false; moel@348: moel@348: match.splice(1,1); moel@348: moel@348: if ( left.substr( left.length - 1 ) === "\\" ) { moel@348: continue; moel@348: } moel@348: moel@348: if ( curLoop === result ) { moel@348: result = []; moel@348: } moel@348: moel@348: if ( Expr.preFilter[ type ] ) { moel@348: match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); moel@348: moel@348: if ( !match ) { moel@348: anyFound = found = true; moel@348: moel@348: } else if ( match === true ) { moel@348: continue; moel@348: } moel@348: } moel@348: moel@348: if ( match ) { moel@348: for ( i = 0; (item = curLoop[i]) != null; i++ ) { moel@348: if ( item ) { moel@348: found = filter( item, match, i, curLoop ); moel@348: pass = not ^ found; moel@348: moel@348: if ( inplace && found != null ) { moel@348: if ( pass ) { moel@348: anyFound = true; moel@348: moel@348: } else { moel@348: curLoop[i] = false; moel@348: } moel@348: moel@348: } else if ( pass ) { moel@348: result.push( item ); moel@348: anyFound = true; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: if ( found !== undefined ) { moel@348: if ( !inplace ) { moel@348: curLoop = result; moel@348: } moel@348: moel@348: expr = expr.replace( Expr.match[ type ], "" ); moel@348: moel@348: if ( !anyFound ) { moel@348: return []; moel@348: } moel@348: moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Improper expression moel@348: if ( expr === old ) { moel@348: if ( anyFound == null ) { moel@348: Sizzle.error( expr ); moel@348: moel@348: } else { moel@348: break; moel@348: } moel@348: } moel@348: moel@348: old = expr; moel@348: } moel@348: moel@348: return curLoop; moel@348: }; moel@348: moel@348: Sizzle.error = function( msg ) { moel@348: throw new Error( "Syntax error, unrecognized expression: " + msg ); moel@348: }; moel@348: moel@348: /** moel@348: * Utility function for retreiving the text value of an array of DOM nodes moel@348: * @param {Array|Element} elem moel@348: */ moel@348: var getText = Sizzle.getText = function( elem ) { moel@348: var i, node, moel@348: nodeType = elem.nodeType, moel@348: ret = ""; moel@348: moel@348: if ( nodeType ) { moel@348: if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { moel@348: // Use textContent || innerText for elements moel@348: if ( typeof elem.textContent === 'string' ) { moel@348: return elem.textContent; moel@348: } else if ( typeof elem.innerText === 'string' ) { moel@348: // Replace IE's carriage returns moel@348: return elem.innerText.replace( rReturn, '' ); moel@348: } else { moel@348: // Traverse it's children moel@348: for ( elem = elem.firstChild; elem; elem = elem.nextSibling) { moel@348: ret += getText( elem ); moel@348: } moel@348: } moel@348: } else if ( nodeType === 3 || nodeType === 4 ) { moel@348: return elem.nodeValue; moel@348: } moel@348: } else { moel@348: moel@348: // If no nodeType, this is expected to be an array moel@348: for ( i = 0; (node = elem[i]); i++ ) { moel@348: // Do not traverse comment nodes moel@348: if ( node.nodeType !== 8 ) { moel@348: ret += getText( node ); moel@348: } moel@348: } moel@348: } moel@348: return ret; moel@348: }; moel@348: moel@348: var Expr = Sizzle.selectors = { moel@348: order: [ "ID", "NAME", "TAG" ], moel@348: moel@348: match: { moel@348: ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, moel@348: CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, moel@348: NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, moel@348: ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, moel@348: TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, moel@348: CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, moel@348: POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, moel@348: PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ moel@348: }, moel@348: moel@348: leftMatch: {}, moel@348: moel@348: attrMap: { moel@348: "class": "className", moel@348: "for": "htmlFor" moel@348: }, moel@348: moel@348: attrHandle: { moel@348: href: function( elem ) { moel@348: return elem.getAttribute( "href" ); moel@348: }, moel@348: type: function( elem ) { moel@348: return elem.getAttribute( "type" ); moel@348: } moel@348: }, moel@348: moel@348: relative: { moel@348: "+": function(checkSet, part){ moel@348: var isPartStr = typeof part === "string", moel@348: isTag = isPartStr && !rNonWord.test( part ), moel@348: isPartStrNotTag = isPartStr && !isTag; moel@348: moel@348: if ( isTag ) { moel@348: part = part.toLowerCase(); moel@348: } moel@348: moel@348: for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { moel@348: if ( (elem = checkSet[i]) ) { moel@348: while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} moel@348: moel@348: checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? moel@348: elem || false : moel@348: elem === part; moel@348: } moel@348: } moel@348: moel@348: if ( isPartStrNotTag ) { moel@348: Sizzle.filter( part, checkSet, true ); moel@348: } moel@348: }, moel@348: moel@348: ">": function( checkSet, part ) { moel@348: var elem, moel@348: isPartStr = typeof part === "string", moel@348: i = 0, moel@348: l = checkSet.length; moel@348: moel@348: if ( isPartStr && !rNonWord.test( part ) ) { moel@348: part = part.toLowerCase(); moel@348: moel@348: for ( ; i < l; i++ ) { moel@348: elem = checkSet[i]; moel@348: moel@348: if ( elem ) { moel@348: var parent = elem.parentNode; moel@348: checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; moel@348: } moel@348: } moel@348: moel@348: } else { moel@348: for ( ; i < l; i++ ) { moel@348: elem = checkSet[i]; moel@348: moel@348: if ( elem ) { moel@348: checkSet[i] = isPartStr ? moel@348: elem.parentNode : moel@348: elem.parentNode === part; moel@348: } moel@348: } moel@348: moel@348: if ( isPartStr ) { moel@348: Sizzle.filter( part, checkSet, true ); moel@348: } moel@348: } moel@348: }, moel@348: moel@348: "": function(checkSet, part, isXML){ moel@348: var nodeCheck, moel@348: doneName = done++, moel@348: checkFn = dirCheck; moel@348: moel@348: if ( typeof part === "string" && !rNonWord.test( part ) ) { moel@348: part = part.toLowerCase(); moel@348: nodeCheck = part; moel@348: checkFn = dirNodeCheck; moel@348: } moel@348: moel@348: checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); moel@348: }, moel@348: moel@348: "~": function( checkSet, part, isXML ) { moel@348: var nodeCheck, moel@348: doneName = done++, moel@348: checkFn = dirCheck; moel@348: moel@348: if ( typeof part === "string" && !rNonWord.test( part ) ) { moel@348: part = part.toLowerCase(); moel@348: nodeCheck = part; moel@348: checkFn = dirNodeCheck; moel@348: } moel@348: moel@348: checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); moel@348: } moel@348: }, moel@348: moel@348: find: { moel@348: ID: function( match, context, isXML ) { moel@348: if ( typeof context.getElementById !== "undefined" && !isXML ) { moel@348: var m = context.getElementById(match[1]); moel@348: // Check parentNode to catch when Blackberry 4.6 returns moel@348: // nodes that are no longer in the document #6963 moel@348: return m && m.parentNode ? [m] : []; moel@348: } moel@348: }, moel@348: moel@348: NAME: function( match, context ) { moel@348: if ( typeof context.getElementsByName !== "undefined" ) { moel@348: var ret = [], moel@348: results = context.getElementsByName( match[1] ); moel@348: moel@348: for ( var i = 0, l = results.length; i < l; i++ ) { moel@348: if ( results[i].getAttribute("name") === match[1] ) { moel@348: ret.push( results[i] ); moel@348: } moel@348: } moel@348: moel@348: return ret.length === 0 ? null : ret; moel@348: } moel@348: }, moel@348: moel@348: TAG: function( match, context ) { moel@348: if ( typeof context.getElementsByTagName !== "undefined" ) { moel@348: return context.getElementsByTagName( match[1] ); moel@348: } moel@348: } moel@348: }, moel@348: preFilter: { moel@348: CLASS: function( match, curLoop, inplace, result, not, isXML ) { moel@348: match = " " + match[1].replace( rBackslash, "" ) + " "; moel@348: moel@348: if ( isXML ) { moel@348: return match; moel@348: } moel@348: moel@348: for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { moel@348: if ( elem ) { moel@348: if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { moel@348: if ( !inplace ) { moel@348: result.push( elem ); moel@348: } moel@348: moel@348: } else if ( inplace ) { moel@348: curLoop[i] = false; moel@348: } moel@348: } moel@348: } moel@348: moel@348: return false; moel@348: }, moel@348: moel@348: ID: function( match ) { moel@348: return match[1].replace( rBackslash, "" ); moel@348: }, moel@348: moel@348: TAG: function( match, curLoop ) { moel@348: return match[1].replace( rBackslash, "" ).toLowerCase(); moel@348: }, moel@348: moel@348: CHILD: function( match ) { moel@348: if ( match[1] === "nth" ) { moel@348: if ( !match[2] ) { moel@348: Sizzle.error( match[0] ); moel@348: } moel@348: moel@348: match[2] = match[2].replace(/^\+|\s*/g, ''); moel@348: moel@348: // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' moel@348: var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( moel@348: match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || moel@348: !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); moel@348: moel@348: // calculate the numbers (first)n+(last) including if they are negative moel@348: match[2] = (test[1] + (test[2] || 1)) - 0; moel@348: match[3] = test[3] - 0; moel@348: } moel@348: else if ( match[2] ) { moel@348: Sizzle.error( match[0] ); moel@348: } moel@348: moel@348: // TODO: Move to normal caching system moel@348: match[0] = done++; moel@348: moel@348: return match; moel@348: }, moel@348: moel@348: ATTR: function( match, curLoop, inplace, result, not, isXML ) { moel@348: var name = match[1] = match[1].replace( rBackslash, "" ); moel@348: moel@348: if ( !isXML && Expr.attrMap[name] ) { moel@348: match[1] = Expr.attrMap[name]; moel@348: } moel@348: moel@348: // Handle if an un-quoted value was used moel@348: match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); moel@348: moel@348: if ( match[2] === "~=" ) { moel@348: match[4] = " " + match[4] + " "; moel@348: } moel@348: moel@348: return match; moel@348: }, moel@348: moel@348: PSEUDO: function( match, curLoop, inplace, result, not ) { moel@348: if ( match[1] === "not" ) { moel@348: // If we're dealing with a complex expression, or a simple one moel@348: if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { moel@348: match[3] = Sizzle(match[3], null, null, curLoop); moel@348: moel@348: } else { moel@348: var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); moel@348: moel@348: if ( !inplace ) { moel@348: result.push.apply( result, ret ); moel@348: } moel@348: moel@348: return false; moel@348: } moel@348: moel@348: } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { moel@348: return true; moel@348: } moel@348: moel@348: return match; moel@348: }, moel@348: moel@348: POS: function( match ) { moel@348: match.unshift( true ); moel@348: moel@348: return match; moel@348: } moel@348: }, moel@348: moel@348: filters: { moel@348: enabled: function( elem ) { moel@348: return elem.disabled === false && elem.type !== "hidden"; moel@348: }, moel@348: moel@348: disabled: function( elem ) { moel@348: return elem.disabled === true; moel@348: }, moel@348: moel@348: checked: function( elem ) { moel@348: return elem.checked === true; moel@348: }, moel@348: moel@348: selected: function( elem ) { moel@348: // Accessing this property makes selected-by-default moel@348: // options in Safari work properly moel@348: if ( elem.parentNode ) { moel@348: elem.parentNode.selectedIndex; moel@348: } moel@348: moel@348: return elem.selected === true; moel@348: }, moel@348: moel@348: parent: function( elem ) { moel@348: return !!elem.firstChild; moel@348: }, moel@348: moel@348: empty: function( elem ) { moel@348: return !elem.firstChild; moel@348: }, moel@348: moel@348: has: function( elem, i, match ) { moel@348: return !!Sizzle( match[3], elem ).length; moel@348: }, moel@348: moel@348: header: function( elem ) { moel@348: return (/h\d/i).test( elem.nodeName ); moel@348: }, moel@348: moel@348: text: function( elem ) { moel@348: var attr = elem.getAttribute( "type" ), type = elem.type; moel@348: // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) moel@348: // use getAttribute instead to test this case moel@348: return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); moel@348: }, moel@348: moel@348: radio: function( elem ) { moel@348: return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; moel@348: }, moel@348: moel@348: checkbox: function( elem ) { moel@348: return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; moel@348: }, moel@348: moel@348: file: function( elem ) { moel@348: return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; moel@348: }, moel@348: moel@348: password: function( elem ) { moel@348: return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; moel@348: }, moel@348: moel@348: submit: function( elem ) { moel@348: var name = elem.nodeName.toLowerCase(); moel@348: return (name === "input" || name === "button") && "submit" === elem.type; moel@348: }, moel@348: moel@348: image: function( elem ) { moel@348: return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; moel@348: }, moel@348: moel@348: reset: function( elem ) { moel@348: var name = elem.nodeName.toLowerCase(); moel@348: return (name === "input" || name === "button") && "reset" === elem.type; moel@348: }, moel@348: moel@348: button: function( elem ) { moel@348: var name = elem.nodeName.toLowerCase(); moel@348: return name === "input" && "button" === elem.type || name === "button"; moel@348: }, moel@348: moel@348: input: function( elem ) { moel@348: return (/input|select|textarea|button/i).test( elem.nodeName ); moel@348: }, moel@348: moel@348: focus: function( elem ) { moel@348: return elem === elem.ownerDocument.activeElement; moel@348: } moel@348: }, moel@348: setFilters: { moel@348: first: function( elem, i ) { moel@348: return i === 0; moel@348: }, moel@348: moel@348: last: function( elem, i, match, array ) { moel@348: return i === array.length - 1; moel@348: }, moel@348: moel@348: even: function( elem, i ) { moel@348: return i % 2 === 0; moel@348: }, moel@348: moel@348: odd: function( elem, i ) { moel@348: return i % 2 === 1; moel@348: }, moel@348: moel@348: lt: function( elem, i, match ) { moel@348: return i < match[3] - 0; moel@348: }, moel@348: moel@348: gt: function( elem, i, match ) { moel@348: return i > match[3] - 0; moel@348: }, moel@348: moel@348: nth: function( elem, i, match ) { moel@348: return match[3] - 0 === i; moel@348: }, moel@348: moel@348: eq: function( elem, i, match ) { moel@348: return match[3] - 0 === i; moel@348: } moel@348: }, moel@348: filter: { moel@348: PSEUDO: function( elem, match, i, array ) { moel@348: var name = match[1], moel@348: filter = Expr.filters[ name ]; moel@348: moel@348: if ( filter ) { moel@348: return filter( elem, i, match, array ); moel@348: moel@348: } else if ( name === "contains" ) { moel@348: return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0; moel@348: moel@348: } else if ( name === "not" ) { moel@348: var not = match[3]; moel@348: moel@348: for ( var j = 0, l = not.length; j < l; j++ ) { moel@348: if ( not[j] === elem ) { moel@348: return false; moel@348: } moel@348: } moel@348: moel@348: return true; moel@348: moel@348: } else { moel@348: Sizzle.error( name ); moel@348: } moel@348: }, moel@348: moel@348: CHILD: function( elem, match ) { moel@348: var first, last, moel@348: doneName, parent, cache, moel@348: count, diff, moel@348: type = match[1], moel@348: node = elem; moel@348: moel@348: switch ( type ) { moel@348: case "only": moel@348: case "first": moel@348: while ( (node = node.previousSibling) ) { moel@348: if ( node.nodeType === 1 ) { moel@348: return false; moel@348: } moel@348: } moel@348: moel@348: if ( type === "first" ) { moel@348: return true; moel@348: } moel@348: moel@348: node = elem; moel@348: moel@348: /* falls through */ moel@348: case "last": moel@348: while ( (node = node.nextSibling) ) { moel@348: if ( node.nodeType === 1 ) { moel@348: return false; moel@348: } moel@348: } moel@348: moel@348: return true; moel@348: moel@348: case "nth": moel@348: first = match[2]; moel@348: last = match[3]; moel@348: moel@348: if ( first === 1 && last === 0 ) { moel@348: return true; moel@348: } moel@348: moel@348: doneName = match[0]; moel@348: parent = elem.parentNode; moel@348: moel@348: if ( parent && (parent[ expando ] !== doneName || !elem.nodeIndex) ) { moel@348: count = 0; moel@348: moel@348: for ( node = parent.firstChild; node; node = node.nextSibling ) { moel@348: if ( node.nodeType === 1 ) { moel@348: node.nodeIndex = ++count; moel@348: } moel@348: } moel@348: moel@348: parent[ expando ] = doneName; moel@348: } moel@348: moel@348: diff = elem.nodeIndex - last; moel@348: moel@348: if ( first === 0 ) { moel@348: return diff === 0; moel@348: moel@348: } else { moel@348: return ( diff % first === 0 && diff / first >= 0 ); moel@348: } moel@348: } moel@348: }, moel@348: moel@348: ID: function( elem, match ) { moel@348: return elem.nodeType === 1 && elem.getAttribute("id") === match; moel@348: }, moel@348: moel@348: TAG: function( elem, match ) { moel@348: return (match === "*" && elem.nodeType === 1) || !!elem.nodeName && elem.nodeName.toLowerCase() === match; moel@348: }, moel@348: moel@348: CLASS: function( elem, match ) { moel@348: return (" " + (elem.className || elem.getAttribute("class")) + " ") moel@348: .indexOf( match ) > -1; moel@348: }, moel@348: moel@348: ATTR: function( elem, match ) { moel@348: var name = match[1], moel@348: result = Sizzle.attr ? moel@348: Sizzle.attr( elem, name ) : moel@348: Expr.attrHandle[ name ] ? moel@348: Expr.attrHandle[ name ]( elem ) : moel@348: elem[ name ] != null ? moel@348: elem[ name ] : moel@348: elem.getAttribute( name ), moel@348: value = result + "", moel@348: type = match[2], moel@348: check = match[4]; moel@348: moel@348: return result == null ? moel@348: type === "!=" : moel@348: !type && Sizzle.attr ? moel@348: result != null : moel@348: type === "=" ? moel@348: value === check : moel@348: type === "*=" ? moel@348: value.indexOf(check) >= 0 : moel@348: type === "~=" ? moel@348: (" " + value + " ").indexOf(check) >= 0 : moel@348: !check ? moel@348: value && result !== false : moel@348: type === "!=" ? moel@348: value !== check : moel@348: type === "^=" ? moel@348: value.indexOf(check) === 0 : moel@348: type === "$=" ? moel@348: value.substr(value.length - check.length) === check : moel@348: type === "|=" ? moel@348: value === check || value.substr(0, check.length + 1) === check + "-" : moel@348: false; moel@348: }, moel@348: moel@348: POS: function( elem, match, i, array ) { moel@348: var name = match[2], moel@348: filter = Expr.setFilters[ name ]; moel@348: moel@348: if ( filter ) { moel@348: return filter( elem, i, match, array ); moel@348: } moel@348: } moel@348: } moel@348: }; moel@348: moel@348: var origPOS = Expr.match.POS, moel@348: fescape = function(all, num){ moel@348: return "\\" + (num - 0 + 1); moel@348: }; moel@348: moel@348: for ( var type in Expr.match ) { moel@348: Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); moel@348: Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); moel@348: } moel@348: // Expose origPOS moel@348: // "global" as in regardless of relation to brackets/parens moel@348: Expr.match.globalPOS = origPOS; moel@348: moel@348: var makeArray = function( array, results ) { moel@348: array = Array.prototype.slice.call( array, 0 ); moel@348: moel@348: if ( results ) { moel@348: results.push.apply( results, array ); moel@348: return results; moel@348: } moel@348: moel@348: return array; moel@348: }; moel@348: moel@348: // Perform a simple check to determine if the browser is capable of moel@348: // converting a NodeList to an array using builtin methods. moel@348: // Also verifies that the returned array holds DOM nodes moel@348: // (which is not the case in the Blackberry browser) moel@348: try { moel@348: Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; moel@348: moel@348: // Provide a fallback method if it does not work moel@348: } catch( e ) { moel@348: makeArray = function( array, results ) { moel@348: var i = 0, moel@348: ret = results || []; moel@348: moel@348: if ( toString.call(array) === "[object Array]" ) { moel@348: Array.prototype.push.apply( ret, array ); moel@348: moel@348: } else { moel@348: if ( typeof array.length === "number" ) { moel@348: for ( var l = array.length; i < l; i++ ) { moel@348: ret.push( array[i] ); moel@348: } moel@348: moel@348: } else { moel@348: for ( ; array[i]; i++ ) { moel@348: ret.push( array[i] ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: return ret; moel@348: }; moel@348: } moel@348: moel@348: var sortOrder, siblingCheck; moel@348: moel@348: if ( document.documentElement.compareDocumentPosition ) { moel@348: sortOrder = function( a, b ) { moel@348: if ( a === b ) { moel@348: hasDuplicate = true; moel@348: return 0; moel@348: } moel@348: moel@348: if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { moel@348: return a.compareDocumentPosition ? -1 : 1; moel@348: } moel@348: moel@348: return a.compareDocumentPosition(b) & 4 ? -1 : 1; moel@348: }; moel@348: moel@348: } else { moel@348: sortOrder = function( a, b ) { moel@348: // The nodes are identical, we can exit early moel@348: if ( a === b ) { moel@348: hasDuplicate = true; moel@348: return 0; moel@348: moel@348: // Fallback to using sourceIndex (in IE) if it's available on both nodes moel@348: } else if ( a.sourceIndex && b.sourceIndex ) { moel@348: return a.sourceIndex - b.sourceIndex; moel@348: } moel@348: moel@348: var al, bl, moel@348: ap = [], moel@348: bp = [], moel@348: aup = a.parentNode, moel@348: bup = b.parentNode, moel@348: cur = aup; moel@348: moel@348: // If the nodes are siblings (or identical) we can do a quick check moel@348: if ( aup === bup ) { moel@348: return siblingCheck( a, b ); moel@348: moel@348: // If no parents were found then the nodes are disconnected moel@348: } else if ( !aup ) { moel@348: return -1; moel@348: moel@348: } else if ( !bup ) { moel@348: return 1; moel@348: } moel@348: moel@348: // Otherwise they're somewhere else in the tree so we need moel@348: // to build up a full list of the parentNodes for comparison moel@348: while ( cur ) { moel@348: ap.unshift( cur ); moel@348: cur = cur.parentNode; moel@348: } moel@348: moel@348: cur = bup; moel@348: moel@348: while ( cur ) { moel@348: bp.unshift( cur ); moel@348: cur = cur.parentNode; moel@348: } moel@348: moel@348: al = ap.length; moel@348: bl = bp.length; moel@348: moel@348: // Start walking down the tree looking for a discrepancy moel@348: for ( var i = 0; i < al && i < bl; i++ ) { moel@348: if ( ap[i] !== bp[i] ) { moel@348: return siblingCheck( ap[i], bp[i] ); moel@348: } moel@348: } moel@348: moel@348: // We ended someplace up the tree so do a sibling check moel@348: return i === al ? moel@348: siblingCheck( a, bp[i], -1 ) : moel@348: siblingCheck( ap[i], b, 1 ); moel@348: }; moel@348: moel@348: siblingCheck = function( a, b, ret ) { moel@348: if ( a === b ) { moel@348: return ret; moel@348: } moel@348: moel@348: var cur = a.nextSibling; moel@348: moel@348: while ( cur ) { moel@348: if ( cur === b ) { moel@348: return -1; moel@348: } moel@348: moel@348: cur = cur.nextSibling; moel@348: } moel@348: moel@348: return 1; moel@348: }; moel@348: } moel@348: moel@348: // Check to see if the browser returns elements by name when moel@348: // querying by getElementById (and provide a workaround) moel@348: (function(){ moel@348: // We're going to inject a fake input element with a specified name moel@348: var form = document.createElement("div"), moel@348: id = "script" + (new Date()).getTime(), moel@348: root = document.documentElement; moel@348: moel@348: form.innerHTML = "<a name='" + id + "'/>"; moel@348: moel@348: // Inject it into the root element, check its status, and remove it quickly moel@348: root.insertBefore( form, root.firstChild ); moel@348: moel@348: // The workaround has to do additional checks after a getElementById moel@348: // Which slows things down for other browsers (hence the branching) moel@348: if ( document.getElementById( id ) ) { moel@348: Expr.find.ID = function( match, context, isXML ) { moel@348: if ( typeof context.getElementById !== "undefined" && !isXML ) { moel@348: var m = context.getElementById(match[1]); moel@348: moel@348: return m ? moel@348: m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? moel@348: [m] : moel@348: undefined : moel@348: []; moel@348: } moel@348: }; moel@348: moel@348: Expr.filter.ID = function( elem, match ) { moel@348: var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); moel@348: moel@348: return elem.nodeType === 1 && node && node.nodeValue === match; moel@348: }; moel@348: } moel@348: moel@348: root.removeChild( form ); moel@348: moel@348: // release memory in IE moel@348: root = form = null; moel@348: })(); moel@348: moel@348: (function(){ moel@348: // Check to see if the browser returns only elements moel@348: // when doing getElementsByTagName("*") moel@348: moel@348: // Create a fake element moel@348: var div = document.createElement("div"); moel@348: div.appendChild( document.createComment("") ); moel@348: moel@348: // Make sure no comments are found moel@348: if ( div.getElementsByTagName("*").length > 0 ) { moel@348: Expr.find.TAG = function( match, context ) { moel@348: var results = context.getElementsByTagName( match[1] ); moel@348: moel@348: // Filter out possible comments moel@348: if ( match[1] === "*" ) { moel@348: var tmp = []; moel@348: moel@348: for ( var i = 0; results[i]; i++ ) { moel@348: if ( results[i].nodeType === 1 ) { moel@348: tmp.push( results[i] ); moel@348: } moel@348: } moel@348: moel@348: results = tmp; moel@348: } moel@348: moel@348: return results; moel@348: }; moel@348: } moel@348: moel@348: // Check to see if an attribute returns normalized href attributes moel@348: div.innerHTML = "<a href='#'></a>"; moel@348: moel@348: if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && moel@348: div.firstChild.getAttribute("href") !== "#" ) { moel@348: moel@348: Expr.attrHandle.href = function( elem ) { moel@348: return elem.getAttribute( "href", 2 ); moel@348: }; moel@348: } moel@348: moel@348: // release memory in IE moel@348: div = null; moel@348: })(); moel@348: moel@348: if ( document.querySelectorAll ) { moel@348: (function(){ moel@348: var oldSizzle = Sizzle, moel@348: div = document.createElement("div"), moel@348: id = "__sizzle__"; moel@348: moel@348: div.innerHTML = "<p class='TEST'></p>"; moel@348: moel@348: // Safari can't handle uppercase or unicode characters when moel@348: // in quirks mode. moel@348: if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { moel@348: return; moel@348: } moel@348: moel@348: Sizzle = function( query, context, extra, seed ) { moel@348: context = context || document; moel@348: moel@348: // Only use querySelectorAll on non-XML documents moel@348: // (ID selectors don't work in non-HTML documents) moel@348: if ( !seed && !Sizzle.isXML(context) ) { moel@348: // See if we find a selector to speed up moel@348: var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); moel@348: moel@348: if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { moel@348: // Speed-up: Sizzle("TAG") moel@348: if ( match[1] ) { moel@348: return makeArray( context.getElementsByTagName( query ), extra ); moel@348: moel@348: // Speed-up: Sizzle(".CLASS") moel@348: } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { moel@348: return makeArray( context.getElementsByClassName( match[2] ), extra ); moel@348: } moel@348: } moel@348: moel@348: if ( context.nodeType === 9 ) { moel@348: // Speed-up: Sizzle("body") moel@348: // The body element only exists once, optimize finding it moel@348: if ( query === "body" && context.body ) { moel@348: return makeArray( [ context.body ], extra ); moel@348: moel@348: // Speed-up: Sizzle("#ID") moel@348: } else if ( match && match[3] ) { moel@348: var elem = context.getElementById( match[3] ); moel@348: moel@348: // Check parentNode to catch when Blackberry 4.6 returns moel@348: // nodes that are no longer in the document #6963 moel@348: if ( elem && elem.parentNode ) { moel@348: // Handle the case where IE and Opera return items moel@348: // by name instead of ID moel@348: if ( elem.id === match[3] ) { moel@348: return makeArray( [ elem ], extra ); moel@348: } moel@348: moel@348: } else { moel@348: return makeArray( [], extra ); moel@348: } moel@348: } moel@348: moel@348: try { moel@348: return makeArray( context.querySelectorAll(query), extra ); moel@348: } catch(qsaError) {} moel@348: moel@348: // qSA works strangely on Element-rooted queries moel@348: // We can work around this by specifying an extra ID on the root moel@348: // and working up from there (Thanks to Andrew Dupont for the technique) moel@348: // IE 8 doesn't work on object elements moel@348: } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { moel@348: var oldContext = context, moel@348: old = context.getAttribute( "id" ), moel@348: nid = old || id, moel@348: hasParent = context.parentNode, moel@348: relativeHierarchySelector = /^\s*[+~]/.test( query ); moel@348: moel@348: if ( !old ) { moel@348: context.setAttribute( "id", nid ); moel@348: } else { moel@348: nid = nid.replace( /'/g, "\\$&" ); moel@348: } moel@348: if ( relativeHierarchySelector && hasParent ) { moel@348: context = context.parentNode; moel@348: } moel@348: moel@348: try { moel@348: if ( !relativeHierarchySelector || hasParent ) { moel@348: return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); moel@348: } moel@348: moel@348: } catch(pseudoError) { moel@348: } finally { moel@348: if ( !old ) { moel@348: oldContext.removeAttribute( "id" ); moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return oldSizzle(query, context, extra, seed); moel@348: }; moel@348: moel@348: for ( var prop in oldSizzle ) { moel@348: Sizzle[ prop ] = oldSizzle[ prop ]; moel@348: } moel@348: moel@348: // release memory in IE moel@348: div = null; moel@348: })(); moel@348: } moel@348: moel@348: (function(){ moel@348: var html = document.documentElement, moel@348: matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; moel@348: moel@348: if ( matches ) { moel@348: // Check to see if it's possible to do matchesSelector moel@348: // on a disconnected node (IE 9 fails this) moel@348: var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), moel@348: pseudoWorks = false; moel@348: moel@348: try { moel@348: // This should fail with an exception moel@348: // Gecko does not error, returns false instead moel@348: matches.call( document.documentElement, "[test!='']:sizzle" ); moel@348: moel@348: } catch( pseudoError ) { moel@348: pseudoWorks = true; moel@348: } moel@348: moel@348: Sizzle.matchesSelector = function( node, expr ) { moel@348: // Make sure that attribute selectors are quoted moel@348: expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); moel@348: moel@348: if ( !Sizzle.isXML( node ) ) { moel@348: try { moel@348: if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { moel@348: var ret = matches.call( node, expr ); moel@348: moel@348: // IE 9's matchesSelector returns false on disconnected nodes moel@348: if ( ret || !disconnectedMatch || moel@348: // As well, disconnected nodes are said to be in a document moel@348: // fragment in IE 9, so check for that moel@348: node.document && node.document.nodeType !== 11 ) { moel@348: return ret; moel@348: } moel@348: } moel@348: } catch(e) {} moel@348: } moel@348: moel@348: return Sizzle(expr, null, null, [node]).length > 0; moel@348: }; moel@348: } moel@348: })(); moel@348: moel@348: (function(){ moel@348: var div = document.createElement("div"); moel@348: moel@348: div.innerHTML = "<div class='test e'></div><div class='test'></div>"; moel@348: moel@348: // Opera can't find a second classname (in 9.6) moel@348: // Also, make sure that getElementsByClassName actually exists moel@348: if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { moel@348: return; moel@348: } moel@348: moel@348: // Safari caches class attributes, doesn't catch changes (in 3.2) moel@348: div.lastChild.className = "e"; moel@348: moel@348: if ( div.getElementsByClassName("e").length === 1 ) { moel@348: return; moel@348: } moel@348: moel@348: Expr.order.splice(1, 0, "CLASS"); moel@348: Expr.find.CLASS = function( match, context, isXML ) { moel@348: if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { moel@348: return context.getElementsByClassName(match[1]); moel@348: } moel@348: }; moel@348: moel@348: // release memory in IE moel@348: div = null; moel@348: })(); moel@348: moel@348: function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { moel@348: for ( var i = 0, l = checkSet.length; i < l; i++ ) { moel@348: var elem = checkSet[i]; moel@348: moel@348: if ( elem ) { moel@348: var match = false; moel@348: moel@348: elem = elem[dir]; moel@348: moel@348: while ( elem ) { moel@348: if ( elem[ expando ] === doneName ) { moel@348: match = checkSet[elem.sizset]; moel@348: break; moel@348: } moel@348: moel@348: if ( elem.nodeType === 1 && !isXML ){ moel@348: elem[ expando ] = doneName; moel@348: elem.sizset = i; moel@348: } moel@348: moel@348: if ( elem.nodeName.toLowerCase() === cur ) { moel@348: match = elem; moel@348: break; moel@348: } moel@348: moel@348: elem = elem[dir]; moel@348: } moel@348: moel@348: checkSet[i] = match; moel@348: } moel@348: } moel@348: } moel@348: moel@348: function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { moel@348: for ( var i = 0, l = checkSet.length; i < l; i++ ) { moel@348: var elem = checkSet[i]; moel@348: moel@348: if ( elem ) { moel@348: var match = false; moel@348: moel@348: elem = elem[dir]; moel@348: moel@348: while ( elem ) { moel@348: if ( elem[ expando ] === doneName ) { moel@348: match = checkSet[elem.sizset]; moel@348: break; moel@348: } moel@348: moel@348: if ( elem.nodeType === 1 ) { moel@348: if ( !isXML ) { moel@348: elem[ expando ] = doneName; moel@348: elem.sizset = i; moel@348: } moel@348: moel@348: if ( typeof cur !== "string" ) { moel@348: if ( elem === cur ) { moel@348: match = true; moel@348: break; moel@348: } moel@348: moel@348: } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { moel@348: match = elem; moel@348: break; moel@348: } moel@348: } moel@348: moel@348: elem = elem[dir]; moel@348: } moel@348: moel@348: checkSet[i] = match; moel@348: } moel@348: } moel@348: } moel@348: moel@348: if ( document.documentElement.contains ) { moel@348: Sizzle.contains = function( a, b ) { moel@348: return a !== b && (a.contains ? a.contains(b) : true); moel@348: }; moel@348: moel@348: } else if ( document.documentElement.compareDocumentPosition ) { moel@348: Sizzle.contains = function( a, b ) { moel@348: return !!(a.compareDocumentPosition(b) & 16); moel@348: }; moel@348: moel@348: } else { moel@348: Sizzle.contains = function() { moel@348: return false; moel@348: }; moel@348: } moel@348: moel@348: Sizzle.isXML = function( elem ) { moel@348: // documentElement is verified for cases where it doesn't yet exist moel@348: // (such as loading iframes in IE - #4833) moel@348: var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; moel@348: moel@348: return documentElement ? documentElement.nodeName !== "HTML" : false; moel@348: }; moel@348: moel@348: var posProcess = function( selector, context, seed ) { moel@348: var match, moel@348: tmpSet = [], moel@348: later = "", moel@348: root = context.nodeType ? [context] : context; moel@348: moel@348: // Position selectors must be done after the filter moel@348: // And so must :not(positional) so we move all PSEUDOs to the end moel@348: while ( (match = Expr.match.PSEUDO.exec( selector )) ) { moel@348: later += match[0]; moel@348: selector = selector.replace( Expr.match.PSEUDO, "" ); moel@348: } moel@348: moel@348: selector = Expr.relative[selector] ? selector + "*" : selector; moel@348: moel@348: for ( var i = 0, l = root.length; i < l; i++ ) { moel@348: Sizzle( selector, root[i], tmpSet, seed ); moel@348: } moel@348: moel@348: return Sizzle.filter( later, tmpSet ); moel@348: }; moel@348: moel@348: // EXPOSE moel@348: // Override sizzle attribute retrieval moel@348: Sizzle.attr = jQuery.attr; moel@348: Sizzle.selectors.attrMap = {}; moel@348: jQuery.find = Sizzle; moel@348: jQuery.expr = Sizzle.selectors; moel@348: jQuery.expr[":"] = jQuery.expr.filters; moel@348: jQuery.unique = Sizzle.uniqueSort; moel@348: jQuery.text = Sizzle.getText; moel@348: jQuery.isXMLDoc = Sizzle.isXML; moel@348: jQuery.contains = Sizzle.contains; moel@348: moel@348: moel@348: })(); moel@348: moel@348: moel@348: var runtil = /Until$/, moel@348: rparentsprev = /^(?:parents|prevUntil|prevAll)/, moel@348: // Note: This RegExp should be improved, or likely pulled from Sizzle moel@348: rmultiselector = /,/, moel@348: isSimple = /^.[^:#\[\.,]*$/, moel@348: slice = Array.prototype.slice, moel@348: POS = jQuery.expr.match.globalPOS, moel@348: // methods guaranteed to produce a unique set when starting from a unique set moel@348: guaranteedUnique = { moel@348: children: true, moel@348: contents: true, moel@348: next: true, moel@348: prev: true moel@348: }; moel@348: moel@348: jQuery.fn.extend({ moel@348: find: function( selector ) { moel@348: var self = this, moel@348: i, l; moel@348: moel@348: if ( typeof selector !== "string" ) { moel@348: return jQuery( selector ).filter(function() { moel@348: for ( i = 0, l = self.length; i < l; i++ ) { moel@348: if ( jQuery.contains( self[ i ], this ) ) { moel@348: return true; moel@348: } moel@348: } moel@348: }); moel@348: } moel@348: moel@348: var ret = this.pushStack( "", "find", selector ), moel@348: length, n, r; moel@348: moel@348: for ( i = 0, l = this.length; i < l; i++ ) { moel@348: length = ret.length; moel@348: jQuery.find( selector, this[i], ret ); moel@348: moel@348: if ( i > 0 ) { moel@348: // Make sure that the results are unique moel@348: for ( n = length; n < ret.length; n++ ) { moel@348: for ( r = 0; r < length; r++ ) { moel@348: if ( ret[r] === ret[n] ) { moel@348: ret.splice(n--, 1); moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: return ret; moel@348: }, moel@348: moel@348: has: function( target ) { moel@348: var targets = jQuery( target ); moel@348: return this.filter(function() { moel@348: for ( var i = 0, l = targets.length; i < l; i++ ) { moel@348: if ( jQuery.contains( this, targets[i] ) ) { moel@348: return true; moel@348: } moel@348: } moel@348: }); moel@348: }, moel@348: moel@348: not: function( selector ) { moel@348: return this.pushStack( winnow(this, selector, false), "not", selector); moel@348: }, moel@348: moel@348: filter: function( selector ) { moel@348: return this.pushStack( winnow(this, selector, true), "filter", selector ); moel@348: }, moel@348: moel@348: is: function( selector ) { moel@348: return !!selector && ( moel@348: typeof selector === "string" ? moel@348: // If this is a positional selector, check membership in the returned set moel@348: // so $("p:first").is("p:last") won't return true for a doc with two "p". moel@348: POS.test( selector ) ? moel@348: jQuery( selector, this.context ).index( this[0] ) >= 0 : moel@348: jQuery.filter( selector, this ).length > 0 : moel@348: this.filter( selector ).length > 0 ); moel@348: }, moel@348: moel@348: closest: function( selectors, context ) { moel@348: var ret = [], i, l, cur = this[0]; moel@348: moel@348: // Array (deprecated as of jQuery 1.7) moel@348: if ( jQuery.isArray( selectors ) ) { moel@348: var level = 1; moel@348: moel@348: while ( cur && cur.ownerDocument && cur !== context ) { moel@348: for ( i = 0; i < selectors.length; i++ ) { moel@348: moel@348: if ( jQuery( cur ).is( selectors[ i ] ) ) { moel@348: ret.push({ selector: selectors[ i ], elem: cur, level: level }); moel@348: } moel@348: } moel@348: moel@348: cur = cur.parentNode; moel@348: level++; moel@348: } moel@348: moel@348: return ret; moel@348: } moel@348: moel@348: // String moel@348: var pos = POS.test( selectors ) || typeof selectors !== "string" ? moel@348: jQuery( selectors, context || this.context ) : moel@348: 0; moel@348: moel@348: for ( i = 0, l = this.length; i < l; i++ ) { moel@348: cur = this[i]; moel@348: moel@348: while ( cur ) { moel@348: if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { moel@348: ret.push( cur ); moel@348: break; moel@348: moel@348: } else { moel@348: cur = cur.parentNode; moel@348: if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: ret = ret.length > 1 ? jQuery.unique( ret ) : ret; moel@348: moel@348: return this.pushStack( ret, "closest", selectors ); moel@348: }, moel@348: moel@348: // Determine the position of an element within moel@348: // the matched set of elements moel@348: index: function( elem ) { moel@348: moel@348: // No argument, return index in parent moel@348: if ( !elem ) { moel@348: return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; moel@348: } moel@348: moel@348: // index in selector moel@348: if ( typeof elem === "string" ) { moel@348: return jQuery.inArray( this[0], jQuery( elem ) ); moel@348: } moel@348: moel@348: // Locate the position of the desired element moel@348: return jQuery.inArray( moel@348: // If it receives a jQuery object, the first element is used moel@348: elem.jquery ? elem[0] : elem, this ); moel@348: }, moel@348: moel@348: add: function( selector, context ) { moel@348: var set = typeof selector === "string" ? moel@348: jQuery( selector, context ) : moel@348: jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), moel@348: all = jQuery.merge( this.get(), set ); moel@348: moel@348: return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? moel@348: all : moel@348: jQuery.unique( all ) ); moel@348: }, moel@348: moel@348: andSelf: function() { moel@348: return this.add( this.prevObject ); moel@348: } moel@348: }); moel@348: moel@348: // A painfully simple check to see if an element is disconnected moel@348: // from a document (should be improved, where feasible). moel@348: function isDisconnected( node ) { moel@348: return !node || !node.parentNode || node.parentNode.nodeType === 11; moel@348: } moel@348: moel@348: jQuery.each({ moel@348: parent: function( elem ) { moel@348: var parent = elem.parentNode; moel@348: return parent && parent.nodeType !== 11 ? parent : null; moel@348: }, moel@348: parents: function( elem ) { moel@348: return jQuery.dir( elem, "parentNode" ); moel@348: }, moel@348: parentsUntil: function( elem, i, until ) { moel@348: return jQuery.dir( elem, "parentNode", until ); moel@348: }, moel@348: next: function( elem ) { moel@348: return jQuery.nth( elem, 2, "nextSibling" ); moel@348: }, moel@348: prev: function( elem ) { moel@348: return jQuery.nth( elem, 2, "previousSibling" ); moel@348: }, moel@348: nextAll: function( elem ) { moel@348: return jQuery.dir( elem, "nextSibling" ); moel@348: }, moel@348: prevAll: function( elem ) { moel@348: return jQuery.dir( elem, "previousSibling" ); moel@348: }, moel@348: nextUntil: function( elem, i, until ) { moel@348: return jQuery.dir( elem, "nextSibling", until ); moel@348: }, moel@348: prevUntil: function( elem, i, until ) { moel@348: return jQuery.dir( elem, "previousSibling", until ); moel@348: }, moel@348: siblings: function( elem ) { moel@348: return jQuery.sibling( ( elem.parentNode || {} ).firstChild, elem ); moel@348: }, moel@348: children: function( elem ) { moel@348: return jQuery.sibling( elem.firstChild ); moel@348: }, moel@348: contents: function( elem ) { moel@348: return jQuery.nodeName( elem, "iframe" ) ? moel@348: elem.contentDocument || elem.contentWindow.document : moel@348: jQuery.makeArray( elem.childNodes ); moel@348: } moel@348: }, function( name, fn ) { moel@348: jQuery.fn[ name ] = function( until, selector ) { moel@348: var ret = jQuery.map( this, fn, until ); moel@348: moel@348: if ( !runtil.test( name ) ) { moel@348: selector = until; moel@348: } moel@348: moel@348: if ( selector && typeof selector === "string" ) { moel@348: ret = jQuery.filter( selector, ret ); moel@348: } moel@348: moel@348: ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; moel@348: moel@348: if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { moel@348: ret = ret.reverse(); moel@348: } moel@348: moel@348: return this.pushStack( ret, name, slice.call( arguments ).join(",") ); moel@348: }; moel@348: }); moel@348: moel@348: jQuery.extend({ moel@348: filter: function( expr, elems, not ) { moel@348: if ( not ) { moel@348: expr = ":not(" + expr + ")"; moel@348: } moel@348: moel@348: return elems.length === 1 ? moel@348: jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : moel@348: jQuery.find.matches(expr, elems); moel@348: }, moel@348: moel@348: dir: function( elem, dir, until ) { moel@348: var matched = [], moel@348: cur = elem[ dir ]; moel@348: moel@348: while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { moel@348: if ( cur.nodeType === 1 ) { moel@348: matched.push( cur ); moel@348: } moel@348: cur = cur[dir]; moel@348: } moel@348: return matched; moel@348: }, moel@348: moel@348: nth: function( cur, result, dir, elem ) { moel@348: result = result || 1; moel@348: var num = 0; moel@348: moel@348: for ( ; cur; cur = cur[dir] ) { moel@348: if ( cur.nodeType === 1 && ++num === result ) { moel@348: break; moel@348: } moel@348: } moel@348: moel@348: return cur; moel@348: }, moel@348: moel@348: sibling: function( n, elem ) { moel@348: var r = []; moel@348: moel@348: for ( ; n; n = n.nextSibling ) { moel@348: if ( n.nodeType === 1 && n !== elem ) { moel@348: r.push( n ); moel@348: } moel@348: } moel@348: moel@348: return r; moel@348: } moel@348: }); moel@348: moel@348: // Implement the identical functionality for filter and not moel@348: function winnow( elements, qualifier, keep ) { moel@348: moel@348: // Can't pass null or undefined to indexOf in Firefox 4 moel@348: // Set to 0 to skip string check moel@348: qualifier = qualifier || 0; moel@348: moel@348: if ( jQuery.isFunction( qualifier ) ) { moel@348: return jQuery.grep(elements, function( elem, i ) { moel@348: var retVal = !!qualifier.call( elem, i, elem ); moel@348: return retVal === keep; moel@348: }); moel@348: moel@348: } else if ( qualifier.nodeType ) { moel@348: return jQuery.grep(elements, function( elem, i ) { moel@348: return ( elem === qualifier ) === keep; moel@348: }); moel@348: moel@348: } else if ( typeof qualifier === "string" ) { moel@348: var filtered = jQuery.grep(elements, function( elem ) { moel@348: return elem.nodeType === 1; moel@348: }); moel@348: moel@348: if ( isSimple.test( qualifier ) ) { moel@348: return jQuery.filter(qualifier, filtered, !keep); moel@348: } else { moel@348: qualifier = jQuery.filter( qualifier, filtered ); moel@348: } moel@348: } moel@348: moel@348: return jQuery.grep(elements, function( elem, i ) { moel@348: return ( jQuery.inArray( elem, qualifier ) >= 0 ) === keep; moel@348: }); moel@348: } moel@348: moel@348: moel@348: moel@348: moel@348: function createSafeFragment( document ) { moel@348: var list = nodeNames.split( "|" ), moel@348: safeFrag = document.createDocumentFragment(); moel@348: moel@348: if ( safeFrag.createElement ) { moel@348: while ( list.length ) { moel@348: safeFrag.createElement( moel@348: list.pop() moel@348: ); moel@348: } moel@348: } moel@348: return safeFrag; moel@348: } moel@348: moel@348: var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|" + moel@348: "header|hgroup|mark|meter|nav|output|progress|section|summary|time|video", moel@348: rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, moel@348: rleadingWhitespace = /^\s+/, moel@348: rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, moel@348: rtagName = /<([\w:]+)/, moel@348: rtbody = /<tbody/i, moel@348: rhtml = /<|&#?\w+;/, moel@348: rnoInnerhtml = /<(?:script|style)/i, moel@348: rnocache = /<(?:script|object|embed|option|style)/i, moel@348: rnoshimcache = new RegExp("<(?:" + nodeNames + ")[\\s/>]", "i"), moel@348: // checked="checked" or checked moel@348: rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, moel@348: rscriptType = /\/(java|ecma)script/i, moel@348: rcleanScript = /^\s*<!(?:\[CDATA\[|\-\-)/, moel@348: wrapMap = { moel@348: option: [ 1, "<select multiple='multiple'>", "</select>" ], moel@348: legend: [ 1, "<fieldset>", "</fieldset>" ], moel@348: thead: [ 1, "<table>", "</table>" ], moel@348: tr: [ 2, "<table><tbody>", "</tbody></table>" ], moel@348: td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], moel@348: col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], moel@348: area: [ 1, "<map>", "</map>" ], moel@348: _default: [ 0, "", "" ] moel@348: }, moel@348: safeFragment = createSafeFragment( document ); moel@348: moel@348: wrapMap.optgroup = wrapMap.option; moel@348: wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; moel@348: wrapMap.th = wrapMap.td; moel@348: moel@348: // IE can't serialize <link> and <script> tags normally moel@348: if ( !jQuery.support.htmlSerialize ) { moel@348: wrapMap._default = [ 1, "div<div>", "</div>" ]; moel@348: } moel@348: moel@348: jQuery.fn.extend({ moel@348: text: function( value ) { moel@348: return jQuery.access( this, function( value ) { moel@348: return value === undefined ? moel@348: jQuery.text( this ) : moel@348: this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) ); moel@348: }, null, value, arguments.length ); moel@348: }, moel@348: moel@348: wrapAll: function( html ) { moel@348: if ( jQuery.isFunction( html ) ) { moel@348: return this.each(function(i) { moel@348: jQuery(this).wrapAll( html.call(this, i) ); moel@348: }); moel@348: } moel@348: moel@348: if ( this[0] ) { moel@348: // The elements to wrap the target around moel@348: var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true); moel@348: moel@348: if ( this[0].parentNode ) { moel@348: wrap.insertBefore( this[0] ); moel@348: } moel@348: moel@348: wrap.map(function() { moel@348: var elem = this; moel@348: moel@348: while ( elem.firstChild && elem.firstChild.nodeType === 1 ) { moel@348: elem = elem.firstChild; moel@348: } moel@348: moel@348: return elem; moel@348: }).append( this ); moel@348: } moel@348: moel@348: return this; moel@348: }, moel@348: moel@348: wrapInner: function( html ) { moel@348: if ( jQuery.isFunction( html ) ) { moel@348: return this.each(function(i) { moel@348: jQuery(this).wrapInner( html.call(this, i) ); moel@348: }); moel@348: } moel@348: moel@348: return this.each(function() { moel@348: var self = jQuery( this ), moel@348: contents = self.contents(); moel@348: moel@348: if ( contents.length ) { moel@348: contents.wrapAll( html ); moel@348: moel@348: } else { moel@348: self.append( html ); moel@348: } moel@348: }); moel@348: }, moel@348: moel@348: wrap: function( html ) { moel@348: var isFunction = jQuery.isFunction( html ); moel@348: moel@348: return this.each(function(i) { moel@348: jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); moel@348: }); moel@348: }, moel@348: moel@348: unwrap: function() { moel@348: return this.parent().each(function() { moel@348: if ( !jQuery.nodeName( this, "body" ) ) { moel@348: jQuery( this ).replaceWith( this.childNodes ); moel@348: } moel@348: }).end(); moel@348: }, moel@348: moel@348: append: function() { moel@348: return this.domManip(arguments, true, function( elem ) { moel@348: if ( this.nodeType === 1 ) { moel@348: this.appendChild( elem ); moel@348: } moel@348: }); moel@348: }, moel@348: moel@348: prepend: function() { moel@348: return this.domManip(arguments, true, function( elem ) { moel@348: if ( this.nodeType === 1 ) { moel@348: this.insertBefore( elem, this.firstChild ); moel@348: } moel@348: }); moel@348: }, moel@348: moel@348: before: function() { moel@348: if ( this[0] && this[0].parentNode ) { moel@348: return this.domManip(arguments, false, function( elem ) { moel@348: this.parentNode.insertBefore( elem, this ); moel@348: }); moel@348: } else if ( arguments.length ) { moel@348: var set = jQuery.clean( arguments ); moel@348: set.push.apply( set, this.toArray() ); moel@348: return this.pushStack( set, "before", arguments ); moel@348: } moel@348: }, moel@348: moel@348: after: function() { moel@348: if ( this[0] && this[0].parentNode ) { moel@348: return this.domManip(arguments, false, function( elem ) { moel@348: this.parentNode.insertBefore( elem, this.nextSibling ); moel@348: }); moel@348: } else if ( arguments.length ) { moel@348: var set = this.pushStack( this, "after", arguments ); moel@348: set.push.apply( set, jQuery.clean(arguments) ); moel@348: return set; moel@348: } moel@348: }, moel@348: moel@348: // keepData is for internal use only--do not document moel@348: remove: function( selector, keepData ) { moel@348: for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { moel@348: if ( !selector || jQuery.filter( selector, [ elem ] ).length ) { moel@348: if ( !keepData && elem.nodeType === 1 ) { moel@348: jQuery.cleanData( elem.getElementsByTagName("*") ); moel@348: jQuery.cleanData( [ elem ] ); moel@348: } moel@348: moel@348: if ( elem.parentNode ) { moel@348: elem.parentNode.removeChild( elem ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: return this; moel@348: }, moel@348: moel@348: empty: function() { moel@348: for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { moel@348: // Remove element nodes and prevent memory leaks moel@348: if ( elem.nodeType === 1 ) { moel@348: jQuery.cleanData( elem.getElementsByTagName("*") ); moel@348: } moel@348: moel@348: // Remove any remaining nodes moel@348: while ( elem.firstChild ) { moel@348: elem.removeChild( elem.firstChild ); moel@348: } moel@348: } moel@348: moel@348: return this; moel@348: }, moel@348: moel@348: clone: function( dataAndEvents, deepDataAndEvents ) { moel@348: dataAndEvents = dataAndEvents == null ? false : dataAndEvents; moel@348: deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; moel@348: moel@348: return this.map( function () { moel@348: return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); moel@348: }); moel@348: }, moel@348: moel@348: html: function( value ) { moel@348: return jQuery.access( this, function( value ) { moel@348: var elem = this[0] || {}, moel@348: i = 0, moel@348: l = this.length; moel@348: moel@348: if ( value === undefined ) { moel@348: return elem.nodeType === 1 ? moel@348: elem.innerHTML.replace( rinlinejQuery, "" ) : moel@348: null; moel@348: } moel@348: moel@348: moel@348: if ( typeof value === "string" && !rnoInnerhtml.test( value ) && moel@348: ( jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value ) ) && moel@348: !wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) { moel@348: moel@348: value = value.replace( rxhtmlTag, "<$1></$2>" ); moel@348: moel@348: try { moel@348: for (; i < l; i++ ) { moel@348: // Remove element nodes and prevent memory leaks moel@348: elem = this[i] || {}; moel@348: if ( elem.nodeType === 1 ) { moel@348: jQuery.cleanData( elem.getElementsByTagName( "*" ) ); moel@348: elem.innerHTML = value; moel@348: } moel@348: } moel@348: moel@348: elem = 0; moel@348: moel@348: // If using innerHTML throws an exception, use the fallback method moel@348: } catch(e) {} moel@348: } moel@348: moel@348: if ( elem ) { moel@348: this.empty().append( value ); moel@348: } moel@348: }, null, value, arguments.length ); moel@348: }, moel@348: moel@348: replaceWith: function( value ) { moel@348: if ( this[0] && this[0].parentNode ) { moel@348: // Make sure that the elements are removed from the DOM before they are inserted moel@348: // this can help fix replacing a parent with child elements moel@348: if ( jQuery.isFunction( value ) ) { moel@348: return this.each(function(i) { moel@348: var self = jQuery(this), old = self.html(); moel@348: self.replaceWith( value.call( this, i, old ) ); moel@348: }); moel@348: } moel@348: moel@348: if ( typeof value !== "string" ) { moel@348: value = jQuery( value ).detach(); moel@348: } moel@348: moel@348: return this.each(function() { moel@348: var next = this.nextSibling, moel@348: parent = this.parentNode; moel@348: moel@348: jQuery( this ).remove(); moel@348: moel@348: if ( next ) { moel@348: jQuery(next).before( value ); moel@348: } else { moel@348: jQuery(parent).append( value ); moel@348: } moel@348: }); moel@348: } else { moel@348: return this.length ? moel@348: this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) : moel@348: this; moel@348: } moel@348: }, moel@348: moel@348: detach: function( selector ) { moel@348: return this.remove( selector, true ); moel@348: }, moel@348: moel@348: domManip: function( args, table, callback ) { moel@348: var results, first, fragment, parent, moel@348: value = args[0], moel@348: scripts = []; moel@348: moel@348: // We can't cloneNode fragments that contain checked, in WebKit moel@348: if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) { moel@348: return this.each(function() { moel@348: jQuery(this).domManip( args, table, callback, true ); moel@348: }); moel@348: } moel@348: moel@348: if ( jQuery.isFunction(value) ) { moel@348: return this.each(function(i) { moel@348: var self = jQuery(this); moel@348: args[0] = value.call(this, i, table ? self.html() : undefined); moel@348: self.domManip( args, table, callback ); moel@348: }); moel@348: } moel@348: moel@348: if ( this[0] ) { moel@348: parent = value && value.parentNode; moel@348: moel@348: // If we're in a fragment, just use that instead of building a new one moel@348: if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) { moel@348: results = { fragment: parent }; moel@348: moel@348: } else { moel@348: results = jQuery.buildFragment( args, this, scripts ); moel@348: } moel@348: moel@348: fragment = results.fragment; moel@348: moel@348: if ( fragment.childNodes.length === 1 ) { moel@348: first = fragment = fragment.firstChild; moel@348: } else { moel@348: first = fragment.firstChild; moel@348: } moel@348: moel@348: if ( first ) { moel@348: table = table && jQuery.nodeName( first, "tr" ); moel@348: moel@348: for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) { moel@348: callback.call( moel@348: table ? moel@348: root(this[i], first) : moel@348: this[i], moel@348: // Make sure that we do not leak memory by inadvertently discarding moel@348: // the original fragment (which might have attached data) instead of moel@348: // using it; in addition, use the original fragment object for the last moel@348: // item instead of first because it can end up being emptied incorrectly moel@348: // in certain situations (Bug #8070). moel@348: // Fragments from the fragment cache must always be cloned and never used moel@348: // in place. moel@348: results.cacheable || ( l > 1 && i < lastIndex ) ? moel@348: jQuery.clone( fragment, true, true ) : moel@348: fragment moel@348: ); moel@348: } moel@348: } moel@348: moel@348: if ( scripts.length ) { moel@348: jQuery.each( scripts, function( i, elem ) { moel@348: if ( elem.src ) { moel@348: jQuery.ajax({ moel@348: type: "GET", moel@348: global: false, moel@348: url: elem.src, moel@348: async: false, moel@348: dataType: "script" moel@348: }); moel@348: } else { moel@348: jQuery.globalEval( ( elem.text || elem.textContent || elem.innerHTML || "" ).replace( rcleanScript, "/*$0*/" ) ); moel@348: } moel@348: moel@348: if ( elem.parentNode ) { moel@348: elem.parentNode.removeChild( elem ); moel@348: } moel@348: }); moel@348: } moel@348: } moel@348: moel@348: return this; moel@348: } moel@348: }); moel@348: moel@348: function root( elem, cur ) { moel@348: return jQuery.nodeName(elem, "table") ? moel@348: (elem.getElementsByTagName("tbody")[0] || moel@348: elem.appendChild(elem.ownerDocument.createElement("tbody"))) : moel@348: elem; moel@348: } moel@348: moel@348: function cloneCopyEvent( src, dest ) { moel@348: moel@348: if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) { moel@348: return; moel@348: } moel@348: moel@348: var type, i, l, moel@348: oldData = jQuery._data( src ), moel@348: curData = jQuery._data( dest, oldData ), moel@348: events = oldData.events; moel@348: moel@348: if ( events ) { moel@348: delete curData.handle; moel@348: curData.events = {}; moel@348: moel@348: for ( type in events ) { moel@348: for ( i = 0, l = events[ type ].length; i < l; i++ ) { moel@348: jQuery.event.add( dest, type, events[ type ][ i ] ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: // make the cloned public data object a copy from the original moel@348: if ( curData.data ) { moel@348: curData.data = jQuery.extend( {}, curData.data ); moel@348: } moel@348: } moel@348: moel@348: function cloneFixAttributes( src, dest ) { moel@348: var nodeName; moel@348: moel@348: // We do not need to do anything for non-Elements moel@348: if ( dest.nodeType !== 1 ) { moel@348: return; moel@348: } moel@348: moel@348: // clearAttributes removes the attributes, which we don't want, moel@348: // but also removes the attachEvent events, which we *do* want moel@348: if ( dest.clearAttributes ) { moel@348: dest.clearAttributes(); moel@348: } moel@348: moel@348: // mergeAttributes, in contrast, only merges back on the moel@348: // original attributes, not the events moel@348: if ( dest.mergeAttributes ) { moel@348: dest.mergeAttributes( src ); moel@348: } moel@348: moel@348: nodeName = dest.nodeName.toLowerCase(); moel@348: moel@348: // IE6-8 fail to clone children inside object elements that use moel@348: // the proprietary classid attribute value (rather than the type moel@348: // attribute) to identify the type of content to display moel@348: if ( nodeName === "object" ) { moel@348: dest.outerHTML = src.outerHTML; moel@348: moel@348: } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) { moel@348: // IE6-8 fails to persist the checked state of a cloned checkbox moel@348: // or radio button. Worse, IE6-7 fail to give the cloned element moel@348: // a checked appearance if the defaultChecked value isn't also set moel@348: if ( src.checked ) { moel@348: dest.defaultChecked = dest.checked = src.checked; moel@348: } moel@348: moel@348: // IE6-7 get confused and end up setting the value of a cloned moel@348: // checkbox/radio button to an empty string instead of "on" moel@348: if ( dest.value !== src.value ) { moel@348: dest.value = src.value; moel@348: } moel@348: moel@348: // IE6-8 fails to return the selected option to the default selected moel@348: // state when cloning options moel@348: } else if ( nodeName === "option" ) { moel@348: dest.selected = src.defaultSelected; moel@348: moel@348: // IE6-8 fails to set the defaultValue to the correct value when moel@348: // cloning other types of input fields moel@348: } else if ( nodeName === "input" || nodeName === "textarea" ) { moel@348: dest.defaultValue = src.defaultValue; moel@348: moel@348: // IE blanks contents when cloning scripts moel@348: } else if ( nodeName === "script" && dest.text !== src.text ) { moel@348: dest.text = src.text; moel@348: } moel@348: moel@348: // Event data gets referenced instead of copied if the expando moel@348: // gets copied too moel@348: dest.removeAttribute( jQuery.expando ); moel@348: moel@348: // Clear flags for bubbling special change/submit events, they must moel@348: // be reattached when the newly cloned events are first activated moel@348: dest.removeAttribute( "_submit_attached" ); moel@348: dest.removeAttribute( "_change_attached" ); moel@348: } moel@348: moel@348: jQuery.buildFragment = function( args, nodes, scripts ) { moel@348: var fragment, cacheable, cacheresults, doc, moel@348: first = args[ 0 ]; moel@348: moel@348: // nodes may contain either an explicit document object, moel@348: // a jQuery collection or context object. moel@348: // If nodes[0] contains a valid object to assign to doc moel@348: if ( nodes && nodes[0] ) { moel@348: doc = nodes[0].ownerDocument || nodes[0]; moel@348: } moel@348: moel@348: // Ensure that an attr object doesn't incorrectly stand in as a document object moel@348: // Chrome and Firefox seem to allow this to occur and will throw exception moel@348: // Fixes #8950 moel@348: if ( !doc.createDocumentFragment ) { moel@348: doc = document; moel@348: } moel@348: moel@348: // Only cache "small" (1/2 KB) HTML strings that are associated with the main document moel@348: // Cloning options loses the selected state, so don't cache them moel@348: // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment moel@348: // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache moel@348: // Lastly, IE6,7,8 will not correctly reuse cached fragments that were created from unknown elems #10501 moel@348: if ( args.length === 1 && typeof first === "string" && first.length < 512 && doc === document && moel@348: first.charAt(0) === "<" && !rnocache.test( first ) && moel@348: (jQuery.support.checkClone || !rchecked.test( first )) && moel@348: (jQuery.support.html5Clone || !rnoshimcache.test( first )) ) { moel@348: moel@348: cacheable = true; moel@348: moel@348: cacheresults = jQuery.fragments[ first ]; moel@348: if ( cacheresults && cacheresults !== 1 ) { moel@348: fragment = cacheresults; moel@348: } moel@348: } moel@348: moel@348: if ( !fragment ) { moel@348: fragment = doc.createDocumentFragment(); moel@348: jQuery.clean( args, doc, fragment, scripts ); moel@348: } moel@348: moel@348: if ( cacheable ) { moel@348: jQuery.fragments[ first ] = cacheresults ? fragment : 1; moel@348: } moel@348: moel@348: return { fragment: fragment, cacheable: cacheable }; moel@348: }; moel@348: moel@348: jQuery.fragments = {}; moel@348: moel@348: jQuery.each({ moel@348: appendTo: "append", moel@348: prependTo: "prepend", moel@348: insertBefore: "before", moel@348: insertAfter: "after", moel@348: replaceAll: "replaceWith" moel@348: }, function( name, original ) { moel@348: jQuery.fn[ name ] = function( selector ) { moel@348: var ret = [], moel@348: insert = jQuery( selector ), moel@348: parent = this.length === 1 && this[0].parentNode; moel@348: moel@348: if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) { moel@348: insert[ original ]( this[0] ); moel@348: return this; moel@348: moel@348: } else { moel@348: for ( var i = 0, l = insert.length; i < l; i++ ) { moel@348: var elems = ( i > 0 ? this.clone(true) : this ).get(); moel@348: jQuery( insert[i] )[ original ]( elems ); moel@348: ret = ret.concat( elems ); moel@348: } moel@348: moel@348: return this.pushStack( ret, name, insert.selector ); moel@348: } moel@348: }; moel@348: }); moel@348: moel@348: function getAll( elem ) { moel@348: if ( typeof elem.getElementsByTagName !== "undefined" ) { moel@348: return elem.getElementsByTagName( "*" ); moel@348: moel@348: } else if ( typeof elem.querySelectorAll !== "undefined" ) { moel@348: return elem.querySelectorAll( "*" ); moel@348: moel@348: } else { moel@348: return []; moel@348: } moel@348: } moel@348: moel@348: // Used in clean, fixes the defaultChecked property moel@348: function fixDefaultChecked( elem ) { moel@348: if ( elem.type === "checkbox" || elem.type === "radio" ) { moel@348: elem.defaultChecked = elem.checked; moel@348: } moel@348: } moel@348: // Finds all inputs and passes them to fixDefaultChecked moel@348: function findInputs( elem ) { moel@348: var nodeName = ( elem.nodeName || "" ).toLowerCase(); moel@348: if ( nodeName === "input" ) { moel@348: fixDefaultChecked( elem ); moel@348: // Skip scripts, get other children moel@348: } else if ( nodeName !== "script" && typeof elem.getElementsByTagName !== "undefined" ) { moel@348: jQuery.grep( elem.getElementsByTagName("input"), fixDefaultChecked ); moel@348: } moel@348: } moel@348: moel@348: // Derived From: http://www.iecss.com/shimprove/javascript/shimprove.1-0-1.js moel@348: function shimCloneNode( elem ) { moel@348: var div = document.createElement( "div" ); moel@348: safeFragment.appendChild( div ); moel@348: moel@348: div.innerHTML = elem.outerHTML; moel@348: return div.firstChild; moel@348: } moel@348: moel@348: jQuery.extend({ moel@348: clone: function( elem, dataAndEvents, deepDataAndEvents ) { moel@348: var srcElements, moel@348: destElements, moel@348: i, moel@348: // IE<=8 does not properly clone detached, unknown element nodes moel@348: clone = jQuery.support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ? moel@348: elem.cloneNode( true ) : moel@348: shimCloneNode( elem ); moel@348: moel@348: if ( (!jQuery.support.noCloneEvent || !jQuery.support.noCloneChecked) && moel@348: (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) { moel@348: // IE copies events bound via attachEvent when using cloneNode. moel@348: // Calling detachEvent on the clone will also remove the events moel@348: // from the original. In order to get around this, we use some moel@348: // proprietary methods to clear the events. Thanks to MooTools moel@348: // guys for this hotness. moel@348: moel@348: cloneFixAttributes( elem, clone ); moel@348: moel@348: // Using Sizzle here is crazy slow, so we use getElementsByTagName instead moel@348: srcElements = getAll( elem ); moel@348: destElements = getAll( clone ); moel@348: moel@348: // Weird iteration because IE will replace the length property moel@348: // with an element if you are cloning the body and one of the moel@348: // elements on the page has a name or id of "length" moel@348: for ( i = 0; srcElements[i]; ++i ) { moel@348: // Ensure that the destination node is not null; Fixes #9587 moel@348: if ( destElements[i] ) { moel@348: cloneFixAttributes( srcElements[i], destElements[i] ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Copy the events from the original to the clone moel@348: if ( dataAndEvents ) { moel@348: cloneCopyEvent( elem, clone ); moel@348: moel@348: if ( deepDataAndEvents ) { moel@348: srcElements = getAll( elem ); moel@348: destElements = getAll( clone ); moel@348: moel@348: for ( i = 0; srcElements[i]; ++i ) { moel@348: cloneCopyEvent( srcElements[i], destElements[i] ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: srcElements = destElements = null; moel@348: moel@348: // Return the cloned set moel@348: return clone; moel@348: }, moel@348: moel@348: clean: function( elems, context, fragment, scripts ) { moel@348: var checkScriptType, script, j, moel@348: ret = []; moel@348: moel@348: context = context || document; moel@348: moel@348: // !context.createElement fails in IE with an error but returns typeof 'object' moel@348: if ( typeof context.createElement === "undefined" ) { moel@348: context = context.ownerDocument || context[0] && context[0].ownerDocument || document; moel@348: } moel@348: moel@348: for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { moel@348: if ( typeof elem === "number" ) { moel@348: elem += ""; moel@348: } moel@348: moel@348: if ( !elem ) { moel@348: continue; moel@348: } moel@348: moel@348: // Convert html string into DOM nodes moel@348: if ( typeof elem === "string" ) { moel@348: if ( !rhtml.test( elem ) ) { moel@348: elem = context.createTextNode( elem ); moel@348: } else { moel@348: // Fix "XHTML"-style tags in all browsers moel@348: elem = elem.replace(rxhtmlTag, "<$1></$2>"); moel@348: moel@348: // Trim whitespace, otherwise indexOf won't work as expected moel@348: var tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase(), moel@348: wrap = wrapMap[ tag ] || wrapMap._default, moel@348: depth = wrap[0], moel@348: div = context.createElement("div"), moel@348: safeChildNodes = safeFragment.childNodes, moel@348: remove; moel@348: moel@348: // Append wrapper element to unknown element safe doc fragment moel@348: if ( context === document ) { moel@348: // Use the fragment we've already created for this document moel@348: safeFragment.appendChild( div ); moel@348: } else { moel@348: // Use a fragment created with the owner document moel@348: createSafeFragment( context ).appendChild( div ); moel@348: } moel@348: moel@348: // Go to html and back, then peel off extra wrappers moel@348: div.innerHTML = wrap[1] + elem + wrap[2]; moel@348: moel@348: // Move to the right depth moel@348: while ( depth-- ) { moel@348: div = div.lastChild; moel@348: } moel@348: moel@348: // Remove IE's autoinserted <tbody> from table fragments moel@348: if ( !jQuery.support.tbody ) { moel@348: moel@348: // String was a <table>, *may* have spurious <tbody> moel@348: var hasBody = rtbody.test(elem), moel@348: tbody = tag === "table" && !hasBody ? moel@348: div.firstChild && div.firstChild.childNodes : moel@348: moel@348: // String was a bare <thead> or <tfoot> moel@348: wrap[1] === "<table>" && !hasBody ? moel@348: div.childNodes : moel@348: []; moel@348: moel@348: for ( j = tbody.length - 1; j >= 0 ; --j ) { moel@348: if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) { moel@348: tbody[ j ].parentNode.removeChild( tbody[ j ] ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: // IE completely kills leading whitespace when innerHTML is used moel@348: if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { moel@348: div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild ); moel@348: } moel@348: moel@348: elem = div.childNodes; moel@348: moel@348: // Clear elements from DocumentFragment (safeFragment or otherwise) moel@348: // to avoid hoarding elements. Fixes #11356 moel@348: if ( div ) { moel@348: div.parentNode.removeChild( div ); moel@348: moel@348: // Guard against -1 index exceptions in FF3.6 moel@348: if ( safeChildNodes.length > 0 ) { moel@348: remove = safeChildNodes[ safeChildNodes.length - 1 ]; moel@348: moel@348: if ( remove && remove.parentNode ) { moel@348: remove.parentNode.removeChild( remove ); moel@348: } moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Resets defaultChecked for any radios and checkboxes moel@348: // about to be appended to the DOM in IE 6/7 (#8060) moel@348: var len; moel@348: if ( !jQuery.support.appendChecked ) { moel@348: if ( elem[0] && typeof (len = elem.length) === "number" ) { moel@348: for ( j = 0; j < len; j++ ) { moel@348: findInputs( elem[j] ); moel@348: } moel@348: } else { moel@348: findInputs( elem ); moel@348: } moel@348: } moel@348: moel@348: if ( elem.nodeType ) { moel@348: ret.push( elem ); moel@348: } else { moel@348: ret = jQuery.merge( ret, elem ); moel@348: } moel@348: } moel@348: moel@348: if ( fragment ) { moel@348: checkScriptType = function( elem ) { moel@348: return !elem.type || rscriptType.test( elem.type ); moel@348: }; moel@348: for ( i = 0; ret[i]; i++ ) { moel@348: script = ret[i]; moel@348: if ( scripts && jQuery.nodeName( script, "script" ) && (!script.type || rscriptType.test( script.type )) ) { moel@348: scripts.push( script.parentNode ? script.parentNode.removeChild( script ) : script ); moel@348: moel@348: } else { moel@348: if ( script.nodeType === 1 ) { moel@348: var jsTags = jQuery.grep( script.getElementsByTagName( "script" ), checkScriptType ); moel@348: moel@348: ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); moel@348: } moel@348: fragment.appendChild( script ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: return ret; moel@348: }, moel@348: moel@348: cleanData: function( elems ) { moel@348: var data, id, moel@348: cache = jQuery.cache, moel@348: special = jQuery.event.special, moel@348: deleteExpando = jQuery.support.deleteExpando; moel@348: moel@348: for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { moel@348: if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { moel@348: continue; moel@348: } moel@348: moel@348: id = elem[ jQuery.expando ]; moel@348: moel@348: if ( id ) { moel@348: data = cache[ id ]; moel@348: moel@348: if ( data && data.events ) { moel@348: for ( var type in data.events ) { moel@348: if ( special[ type ] ) { moel@348: jQuery.event.remove( elem, type ); moel@348: moel@348: // This is a shortcut to avoid jQuery.event.remove's overhead moel@348: } else { moel@348: jQuery.removeEvent( elem, type, data.handle ); moel@348: } moel@348: } moel@348: moel@348: // Null the DOM reference to avoid IE6/7/8 leak (#7054) moel@348: if ( data.handle ) { moel@348: data.handle.elem = null; moel@348: } moel@348: } moel@348: moel@348: if ( deleteExpando ) { moel@348: delete elem[ jQuery.expando ]; moel@348: moel@348: } else if ( elem.removeAttribute ) { moel@348: elem.removeAttribute( jQuery.expando ); moel@348: } moel@348: moel@348: delete cache[ id ]; moel@348: } moel@348: } moel@348: } moel@348: }); moel@348: moel@348: moel@348: moel@348: moel@348: var ralpha = /alpha\([^)]*\)/i, moel@348: ropacity = /opacity=([^)]*)/, moel@348: // fixed for IE9, see #8346 moel@348: rupper = /([A-Z]|^ms)/g, moel@348: rnum = /^[\-+]?(?:\d*\.)?\d+$/i, moel@348: rnumnonpx = /^-?(?:\d*\.)?\d+(?!px)[^\d\s]+$/i, moel@348: rrelNum = /^([\-+])=([\-+.\de]+)/, moel@348: rmargin = /^margin/, moel@348: moel@348: cssShow = { position: "absolute", visibility: "hidden", display: "block" }, moel@348: moel@348: // order is important! moel@348: cssExpand = [ "Top", "Right", "Bottom", "Left" ], moel@348: moel@348: curCSS, moel@348: moel@348: getComputedStyle, moel@348: currentStyle; moel@348: moel@348: jQuery.fn.css = function( name, value ) { moel@348: return jQuery.access( this, function( elem, name, value ) { moel@348: return value !== undefined ? moel@348: jQuery.style( elem, name, value ) : moel@348: jQuery.css( elem, name ); moel@348: }, name, value, arguments.length > 1 ); moel@348: }; moel@348: moel@348: jQuery.extend({ moel@348: // Add in style property hooks for overriding the default moel@348: // behavior of getting and setting a style property moel@348: cssHooks: { moel@348: opacity: { moel@348: get: function( elem, computed ) { moel@348: if ( computed ) { moel@348: // We should always get a number back from opacity moel@348: var ret = curCSS( elem, "opacity" ); moel@348: return ret === "" ? "1" : ret; moel@348: moel@348: } else { moel@348: return elem.style.opacity; moel@348: } moel@348: } moel@348: } moel@348: }, moel@348: moel@348: // Exclude the following css properties to add px moel@348: cssNumber: { moel@348: "fillOpacity": true, moel@348: "fontWeight": true, moel@348: "lineHeight": true, moel@348: "opacity": true, moel@348: "orphans": true, moel@348: "widows": true, moel@348: "zIndex": true, moel@348: "zoom": true moel@348: }, moel@348: moel@348: // Add in properties whose names you wish to fix before moel@348: // setting or getting the value moel@348: cssProps: { moel@348: // normalize float css property moel@348: "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat" moel@348: }, moel@348: moel@348: // Get and set the style property on a DOM Node moel@348: style: function( elem, name, value, extra ) { moel@348: // Don't set styles on text and comment nodes moel@348: if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { moel@348: return; moel@348: } moel@348: moel@348: // Make sure that we're working with the right name moel@348: var ret, type, origName = jQuery.camelCase( name ), moel@348: style = elem.style, hooks = jQuery.cssHooks[ origName ]; moel@348: moel@348: name = jQuery.cssProps[ origName ] || origName; moel@348: moel@348: // Check if we're setting a value moel@348: if ( value !== undefined ) { moel@348: type = typeof value; moel@348: moel@348: // convert relative number strings (+= or -=) to relative numbers. #7345 moel@348: if ( type === "string" && (ret = rrelNum.exec( value )) ) { moel@348: value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) ); moel@348: // Fixes bug #9237 moel@348: type = "number"; moel@348: } moel@348: moel@348: // Make sure that NaN and null values aren't set. See: #7116 moel@348: if ( value == null || type === "number" && isNaN( value ) ) { moel@348: return; moel@348: } moel@348: moel@348: // If a number was passed in, add 'px' to the (except for certain CSS properties) moel@348: if ( type === "number" && !jQuery.cssNumber[ origName ] ) { moel@348: value += "px"; moel@348: } moel@348: moel@348: // If a hook was provided, use that value, otherwise just set the specified value moel@348: if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) { moel@348: // Wrapped to prevent IE from throwing errors when 'invalid' values are provided moel@348: // Fixes bug #5509 moel@348: try { moel@348: style[ name ] = value; moel@348: } catch(e) {} moel@348: } moel@348: moel@348: } else { moel@348: // If a hook was provided get the non-computed value from there moel@348: if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) { moel@348: return ret; moel@348: } moel@348: moel@348: // Otherwise just get the value from the style object moel@348: return style[ name ]; moel@348: } moel@348: }, moel@348: moel@348: css: function( elem, name, extra ) { moel@348: var ret, hooks; moel@348: moel@348: // Make sure that we're working with the right name moel@348: name = jQuery.camelCase( name ); moel@348: hooks = jQuery.cssHooks[ name ]; moel@348: name = jQuery.cssProps[ name ] || name; moel@348: moel@348: // cssFloat needs a special treatment moel@348: if ( name === "cssFloat" ) { moel@348: name = "float"; moel@348: } moel@348: moel@348: // If a hook was provided get the computed value from there moel@348: if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) { moel@348: return ret; moel@348: moel@348: // Otherwise, if a way to get the computed value exists, use that moel@348: } else if ( curCSS ) { moel@348: return curCSS( elem, name ); moel@348: } moel@348: }, moel@348: moel@348: // A method for quickly swapping in/out CSS properties to get correct calculations moel@348: swap: function( elem, options, callback ) { moel@348: var old = {}, moel@348: ret, name; moel@348: moel@348: // Remember the old values, and insert the new ones moel@348: for ( name in options ) { moel@348: old[ name ] = elem.style[ name ]; moel@348: elem.style[ name ] = options[ name ]; moel@348: } moel@348: moel@348: ret = callback.call( elem ); moel@348: moel@348: // Revert the old values moel@348: for ( name in options ) { moel@348: elem.style[ name ] = old[ name ]; moel@348: } moel@348: moel@348: return ret; moel@348: } moel@348: }); moel@348: moel@348: // DEPRECATED in 1.3, Use jQuery.css() instead moel@348: jQuery.curCSS = jQuery.css; moel@348: moel@348: if ( document.defaultView && document.defaultView.getComputedStyle ) { moel@348: getComputedStyle = function( elem, name ) { moel@348: var ret, defaultView, computedStyle, width, moel@348: style = elem.style; moel@348: moel@348: name = name.replace( rupper, "-$1" ).toLowerCase(); moel@348: moel@348: if ( (defaultView = elem.ownerDocument.defaultView) && moel@348: (computedStyle = defaultView.getComputedStyle( elem, null )) ) { moel@348: moel@348: ret = computedStyle.getPropertyValue( name ); moel@348: if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) { moel@348: ret = jQuery.style( elem, name ); moel@348: } moel@348: } moel@348: moel@348: // A tribute to the "awesome hack by Dean Edwards" moel@348: // WebKit uses "computed value (percentage if specified)" instead of "used value" for margins moel@348: // which is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values moel@348: if ( !jQuery.support.pixelMargin && computedStyle && rmargin.test( name ) && rnumnonpx.test( ret ) ) { moel@348: width = style.width; moel@348: style.width = ret; moel@348: ret = computedStyle.width; moel@348: style.width = width; moel@348: } moel@348: moel@348: return ret; moel@348: }; moel@348: } moel@348: moel@348: if ( document.documentElement.currentStyle ) { moel@348: currentStyle = function( elem, name ) { moel@348: var left, rsLeft, uncomputed, moel@348: ret = elem.currentStyle && elem.currentStyle[ name ], moel@348: style = elem.style; moel@348: moel@348: // Avoid setting ret to empty string here moel@348: // so we don't default to auto moel@348: if ( ret == null && style && (uncomputed = style[ name ]) ) { moel@348: ret = uncomputed; moel@348: } moel@348: moel@348: // From the awesome hack by Dean Edwards moel@348: // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 moel@348: moel@348: // If we're not dealing with a regular pixel number moel@348: // but a number that has a weird ending, we need to convert it to pixels moel@348: if ( rnumnonpx.test( ret ) ) { moel@348: moel@348: // Remember the original values moel@348: left = style.left; moel@348: rsLeft = elem.runtimeStyle && elem.runtimeStyle.left; moel@348: moel@348: // Put in the new values to get a computed value out moel@348: if ( rsLeft ) { moel@348: elem.runtimeStyle.left = elem.currentStyle.left; moel@348: } moel@348: style.left = name === "fontSize" ? "1em" : ret; moel@348: ret = style.pixelLeft + "px"; moel@348: moel@348: // Revert the changed values moel@348: style.left = left; moel@348: if ( rsLeft ) { moel@348: elem.runtimeStyle.left = rsLeft; moel@348: } moel@348: } moel@348: moel@348: return ret === "" ? "auto" : ret; moel@348: }; moel@348: } moel@348: moel@348: curCSS = getComputedStyle || currentStyle; moel@348: moel@348: function getWidthOrHeight( elem, name, extra ) { moel@348: moel@348: // Start with offset property moel@348: var val = name === "width" ? elem.offsetWidth : elem.offsetHeight, moel@348: i = name === "width" ? 1 : 0, moel@348: len = 4; moel@348: moel@348: if ( val > 0 ) { moel@348: if ( extra !== "border" ) { moel@348: for ( ; i < len; i += 2 ) { moel@348: if ( !extra ) { moel@348: val -= parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0; moel@348: } moel@348: if ( extra === "margin" ) { moel@348: val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ] ) ) || 0; moel@348: } else { moel@348: val -= parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; moel@348: } moel@348: } moel@348: } moel@348: moel@348: return val + "px"; moel@348: } moel@348: moel@348: // Fall back to computed then uncomputed css if necessary moel@348: val = curCSS( elem, name ); moel@348: if ( val < 0 || val == null ) { moel@348: val = elem.style[ name ]; moel@348: } moel@348: moel@348: // Computed unit is not pixels. Stop here and return. moel@348: if ( rnumnonpx.test(val) ) { moel@348: return val; moel@348: } moel@348: moel@348: // Normalize "", auto, and prepare for extra moel@348: val = parseFloat( val ) || 0; moel@348: moel@348: // Add padding, border, margin moel@348: if ( extra ) { moel@348: for ( ; i < len; i += 2 ) { moel@348: val += parseFloat( jQuery.css( elem, "padding" + cssExpand[ i ] ) ) || 0; moel@348: if ( extra !== "padding" ) { moel@348: val += parseFloat( jQuery.css( elem, "border" + cssExpand[ i ] + "Width" ) ) || 0; moel@348: } moel@348: if ( extra === "margin" ) { moel@348: val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ]) ) || 0; moel@348: } moel@348: } moel@348: } moel@348: moel@348: return val + "px"; moel@348: } moel@348: moel@348: jQuery.each([ "height", "width" ], function( i, name ) { moel@348: jQuery.cssHooks[ name ] = { moel@348: get: function( elem, computed, extra ) { moel@348: if ( computed ) { moel@348: if ( elem.offsetWidth !== 0 ) { moel@348: return getWidthOrHeight( elem, name, extra ); moel@348: } else { moel@348: return jQuery.swap( elem, cssShow, function() { moel@348: return getWidthOrHeight( elem, name, extra ); moel@348: }); moel@348: } moel@348: } moel@348: }, moel@348: moel@348: set: function( elem, value ) { moel@348: return rnum.test( value ) ? moel@348: value + "px" : moel@348: value; moel@348: } moel@348: }; moel@348: }); moel@348: moel@348: if ( !jQuery.support.opacity ) { moel@348: jQuery.cssHooks.opacity = { moel@348: get: function( elem, computed ) { moel@348: // IE uses filters for opacity moel@348: return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? moel@348: ( parseFloat( RegExp.$1 ) / 100 ) + "" : moel@348: computed ? "1" : ""; moel@348: }, moel@348: moel@348: set: function( elem, value ) { moel@348: var style = elem.style, moel@348: currentStyle = elem.currentStyle, moel@348: opacity = jQuery.isNumeric( value ) ? "alpha(opacity=" + value * 100 + ")" : "", moel@348: filter = currentStyle && currentStyle.filter || style.filter || ""; moel@348: moel@348: // IE has trouble with opacity if it does not have layout moel@348: // Force it by setting the zoom level moel@348: style.zoom = 1; moel@348: moel@348: // if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652 moel@348: if ( value >= 1 && jQuery.trim( filter.replace( ralpha, "" ) ) === "" ) { moel@348: moel@348: // Setting style.filter to null, "" & " " still leave "filter:" in the cssText moel@348: // if "filter:" is present at all, clearType is disabled, we want to avoid this moel@348: // style.removeAttribute is IE Only, but so apparently is this code path... moel@348: style.removeAttribute( "filter" ); moel@348: moel@348: // if there there is no filter style applied in a css rule, we are done moel@348: if ( currentStyle && !currentStyle.filter ) { moel@348: return; moel@348: } moel@348: } moel@348: moel@348: // otherwise, set new filter values moel@348: style.filter = ralpha.test( filter ) ? moel@348: filter.replace( ralpha, opacity ) : moel@348: filter + " " + opacity; moel@348: } moel@348: }; moel@348: } moel@348: moel@348: jQuery(function() { moel@348: // This hook cannot be added until DOM ready because the support test moel@348: // for it is not run until after DOM ready moel@348: if ( !jQuery.support.reliableMarginRight ) { moel@348: jQuery.cssHooks.marginRight = { moel@348: get: function( elem, computed ) { moel@348: // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right moel@348: // Work around by temporarily setting element display to inline-block moel@348: return jQuery.swap( elem, { "display": "inline-block" }, function() { moel@348: if ( computed ) { moel@348: return curCSS( elem, "margin-right" ); moel@348: } else { moel@348: return elem.style.marginRight; moel@348: } moel@348: }); moel@348: } moel@348: }; moel@348: } moel@348: }); moel@348: moel@348: if ( jQuery.expr && jQuery.expr.filters ) { moel@348: jQuery.expr.filters.hidden = function( elem ) { moel@348: var width = elem.offsetWidth, moel@348: height = elem.offsetHeight; moel@348: moel@348: return ( width === 0 && height === 0 ) || (!jQuery.support.reliableHiddenOffsets && ((elem.style && elem.style.display) || jQuery.css( elem, "display" )) === "none"); moel@348: }; moel@348: moel@348: jQuery.expr.filters.visible = function( elem ) { moel@348: return !jQuery.expr.filters.hidden( elem ); moel@348: }; moel@348: } moel@348: moel@348: // These hooks are used by animate to expand properties moel@348: jQuery.each({ moel@348: margin: "", moel@348: padding: "", moel@348: border: "Width" moel@348: }, function( prefix, suffix ) { moel@348: moel@348: jQuery.cssHooks[ prefix + suffix ] = { moel@348: expand: function( value ) { moel@348: var i, moel@348: moel@348: // assumes a single number if not a string moel@348: parts = typeof value === "string" ? value.split(" ") : [ value ], moel@348: expanded = {}; moel@348: moel@348: for ( i = 0; i < 4; i++ ) { moel@348: expanded[ prefix + cssExpand[ i ] + suffix ] = moel@348: parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; moel@348: } moel@348: moel@348: return expanded; moel@348: } moel@348: }; moel@348: }); moel@348: moel@348: moel@348: moel@348: moel@348: var r20 = /%20/g, moel@348: rbracket = /\[\]$/, moel@348: rCRLF = /\r?\n/g, moel@348: rhash = /#.*$/, moel@348: rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL moel@348: rinput = /^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i, moel@348: // #7653, #8125, #8152: local protocol detection moel@348: rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/, moel@348: rnoContent = /^(?:GET|HEAD)$/, moel@348: rprotocol = /^\/\//, moel@348: rquery = /\?/, moel@348: rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, moel@348: rselectTextarea = /^(?:select|textarea)/i, moel@348: rspacesAjax = /\s+/, moel@348: rts = /([?&])_=[^&]*/, moel@348: rurl = /^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/, moel@348: moel@348: // Keep a copy of the old load method moel@348: _load = jQuery.fn.load, moel@348: moel@348: /* Prefilters moel@348: * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) moel@348: * 2) These are called: moel@348: * - BEFORE asking for a transport moel@348: * - AFTER param serialization (s.data is a string if s.processData is true) moel@348: * 3) key is the dataType moel@348: * 4) the catchall symbol "*" can be used moel@348: * 5) execution will start with transport dataType and THEN continue down to "*" if needed moel@348: */ moel@348: prefilters = {}, moel@348: moel@348: /* Transports bindings moel@348: * 1) key is the dataType moel@348: * 2) the catchall symbol "*" can be used moel@348: * 3) selection will start with transport dataType and THEN go to "*" if needed moel@348: */ moel@348: transports = {}, moel@348: moel@348: // Document location moel@348: ajaxLocation, moel@348: moel@348: // Document location segments moel@348: ajaxLocParts, moel@348: moel@348: // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression moel@348: allTypes = ["*/"] + ["*"]; moel@348: moel@348: // #8138, IE may throw an exception when accessing moel@348: // a field from window.location if document.domain has been set moel@348: try { moel@348: ajaxLocation = location.href; moel@348: } catch( e ) { moel@348: // Use the href attribute of an A element moel@348: // since IE will modify it given document.location moel@348: ajaxLocation = document.createElement( "a" ); moel@348: ajaxLocation.href = ""; moel@348: ajaxLocation = ajaxLocation.href; moel@348: } moel@348: moel@348: // Segment location into parts moel@348: ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; moel@348: moel@348: // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport moel@348: function addToPrefiltersOrTransports( structure ) { moel@348: moel@348: // dataTypeExpression is optional and defaults to "*" moel@348: return function( dataTypeExpression, func ) { moel@348: moel@348: if ( typeof dataTypeExpression !== "string" ) { moel@348: func = dataTypeExpression; moel@348: dataTypeExpression = "*"; moel@348: } moel@348: moel@348: if ( jQuery.isFunction( func ) ) { moel@348: var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ), moel@348: i = 0, moel@348: length = dataTypes.length, moel@348: dataType, moel@348: list, moel@348: placeBefore; moel@348: moel@348: // For each dataType in the dataTypeExpression moel@348: for ( ; i < length; i++ ) { moel@348: dataType = dataTypes[ i ]; moel@348: // We control if we're asked to add before moel@348: // any existing element moel@348: placeBefore = /^\+/.test( dataType ); moel@348: if ( placeBefore ) { moel@348: dataType = dataType.substr( 1 ) || "*"; moel@348: } moel@348: list = structure[ dataType ] = structure[ dataType ] || []; moel@348: // then we add to the structure accordingly moel@348: list[ placeBefore ? "unshift" : "push" ]( func ); moel@348: } moel@348: } moel@348: }; moel@348: } moel@348: moel@348: // Base inspection function for prefilters and transports moel@348: function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR, moel@348: dataType /* internal */, inspected /* internal */ ) { moel@348: moel@348: dataType = dataType || options.dataTypes[ 0 ]; moel@348: inspected = inspected || {}; moel@348: moel@348: inspected[ dataType ] = true; moel@348: moel@348: var list = structure[ dataType ], moel@348: i = 0, moel@348: length = list ? list.length : 0, moel@348: executeOnly = ( structure === prefilters ), moel@348: selection; moel@348: moel@348: for ( ; i < length && ( executeOnly || !selection ); i++ ) { moel@348: selection = list[ i ]( options, originalOptions, jqXHR ); moel@348: // If we got redirected to another dataType moel@348: // we try there if executing only and not done already moel@348: if ( typeof selection === "string" ) { moel@348: if ( !executeOnly || inspected[ selection ] ) { moel@348: selection = undefined; moel@348: } else { moel@348: options.dataTypes.unshift( selection ); moel@348: selection = inspectPrefiltersOrTransports( moel@348: structure, options, originalOptions, jqXHR, selection, inspected ); moel@348: } moel@348: } moel@348: } moel@348: // If we're only executing or nothing was selected moel@348: // we try the catchall dataType if not done already moel@348: if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) { moel@348: selection = inspectPrefiltersOrTransports( moel@348: structure, options, originalOptions, jqXHR, "*", inspected ); moel@348: } moel@348: // unnecessary when only executing (prefilters) moel@348: // but it'll be ignored by the caller in that case moel@348: return selection; moel@348: } moel@348: moel@348: // A special extend for ajax options moel@348: // that takes "flat" options (not to be deep extended) moel@348: // Fixes #9887 moel@348: function ajaxExtend( target, src ) { moel@348: var key, deep, moel@348: flatOptions = jQuery.ajaxSettings.flatOptions || {}; moel@348: for ( key in src ) { moel@348: if ( src[ key ] !== undefined ) { moel@348: ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; moel@348: } moel@348: } moel@348: if ( deep ) { moel@348: jQuery.extend( true, target, deep ); moel@348: } moel@348: } moel@348: moel@348: jQuery.fn.extend({ moel@348: load: function( url, params, callback ) { moel@348: if ( typeof url !== "string" && _load ) { moel@348: return _load.apply( this, arguments ); moel@348: moel@348: // Don't do a request if no elements are being requested moel@348: } else if ( !this.length ) { moel@348: return this; moel@348: } moel@348: moel@348: var off = url.indexOf( " " ); moel@348: if ( off >= 0 ) { moel@348: var selector = url.slice( off, url.length ); moel@348: url = url.slice( 0, off ); moel@348: } moel@348: moel@348: // Default to a GET request moel@348: var type = "GET"; moel@348: moel@348: // If the second parameter was provided moel@348: if ( params ) { moel@348: // If it's a function moel@348: if ( jQuery.isFunction( params ) ) { moel@348: // We assume that it's the callback moel@348: callback = params; moel@348: params = undefined; moel@348: moel@348: // Otherwise, build a param string moel@348: } else if ( typeof params === "object" ) { moel@348: params = jQuery.param( params, jQuery.ajaxSettings.traditional ); moel@348: type = "POST"; moel@348: } moel@348: } moel@348: moel@348: var self = this; moel@348: moel@348: // Request the remote document moel@348: jQuery.ajax({ moel@348: url: url, moel@348: type: type, moel@348: dataType: "html", moel@348: data: params, moel@348: // Complete callback (responseText is used internally) moel@348: complete: function( jqXHR, status, responseText ) { moel@348: // Store the response as specified by the jqXHR object moel@348: responseText = jqXHR.responseText; moel@348: // If successful, inject the HTML into all the matched elements moel@348: if ( jqXHR.isResolved() ) { moel@348: // #4825: Get the actual response in case moel@348: // a dataFilter is present in ajaxSettings moel@348: jqXHR.done(function( r ) { moel@348: responseText = r; moel@348: }); moel@348: // See if a selector was specified moel@348: self.html( selector ? moel@348: // Create a dummy div to hold the results moel@348: jQuery("<div>") moel@348: // inject the contents of the document in, removing the scripts moel@348: // to avoid any 'Permission Denied' errors in IE moel@348: .append(responseText.replace(rscript, "")) moel@348: moel@348: // Locate the specified elements moel@348: .find(selector) : moel@348: moel@348: // If not, just inject the full result moel@348: responseText ); moel@348: } moel@348: moel@348: if ( callback ) { moel@348: self.each( callback, [ responseText, status, jqXHR ] ); moel@348: } moel@348: } moel@348: }); moel@348: moel@348: return this; moel@348: }, moel@348: moel@348: serialize: function() { moel@348: return jQuery.param( this.serializeArray() ); moel@348: }, moel@348: moel@348: serializeArray: function() { moel@348: return this.map(function(){ moel@348: return this.elements ? jQuery.makeArray( this.elements ) : this; moel@348: }) moel@348: .filter(function(){ moel@348: return this.name && !this.disabled && moel@348: ( this.checked || rselectTextarea.test( this.nodeName ) || moel@348: rinput.test( this.type ) ); moel@348: }) moel@348: .map(function( i, elem ){ moel@348: var val = jQuery( this ).val(); moel@348: moel@348: return val == null ? moel@348: null : moel@348: jQuery.isArray( val ) ? moel@348: jQuery.map( val, function( val, i ){ moel@348: return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; moel@348: }) : moel@348: { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; moel@348: }).get(); moel@348: } moel@348: }); moel@348: moel@348: // Attach a bunch of functions for handling common AJAX events moel@348: jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){ moel@348: jQuery.fn[ o ] = function( f ){ moel@348: return this.on( o, f ); moel@348: }; moel@348: }); moel@348: moel@348: jQuery.each( [ "get", "post" ], function( i, method ) { moel@348: jQuery[ method ] = function( url, data, callback, type ) { moel@348: // shift arguments if data argument was omitted moel@348: if ( jQuery.isFunction( data ) ) { moel@348: type = type || callback; moel@348: callback = data; moel@348: data = undefined; moel@348: } moel@348: moel@348: return jQuery.ajax({ moel@348: type: method, moel@348: url: url, moel@348: data: data, moel@348: success: callback, moel@348: dataType: type moel@348: }); moel@348: }; moel@348: }); moel@348: moel@348: jQuery.extend({ moel@348: moel@348: getScript: function( url, callback ) { moel@348: return jQuery.get( url, undefined, callback, "script" ); moel@348: }, moel@348: moel@348: getJSON: function( url, data, callback ) { moel@348: return jQuery.get( url, data, callback, "json" ); moel@348: }, moel@348: moel@348: // Creates a full fledged settings object into target moel@348: // with both ajaxSettings and settings fields. moel@348: // If target is omitted, writes into ajaxSettings. moel@348: ajaxSetup: function( target, settings ) { moel@348: if ( settings ) { moel@348: // Building a settings object moel@348: ajaxExtend( target, jQuery.ajaxSettings ); moel@348: } else { moel@348: // Extending ajaxSettings moel@348: settings = target; moel@348: target = jQuery.ajaxSettings; moel@348: } moel@348: ajaxExtend( target, settings ); moel@348: return target; moel@348: }, moel@348: moel@348: ajaxSettings: { moel@348: url: ajaxLocation, moel@348: isLocal: rlocalProtocol.test( ajaxLocParts[ 1 ] ), moel@348: global: true, moel@348: type: "GET", moel@348: contentType: "application/x-www-form-urlencoded; charset=UTF-8", moel@348: processData: true, moel@348: async: true, moel@348: /* moel@348: timeout: 0, moel@348: data: null, moel@348: dataType: null, moel@348: username: null, moel@348: password: null, moel@348: cache: null, moel@348: traditional: false, moel@348: headers: {}, moel@348: */ moel@348: moel@348: accepts: { moel@348: xml: "application/xml, text/xml", moel@348: html: "text/html", moel@348: text: "text/plain", moel@348: json: "application/json, text/javascript", moel@348: "*": allTypes moel@348: }, moel@348: moel@348: contents: { moel@348: xml: /xml/, moel@348: html: /html/, moel@348: json: /json/ moel@348: }, moel@348: moel@348: responseFields: { moel@348: xml: "responseXML", moel@348: text: "responseText" moel@348: }, moel@348: moel@348: // List of data converters moel@348: // 1) key format is "source_type destination_type" (a single space in-between) moel@348: // 2) the catchall symbol "*" can be used for source_type moel@348: converters: { moel@348: moel@348: // Convert anything to text moel@348: "* text": window.String, moel@348: moel@348: // Text to html (true = no transformation) moel@348: "text html": true, moel@348: moel@348: // Evaluate text as a json expression moel@348: "text json": jQuery.parseJSON, moel@348: moel@348: // Parse text as xml moel@348: "text xml": jQuery.parseXML moel@348: }, moel@348: moel@348: // For options that shouldn't be deep extended: moel@348: // you can add your own custom options here if moel@348: // and when you create one that shouldn't be moel@348: // deep extended (see ajaxExtend) moel@348: flatOptions: { moel@348: context: true, moel@348: url: true moel@348: } moel@348: }, moel@348: moel@348: ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), moel@348: ajaxTransport: addToPrefiltersOrTransports( transports ), moel@348: moel@348: // Main method moel@348: ajax: function( url, options ) { moel@348: moel@348: // If url is an object, simulate pre-1.5 signature moel@348: if ( typeof url === "object" ) { moel@348: options = url; moel@348: url = undefined; moel@348: } moel@348: moel@348: // Force options to be an object moel@348: options = options || {}; moel@348: moel@348: var // Create the final options object moel@348: s = jQuery.ajaxSetup( {}, options ), moel@348: // Callbacks context moel@348: callbackContext = s.context || s, moel@348: // Context for global events moel@348: // It's the callbackContext if one was provided in the options moel@348: // and if it's a DOM node or a jQuery collection moel@348: globalEventContext = callbackContext !== s && moel@348: ( callbackContext.nodeType || callbackContext instanceof jQuery ) ? moel@348: jQuery( callbackContext ) : jQuery.event, moel@348: // Deferreds moel@348: deferred = jQuery.Deferred(), moel@348: completeDeferred = jQuery.Callbacks( "once memory" ), moel@348: // Status-dependent callbacks moel@348: statusCode = s.statusCode || {}, moel@348: // ifModified key moel@348: ifModifiedKey, moel@348: // Headers (they are sent all at once) moel@348: requestHeaders = {}, moel@348: requestHeadersNames = {}, moel@348: // Response headers moel@348: responseHeadersString, moel@348: responseHeaders, moel@348: // transport moel@348: transport, moel@348: // timeout handle moel@348: timeoutTimer, moel@348: // Cross-domain detection vars moel@348: parts, moel@348: // The jqXHR state moel@348: state = 0, moel@348: // To know if global events are to be dispatched moel@348: fireGlobals, moel@348: // Loop variable moel@348: i, moel@348: // Fake xhr moel@348: jqXHR = { moel@348: moel@348: readyState: 0, moel@348: moel@348: // Caches the header moel@348: setRequestHeader: function( name, value ) { moel@348: if ( !state ) { moel@348: var lname = name.toLowerCase(); moel@348: name = requestHeadersNames[ lname ] = requestHeadersNames[ lname ] || name; moel@348: requestHeaders[ name ] = value; moel@348: } moel@348: return this; moel@348: }, moel@348: moel@348: // Raw string moel@348: getAllResponseHeaders: function() { moel@348: return state === 2 ? responseHeadersString : null; moel@348: }, moel@348: moel@348: // Builds headers hashtable if needed moel@348: getResponseHeader: function( key ) { moel@348: var match; moel@348: if ( state === 2 ) { moel@348: if ( !responseHeaders ) { moel@348: responseHeaders = {}; moel@348: while( ( match = rheaders.exec( responseHeadersString ) ) ) { moel@348: responseHeaders[ match[1].toLowerCase() ] = match[ 2 ]; moel@348: } moel@348: } moel@348: match = responseHeaders[ key.toLowerCase() ]; moel@348: } moel@348: return match === undefined ? null : match; moel@348: }, moel@348: moel@348: // Overrides response content-type header moel@348: overrideMimeType: function( type ) { moel@348: if ( !state ) { moel@348: s.mimeType = type; moel@348: } moel@348: return this; moel@348: }, moel@348: moel@348: // Cancel the request moel@348: abort: function( statusText ) { moel@348: statusText = statusText || "abort"; moel@348: if ( transport ) { moel@348: transport.abort( statusText ); moel@348: } moel@348: done( 0, statusText ); moel@348: return this; moel@348: } moel@348: }; moel@348: moel@348: // Callback for when everything is done moel@348: // It is defined here because jslint complains if it is declared moel@348: // at the end of the function (which would be more logical and readable) moel@348: function done( status, nativeStatusText, responses, headers ) { moel@348: moel@348: // Called once moel@348: if ( state === 2 ) { moel@348: return; moel@348: } moel@348: moel@348: // State is "done" now moel@348: state = 2; moel@348: moel@348: // Clear timeout if it exists moel@348: if ( timeoutTimer ) { moel@348: clearTimeout( timeoutTimer ); moel@348: } moel@348: moel@348: // Dereference transport for early garbage collection moel@348: // (no matter how long the jqXHR object will be used) moel@348: transport = undefined; moel@348: moel@348: // Cache response headers moel@348: responseHeadersString = headers || ""; moel@348: moel@348: // Set readyState moel@348: jqXHR.readyState = status > 0 ? 4 : 0; moel@348: moel@348: var isSuccess, moel@348: success, moel@348: error, moel@348: statusText = nativeStatusText, moel@348: response = responses ? ajaxHandleResponses( s, jqXHR, responses ) : undefined, moel@348: lastModified, moel@348: etag; moel@348: moel@348: // If successful, handle type chaining moel@348: if ( status >= 200 && status < 300 || status === 304 ) { moel@348: moel@348: // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. moel@348: if ( s.ifModified ) { moel@348: moel@348: if ( ( lastModified = jqXHR.getResponseHeader( "Last-Modified" ) ) ) { moel@348: jQuery.lastModified[ ifModifiedKey ] = lastModified; moel@348: } moel@348: if ( ( etag = jqXHR.getResponseHeader( "Etag" ) ) ) { moel@348: jQuery.etag[ ifModifiedKey ] = etag; moel@348: } moel@348: } moel@348: moel@348: // If not modified moel@348: if ( status === 304 ) { moel@348: moel@348: statusText = "notmodified"; moel@348: isSuccess = true; moel@348: moel@348: // If we have data moel@348: } else { moel@348: moel@348: try { moel@348: success = ajaxConvert( s, response ); moel@348: statusText = "success"; moel@348: isSuccess = true; moel@348: } catch(e) { moel@348: // We have a parsererror moel@348: statusText = "parsererror"; moel@348: error = e; moel@348: } moel@348: } moel@348: } else { moel@348: // We extract error from statusText moel@348: // then normalize statusText and status for non-aborts moel@348: error = statusText; moel@348: if ( !statusText || status ) { moel@348: statusText = "error"; moel@348: if ( status < 0 ) { moel@348: status = 0; moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Set data for the fake xhr object moel@348: jqXHR.status = status; moel@348: jqXHR.statusText = "" + ( nativeStatusText || statusText ); moel@348: moel@348: // Success/Error moel@348: if ( isSuccess ) { moel@348: deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); moel@348: } else { moel@348: deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); moel@348: } moel@348: moel@348: // Status-dependent callbacks moel@348: jqXHR.statusCode( statusCode ); moel@348: statusCode = undefined; moel@348: moel@348: if ( fireGlobals ) { moel@348: globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ), moel@348: [ jqXHR, s, isSuccess ? success : error ] ); moel@348: } moel@348: moel@348: // Complete moel@348: completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); moel@348: moel@348: if ( fireGlobals ) { moel@348: globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); moel@348: // Handle the global AJAX counter moel@348: if ( !( --jQuery.active ) ) { moel@348: jQuery.event.trigger( "ajaxStop" ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Attach deferreds moel@348: deferred.promise( jqXHR ); moel@348: jqXHR.success = jqXHR.done; moel@348: jqXHR.error = jqXHR.fail; moel@348: jqXHR.complete = completeDeferred.add; moel@348: moel@348: // Status-dependent callbacks moel@348: jqXHR.statusCode = function( map ) { moel@348: if ( map ) { moel@348: var tmp; moel@348: if ( state < 2 ) { moel@348: for ( tmp in map ) { moel@348: statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ]; moel@348: } moel@348: } else { moel@348: tmp = map[ jqXHR.status ]; moel@348: jqXHR.then( tmp, tmp ); moel@348: } moel@348: } moel@348: return this; moel@348: }; moel@348: moel@348: // Remove hash character (#7531: and string promotion) moel@348: // Add protocol if not provided (#5866: IE7 issue with protocol-less urls) moel@348: // We also use the url parameter if available moel@348: s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" ); moel@348: moel@348: // Extract dataTypes list moel@348: s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax ); moel@348: moel@348: // Determine if a cross-domain request is in order moel@348: if ( s.crossDomain == null ) { moel@348: parts = rurl.exec( s.url.toLowerCase() ); moel@348: s.crossDomain = !!( parts && moel@348: ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] || moel@348: ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) != moel@348: ( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) ) moel@348: ); moel@348: } moel@348: moel@348: // Convert data if not already a string moel@348: if ( s.data && s.processData && typeof s.data !== "string" ) { moel@348: s.data = jQuery.param( s.data, s.traditional ); moel@348: } moel@348: moel@348: // Apply prefilters moel@348: inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); moel@348: moel@348: // If request was aborted inside a prefilter, stop there moel@348: if ( state === 2 ) { moel@348: return false; moel@348: } moel@348: moel@348: // We can fire global events as of now if asked to moel@348: fireGlobals = s.global; moel@348: moel@348: // Uppercase the type moel@348: s.type = s.type.toUpperCase(); moel@348: moel@348: // Determine if request has content moel@348: s.hasContent = !rnoContent.test( s.type ); moel@348: moel@348: // Watch for a new set of requests moel@348: if ( fireGlobals && jQuery.active++ === 0 ) { moel@348: jQuery.event.trigger( "ajaxStart" ); moel@348: } moel@348: moel@348: // More options handling for requests with no content moel@348: if ( !s.hasContent ) { moel@348: moel@348: // If data is available, append data to url moel@348: if ( s.data ) { moel@348: s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data; moel@348: // #9682: remove data so that it's not used in an eventual retry moel@348: delete s.data; moel@348: } moel@348: moel@348: // Get ifModifiedKey before adding the anti-cache parameter moel@348: ifModifiedKey = s.url; moel@348: moel@348: // Add anti-cache in url if needed moel@348: if ( s.cache === false ) { moel@348: moel@348: var ts = jQuery.now(), moel@348: // try replacing _= if it is there moel@348: ret = s.url.replace( rts, "$1_=" + ts ); moel@348: moel@348: // if nothing was replaced, add timestamp to the end moel@348: s.url = ret + ( ( ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" ); moel@348: } moel@348: } moel@348: moel@348: // Set the correct header, if data is being sent moel@348: if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { moel@348: jqXHR.setRequestHeader( "Content-Type", s.contentType ); moel@348: } moel@348: moel@348: // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. moel@348: if ( s.ifModified ) { moel@348: ifModifiedKey = ifModifiedKey || s.url; moel@348: if ( jQuery.lastModified[ ifModifiedKey ] ) { moel@348: jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ ifModifiedKey ] ); moel@348: } moel@348: if ( jQuery.etag[ ifModifiedKey ] ) { moel@348: jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ ifModifiedKey ] ); moel@348: } moel@348: } moel@348: moel@348: // Set the Accepts header for the server, depending on the dataType moel@348: jqXHR.setRequestHeader( moel@348: "Accept", moel@348: s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ? moel@348: s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : moel@348: s.accepts[ "*" ] moel@348: ); moel@348: moel@348: // Check for headers option moel@348: for ( i in s.headers ) { moel@348: jqXHR.setRequestHeader( i, s.headers[ i ] ); moel@348: } moel@348: moel@348: // Allow custom headers/mimetypes and early abort moel@348: if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || state === 2 ) ) { moel@348: // Abort if not done already moel@348: jqXHR.abort(); moel@348: return false; moel@348: moel@348: } moel@348: moel@348: // Install callbacks on deferreds moel@348: for ( i in { success: 1, error: 1, complete: 1 } ) { moel@348: jqXHR[ i ]( s[ i ] ); moel@348: } moel@348: moel@348: // Get transport moel@348: transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); moel@348: moel@348: // If no transport, we auto-abort moel@348: if ( !transport ) { moel@348: done( -1, "No Transport" ); moel@348: } else { moel@348: jqXHR.readyState = 1; moel@348: // Send global event moel@348: if ( fireGlobals ) { moel@348: globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); moel@348: } moel@348: // Timeout moel@348: if ( s.async && s.timeout > 0 ) { moel@348: timeoutTimer = setTimeout( function(){ moel@348: jqXHR.abort( "timeout" ); moel@348: }, s.timeout ); moel@348: } moel@348: moel@348: try { moel@348: state = 1; moel@348: transport.send( requestHeaders, done ); moel@348: } catch (e) { moel@348: // Propagate exception as error if not done moel@348: if ( state < 2 ) { moel@348: done( -1, e ); moel@348: // Simply rethrow otherwise moel@348: } else { moel@348: throw e; moel@348: } moel@348: } moel@348: } moel@348: moel@348: return jqXHR; moel@348: }, moel@348: moel@348: // Serialize an array of form elements or a set of moel@348: // key/values into a query string moel@348: param: function( a, traditional ) { moel@348: var s = [], moel@348: add = function( key, value ) { moel@348: // If value is a function, invoke it and return its value moel@348: value = jQuery.isFunction( value ) ? value() : value; moel@348: s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value ); moel@348: }; moel@348: moel@348: // Set traditional to true for jQuery <= 1.3.2 behavior. moel@348: if ( traditional === undefined ) { moel@348: traditional = jQuery.ajaxSettings.traditional; moel@348: } moel@348: moel@348: // If an array was passed in, assume that it is an array of form elements. moel@348: if ( jQuery.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { moel@348: // Serialize the form elements moel@348: jQuery.each( a, function() { moel@348: add( this.name, this.value ); moel@348: }); moel@348: moel@348: } else { moel@348: // If traditional, encode the "old" way (the way 1.3.2 or older moel@348: // did it), otherwise encode params recursively. moel@348: for ( var prefix in a ) { moel@348: buildParams( prefix, a[ prefix ], traditional, add ); moel@348: } moel@348: } moel@348: moel@348: // Return the resulting serialization moel@348: return s.join( "&" ).replace( r20, "+" ); moel@348: } moel@348: }); moel@348: moel@348: function buildParams( prefix, obj, traditional, add ) { moel@348: if ( jQuery.isArray( obj ) ) { moel@348: // Serialize array item. moel@348: jQuery.each( obj, function( i, v ) { moel@348: if ( traditional || rbracket.test( prefix ) ) { moel@348: // Treat each array item as a scalar. moel@348: add( prefix, v ); moel@348: moel@348: } else { moel@348: // If array item is non-scalar (array or object), encode its moel@348: // numeric index to resolve deserialization ambiguity issues. moel@348: // Note that rack (as of 1.0.0) can't currently deserialize moel@348: // nested arrays properly, and attempting to do so may cause moel@348: // a server error. Possible fixes are to modify rack's moel@348: // deserialization algorithm or to provide an option or flag moel@348: // to force array serialization to be shallow. moel@348: buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); moel@348: } moel@348: }); moel@348: moel@348: } else if ( !traditional && jQuery.type( obj ) === "object" ) { moel@348: // Serialize object item. moel@348: for ( var name in obj ) { moel@348: buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); moel@348: } moel@348: moel@348: } else { moel@348: // Serialize scalar item. moel@348: add( prefix, obj ); moel@348: } moel@348: } moel@348: moel@348: // This is still on the jQuery object... for now moel@348: // Want to move this to jQuery.ajax some day moel@348: jQuery.extend({ moel@348: moel@348: // Counter for holding the number of active queries moel@348: active: 0, moel@348: moel@348: // Last-Modified header cache for next request moel@348: lastModified: {}, moel@348: etag: {} moel@348: moel@348: }); moel@348: moel@348: /* Handles responses to an ajax request: moel@348: * - sets all responseXXX fields accordingly moel@348: * - finds the right dataType (mediates between content-type and expected dataType) moel@348: * - returns the corresponding response moel@348: */ moel@348: function ajaxHandleResponses( s, jqXHR, responses ) { moel@348: moel@348: var contents = s.contents, moel@348: dataTypes = s.dataTypes, moel@348: responseFields = s.responseFields, moel@348: ct, moel@348: type, moel@348: finalDataType, moel@348: firstDataType; moel@348: moel@348: // Fill responseXXX fields moel@348: for ( type in responseFields ) { moel@348: if ( type in responses ) { moel@348: jqXHR[ responseFields[type] ] = responses[ type ]; moel@348: } moel@348: } moel@348: moel@348: // Remove auto dataType and get content-type in the process moel@348: while( dataTypes[ 0 ] === "*" ) { moel@348: dataTypes.shift(); moel@348: if ( ct === undefined ) { moel@348: ct = s.mimeType || jqXHR.getResponseHeader( "content-type" ); moel@348: } moel@348: } moel@348: moel@348: // Check if we're dealing with a known content-type moel@348: if ( ct ) { moel@348: for ( type in contents ) { moel@348: if ( contents[ type ] && contents[ type ].test( ct ) ) { moel@348: dataTypes.unshift( type ); moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Check to see if we have a response for the expected dataType moel@348: if ( dataTypes[ 0 ] in responses ) { moel@348: finalDataType = dataTypes[ 0 ]; moel@348: } else { moel@348: // Try convertible dataTypes moel@348: for ( type in responses ) { moel@348: if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) { moel@348: finalDataType = type; moel@348: break; moel@348: } moel@348: if ( !firstDataType ) { moel@348: firstDataType = type; moel@348: } moel@348: } moel@348: // Or just use first one moel@348: finalDataType = finalDataType || firstDataType; moel@348: } moel@348: moel@348: // If we found a dataType moel@348: // We add the dataType to the list if needed moel@348: // and return the corresponding response moel@348: if ( finalDataType ) { moel@348: if ( finalDataType !== dataTypes[ 0 ] ) { moel@348: dataTypes.unshift( finalDataType ); moel@348: } moel@348: return responses[ finalDataType ]; moel@348: } moel@348: } moel@348: moel@348: // Chain conversions given the request and the original response moel@348: function ajaxConvert( s, response ) { moel@348: moel@348: // Apply the dataFilter if provided moel@348: if ( s.dataFilter ) { moel@348: response = s.dataFilter( response, s.dataType ); moel@348: } moel@348: moel@348: var dataTypes = s.dataTypes, moel@348: converters = {}, moel@348: i, moel@348: key, moel@348: length = dataTypes.length, moel@348: tmp, moel@348: // Current and previous dataTypes moel@348: current = dataTypes[ 0 ], moel@348: prev, moel@348: // Conversion expression moel@348: conversion, moel@348: // Conversion function moel@348: conv, moel@348: // Conversion functions (transitive conversion) moel@348: conv1, moel@348: conv2; moel@348: moel@348: // For each dataType in the chain moel@348: for ( i = 1; i < length; i++ ) { moel@348: moel@348: // Create converters map moel@348: // with lowercased keys moel@348: if ( i === 1 ) { moel@348: for ( key in s.converters ) { moel@348: if ( typeof key === "string" ) { moel@348: converters[ key.toLowerCase() ] = s.converters[ key ]; moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Get the dataTypes moel@348: prev = current; moel@348: current = dataTypes[ i ]; moel@348: moel@348: // If current is auto dataType, update it to prev moel@348: if ( current === "*" ) { moel@348: current = prev; moel@348: // If no auto and dataTypes are actually different moel@348: } else if ( prev !== "*" && prev !== current ) { moel@348: moel@348: // Get the converter moel@348: conversion = prev + " " + current; moel@348: conv = converters[ conversion ] || converters[ "* " + current ]; moel@348: moel@348: // If there is no direct converter, search transitively moel@348: if ( !conv ) { moel@348: conv2 = undefined; moel@348: for ( conv1 in converters ) { moel@348: tmp = conv1.split( " " ); moel@348: if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) { moel@348: conv2 = converters[ tmp[1] + " " + current ]; moel@348: if ( conv2 ) { moel@348: conv1 = converters[ conv1 ]; moel@348: if ( conv1 === true ) { moel@348: conv = conv2; moel@348: } else if ( conv2 === true ) { moel@348: conv = conv1; moel@348: } moel@348: break; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: // If we found no converter, dispatch an error moel@348: if ( !( conv || conv2 ) ) { moel@348: jQuery.error( "No conversion from " + conversion.replace(" "," to ") ); moel@348: } moel@348: // If found converter is not an equivalence moel@348: if ( conv !== true ) { moel@348: // Convert with 1 or 2 converters accordingly moel@348: response = conv ? conv( response ) : conv2( conv1(response) ); moel@348: } moel@348: } moel@348: } moel@348: return response; moel@348: } moel@348: moel@348: moel@348: moel@348: moel@348: var jsc = jQuery.now(), moel@348: jsre = /(\=)\?(&|$)|\?\?/i; moel@348: moel@348: // Default jsonp settings moel@348: jQuery.ajaxSetup({ moel@348: jsonp: "callback", moel@348: jsonpCallback: function() { moel@348: return jQuery.expando + "_" + ( jsc++ ); moel@348: } moel@348: }); moel@348: moel@348: // Detect, normalize options and install callbacks for jsonp requests moel@348: jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { moel@348: moel@348: var inspectData = ( typeof s.data === "string" ) && /^application\/x\-www\-form\-urlencoded/.test( s.contentType ); moel@348: moel@348: if ( s.dataTypes[ 0 ] === "jsonp" || moel@348: s.jsonp !== false && ( jsre.test( s.url ) || moel@348: inspectData && jsre.test( s.data ) ) ) { moel@348: moel@348: var responseContainer, moel@348: jsonpCallback = s.jsonpCallback = moel@348: jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback, moel@348: previous = window[ jsonpCallback ], moel@348: url = s.url, moel@348: data = s.data, moel@348: replace = "$1" + jsonpCallback + "$2"; moel@348: moel@348: if ( s.jsonp !== false ) { moel@348: url = url.replace( jsre, replace ); moel@348: if ( s.url === url ) { moel@348: if ( inspectData ) { moel@348: data = data.replace( jsre, replace ); moel@348: } moel@348: if ( s.data === data ) { moel@348: // Add callback manually moel@348: url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback; moel@348: } moel@348: } moel@348: } moel@348: moel@348: s.url = url; moel@348: s.data = data; moel@348: moel@348: // Install callback moel@348: window[ jsonpCallback ] = function( response ) { moel@348: responseContainer = [ response ]; moel@348: }; moel@348: moel@348: // Clean-up function moel@348: jqXHR.always(function() { moel@348: // Set callback back to previous value moel@348: window[ jsonpCallback ] = previous; moel@348: // Call if it was a function and we have a response moel@348: if ( responseContainer && jQuery.isFunction( previous ) ) { moel@348: window[ jsonpCallback ]( responseContainer[ 0 ] ); moel@348: } moel@348: }); moel@348: moel@348: // Use data converter to retrieve json after script execution moel@348: s.converters["script json"] = function() { moel@348: if ( !responseContainer ) { moel@348: jQuery.error( jsonpCallback + " was not called" ); moel@348: } moel@348: return responseContainer[ 0 ]; moel@348: }; moel@348: moel@348: // force json dataType moel@348: s.dataTypes[ 0 ] = "json"; moel@348: moel@348: // Delegate to script moel@348: return "script"; moel@348: } moel@348: }); moel@348: moel@348: moel@348: moel@348: moel@348: // Install script dataType moel@348: jQuery.ajaxSetup({ moel@348: accepts: { moel@348: script: "text/javascript, application/javascript, application/ecmascript, application/x-ecmascript" moel@348: }, moel@348: contents: { moel@348: script: /javascript|ecmascript/ moel@348: }, moel@348: converters: { moel@348: "text script": function( text ) { moel@348: jQuery.globalEval( text ); moel@348: return text; moel@348: } moel@348: } moel@348: }); moel@348: moel@348: // Handle cache's special case and global moel@348: jQuery.ajaxPrefilter( "script", function( s ) { moel@348: if ( s.cache === undefined ) { moel@348: s.cache = false; moel@348: } moel@348: if ( s.crossDomain ) { moel@348: s.type = "GET"; moel@348: s.global = false; moel@348: } moel@348: }); moel@348: moel@348: // Bind script tag hack transport moel@348: jQuery.ajaxTransport( "script", function(s) { moel@348: moel@348: // This transport only deals with cross domain requests moel@348: if ( s.crossDomain ) { moel@348: moel@348: var script, moel@348: head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement; moel@348: moel@348: return { moel@348: moel@348: send: function( _, callback ) { moel@348: moel@348: script = document.createElement( "script" ); moel@348: moel@348: script.async = "async"; moel@348: moel@348: if ( s.scriptCharset ) { moel@348: script.charset = s.scriptCharset; moel@348: } moel@348: moel@348: script.src = s.url; moel@348: moel@348: // Attach handlers for all browsers moel@348: script.onload = script.onreadystatechange = function( _, isAbort ) { moel@348: moel@348: if ( isAbort || !script.readyState || /loaded|complete/.test( script.readyState ) ) { moel@348: moel@348: // Handle memory leak in IE moel@348: script.onload = script.onreadystatechange = null; moel@348: moel@348: // Remove the script moel@348: if ( head && script.parentNode ) { moel@348: head.removeChild( script ); moel@348: } moel@348: moel@348: // Dereference the script moel@348: script = undefined; moel@348: moel@348: // Callback if not abort moel@348: if ( !isAbort ) { moel@348: callback( 200, "success" ); moel@348: } moel@348: } moel@348: }; moel@348: // Use insertBefore instead of appendChild to circumvent an IE6 bug. moel@348: // This arises when a base node is used (#2709 and #4378). moel@348: head.insertBefore( script, head.firstChild ); moel@348: }, moel@348: moel@348: abort: function() { moel@348: if ( script ) { moel@348: script.onload( 0, 1 ); moel@348: } moel@348: } moel@348: }; moel@348: } moel@348: }); moel@348: moel@348: moel@348: moel@348: moel@348: var // #5280: Internet Explorer will keep connections alive if we don't abort on unload moel@348: xhrOnUnloadAbort = window.ActiveXObject ? function() { moel@348: // Abort all pending requests moel@348: for ( var key in xhrCallbacks ) { moel@348: xhrCallbacks[ key ]( 0, 1 ); moel@348: } moel@348: } : false, moel@348: xhrId = 0, moel@348: xhrCallbacks; moel@348: moel@348: // Functions to create xhrs moel@348: function createStandardXHR() { moel@348: try { moel@348: return new window.XMLHttpRequest(); moel@348: } catch( e ) {} moel@348: } moel@348: moel@348: function createActiveXHR() { moel@348: try { moel@348: return new window.ActiveXObject( "Microsoft.XMLHTTP" ); moel@348: } catch( e ) {} moel@348: } moel@348: moel@348: // Create the request object moel@348: // (This is still attached to ajaxSettings for backward compatibility) moel@348: jQuery.ajaxSettings.xhr = window.ActiveXObject ? moel@348: /* Microsoft failed to properly moel@348: * implement the XMLHttpRequest in IE7 (can't request local files), moel@348: * so we use the ActiveXObject when it is available moel@348: * Additionally XMLHttpRequest can be disabled in IE7/IE8 so moel@348: * we need a fallback. moel@348: */ moel@348: function() { moel@348: return !this.isLocal && createStandardXHR() || createActiveXHR(); moel@348: } : moel@348: // For all other browsers, use the standard XMLHttpRequest object moel@348: createStandardXHR; moel@348: moel@348: // Determine support properties moel@348: (function( xhr ) { moel@348: jQuery.extend( jQuery.support, { moel@348: ajax: !!xhr, moel@348: cors: !!xhr && ( "withCredentials" in xhr ) moel@348: }); moel@348: })( jQuery.ajaxSettings.xhr() ); moel@348: moel@348: // Create transport if the browser can provide an xhr moel@348: if ( jQuery.support.ajax ) { moel@348: moel@348: jQuery.ajaxTransport(function( s ) { moel@348: // Cross domain only allowed if supported through XMLHttpRequest moel@348: if ( !s.crossDomain || jQuery.support.cors ) { moel@348: moel@348: var callback; moel@348: moel@348: return { moel@348: send: function( headers, complete ) { moel@348: moel@348: // Get a new xhr moel@348: var xhr = s.xhr(), moel@348: handle, moel@348: i; moel@348: moel@348: // Open the socket moel@348: // Passing null username, generates a login popup on Opera (#2865) moel@348: if ( s.username ) { moel@348: xhr.open( s.type, s.url, s.async, s.username, s.password ); moel@348: } else { moel@348: xhr.open( s.type, s.url, s.async ); moel@348: } moel@348: moel@348: // Apply custom fields if provided moel@348: if ( s.xhrFields ) { moel@348: for ( i in s.xhrFields ) { moel@348: xhr[ i ] = s.xhrFields[ i ]; moel@348: } moel@348: } moel@348: moel@348: // Override mime type if needed moel@348: if ( s.mimeType && xhr.overrideMimeType ) { moel@348: xhr.overrideMimeType( s.mimeType ); moel@348: } moel@348: moel@348: // X-Requested-With header moel@348: // For cross-domain requests, seeing as conditions for a preflight are moel@348: // akin to a jigsaw puzzle, we simply never set it to be sure. moel@348: // (it can always be set on a per-request basis or even using ajaxSetup) moel@348: // For same-domain requests, won't change header if already provided. moel@348: if ( !s.crossDomain && !headers["X-Requested-With"] ) { moel@348: headers[ "X-Requested-With" ] = "XMLHttpRequest"; moel@348: } moel@348: moel@348: // Need an extra try/catch for cross domain requests in Firefox 3 moel@348: try { moel@348: for ( i in headers ) { moel@348: xhr.setRequestHeader( i, headers[ i ] ); moel@348: } moel@348: } catch( _ ) {} moel@348: moel@348: // Do send the request moel@348: // This may raise an exception which is actually moel@348: // handled in jQuery.ajax (so no try/catch here) moel@348: xhr.send( ( s.hasContent && s.data ) || null ); moel@348: moel@348: // Listener moel@348: callback = function( _, isAbort ) { moel@348: moel@348: var status, moel@348: statusText, moel@348: responseHeaders, moel@348: responses, moel@348: xml; moel@348: moel@348: // Firefox throws exceptions when accessing properties moel@348: // of an xhr when a network error occured moel@348: // http://helpful.knobs-dials.com/index.php/Component_returned_failure_code:_0x80040111_(NS_ERROR_NOT_AVAILABLE) moel@348: try { moel@348: moel@348: // Was never called and is aborted or complete moel@348: if ( callback && ( isAbort || xhr.readyState === 4 ) ) { moel@348: moel@348: // Only called once moel@348: callback = undefined; moel@348: moel@348: // Do not keep as active anymore moel@348: if ( handle ) { moel@348: xhr.onreadystatechange = jQuery.noop; moel@348: if ( xhrOnUnloadAbort ) { moel@348: delete xhrCallbacks[ handle ]; moel@348: } moel@348: } moel@348: moel@348: // If it's an abort moel@348: if ( isAbort ) { moel@348: // Abort it manually if needed moel@348: if ( xhr.readyState !== 4 ) { moel@348: xhr.abort(); moel@348: } moel@348: } else { moel@348: status = xhr.status; moel@348: responseHeaders = xhr.getAllResponseHeaders(); moel@348: responses = {}; moel@348: xml = xhr.responseXML; moel@348: moel@348: // Construct response list moel@348: if ( xml && xml.documentElement /* #4958 */ ) { moel@348: responses.xml = xml; moel@348: } moel@348: moel@348: // When requesting binary data, IE6-9 will throw an exception moel@348: // on any attempt to access responseText (#11426) moel@348: try { moel@348: responses.text = xhr.responseText; moel@348: } catch( _ ) { moel@348: } moel@348: moel@348: // Firefox throws an exception when accessing moel@348: // statusText for faulty cross-domain requests moel@348: try { moel@348: statusText = xhr.statusText; moel@348: } catch( e ) { moel@348: // We normalize with Webkit giving an empty statusText moel@348: statusText = ""; moel@348: } moel@348: moel@348: // Filter status for non standard behaviors moel@348: moel@348: // If the request is local and we have data: assume a success moel@348: // (success with no data won't get notified, that's the best we moel@348: // can do given current implementations) moel@348: if ( !status && s.isLocal && !s.crossDomain ) { moel@348: status = responses.text ? 200 : 404; moel@348: // IE - #1450: sometimes returns 1223 when it should be 204 moel@348: } else if ( status === 1223 ) { moel@348: status = 204; moel@348: } moel@348: } moel@348: } moel@348: } catch( firefoxAccessException ) { moel@348: if ( !isAbort ) { moel@348: complete( -1, firefoxAccessException ); moel@348: } moel@348: } moel@348: moel@348: // Call complete if needed moel@348: if ( responses ) { moel@348: complete( status, statusText, responses, responseHeaders ); moel@348: } moel@348: }; moel@348: moel@348: // if we're in sync mode or it's in cache moel@348: // and has been retrieved directly (IE6 & IE7) moel@348: // we need to manually fire the callback moel@348: if ( !s.async || xhr.readyState === 4 ) { moel@348: callback(); moel@348: } else { moel@348: handle = ++xhrId; moel@348: if ( xhrOnUnloadAbort ) { moel@348: // Create the active xhrs callbacks list if needed moel@348: // and attach the unload handler moel@348: if ( !xhrCallbacks ) { moel@348: xhrCallbacks = {}; moel@348: jQuery( window ).unload( xhrOnUnloadAbort ); moel@348: } moel@348: // Add to list of active xhrs callbacks moel@348: xhrCallbacks[ handle ] = callback; moel@348: } moel@348: xhr.onreadystatechange = callback; moel@348: } moel@348: }, moel@348: moel@348: abort: function() { moel@348: if ( callback ) { moel@348: callback(0,1); moel@348: } moel@348: } moel@348: }; moel@348: } moel@348: }); moel@348: } moel@348: moel@348: moel@348: moel@348: moel@348: var elemdisplay = {}, moel@348: iframe, iframeDoc, moel@348: rfxtypes = /^(?:toggle|show|hide)$/, moel@348: rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i, moel@348: timerId, moel@348: fxAttrs = [ moel@348: // height animations moel@348: [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ], moel@348: // width animations moel@348: [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ], moel@348: // opacity animations moel@348: [ "opacity" ] moel@348: ], moel@348: fxNow; moel@348: moel@348: jQuery.fn.extend({ moel@348: show: function( speed, easing, callback ) { moel@348: var elem, display; moel@348: moel@348: if ( speed || speed === 0 ) { moel@348: return this.animate( genFx("show", 3), speed, easing, callback ); moel@348: moel@348: } else { moel@348: for ( var i = 0, j = this.length; i < j; i++ ) { moel@348: elem = this[ i ]; moel@348: moel@348: if ( elem.style ) { moel@348: display = elem.style.display; moel@348: moel@348: // Reset the inline display of this element to learn if it is moel@348: // being hidden by cascaded rules or not moel@348: if ( !jQuery._data(elem, "olddisplay") && display === "none" ) { moel@348: display = elem.style.display = ""; moel@348: } moel@348: moel@348: // Set elements which have been overridden with display: none moel@348: // in a stylesheet to whatever the default browser style is moel@348: // for such an element moel@348: if ( (display === "" && jQuery.css(elem, "display") === "none") || moel@348: !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) { moel@348: jQuery._data( elem, "olddisplay", defaultDisplay(elem.nodeName) ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Set the display of most of the elements in a second loop moel@348: // to avoid the constant reflow moel@348: for ( i = 0; i < j; i++ ) { moel@348: elem = this[ i ]; moel@348: moel@348: if ( elem.style ) { moel@348: display = elem.style.display; moel@348: moel@348: if ( display === "" || display === "none" ) { moel@348: elem.style.display = jQuery._data( elem, "olddisplay" ) || ""; moel@348: } moel@348: } moel@348: } moel@348: moel@348: return this; moel@348: } moel@348: }, moel@348: moel@348: hide: function( speed, easing, callback ) { moel@348: if ( speed || speed === 0 ) { moel@348: return this.animate( genFx("hide", 3), speed, easing, callback); moel@348: moel@348: } else { moel@348: var elem, display, moel@348: i = 0, moel@348: j = this.length; moel@348: moel@348: for ( ; i < j; i++ ) { moel@348: elem = this[i]; moel@348: if ( elem.style ) { moel@348: display = jQuery.css( elem, "display" ); moel@348: moel@348: if ( display !== "none" && !jQuery._data( elem, "olddisplay" ) ) { moel@348: jQuery._data( elem, "olddisplay", display ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: // Set the display of the elements in a second loop moel@348: // to avoid the constant reflow moel@348: for ( i = 0; i < j; i++ ) { moel@348: if ( this[i].style ) { moel@348: this[i].style.display = "none"; moel@348: } moel@348: } moel@348: moel@348: return this; moel@348: } moel@348: }, moel@348: moel@348: // Save the old toggle function moel@348: _toggle: jQuery.fn.toggle, moel@348: moel@348: toggle: function( fn, fn2, callback ) { moel@348: var bool = typeof fn === "boolean"; moel@348: moel@348: if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) { moel@348: this._toggle.apply( this, arguments ); moel@348: moel@348: } else if ( fn == null || bool ) { moel@348: this.each(function() { moel@348: var state = bool ? fn : jQuery(this).is(":hidden"); moel@348: jQuery(this)[ state ? "show" : "hide" ](); moel@348: }); moel@348: moel@348: } else { moel@348: this.animate(genFx("toggle", 3), fn, fn2, callback); moel@348: } moel@348: moel@348: return this; moel@348: }, moel@348: moel@348: fadeTo: function( speed, to, easing, callback ) { moel@348: return this.filter(":hidden").css("opacity", 0).show().end() moel@348: .animate({opacity: to}, speed, easing, callback); moel@348: }, moel@348: moel@348: animate: function( prop, speed, easing, callback ) { moel@348: var optall = jQuery.speed( speed, easing, callback ); moel@348: moel@348: if ( jQuery.isEmptyObject( prop ) ) { moel@348: return this.each( optall.complete, [ false ] ); moel@348: } moel@348: moel@348: // Do not change referenced properties as per-property easing will be lost moel@348: prop = jQuery.extend( {}, prop ); moel@348: moel@348: function doAnimation() { moel@348: // XXX 'this' does not always have a nodeName when running the moel@348: // test suite moel@348: moel@348: if ( optall.queue === false ) { moel@348: jQuery._mark( this ); moel@348: } moel@348: moel@348: var opt = jQuery.extend( {}, optall ), moel@348: isElement = this.nodeType === 1, moel@348: hidden = isElement && jQuery(this).is(":hidden"), moel@348: name, val, p, e, hooks, replace, moel@348: parts, start, end, unit, moel@348: method; moel@348: moel@348: // will store per property easing and be used to determine when an animation is complete moel@348: opt.animatedProperties = {}; moel@348: moel@348: // first pass over propertys to expand / normalize moel@348: for ( p in prop ) { moel@348: name = jQuery.camelCase( p ); moel@348: if ( p !== name ) { moel@348: prop[ name ] = prop[ p ]; moel@348: delete prop[ p ]; moel@348: } moel@348: moel@348: if ( ( hooks = jQuery.cssHooks[ name ] ) && "expand" in hooks ) { moel@348: replace = hooks.expand( prop[ name ] ); moel@348: delete prop[ name ]; moel@348: moel@348: // not quite $.extend, this wont overwrite keys already present. moel@348: // also - reusing 'p' from above because we have the correct "name" moel@348: for ( p in replace ) { moel@348: if ( ! ( p in prop ) ) { moel@348: prop[ p ] = replace[ p ]; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: for ( name in prop ) { moel@348: val = prop[ name ]; moel@348: // easing resolution: per property > opt.specialEasing > opt.easing > 'swing' (default) moel@348: if ( jQuery.isArray( val ) ) { moel@348: opt.animatedProperties[ name ] = val[ 1 ]; moel@348: val = prop[ name ] = val[ 0 ]; moel@348: } else { moel@348: opt.animatedProperties[ name ] = opt.specialEasing && opt.specialEasing[ name ] || opt.easing || 'swing'; moel@348: } moel@348: moel@348: if ( val === "hide" && hidden || val === "show" && !hidden ) { moel@348: return opt.complete.call( this ); moel@348: } moel@348: moel@348: if ( isElement && ( name === "height" || name === "width" ) ) { moel@348: // Make sure that nothing sneaks out moel@348: // Record all 3 overflow attributes because IE does not moel@348: // change the overflow attribute when overflowX and moel@348: // overflowY are set to the same value moel@348: opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ]; moel@348: moel@348: // Set display property to inline-block for height/width moel@348: // animations on inline elements that are having width/height animated moel@348: if ( jQuery.css( this, "display" ) === "inline" && moel@348: jQuery.css( this, "float" ) === "none" ) { moel@348: moel@348: // inline-level elements accept inline-block; moel@348: // block-level elements need to be inline with layout moel@348: if ( !jQuery.support.inlineBlockNeedsLayout || defaultDisplay( this.nodeName ) === "inline" ) { moel@348: this.style.display = "inline-block"; moel@348: moel@348: } else { moel@348: this.style.zoom = 1; moel@348: } moel@348: } moel@348: } moel@348: } moel@348: moel@348: if ( opt.overflow != null ) { moel@348: this.style.overflow = "hidden"; moel@348: } moel@348: moel@348: for ( p in prop ) { moel@348: e = new jQuery.fx( this, opt, p ); moel@348: val = prop[ p ]; moel@348: moel@348: if ( rfxtypes.test( val ) ) { moel@348: moel@348: // Tracks whether to show or hide based on private moel@348: // data attached to the element moel@348: method = jQuery._data( this, "toggle" + p ) || ( val === "toggle" ? hidden ? "show" : "hide" : 0 ); moel@348: if ( method ) { moel@348: jQuery._data( this, "toggle" + p, method === "show" ? "hide" : "show" ); moel@348: e[ method ](); moel@348: } else { moel@348: e[ val ](); moel@348: } moel@348: moel@348: } else { moel@348: parts = rfxnum.exec( val ); moel@348: start = e.cur(); moel@348: moel@348: if ( parts ) { moel@348: end = parseFloat( parts[2] ); moel@348: unit = parts[3] || ( jQuery.cssNumber[ p ] ? "" : "px" ); moel@348: moel@348: // We need to compute starting value moel@348: if ( unit !== "px" ) { moel@348: jQuery.style( this, p, (end || 1) + unit); moel@348: start = ( (end || 1) / e.cur() ) * start; moel@348: jQuery.style( this, p, start + unit); moel@348: } moel@348: moel@348: // If a +=/-= token was provided, we're doing a relative animation moel@348: if ( parts[1] ) { moel@348: end = ( (parts[ 1 ] === "-=" ? -1 : 1) * end ) + start; moel@348: } moel@348: moel@348: e.custom( start, end, unit ); moel@348: moel@348: } else { moel@348: e.custom( start, val, "" ); moel@348: } moel@348: } moel@348: } moel@348: moel@348: // For JS strict compliance moel@348: return true; moel@348: } moel@348: moel@348: return optall.queue === false ? moel@348: this.each( doAnimation ) : moel@348: this.queue( optall.queue, doAnimation ); moel@348: }, moel@348: moel@348: stop: function( type, clearQueue, gotoEnd ) { moel@348: if ( typeof type !== "string" ) { moel@348: gotoEnd = clearQueue; moel@348: clearQueue = type; moel@348: type = undefined; moel@348: } moel@348: if ( clearQueue && type !== false ) { moel@348: this.queue( type || "fx", [] ); moel@348: } moel@348: moel@348: return this.each(function() { moel@348: var index, moel@348: hadTimers = false, moel@348: timers = jQuery.timers, moel@348: data = jQuery._data( this ); moel@348: moel@348: // clear marker counters if we know they won't be moel@348: if ( !gotoEnd ) { moel@348: jQuery._unmark( true, this ); moel@348: } moel@348: moel@348: function stopQueue( elem, data, index ) { moel@348: var hooks = data[ index ]; moel@348: jQuery.removeData( elem, index, true ); moel@348: hooks.stop( gotoEnd ); moel@348: } moel@348: moel@348: if ( type == null ) { moel@348: for ( index in data ) { moel@348: if ( data[ index ] && data[ index ].stop && index.indexOf(".run") === index.length - 4 ) { moel@348: stopQueue( this, data, index ); moel@348: } moel@348: } moel@348: } else if ( data[ index = type + ".run" ] && data[ index ].stop ){ moel@348: stopQueue( this, data, index ); moel@348: } moel@348: moel@348: for ( index = timers.length; index--; ) { moel@348: if ( timers[ index ].elem === this && (type == null || timers[ index ].queue === type) ) { moel@348: if ( gotoEnd ) { moel@348: moel@348: // force the next step to be the last moel@348: timers[ index ]( true ); moel@348: } else { moel@348: timers[ index ].saveState(); moel@348: } moel@348: hadTimers = true; moel@348: timers.splice( index, 1 ); moel@348: } moel@348: } moel@348: moel@348: // start the next in the queue if the last step wasn't forced moel@348: // timers currently will call their complete callbacks, which will dequeue moel@348: // but only if they were gotoEnd moel@348: if ( !( gotoEnd && hadTimers ) ) { moel@348: jQuery.dequeue( this, type ); moel@348: } moel@348: }); moel@348: } moel@348: moel@348: }); moel@348: moel@348: // Animations created synchronously will run synchronously moel@348: function createFxNow() { moel@348: setTimeout( clearFxNow, 0 ); moel@348: return ( fxNow = jQuery.now() ); moel@348: } moel@348: moel@348: function clearFxNow() { moel@348: fxNow = undefined; moel@348: } moel@348: moel@348: // Generate parameters to create a standard animation moel@348: function genFx( type, num ) { moel@348: var obj = {}; moel@348: moel@348: jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice( 0, num )), function() { moel@348: obj[ this ] = type; moel@348: }); moel@348: moel@348: return obj; moel@348: } moel@348: moel@348: // Generate shortcuts for custom animations moel@348: jQuery.each({ moel@348: slideDown: genFx( "show", 1 ), moel@348: slideUp: genFx( "hide", 1 ), moel@348: slideToggle: genFx( "toggle", 1 ), moel@348: fadeIn: { opacity: "show" }, moel@348: fadeOut: { opacity: "hide" }, moel@348: fadeToggle: { opacity: "toggle" } moel@348: }, function( name, props ) { moel@348: jQuery.fn[ name ] = function( speed, easing, callback ) { moel@348: return this.animate( props, speed, easing, callback ); moel@348: }; moel@348: }); moel@348: moel@348: jQuery.extend({ moel@348: speed: function( speed, easing, fn ) { moel@348: var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { moel@348: complete: fn || !fn && easing || moel@348: jQuery.isFunction( speed ) && speed, moel@348: duration: speed, moel@348: easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing moel@348: }; moel@348: moel@348: opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : moel@348: opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; moel@348: moel@348: // normalize opt.queue - true/undefined/null -> "fx" moel@348: if ( opt.queue == null || opt.queue === true ) { moel@348: opt.queue = "fx"; moel@348: } moel@348: moel@348: // Queueing moel@348: opt.old = opt.complete; moel@348: moel@348: opt.complete = function( noUnmark ) { moel@348: if ( jQuery.isFunction( opt.old ) ) { moel@348: opt.old.call( this ); moel@348: } moel@348: moel@348: if ( opt.queue ) { moel@348: jQuery.dequeue( this, opt.queue ); moel@348: } else if ( noUnmark !== false ) { moel@348: jQuery._unmark( this ); moel@348: } moel@348: }; moel@348: moel@348: return opt; moel@348: }, moel@348: moel@348: easing: { moel@348: linear: function( p ) { moel@348: return p; moel@348: }, moel@348: swing: function( p ) { moel@348: return ( -Math.cos( p*Math.PI ) / 2 ) + 0.5; moel@348: } moel@348: }, moel@348: moel@348: timers: [], moel@348: moel@348: fx: function( elem, options, prop ) { moel@348: this.options = options; moel@348: this.elem = elem; moel@348: this.prop = prop; moel@348: moel@348: options.orig = options.orig || {}; moel@348: } moel@348: moel@348: }); moel@348: moel@348: jQuery.fx.prototype = { moel@348: // Simple function for setting a style value moel@348: update: function() { moel@348: if ( this.options.step ) { moel@348: this.options.step.call( this.elem, this.now, this ); moel@348: } moel@348: moel@348: ( jQuery.fx.step[ this.prop ] || jQuery.fx.step._default )( this ); moel@348: }, moel@348: moel@348: // Get the current size moel@348: cur: function() { moel@348: if ( this.elem[ this.prop ] != null && (!this.elem.style || this.elem.style[ this.prop ] == null) ) { moel@348: return this.elem[ this.prop ]; moel@348: } moel@348: moel@348: var parsed, moel@348: r = jQuery.css( this.elem, this.prop ); moel@348: // Empty strings, null, undefined and "auto" are converted to 0, moel@348: // complex values such as "rotate(1rad)" are returned as is, moel@348: // simple values such as "10px" are parsed to Float. moel@348: return isNaN( parsed = parseFloat( r ) ) ? !r || r === "auto" ? 0 : r : parsed; moel@348: }, moel@348: moel@348: // Start an animation from one number to another moel@348: custom: function( from, to, unit ) { moel@348: var self = this, moel@348: fx = jQuery.fx; moel@348: moel@348: this.startTime = fxNow || createFxNow(); moel@348: this.end = to; moel@348: this.now = this.start = from; moel@348: this.pos = this.state = 0; moel@348: this.unit = unit || this.unit || ( jQuery.cssNumber[ this.prop ] ? "" : "px" ); moel@348: moel@348: function t( gotoEnd ) { moel@348: return self.step( gotoEnd ); moel@348: } moel@348: moel@348: t.queue = this.options.queue; moel@348: t.elem = this.elem; moel@348: t.saveState = function() { moel@348: if ( jQuery._data( self.elem, "fxshow" + self.prop ) === undefined ) { moel@348: if ( self.options.hide ) { moel@348: jQuery._data( self.elem, "fxshow" + self.prop, self.start ); moel@348: } else if ( self.options.show ) { moel@348: jQuery._data( self.elem, "fxshow" + self.prop, self.end ); moel@348: } moel@348: } moel@348: }; moel@348: moel@348: if ( t() && jQuery.timers.push(t) && !timerId ) { moel@348: timerId = setInterval( fx.tick, fx.interval ); moel@348: } moel@348: }, moel@348: moel@348: // Simple 'show' function moel@348: show: function() { moel@348: var dataShow = jQuery._data( this.elem, "fxshow" + this.prop ); moel@348: moel@348: // Remember where we started, so that we can go back to it later moel@348: this.options.orig[ this.prop ] = dataShow || jQuery.style( this.elem, this.prop ); moel@348: this.options.show = true; moel@348: moel@348: // Begin the animation moel@348: // Make sure that we start at a small width/height to avoid any flash of content moel@348: if ( dataShow !== undefined ) { moel@348: // This show is picking up where a previous hide or show left off moel@348: this.custom( this.cur(), dataShow ); moel@348: } else { moel@348: this.custom( this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur() ); moel@348: } moel@348: moel@348: // Start by showing the element moel@348: jQuery( this.elem ).show(); moel@348: }, moel@348: moel@348: // Simple 'hide' function moel@348: hide: function() { moel@348: // Remember where we started, so that we can go back to it later moel@348: this.options.orig[ this.prop ] = jQuery._data( this.elem, "fxshow" + this.prop ) || jQuery.style( this.elem, this.prop ); moel@348: this.options.hide = true; moel@348: moel@348: // Begin the animation moel@348: this.custom( this.cur(), 0 ); moel@348: }, moel@348: moel@348: // Each step of an animation moel@348: step: function( gotoEnd ) { moel@348: var p, n, complete, moel@348: t = fxNow || createFxNow(), moel@348: done = true, moel@348: elem = this.elem, moel@348: options = this.options; moel@348: moel@348: if ( gotoEnd || t >= options.duration + this.startTime ) { moel@348: this.now = this.end; moel@348: this.pos = this.state = 1; moel@348: this.update(); moel@348: moel@348: options.animatedProperties[ this.prop ] = true; moel@348: moel@348: for ( p in options.animatedProperties ) { moel@348: if ( options.animatedProperties[ p ] !== true ) { moel@348: done = false; moel@348: } moel@348: } moel@348: moel@348: if ( done ) { moel@348: // Reset the overflow moel@348: if ( options.overflow != null && !jQuery.support.shrinkWrapBlocks ) { moel@348: moel@348: jQuery.each( [ "", "X", "Y" ], function( index, value ) { moel@348: elem.style[ "overflow" + value ] = options.overflow[ index ]; moel@348: }); moel@348: } moel@348: moel@348: // Hide the element if the "hide" operation was done moel@348: if ( options.hide ) { moel@348: jQuery( elem ).hide(); moel@348: } moel@348: moel@348: // Reset the properties, if the item has been hidden or shown moel@348: if ( options.hide || options.show ) { moel@348: for ( p in options.animatedProperties ) { moel@348: jQuery.style( elem, p, options.orig[ p ] ); moel@348: jQuery.removeData( elem, "fxshow" + p, true ); moel@348: // Toggle data is no longer needed moel@348: jQuery.removeData( elem, "toggle" + p, true ); moel@348: } moel@348: } moel@348: moel@348: // Execute the complete function moel@348: // in the event that the complete function throws an exception moel@348: // we must ensure it won't be called twice. #5684 moel@348: moel@348: complete = options.complete; moel@348: if ( complete ) { moel@348: moel@348: options.complete = false; moel@348: complete.call( elem ); moel@348: } moel@348: } moel@348: moel@348: return false; moel@348: moel@348: } else { moel@348: // classical easing cannot be used with an Infinity duration moel@348: if ( options.duration == Infinity ) { moel@348: this.now = t; moel@348: } else { moel@348: n = t - this.startTime; moel@348: this.state = n / options.duration; moel@348: moel@348: // Perform the easing function, defaults to swing moel@348: this.pos = jQuery.easing[ options.animatedProperties[this.prop] ]( this.state, n, 0, 1, options.duration ); moel@348: this.now = this.start + ( (this.end - this.start) * this.pos ); moel@348: } moel@348: // Perform the next step of the animation moel@348: this.update(); moel@348: } moel@348: moel@348: return true; moel@348: } moel@348: }; moel@348: moel@348: jQuery.extend( jQuery.fx, { moel@348: tick: function() { moel@348: var timer, moel@348: timers = jQuery.timers, moel@348: i = 0; moel@348: moel@348: for ( ; i < timers.length; i++ ) { moel@348: timer = timers[ i ]; moel@348: // Checks the timer has not already been removed moel@348: if ( !timer() && timers[ i ] === timer ) { moel@348: timers.splice( i--, 1 ); moel@348: } moel@348: } moel@348: moel@348: if ( !timers.length ) { moel@348: jQuery.fx.stop(); moel@348: } moel@348: }, moel@348: moel@348: interval: 13, moel@348: moel@348: stop: function() { moel@348: clearInterval( timerId ); moel@348: timerId = null; moel@348: }, moel@348: moel@348: speeds: { moel@348: slow: 600, moel@348: fast: 200, moel@348: // Default speed moel@348: _default: 400 moel@348: }, moel@348: moel@348: step: { moel@348: opacity: function( fx ) { moel@348: jQuery.style( fx.elem, "opacity", fx.now ); moel@348: }, moel@348: moel@348: _default: function( fx ) { moel@348: if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) { moel@348: fx.elem.style[ fx.prop ] = fx.now + fx.unit; moel@348: } else { moel@348: fx.elem[ fx.prop ] = fx.now; moel@348: } moel@348: } moel@348: } moel@348: }); moel@348: moel@348: // Ensure props that can't be negative don't go there on undershoot easing moel@348: jQuery.each( fxAttrs.concat.apply( [], fxAttrs ), function( i, prop ) { moel@348: // exclude marginTop, marginLeft, marginBottom and marginRight from this list moel@348: if ( prop.indexOf( "margin" ) ) { moel@348: jQuery.fx.step[ prop ] = function( fx ) { moel@348: jQuery.style( fx.elem, prop, Math.max(0, fx.now) + fx.unit ); moel@348: }; moel@348: } moel@348: }); moel@348: moel@348: if ( jQuery.expr && jQuery.expr.filters ) { moel@348: jQuery.expr.filters.animated = function( elem ) { moel@348: return jQuery.grep(jQuery.timers, function( fn ) { moel@348: return elem === fn.elem; moel@348: }).length; moel@348: }; moel@348: } moel@348: moel@348: // Try to restore the default display value of an element moel@348: function defaultDisplay( nodeName ) { moel@348: moel@348: if ( !elemdisplay[ nodeName ] ) { moel@348: moel@348: var body = document.body, moel@348: elem = jQuery( "<" + nodeName + ">" ).appendTo( body ), moel@348: display = elem.css( "display" ); moel@348: elem.remove(); moel@348: moel@348: // If the simple way fails, moel@348: // get element's real default display by attaching it to a temp iframe moel@348: if ( display === "none" || display === "" ) { moel@348: // No iframe to use yet, so create it moel@348: if ( !iframe ) { moel@348: iframe = document.createElement( "iframe" ); moel@348: iframe.frameBorder = iframe.width = iframe.height = 0; moel@348: } moel@348: moel@348: body.appendChild( iframe ); moel@348: moel@348: // Create a cacheable copy of the iframe document on first call. moel@348: // IE and Opera will allow us to reuse the iframeDoc without re-writing the fake HTML moel@348: // document to it; WebKit & Firefox won't allow reusing the iframe document. moel@348: if ( !iframeDoc || !iframe.createElement ) { moel@348: iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document; moel@348: iframeDoc.write( ( jQuery.support.boxModel ? "<!doctype html>" : "" ) + "<html><body>" ); moel@348: iframeDoc.close(); moel@348: } moel@348: moel@348: elem = iframeDoc.createElement( nodeName ); moel@348: moel@348: iframeDoc.body.appendChild( elem ); moel@348: moel@348: display = jQuery.css( elem, "display" ); moel@348: body.removeChild( iframe ); moel@348: } moel@348: moel@348: // Store the correct default display moel@348: elemdisplay[ nodeName ] = display; moel@348: } moel@348: moel@348: return elemdisplay[ nodeName ]; moel@348: } moel@348: moel@348: moel@348: moel@348: moel@348: var getOffset, moel@348: rtable = /^t(?:able|d|h)$/i, moel@348: rroot = /^(?:body|html)$/i; moel@348: moel@348: if ( "getBoundingClientRect" in document.documentElement ) { moel@348: getOffset = function( elem, doc, docElem, box ) { moel@348: try { moel@348: box = elem.getBoundingClientRect(); moel@348: } catch(e) {} moel@348: moel@348: // Make sure we're not dealing with a disconnected DOM node moel@348: if ( !box || !jQuery.contains( docElem, elem ) ) { moel@348: return box ? { top: box.top, left: box.left } : { top: 0, left: 0 }; moel@348: } moel@348: moel@348: var body = doc.body, moel@348: win = getWindow( doc ), moel@348: clientTop = docElem.clientTop || body.clientTop || 0, moel@348: clientLeft = docElem.clientLeft || body.clientLeft || 0, moel@348: scrollTop = win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop, moel@348: scrollLeft = win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft, moel@348: top = box.top + scrollTop - clientTop, moel@348: left = box.left + scrollLeft - clientLeft; moel@348: moel@348: return { top: top, left: left }; moel@348: }; moel@348: moel@348: } else { moel@348: getOffset = function( elem, doc, docElem ) { moel@348: var computedStyle, moel@348: offsetParent = elem.offsetParent, moel@348: prevOffsetParent = elem, moel@348: body = doc.body, moel@348: defaultView = doc.defaultView, moel@348: prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle, moel@348: top = elem.offsetTop, moel@348: left = elem.offsetLeft; moel@348: moel@348: while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) { moel@348: if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) { moel@348: break; moel@348: } moel@348: moel@348: computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle; moel@348: top -= elem.scrollTop; moel@348: left -= elem.scrollLeft; moel@348: moel@348: if ( elem === offsetParent ) { moel@348: top += elem.offsetTop; moel@348: left += elem.offsetLeft; moel@348: moel@348: if ( jQuery.support.doesNotAddBorder && !(jQuery.support.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) { moel@348: top += parseFloat( computedStyle.borderTopWidth ) || 0; moel@348: left += parseFloat( computedStyle.borderLeftWidth ) || 0; moel@348: } moel@348: moel@348: prevOffsetParent = offsetParent; moel@348: offsetParent = elem.offsetParent; moel@348: } moel@348: moel@348: if ( jQuery.support.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) { moel@348: top += parseFloat( computedStyle.borderTopWidth ) || 0; moel@348: left += parseFloat( computedStyle.borderLeftWidth ) || 0; moel@348: } moel@348: moel@348: prevComputedStyle = computedStyle; moel@348: } moel@348: moel@348: if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) { moel@348: top += body.offsetTop; moel@348: left += body.offsetLeft; moel@348: } moel@348: moel@348: if ( jQuery.support.fixedPosition && prevComputedStyle.position === "fixed" ) { moel@348: top += Math.max( docElem.scrollTop, body.scrollTop ); moel@348: left += Math.max( docElem.scrollLeft, body.scrollLeft ); moel@348: } moel@348: moel@348: return { top: top, left: left }; moel@348: }; moel@348: } moel@348: moel@348: jQuery.fn.offset = function( options ) { moel@348: if ( arguments.length ) { moel@348: return options === undefined ? moel@348: this : moel@348: this.each(function( i ) { moel@348: jQuery.offset.setOffset( this, options, i ); moel@348: }); moel@348: } moel@348: moel@348: var elem = this[0], moel@348: doc = elem && elem.ownerDocument; moel@348: moel@348: if ( !doc ) { moel@348: return null; moel@348: } moel@348: moel@348: if ( elem === doc.body ) { moel@348: return jQuery.offset.bodyOffset( elem ); moel@348: } moel@348: moel@348: return getOffset( elem, doc, doc.documentElement ); moel@348: }; moel@348: moel@348: jQuery.offset = { moel@348: moel@348: bodyOffset: function( body ) { moel@348: var top = body.offsetTop, moel@348: left = body.offsetLeft; moel@348: moel@348: if ( jQuery.support.doesNotIncludeMarginInBodyOffset ) { moel@348: top += parseFloat( jQuery.css(body, "marginTop") ) || 0; moel@348: left += parseFloat( jQuery.css(body, "marginLeft") ) || 0; moel@348: } moel@348: moel@348: return { top: top, left: left }; moel@348: }, moel@348: moel@348: setOffset: function( elem, options, i ) { moel@348: var position = jQuery.css( elem, "position" ); moel@348: moel@348: // set position first, in-case top/left are set even on static elem moel@348: if ( position === "static" ) { moel@348: elem.style.position = "relative"; moel@348: } moel@348: moel@348: var curElem = jQuery( elem ), moel@348: curOffset = curElem.offset(), moel@348: curCSSTop = jQuery.css( elem, "top" ), moel@348: curCSSLeft = jQuery.css( elem, "left" ), moel@348: calculatePosition = ( position === "absolute" || position === "fixed" ) && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1, moel@348: props = {}, curPosition = {}, curTop, curLeft; moel@348: moel@348: // need to be able to calculate position if either top or left is auto and position is either absolute or fixed moel@348: if ( calculatePosition ) { moel@348: curPosition = curElem.position(); moel@348: curTop = curPosition.top; moel@348: curLeft = curPosition.left; moel@348: } else { moel@348: curTop = parseFloat( curCSSTop ) || 0; moel@348: curLeft = parseFloat( curCSSLeft ) || 0; moel@348: } moel@348: moel@348: if ( jQuery.isFunction( options ) ) { moel@348: options = options.call( elem, i, curOffset ); moel@348: } moel@348: moel@348: if ( options.top != null ) { moel@348: props.top = ( options.top - curOffset.top ) + curTop; moel@348: } moel@348: if ( options.left != null ) { moel@348: props.left = ( options.left - curOffset.left ) + curLeft; moel@348: } moel@348: moel@348: if ( "using" in options ) { moel@348: options.using.call( elem, props ); moel@348: } else { moel@348: curElem.css( props ); moel@348: } moel@348: } moel@348: }; moel@348: moel@348: moel@348: jQuery.fn.extend({ moel@348: moel@348: position: function() { moel@348: if ( !this[0] ) { moel@348: return null; moel@348: } moel@348: moel@348: var elem = this[0], moel@348: moel@348: // Get *real* offsetParent moel@348: offsetParent = this.offsetParent(), moel@348: moel@348: // Get correct offsets moel@348: offset = this.offset(), moel@348: parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset(); moel@348: moel@348: // Subtract element margins moel@348: // note: when an element has margin: auto the offsetLeft and marginLeft moel@348: // are the same in Safari causing offset.left to incorrectly be 0 moel@348: offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0; moel@348: offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0; moel@348: moel@348: // Add offsetParent borders moel@348: parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0; moel@348: parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0; moel@348: moel@348: // Subtract the two offsets moel@348: return { moel@348: top: offset.top - parentOffset.top, moel@348: left: offset.left - parentOffset.left moel@348: }; moel@348: }, moel@348: moel@348: offsetParent: function() { moel@348: return this.map(function() { moel@348: var offsetParent = this.offsetParent || document.body; moel@348: while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) { moel@348: offsetParent = offsetParent.offsetParent; moel@348: } moel@348: return offsetParent; moel@348: }); moel@348: } moel@348: }); moel@348: moel@348: moel@348: // Create scrollLeft and scrollTop methods moel@348: jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) { moel@348: var top = /Y/.test( prop ); moel@348: moel@348: jQuery.fn[ method ] = function( val ) { moel@348: return jQuery.access( this, function( elem, method, val ) { moel@348: var win = getWindow( elem ); moel@348: moel@348: if ( val === undefined ) { moel@348: return win ? (prop in win) ? win[ prop ] : moel@348: jQuery.support.boxModel && win.document.documentElement[ method ] || moel@348: win.document.body[ method ] : moel@348: elem[ method ]; moel@348: } moel@348: moel@348: if ( win ) { moel@348: win.scrollTo( moel@348: !top ? val : jQuery( win ).scrollLeft(), moel@348: top ? val : jQuery( win ).scrollTop() moel@348: ); moel@348: moel@348: } else { moel@348: elem[ method ] = val; moel@348: } moel@348: }, method, val, arguments.length, null ); moel@348: }; moel@348: }); moel@348: moel@348: function getWindow( elem ) { moel@348: return jQuery.isWindow( elem ) ? moel@348: elem : moel@348: elem.nodeType === 9 ? moel@348: elem.defaultView || elem.parentWindow : moel@348: false; moel@348: } moel@348: moel@348: moel@348: moel@348: moel@348: // Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods moel@348: jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { moel@348: var clientProp = "client" + name, moel@348: scrollProp = "scroll" + name, moel@348: offsetProp = "offset" + name; moel@348: moel@348: // innerHeight and innerWidth moel@348: jQuery.fn[ "inner" + name ] = function() { moel@348: var elem = this[0]; moel@348: return elem ? moel@348: elem.style ? moel@348: parseFloat( jQuery.css( elem, type, "padding" ) ) : moel@348: this[ type ]() : moel@348: null; moel@348: }; moel@348: moel@348: // outerHeight and outerWidth moel@348: jQuery.fn[ "outer" + name ] = function( margin ) { moel@348: var elem = this[0]; moel@348: return elem ? moel@348: elem.style ? moel@348: parseFloat( jQuery.css( elem, type, margin ? "margin" : "border" ) ) : moel@348: this[ type ]() : moel@348: null; moel@348: }; moel@348: moel@348: jQuery.fn[ type ] = function( value ) { moel@348: return jQuery.access( this, function( elem, type, value ) { moel@348: var doc, docElemProp, orig, ret; moel@348: moel@348: if ( jQuery.isWindow( elem ) ) { moel@348: // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat moel@348: doc = elem.document; moel@348: docElemProp = doc.documentElement[ clientProp ]; moel@348: return jQuery.support.boxModel && docElemProp || moel@348: doc.body && doc.body[ clientProp ] || docElemProp; moel@348: } moel@348: moel@348: // Get document width or height moel@348: if ( elem.nodeType === 9 ) { moel@348: // Either scroll[Width/Height] or offset[Width/Height], whichever is greater moel@348: doc = elem.documentElement; moel@348: moel@348: // when a window > document, IE6 reports a offset[Width/Height] > client[Width/Height] moel@348: // so we can't use max, as it'll choose the incorrect offset[Width/Height] moel@348: // instead we use the correct client[Width/Height] moel@348: // support:IE6 moel@348: if ( doc[ clientProp ] >= doc[ scrollProp ] ) { moel@348: return doc[ clientProp ]; moel@348: } moel@348: moel@348: return Math.max( moel@348: elem.body[ scrollProp ], doc[ scrollProp ], moel@348: elem.body[ offsetProp ], doc[ offsetProp ] moel@348: ); moel@348: } moel@348: moel@348: // Get width or height on the element moel@348: if ( value === undefined ) { moel@348: orig = jQuery.css( elem, type ); moel@348: ret = parseFloat( orig ); moel@348: return jQuery.isNumeric( ret ) ? ret : orig; moel@348: } moel@348: moel@348: // Set the width or height on the element moel@348: jQuery( elem ).css( type, value ); moel@348: }, type, value, arguments.length, null ); moel@348: }; moel@348: }); moel@348: moel@348: moel@348: moel@348: moel@348: // Expose jQuery to the global object moel@348: window.jQuery = window.$ = jQuery; moel@348: moel@348: // Expose jQuery as an AMD module, but only for AMD loaders that moel@348: // understand the issues with loading multiple versions of jQuery moel@348: // in a page that all might call define(). The loader will indicate moel@348: // they have special allowances for multiple jQuery versions by moel@348: // specifying define.amd.jQuery = true. Register as a named module, moel@348: // since jQuery can be concatenated with other files that may use define, moel@348: // but not use a proper concatenation script that understands anonymous moel@348: // AMD modules. A named AMD is safest and most robust way to register. moel@348: // Lowercase jquery is used because AMD module names are derived from moel@348: // file names, and jQuery is normally delivered in a lowercase file name. moel@348: // Do this after creating the global so that if an AMD module wants to call moel@348: // noConflict to hide this version of jQuery, it will work. moel@348: if ( typeof define === "function" && define.amd && define.amd.jQuery ) { moel@348: define( "jquery", [], function () { return jQuery; } ); moel@348: } moel@348: moel@348: moel@348: moel@348: })( window );