diff --git a/Frameworks/Ajax/Ajax/WebServerResources/prototype.js b/Frameworks/Ajax/Ajax/WebServerResources/prototype.js index 3ace763f154..5c7ed2bd4cf 100644 --- a/Frameworks/Ajax/Ajax/WebServerResources/prototype.js +++ b/Frameworks/Ajax/Ajax/WebServerResources/prototype.js @@ -1,4 +1,4 @@ -/* Prototype JavaScript framework, version 1.7.1 +/* Prototype JavaScript framework, version 1.7.2 * (c) 2005-2010 Sam Stephenson * * Prototype is freely distributable under the terms of an MIT-style license. @@ -8,7 +8,7 @@ var Prototype = { - Version: '1.7.1', + Version: '1.7.2', Browser: (function(){ var ua = navigator.userAgent; @@ -399,7 +399,7 @@ Object.extend(Function.prototype, (function() { var __method = this, args = slice.call(arguments, 1); var bound = function() { - var a = merge(args, arguments), c = context; + var a = merge(args, arguments); var c = this instanceof bound ? this : context; return __method.apply(c, a); }; @@ -564,6 +564,11 @@ Object.extend(String.prototype, (function() { return function(match) { return template.evaluate(match) }; } + function isNonEmptyRegExp(regexp) { + return regexp.source && regexp.source !== '(?:)'; + } + + function gsub(pattern, replacement) { var result = '', source = this, match; replacement = prepareReplacement(replacement); @@ -571,13 +576,14 @@ Object.extend(String.prototype, (function() { if (Object.isString(pattern)) pattern = RegExp.escape(pattern); - if (!(pattern.length || pattern.source)) { + if (!(pattern.length || isNonEmptyRegExp(pattern))) { replacement = replacement(''); return replacement + source.split('').join(replacement) + replacement; } while (source.length > 0) { - if (match = source.match(pattern)) { + match = source.match(pattern) + if (match && match[0].length > 0) { result += source.slice(0, match.index); result += String.interpret(replacement(match)); source = source.slice(match.index + match[0].length); @@ -652,7 +658,10 @@ Object.extend(String.prototype, (function() { var key = decodeURIComponent(pair.shift()), value = pair.length > 1 ? pair.join('=') : pair[0]; - if (value != undefined) value = decodeURIComponent(value); + if (value != undefined) { + value = value.gsub('+', ' '); + value = decodeURIComponent(value); + } if (key in hash) { if (!Object.isArray(hash[key])) hash[key] = [hash[key]]; @@ -746,12 +755,17 @@ Object.extend(String.prototype, (function() { return this.indexOf(pattern) > -1; } - function startsWith(pattern) { - return this.lastIndexOf(pattern, 0) === 0; + function startsWith(pattern, position) { + position = Object.isNumber(position) ? position : 0; + return this.lastIndexOf(pattern, position) === position; } - function endsWith(pattern) { - var d = this.length - pattern.length; + function endsWith(pattern, position) { + pattern = String(pattern); + position = Object.isNumber(position) ? position : this.length; + if (position < 0) position = 0; + if (position > this.length) position = this.length; + var d = position - pattern.length; return d >= 0 && this.indexOf(pattern, d) === d; } @@ -793,8 +807,8 @@ Object.extend(String.prototype, (function() { isJSON: isJSON, evalJSON: NATIVE_JSON_PARSE_SUPPORT ? parseJSON : evalJSON, include: include, - startsWith: startsWith, - endsWith: endsWith, + startsWith: String.prototype.startsWith || startsWith, + endsWith: String.prototype.endsWith || endsWith, empty: empty, blank: blank, interpolate: interpolate @@ -921,8 +935,8 @@ var Enumerable = (function() { } function include(object) { - if (Object.isFunction(this.indexOf)) - if (this.indexOf(object) != -1) return true; + if (Object.isFunction(this.indexOf) && this.indexOf(object) != -1) + return true; var found = false; this.each(function(value) { @@ -1406,11 +1420,13 @@ var Hash = Class.create(Enumerable, (function() { function _each(iterator, context) { + var i = 0; for (var key in this._object) { var value = this._object[key], pair = [key, value]; pair.key = key; pair.value = value; - iterator.call(context, pair); + iterator.call(context, pair, i); + i++; } } @@ -1464,11 +1480,11 @@ var Hash = Class.create(Enumerable, (function() { function toQueryPair(key, value) { if (Object.isUndefined(value)) return key; - var value = String.interpret(value); + value = String.interpret(value); value = value.gsub(/(\r)?\n/, '\r\n'); value = encodeURIComponent(value); - value = value.gsub(/%20/, '+'); // Why reencoding spaces already encoded by encodeURIComponent? This one does not seems to harm. + value = value.gsub(/%20/, '+'); return key + '=' + value; } @@ -1580,9 +1596,9 @@ var ObjectRange = Class.create(Enumerable, (function() { } function _each(iterator, context) { - var value = this.start; - while (this.include(value)) { - iterator.call(context, value); + var value = this.start, i; + for (i = 0; this.include(value); i++) { + iterator.call(context, value, i); value = value.succ(); } } @@ -1777,7 +1793,8 @@ Ajax.Request = Class.create(Ajax.Base, { } for (var name in headers) - this.transport.setRequestHeader(name, headers[name]); + if (headers[name] != null) + this.transport.setRequestHeader(name, headers[name]); }, success: function() { @@ -2628,6 +2645,7 @@ Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { } function down(element, expression, index) { + if (arguments.length === 1) return firstDescendant(element); element = $(element), expression = expression || 0, index = index || 0; if (Object.isNumber(expression)) @@ -2755,9 +2773,9 @@ Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { } var PROBLEMATIC_ATTRIBUTE_READING = (function() { - DIV.setAttribute('onclick', Prototype.emptyFunction); + DIV.setAttribute('onclick', []); var value = DIV.getAttribute('onclick'); - var isFunction = (typeof value === 'function'); + var isFunction = Object.isArray(value); DIV.removeAttribute('onclick'); return isFunction; })(); @@ -2783,7 +2801,7 @@ Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { name = table.names[attr] || attr; value = attributes[attr]; if (table.values[attr]) - name = table.values[attr](element, value); + name = table.values[attr](element, value) || name; if (value === false || value === null) element.removeAttribute(name); else if (value === true) @@ -2794,13 +2812,32 @@ Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { return element; } + var PROBLEMATIC_HAS_ATTRIBUTE_WITH_CHECKBOXES = (function () { + if (!HAS_EXTENDED_CREATE_ELEMENT_SYNTAX) { + return false; + } + var checkbox = document.createElement(''); + checkbox.checked = true; + var node = checkbox.getAttributeNode('checked'); + return !node || !node.specified; + })(); + function hasAttribute(element, attribute) { attribute = ATTRIBUTE_TRANSLATIONS.has[attribute] || attribute; var node = $(element).getAttributeNode(attribute); return !!(node && node.specified); } - GLOBAL.Element.Methods.Simulated.hasAttribute = hasAttribute; + function hasAttribute_IE(element, attribute) { + if (attribute === 'checked') { + return element.checked; + } + return hasAttribute(element, attribute); + } + + GLOBAL.Element.Methods.Simulated.hasAttribute = + PROBLEMATIC_HAS_ATTRIBUTE_WITH_CHECKBOXES ? + hasAttribute_IE : hasAttribute; function classNames(element) { return new Element.ClassNames(element); @@ -3104,7 +3141,7 @@ Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { } function hasLayout_IE(element) { - if (!element.currentStyle.hasLayout) + if (!element.currentStyle || !element.currentStyle.hasLayout) element.style.zoom = 1; return element; } @@ -3157,7 +3194,7 @@ Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { var filter = Element.getStyle(element, 'filter'); if (filter.length === 0) return 1.0; var match = (filter || '').match(/alpha\(opacity=(.*)\)/); - if (match[1]) return parseFloat(match[1]) / 100; + if (match && match[1]) return parseFloat(match[1]) / 100; return 1.0; } @@ -3250,6 +3287,7 @@ Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { function checkElementPrototypeDeficiency(tagName) { if (typeof window.Element === 'undefined') return false; + if (!HAS_EXTENDED_CREATE_ELEMENT_SYNTAX) return false; var proto = window.Element.prototype; if (proto) { var id = '_' + (Math.random() + '').slice(2), @@ -3432,6 +3470,14 @@ Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { Element.addMethods(methods); + function destroyCache_IE() { + DIV = null; + ELEMENT_CACHE = null; + } + + if (window.attachEvent) + window.attachEvent('onunload', destroyCache_IE); + })(this); (function() { @@ -4056,9 +4102,16 @@ Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { function cumulativeScrollOffset(element) { var valueT = 0, valueL = 0; do { - valueT += element.scrollTop || 0; - valueL += element.scrollLeft || 0; - element = element.parentNode; + if (element === document.body) { + var bodyScrollNode = document.documentElement || document.body.parentNode || document.body; + valueT += !Object.isUndefined(window.pageYOffset) ? window.pageYOffset : bodyScrollNode.scrollTop || 0; + valueL += !Object.isUndefined(window.pageXOffset) ? window.pageXOffset : bodyScrollNode.scrollLeft || 0; + break; + } else { + valueT += element.scrollTop || 0; + valueL += element.scrollLeft || 0; + element = element.parentNode; + } } while (element); return new Element.Offset(valueL, valueT); } @@ -4066,7 +4119,8 @@ Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { function viewportOffset(forElement) { var valueT = 0, valueL = 0, docBody = document.body; - var element = $(forElement); + forElement = $(forElement); + var element = forElement; do { valueT += element.offsetTop || 0; valueL += element.offsetLeft || 0; @@ -4099,10 +4153,11 @@ Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { var layout = element.getLayout(); element.store('prototype_absolutize_original_styles', { - left: element.getStyle('left'), - top: element.getStyle('top'), - width: element.getStyle('width'), - height: element.getStyle('height') + position: element.getStyle('position'), + left: element.getStyle('left'), + top: element.getStyle('top'), + width: element.getStyle('width'), + height: element.getStyle('height') }); element.setStyle({ @@ -4432,1336 +4487,1747 @@ Prototype.Selector = (function() { extendElement: Element.extend }; })(); +Prototype._original_property = window.Sizzle; /*! - * Sizzle CSS Selector Engine - * Copyright 2011, The Dojo Foundation - * Released under the MIT, BSD, and GPL Licenses. - * More information: http://sizzlejs.com/ + * Sizzle CSS Selector Engine v@VERSION + * http://sizzlejs.com/ + * + * Copyright 2013 jQuery Foundation, Inc. and other contributors + * Released under the MIT license + * http://jquery.org/license + * + * Date: @DATE */ -(function(){ - -var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, +(function( window ) { + +var i, + support, + Expr, + getText, + isXML, + compile, + select, + outermostContext, + sortInput, + hasDuplicate, + + setDocument, + document, + docElem, + documentIsHTML, + rbuggyQSA, + rbuggyMatches, + matches, + contains, + + expando = "sizzle" + -(new Date()), + preferredDoc = window.document, + dirruns = 0, done = 0, - toString = Object.prototype.toString, - hasDuplicate = false, - baseHasDuplicate = true, - rBackslash = /\\/g, - rNonWord = /\W/; - -[0, 0].sort(function() { - baseHasDuplicate = false; - return 0; -}); + classCache = createCache(), + tokenCache = createCache(), + compilerCache = createCache(), + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + } + return 0; + }, -var Sizzle = function( selector, context, results, seed ) { - results = results || []; - context = context || document; + strundefined = typeof undefined, + MAX_NEGATIVE = 1 << 31, - var origContext = context; + hasOwn = ({}).hasOwnProperty, + arr = [], + pop = arr.pop, + push_native = arr.push, + push = arr.push, + slice = arr.slice, + indexOf = arr.indexOf || function( elem ) { + var i = 0, + len = this.length; + for ( ; i < len; i++ ) { + if ( this[i] === elem ) { + return i; + } + } + return -1; + }, - if ( context.nodeType !== 1 && context.nodeType !== 9 ) { - return []; - } + booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped", - if ( !selector || typeof selector !== "string" ) { - return results; - } - var m, set, checkSet, extra, ret, cur, pop, i, - prune = true, - contextXML = Sizzle.isXML( context ), - parts = [], - soFar = selector; + whitespace = "[\\x20\\t\\r\\n\\f]", + characterEncoding = "(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+", - do { - chunker.exec( "" ); - m = chunker.exec( soFar ); + identifier = characterEncoding.replace( "w", "w#" ), - if ( m ) { - soFar = m[3]; + attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + + "*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", - parts.push( m[1] ); + pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)", - if ( m[2] ) { - extra = m[3]; - break; - } - } - } while ( m ); + rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), - if ( parts.length > 1 && origPOS.exec( selector ) ) { + rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), + rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ), - if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { - set = posProcess( parts[0] + parts[1], context ); + rattributeQuotes = new RegExp( "=" + whitespace + "*([^\\]'\"]*?)" + whitespace + "*\\]", "g" ), - } else { - set = Expr.relative[ parts[0] ] ? - [ context ] : - Sizzle( parts.shift(), context ); + rpseudo = new RegExp( pseudos ), + ridentifier = new RegExp( "^" + identifier + "$" ), - while ( parts.length ) { - selector = parts.shift(); + matchExpr = { + "ID": new RegExp( "^#(" + characterEncoding + ")" ), + "CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ), + "TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ), + "ATTR": new RegExp( "^" + attributes ), + "PSEUDO": new RegExp( "^" + pseudos ), + "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), + "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), + "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) + }, - if ( Expr.relative[ selector ] ) { - selector += parts.shift(); - } + rinputs = /^(?:input|select|textarea|button)$/i, + rheader = /^h\d$/i, - set = posProcess( selector, set ); - } - } + rnative = /^[^{]+\{\s*\[native \w/, - } else { - if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && - Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { + rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, + + rsibling = /[+~]/, + rescape = /'|\\/g, + + runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ), + funescape = function( _, escaped, escapedWhitespace ) { + var high = "0x" + escaped - 0x10000; + return high !== high || escapedWhitespace ? + escaped : + high < 0 ? + String.fromCharCode( high + 0x10000 ) : + String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); + }; - ret = Sizzle.find( parts.shift(), context, contextXML ); - context = ret.expr ? - Sizzle.filter( ret.expr, ret.set )[0] : - ret.set[0]; +try { + push.apply( + (arr = slice.call( preferredDoc.childNodes )), + preferredDoc.childNodes + ); + arr[ preferredDoc.childNodes.length ].nodeType; +} catch ( e ) { + push = { apply: arr.length ? + + function( target, els ) { + push_native.apply( target, slice.call(els) ); + } : + + function( target, els ) { + var j = target.length, + i = 0; + while ( (target[j++] = els[i++]) ) {} + target.length = j - 1; } + }; +} - if ( context ) { - ret = seed ? - { expr: parts.pop(), set: makeArray(seed) } : - Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); +function Sizzle( selector, context, results, seed ) { + var match, elem, m, nodeType, + i, groups, old, nid, newContext, newSelector; - set = ret.expr ? - Sizzle.filter( ret.expr, ret.set ) : - ret.set; + if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) { + setDocument( context ); + } - if ( parts.length > 0 ) { - checkSet = makeArray( set ); + context = context || document; + results = results || []; - } else { - prune = false; - } + if ( !selector || typeof selector !== "string" ) { + return results; + } + + if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { + return []; + } - while ( parts.length ) { - cur = parts.pop(); - pop = cur; + if ( documentIsHTML && !seed ) { - if ( !Expr.relative[ cur ] ) { - cur = ""; + if ( (match = rquickExpr.exec( selector )) ) { + if ( (m = match[1]) ) { + if ( nodeType === 9 ) { + elem = context.getElementById( m ); + if ( elem && elem.parentNode ) { + if ( elem.id === m ) { + results.push( elem ); + return results; + } + } else { + return results; + } } else { - pop = parts.pop(); + if ( context.ownerDocument && (elem = context.ownerDocument.getElementById( m )) && + contains( context, elem ) && elem.id === m ) { + results.push( elem ); + return results; + } } - if ( pop == null ) { - pop = context; - } + } else if ( match[2] ) { + push.apply( results, context.getElementsByTagName( selector ) ); + return results; - Expr.relative[ cur ]( checkSet, pop, contextXML ); + } else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) { + push.apply( results, context.getElementsByClassName( m ) ); + return results; } - - } else { - checkSet = parts = []; } - } - if ( !checkSet ) { - checkSet = set; - } + if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { + nid = old = expando; + newContext = context; + newSelector = nodeType === 9 && selector; - if ( !checkSet ) { - Sizzle.error( cur || selector ); - } + if ( nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + groups = tokenize( selector ); - if ( toString.call(checkSet) === "[object Array]" ) { - if ( !prune ) { - results.push.apply( results, checkSet ); + if ( (old = context.getAttribute("id")) ) { + nid = old.replace( rescape, "\\$&" ); + } else { + context.setAttribute( "id", nid ); + } + nid = "[id='" + nid + "'] "; - } else if ( context && context.nodeType === 1 ) { - for ( i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { - results.push( set[i] ); + i = groups.length; + while ( i-- ) { + groups[i] = nid + toSelector( groups[i] ); } + newContext = rsibling.test( selector ) && testContext( context.parentNode ) || context; + newSelector = groups.join(","); } - } else { - for ( i = 0; checkSet[i] != null; i++ ) { - if ( checkSet[i] && checkSet[i].nodeType === 1 ) { - results.push( set[i] ); + if ( newSelector ) { + try { + push.apply( results, + newContext.querySelectorAll( newSelector ) + ); + return results; + } catch(qsaError) { + } finally { + if ( !old ) { + context.removeAttribute("id"); + } } } } - - } else { - makeArray( checkSet, results ); } - if ( extra ) { - Sizzle( extra, origContext, results, seed ); - Sizzle.uniqueSort( results ); - } + return select( selector.replace( rtrim, "$1" ), context, results, seed ); +} - return results; -}; +/** + * Create key-value caches of limited size + * @returns {Function(string, Object)} Returns the Object data after storing it on itself with + * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) + * deleting the oldest entry + */ +function createCache() { + var keys = []; -Sizzle.uniqueSort = function( results ) { - if ( sortOrder ) { - hasDuplicate = baseHasDuplicate; - results.sort( sortOrder ); - - if ( hasDuplicate ) { - for ( var i = 1; i < results.length; i++ ) { - if ( results[i] === results[ i - 1 ] ) { - results.splice( i--, 1 ); - } - } + function cache( key, value ) { + if ( keys.push( key + " " ) > Expr.cacheLength ) { + delete cache[ keys.shift() ]; } + return (cache[ key + " " ] = value); } + return cache; +} - return results; -}; - -Sizzle.matches = function( expr, set ) { - return Sizzle( expr, null, null, set ); -}; - -Sizzle.matchesSelector = function( node, expr ) { - return Sizzle( expr, null, null, [node] ).length > 0; -}; +/** + * Mark a function for special use by Sizzle + * @param {Function} fn The function to mark + */ +function markFunction( fn ) { + fn[ expando ] = true; + return fn; +} -Sizzle.find = function( expr, context, isXML ) { - var set; +/** + * Support testing using an element + * @param {Function} fn Passed the created div and expects a boolean result + */ +function assert( fn ) { + var div = document.createElement("div"); - if ( !expr ) { - return []; + try { + return !!fn( div ); + } catch (e) { + return false; + } finally { + if ( div.parentNode ) { + div.parentNode.removeChild( div ); + } + div = null; } +} - for ( var i = 0, l = Expr.order.length; i < l; i++ ) { - var match, - type = Expr.order[i]; +/** + * Adds the same handler for all of the specified attrs + * @param {String} attrs Pipe-separated list of attributes + * @param {Function} handler The method that will be applied + */ +function addHandle( attrs, handler ) { + var arr = attrs.split("|"), + i = attrs.length; - if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { - var left = match[1]; - match.splice( 1, 1 ); + while ( i-- ) { + Expr.attrHandle[ arr[i] ] = handler; + } +} - if ( left.substr( left.length - 1 ) !== "\\" ) { - match[1] = (match[1] || "").replace( rBackslash, "" ); - set = Expr.find[ type ]( match, context, isXML ); +/** + * Checks document order of two siblings + * @param {Element} a + * @param {Element} b + * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b + */ +function siblingCheck( a, b ) { + var cur = b && a, + diff = cur && a.nodeType === 1 && b.nodeType === 1 && + ( ~b.sourceIndex || MAX_NEGATIVE ) - + ( ~a.sourceIndex || MAX_NEGATIVE ); + + if ( diff ) { + return diff; + } - if ( set != null ) { - expr = expr.replace( Expr.match[ type ], "" ); - break; - } + if ( cur ) { + while ( (cur = cur.nextSibling) ) { + if ( cur === b ) { + return -1; } } } - if ( !set ) { - set = typeof context.getElementsByTagName !== "undefined" ? - context.getElementsByTagName( "*" ) : - []; - } + return a ? 1 : -1; +} - return { set: set, expr: expr }; -}; +/** + * Returns a function to use in pseudos for input types + * @param {String} type + */ +function createInputPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for buttons + * @param {String} type + */ +function createButtonPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && elem.type === type; + }; +} -Sizzle.filter = function( expr, set, inplace, not ) { - var match, anyFound, - old = expr, - result = [], - curLoop = set, - isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); +/** + * Returns a function to use in pseudos for positionals + * @param {Function} fn + */ +function createPositionalPseudo( fn ) { + return markFunction(function( argument ) { + argument = +argument; + return markFunction(function( seed, matches ) { + var j, + matchIndexes = fn( [], seed.length, argument ), + i = matchIndexes.length; + + while ( i-- ) { + if ( seed[ (j = matchIndexes[i]) ] ) { + seed[j] = !(matches[j] = seed[j]); + } + } + }); + }); +} - while ( expr && set.length ) { - for ( var type in Expr.filter ) { - if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { - var found, item, - filter = Expr.filter[ type ], - left = match[1]; +/** + * Checks a node for validity as a Sizzle context + * @param {Element|Object=} context + * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value + */ +function testContext( context ) { + return context && typeof context.getElementsByTagName !== strundefined && context; +} - anyFound = false; +support = Sizzle.support = {}; - match.splice(1,1); +/** + * Detects XML nodes + * @param {Element|Object} elem An element or a document + * @returns {Boolean} True iff elem is a non-HTML XML node + */ +isXML = Sizzle.isXML = function( elem ) { + var documentElement = elem && (elem.ownerDocument || elem).documentElement; + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; - if ( left.substr( left.length - 1 ) === "\\" ) { - continue; - } +/** + * Sets document-related variables once based on the current document + * @param {Element|Object} [doc] An element or document object to use to set the document + * @returns {Object} Returns the current document + */ +setDocument = Sizzle.setDocument = function( node ) { + var hasCompare, + doc = node ? node.ownerDocument || node : preferredDoc, + parent = doc.defaultView; - if ( curLoop === result ) { - result = []; - } + if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { + return document; + } - if ( Expr.preFilter[ type ] ) { - match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); + document = doc; + docElem = doc.documentElement; - if ( !match ) { - anyFound = found = true; + documentIsHTML = !isXML( doc ); - } else if ( match === true ) { - continue; - } - } + if ( parent && parent !== parent.top ) { + if ( parent.addEventListener ) { + parent.addEventListener( "unload", function() { + setDocument(); + }, false ); + } else if ( parent.attachEvent ) { + parent.attachEvent( "onunload", function() { + setDocument(); + }); + } + } - if ( match ) { - for ( var i = 0; (item = curLoop[i]) != null; i++ ) { - if ( item ) { - found = filter( item, match, i, curLoop ); - var pass = not ^ !!found; + /* Attributes + ---------------------------------------------------------------------- */ - if ( inplace && found != null ) { - if ( pass ) { - anyFound = true; + support.attributes = assert(function( div ) { + div.className = "i"; + return !div.getAttribute("className"); + }); - } else { - curLoop[i] = false; - } + /* getElement(s)By* + ---------------------------------------------------------------------- */ - } else if ( pass ) { - result.push( item ); - anyFound = true; - } - } - } - } + support.getElementsByTagName = assert(function( div ) { + div.appendChild( doc.createComment("") ); + return !div.getElementsByTagName("*").length; + }); - if ( found !== undefined ) { - if ( !inplace ) { - curLoop = result; - } + support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) { + div.innerHTML = "
"; - expr = expr.replace( Expr.match[ type ], "" ); + div.firstChild.className = "i"; + return div.getElementsByClassName("i").length === 2; + }); - if ( !anyFound ) { - return []; - } + support.getById = assert(function( div ) { + docElem.appendChild( div ).id = expando; + return !doc.getElementsByName || !doc.getElementsByName( expando ).length; + }); - break; - } + if ( support.getById ) { + Expr.find["ID"] = function( id, context ) { + if ( typeof context.getElementById !== strundefined && documentIsHTML ) { + var m = context.getElementById( id ); + return m && m.parentNode ? [m] : []; } - } - - if ( expr === old ) { - if ( anyFound == null ) { - Sizzle.error( expr ); + }; + Expr.filter["ID"] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + return elem.getAttribute("id") === attrId; + }; + }; + } else { + delete Expr.find["ID"]; + + Expr.filter["ID"] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); + return node && node.value === attrId; + }; + }; + } - } else { - break; + Expr.find["TAG"] = support.getElementsByTagName ? + function( tag, context ) { + if ( typeof context.getElementsByTagName !== strundefined ) { + return context.getElementsByTagName( tag ); } - } + } : + function( tag, context ) { + var elem, + tmp = [], + i = 0, + results = context.getElementsByTagName( tag ); - old = expr; - } + if ( tag === "*" ) { + while ( (elem = results[i++]) ) { + if ( elem.nodeType === 1 ) { + tmp.push( elem ); + } + } - return curLoop; -}; + return tmp; + } + return results; + }; -Sizzle.error = function( msg ) { - throw "Syntax error, unrecognized expression: " + msg; -}; + Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { + if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) { + return context.getElementsByClassName( className ); + } + }; -var Expr = Sizzle.selectors = { - order: [ "ID", "NAME", "TAG" ], - - match: { - ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, - NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, - ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, - TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, - CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, - POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, - PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ - }, + /* QSA/matchesSelector + ---------------------------------------------------------------------- */ - leftMatch: {}, - attrMap: { - "class": "className", - "for": "htmlFor" - }, + rbuggyMatches = []; - attrHandle: { - href: function( elem ) { - return elem.getAttribute( "href" ); - }, - type: function( elem ) { - return elem.getAttribute( "type" ); - } - }, + rbuggyQSA = []; - relative: { - "+": function(checkSet, part){ - var isPartStr = typeof part === "string", - isTag = isPartStr && !rNonWord.test( part ), - isPartStrNotTag = isPartStr && !isTag; + if ( (support.qsa = rnative.test( doc.querySelectorAll )) ) { + assert(function( div ) { + div.innerHTML = ""; - if ( isTag ) { - part = part.toLowerCase(); + if ( div.querySelectorAll("[t^='']").length ) { + rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); } - for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { - if ( (elem = checkSet[i]) ) { - while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} + if ( !div.querySelectorAll("[selected]").length ) { + rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); + } - checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? - elem || false : - elem === part; - } + if ( !div.querySelectorAll(":checked").length ) { + rbuggyQSA.push(":checked"); } + }); + + assert(function( div ) { + var input = doc.createElement("input"); + input.setAttribute( "type", "hidden" ); + div.appendChild( input ).setAttribute( "name", "D" ); - if ( isPartStrNotTag ) { - Sizzle.filter( part, checkSet, true ); + if ( div.querySelectorAll("[name=d]").length ) { + rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); } - }, - ">": function( checkSet, part ) { - var elem, - isPartStr = typeof part === "string", - i = 0, - l = checkSet.length; + if ( !div.querySelectorAll(":enabled").length ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } - if ( isPartStr && !rNonWord.test( part ) ) { - part = part.toLowerCase(); + div.querySelectorAll("*,:x"); + rbuggyQSA.push(",.*:"); + }); + } - for ( ; i < l; i++ ) { - elem = checkSet[i]; + if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector || + docElem.mozMatchesSelector || + docElem.oMatchesSelector || + docElem.msMatchesSelector) )) ) { - if ( elem ) { - var parent = elem.parentNode; - checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; - } - } + assert(function( div ) { + support.disconnectedMatch = matches.call( div, "div" ); - } else { - for ( ; i < l; i++ ) { - elem = checkSet[i]; + matches.call( div, "[s!='']:x" ); + rbuggyMatches.push( "!=", pseudos ); + }); + } - if ( elem ) { - checkSet[i] = isPartStr ? - elem.parentNode : - elem.parentNode === part; + rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") ); + rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") ); + + /* Contains + ---------------------------------------------------------------------- */ + hasCompare = rnative.test( docElem.compareDocumentPosition ); + + contains = hasCompare || rnative.test( docElem.contains ) ? + function( a, b ) { + var adown = a.nodeType === 9 ? a.documentElement : a, + bup = b && b.parentNode; + return a === bup || !!( bup && bup.nodeType === 1 && ( + adown.contains ? + adown.contains( bup ) : + a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 + )); + } : + function( a, b ) { + if ( b ) { + while ( (b = b.parentNode) ) { + if ( b === a ) { + return true; } } - - if ( isPartStr ) { - Sizzle.filter( part, checkSet, true ); - } } - }, + return false; + }; - "": function(checkSet, part, isXML){ - var nodeCheck, - doneName = done++, - checkFn = dirCheck; + /* Sorting + ---------------------------------------------------------------------- */ - if ( typeof part === "string" && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; - } + sortOrder = hasCompare ? + function( a, b ) { - checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); - }, + if ( a === b ) { + hasDuplicate = true; + return 0; + } - "~": function( checkSet, part, isXML ) { - var nodeCheck, - doneName = done++, - checkFn = dirCheck; + var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; + if ( compare ) { + return compare; + } - if ( typeof part === "string" && !rNonWord.test( part ) ) { - part = part.toLowerCase(); - nodeCheck = part; - checkFn = dirNodeCheck; - } + compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ? + a.compareDocumentPosition( b ) : - checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); - } - }, + 1; - find: { - ID: function( match, context, isXML ) { - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); - return m && m.parentNode ? [m] : []; + if ( compare & 1 || + (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) { + + if ( a === doc || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) { + return -1; + } + if ( b === doc || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) { + return 1; } - }, - NAME: function( match, context ) { - if ( typeof context.getElementsByName !== "undefined" ) { - var ret = [], - results = context.getElementsByName( match[1] ); + return sortInput ? + ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : + 0; + } - for ( var i = 0, l = results.length; i < l; i++ ) { - if ( results[i].getAttribute("name") === match[1] ) { - ret.push( results[i] ); - } - } + return compare & 4 ? -1 : 1; + } : + function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + return 0; + } - return ret.length === 0 ? null : ret; - } - }, + var cur, + i = 0, + aup = a.parentNode, + bup = b.parentNode, + ap = [ a ], + bp = [ b ]; + + if ( !aup || !bup ) { + return a === doc ? -1 : + b === doc ? 1 : + aup ? -1 : + bup ? 1 : + sortInput ? + ( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : + 0; + + } else if ( aup === bup ) { + return siblingCheck( a, b ); + } - TAG: function( match, context ) { - if ( typeof context.getElementsByTagName !== "undefined" ) { - return context.getElementsByTagName( match[1] ); - } + cur = a; + while ( (cur = cur.parentNode) ) { + ap.unshift( cur ); + } + cur = b; + while ( (cur = cur.parentNode) ) { + bp.unshift( cur ); } - }, - preFilter: { - CLASS: function( match, curLoop, inplace, result, not, isXML ) { - match = " " + match[1].replace( rBackslash, "" ) + " "; - if ( isXML ) { - return match; - } + while ( ap[i] === bp[i] ) { + i++; + } - for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { - if ( elem ) { - if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { - if ( !inplace ) { - result.push( elem ); - } + return i ? + siblingCheck( ap[i], bp[i] ) : - } else if ( inplace ) { - curLoop[i] = false; - } - } - } + ap[i] === preferredDoc ? -1 : + bp[i] === preferredDoc ? 1 : + 0; + }; - return false; - }, + return doc; +}; - ID: function( match ) { - return match[1].replace( rBackslash, "" ); - }, +Sizzle.matches = function( expr, elements ) { + return Sizzle( expr, null, null, elements ); +}; - TAG: function( match, curLoop ) { - return match[1].replace( rBackslash, "" ).toLowerCase(); - }, +Sizzle.matchesSelector = function( elem, expr ) { + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } - CHILD: function( match ) { - if ( match[1] === "nth" ) { - if ( !match[2] ) { - Sizzle.error( match[0] ); - } + expr = expr.replace( rattributeQuotes, "='$1']" ); - match[2] = match[2].replace(/^\+|\s*/g, ''); + if ( support.matchesSelector && documentIsHTML && + ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && + ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { - var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( - match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || - !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); + try { + var ret = matches.call( elem, expr ); - match[2] = (test[1] + (test[2] || 1)) - 0; - match[3] = test[3] - 0; - } - else if ( match[2] ) { - Sizzle.error( match[0] ); + if ( ret || support.disconnectedMatch || + elem.document && elem.document.nodeType !== 11 ) { + return ret; } + } catch(e) {} + } - match[0] = done++; + return Sizzle( expr, document, null, [elem] ).length > 0; +}; - return match; - }, +Sizzle.contains = function( context, elem ) { + if ( ( context.ownerDocument || context ) !== document ) { + setDocument( context ); + } + return contains( context, elem ); +}; - ATTR: function( match, curLoop, inplace, result, not, isXML ) { - var name = match[1] = match[1].replace( rBackslash, "" ); +Sizzle.attr = function( elem, name ) { + if ( ( elem.ownerDocument || elem ) !== document ) { + setDocument( elem ); + } - if ( !isXML && Expr.attrMap[name] ) { - match[1] = Expr.attrMap[name]; - } + var fn = Expr.attrHandle[ name.toLowerCase() ], + val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? + fn( elem, name, !documentIsHTML ) : + undefined; + + return val !== undefined ? + val : + support.attributes || !documentIsHTML ? + elem.getAttribute( name ) : + (val = elem.getAttributeNode(name)) && val.specified ? + val.value : + null; +}; - match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; - if ( match[2] === "~=" ) { - match[4] = " " + match[4] + " "; +/** + * Document sorting and removing duplicates + * @param {ArrayLike} results + */ +Sizzle.uniqueSort = function( results ) { + var elem, + duplicates = [], + j = 0, + i = 0; + + hasDuplicate = !support.detectDuplicates; + sortInput = !support.sortStable && results.slice( 0 ); + results.sort( sortOrder ); + + if ( hasDuplicate ) { + while ( (elem = results[i++]) ) { + if ( elem === results[ i ] ) { + j = duplicates.push( i ); } + } + while ( j-- ) { + results.splice( duplicates[ j ], 1 ); + } + } - return match; - }, - - PSEUDO: function( match, curLoop, inplace, result, not ) { - if ( match[1] === "not" ) { - if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { - match[3] = Sizzle(match[3], null, null, curLoop); - - } else { - var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); - - if ( !inplace ) { - result.push.apply( result, ret ); - } + sortInput = null; - return false; - } + return results; +}; - } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { - return true; +/** + * Utility function for retrieving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +getText = Sizzle.getText = function( elem ) { + var node, + ret = "", + i = 0, + nodeType = elem.nodeType; + + if ( !nodeType ) { + while ( (node = elem[i++]) ) { + ret += getText( node ); + } + } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + if ( typeof elem.textContent === "string" ) { + return elem.textContent; + } else { + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + ret += getText( elem ); } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } - return match; - }, + return ret; +}; - POS: function( match ) { - match.unshift( true ); +Expr = Sizzle.selectors = { - return match; - } - }, + cacheLength: 50, - filters: { - enabled: function( elem ) { - return elem.disabled === false && elem.type !== "hidden"; - }, + createPseudo: markFunction, - disabled: function( elem ) { - return elem.disabled === true; - }, + match: matchExpr, - checked: function( elem ) { - return elem.checked === true; - }, + attrHandle: {}, - selected: function( elem ) { - if ( elem.parentNode ) { - elem.parentNode.selectedIndex; - } - - return elem.selected === true; - }, + find: {}, - parent: function( elem ) { - return !!elem.firstChild; - }, + relative: { + ">": { dir: "parentNode", first: true }, + " ": { dir: "parentNode" }, + "+": { dir: "previousSibling", first: true }, + "~": { dir: "previousSibling" } + }, - empty: function( elem ) { - return !elem.firstChild; - }, + preFilter: { + "ATTR": function( match ) { + match[1] = match[1].replace( runescape, funescape ); - has: function( elem, i, match ) { - return !!Sizzle( match[3], elem ).length; - }, + match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape ); - header: function( elem ) { - return (/h\d/i).test( elem.nodeName ); - }, + if ( match[2] === "~=" ) { + match[3] = " " + match[3] + " "; + } - text: function( elem ) { - var attr = elem.getAttribute( "type" ), type = elem.type; - return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); + return match.slice( 0, 4 ); }, - radio: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; - }, + "CHILD": function( match ) { + /* matches from matchExpr["CHILD"] + 1 type (only|nth|...) + 2 what (child|of-type) + 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) + 4 xn-component of xn+y argument ([+-]?\d*n|) + 5 sign of xn-component + 6 x of xn-component + 7 sign of y-component + 8 y of y-component + */ + match[1] = match[1].toLowerCase(); + + if ( match[1].slice( 0, 3 ) === "nth" ) { + if ( !match[3] ) { + Sizzle.error( match[0] ); + } - checkbox: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; - }, + match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) ); + match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" ); - file: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; - }, + } else if ( match[3] ) { + Sizzle.error( match[0] ); + } - password: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; + return match; }, - submit: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && "submit" === elem.type; - }, + "PSEUDO": function( match ) { + var excess, + unquoted = !match[5] && match[2]; - image: function( elem ) { - return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; - }, + if ( matchExpr["CHILD"].test( match[0] ) ) { + return null; + } - reset: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return (name === "input" || name === "button") && "reset" === elem.type; - }, + if ( match[3] && match[4] !== undefined ) { + match[2] = match[4]; - button: function( elem ) { - var name = elem.nodeName.toLowerCase(); - return name === "input" && "button" === elem.type || name === "button"; - }, + } else if ( unquoted && rpseudo.test( unquoted ) && + (excess = tokenize( unquoted, true )) && + (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) { - input: function( elem ) { - return (/input|select|textarea|button/i).test( elem.nodeName ); - }, + match[0] = match[0].slice( 0, excess ); + match[2] = unquoted.slice( 0, excess ); + } - focus: function( elem ) { - return elem === elem.ownerDocument.activeElement; + return match.slice( 0, 3 ); } }, - setFilters: { - first: function( elem, i ) { - return i === 0; - }, - - last: function( elem, i, match, array ) { - return i === array.length - 1; - }, - - even: function( elem, i ) { - return i % 2 === 0; - }, - odd: function( elem, i ) { - return i % 2 === 1; - }, + filter: { - lt: function( elem, i, match ) { - return i < match[3] - 0; + "TAG": function( nodeNameSelector ) { + var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); + return nodeNameSelector === "*" ? + function() { return true; } : + function( elem ) { + return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; + }; }, - gt: function( elem, i, match ) { - return i > match[3] - 0; - }, + "CLASS": function( className ) { + var pattern = classCache[ className + " " ]; - nth: function( elem, i, match ) { - return match[3] - 0 === i; + return pattern || + (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && + classCache( className, function( elem ) { + return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" ); + }); }, - eq: function( elem, i, match ) { - return match[3] - 0 === i; - } - }, - filter: { - PSEUDO: function( elem, match, i, array ) { - var name = match[1], - filter = Expr.filters[ name ]; + "ATTR": function( name, operator, check ) { + return function( elem ) { + var result = Sizzle.attr( elem, name ); - if ( filter ) { - return filter( elem, i, match, array ); - - } else if ( name === "contains" ) { - return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0; - - } else if ( name === "not" ) { - var not = match[3]; - - for ( var j = 0, l = not.length; j < l; j++ ) { - if ( not[j] === elem ) { - return false; - } + if ( result == null ) { + return operator === "!="; + } + if ( !operator ) { + return true; } - return true; - - } else { - Sizzle.error( name ); - } + result += ""; + + return operator === "=" ? result === check : + operator === "!=" ? result !== check : + operator === "^=" ? check && result.indexOf( check ) === 0 : + operator === "*=" ? check && result.indexOf( check ) > -1 : + operator === "$=" ? check && result.slice( -check.length ) === check : + operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : + operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : + false; + }; }, - CHILD: function( elem, match ) { - var type = match[1], - node = elem; - - switch ( type ) { - case "only": - case "first": - while ( (node = node.previousSibling) ) { - if ( node.nodeType === 1 ) { - return false; + "CHILD": function( type, what, argument, first, last ) { + var simple = type.slice( 0, 3 ) !== "nth", + forward = type.slice( -4 ) !== "last", + ofType = what === "of-type"; + + return first === 1 && last === 0 ? + + function( elem ) { + return !!elem.parentNode; + } : + + function( elem, context, xml ) { + var cache, outerCache, node, diff, nodeIndex, start, + dir = simple !== forward ? "nextSibling" : "previousSibling", + parent = elem.parentNode, + name = ofType && elem.nodeName.toLowerCase(), + useCache = !xml && !ofType; + + if ( parent ) { + + if ( simple ) { + while ( dir ) { + node = elem; + while ( (node = node[ dir ]) ) { + if ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) { + return false; + } + } + start = dir = type === "only" && !start && "nextSibling"; + } + return true; } - } - if ( type === "first" ) { - return true; - } + start = [ forward ? parent.firstChild : parent.lastChild ]; - node = elem; + if ( forward && useCache ) { + outerCache = parent[ expando ] || (parent[ expando ] = {}); + cache = outerCache[ type ] || []; + nodeIndex = cache[0] === dirruns && cache[1]; + diff = cache[0] === dirruns && cache[2]; + node = nodeIndex && parent.childNodes[ nodeIndex ]; - case "last": - while ( (node = node.nextSibling) ) { - if ( node.nodeType === 1 ) { - return false; - } - } + while ( (node = ++nodeIndex && node && node[ dir ] || - return true; + (diff = nodeIndex = 0) || start.pop()) ) { - case "nth": - var first = match[2], - last = match[3]; + if ( node.nodeType === 1 && ++diff && node === elem ) { + outerCache[ type ] = [ dirruns, nodeIndex, diff ]; + break; + } + } - if ( first === 1 && last === 0 ) { - return true; - } + } else if ( useCache && (cache = (elem[ expando ] || (elem[ expando ] = {}))[ type ]) && cache[0] === dirruns ) { + diff = cache[1]; - var doneName = match[0], - parent = elem.parentNode; + } else { + while ( (node = ++nodeIndex && node && node[ dir ] || + (diff = nodeIndex = 0) || start.pop()) ) { - if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { - var count = 0; + if ( ( ofType ? node.nodeName.toLowerCase() === name : node.nodeType === 1 ) && ++diff ) { + if ( useCache ) { + (node[ expando ] || (node[ expando ] = {}))[ type ] = [ dirruns, diff ]; + } - for ( node = parent.firstChild; node; node = node.nextSibling ) { - if ( node.nodeType === 1 ) { - node.nodeIndex = ++count; + if ( node === elem ) { + break; + } + } } } - parent.sizcache = doneName; + diff -= last; + return diff === first || ( diff % first === 0 && diff / first >= 0 ); } + }; + }, - var diff = elem.nodeIndex - last; + "PSEUDO": function( pseudo, argument ) { + var args, + fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || + Sizzle.error( "unsupported pseudo: " + pseudo ); - if ( first === 0 ) { - return diff === 0; + if ( fn[ expando ] ) { + return fn( argument ); + } - } else { - return ( diff % first === 0 && diff / first >= 0 ); + if ( fn.length > 1 ) { + args = [ pseudo, pseudo, "", argument ]; + return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? + markFunction(function( seed, matches ) { + var idx, + matched = fn( seed, argument ), + i = matched.length; + while ( i-- ) { + idx = indexOf.call( seed, matched[i] ); + seed[ idx ] = !( matches[ idx ] = matched[i] ); + } + }) : + function( elem ) { + return fn( elem, 0, args ); + }; + } + + return fn; + } + }, + + pseudos: { + "not": markFunction(function( selector ) { + var input = [], + results = [], + matcher = compile( selector.replace( rtrim, "$1" ) ); + + return matcher[ expando ] ? + markFunction(function( seed, matches, context, xml ) { + var elem, + unmatched = matcher( seed, null, xml, [] ), + i = seed.length; + + while ( i-- ) { + if ( (elem = unmatched[i]) ) { + seed[i] = !(matches[i] = elem); + } } + }) : + function( elem, context, xml ) { + input[0] = elem; + matcher( input, null, xml, results ); + return !results.pop(); + }; + }), + + "has": markFunction(function( selector ) { + return function( elem ) { + return Sizzle( selector, elem ).length > 0; + }; + }), + + "contains": markFunction(function( text ) { + return function( elem ) { + return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; + }; + }), + + "lang": markFunction( function( lang ) { + if ( !ridentifier.test(lang || "") ) { + Sizzle.error( "unsupported lang: " + lang ); } + lang = lang.replace( runescape, funescape ).toLowerCase(); + return function( elem ) { + var elemLang; + do { + if ( (elemLang = documentIsHTML ? + elem.lang : + elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) { + + elemLang = elemLang.toLowerCase(); + return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; + } + } while ( (elem = elem.parentNode) && elem.nodeType === 1 ); + return false; + }; + }), + + "target": function( elem ) { + var hash = window.location && window.location.hash; + return hash && hash.slice( 1 ) === elem.id; }, - ID: function( elem, match ) { - return elem.nodeType === 1 && elem.getAttribute("id") === match; + "root": function( elem ) { + return elem === docElem; }, - TAG: function( elem, match ) { - return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; + "focus": function( elem ) { + return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex); }, - CLASS: function( elem, match ) { - return (" " + (elem.className || elem.getAttribute("class")) + " ") - .indexOf( match ) > -1; + "enabled": function( elem ) { + return elem.disabled === false; }, - ATTR: function( elem, match ) { - var name = match[1], - result = Expr.attrHandle[ name ] ? - Expr.attrHandle[ name ]( elem ) : - elem[ name ] != null ? - elem[ name ] : - elem.getAttribute( name ), - value = result + "", - type = match[2], - check = match[4]; - - return result == null ? - type === "!=" : - type === "=" ? - value === check : - type === "*=" ? - value.indexOf(check) >= 0 : - type === "~=" ? - (" " + value + " ").indexOf(check) >= 0 : - !check ? - value && result !== false : - type === "!=" ? - value !== check : - type === "^=" ? - value.indexOf(check) === 0 : - type === "$=" ? - value.substr(value.length - check.length) === check : - type === "|=" ? - value === check || value.substr(0, check.length + 1) === check + "-" : - false; + "disabled": function( elem ) { + return elem.disabled === true; }, - POS: function( elem, match, i, array ) { - var name = match[2], - filter = Expr.setFilters[ name ]; + "checked": function( elem ) { + var nodeName = elem.nodeName.toLowerCase(); + return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected); + }, - if ( filter ) { - return filter( elem, i, match, array ); + "selected": function( elem ) { + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; } - } - } -}; - -var origPOS = Expr.match.POS, - fescape = function(all, num){ - return "\\" + (num - 0 + 1); - }; -for ( var type in Expr.match ) { - Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); - Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); -} + return elem.selected === true; + }, -var makeArray = function( array, results ) { - array = Array.prototype.slice.call( array, 0 ); + "empty": function( elem ) { + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + if ( elem.nodeType < 6 ) { + return false; + } + } + return true; + }, - if ( results ) { - results.push.apply( results, array ); - return results; - } + "parent": function( elem ) { + return !Expr.pseudos["empty"]( elem ); + }, - return array; -}; + "header": function( elem ) { + return rheader.test( elem.nodeName ); + }, -try { - Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; + "input": function( elem ) { + return rinputs.test( elem.nodeName ); + }, -} catch( e ) { - makeArray = function( array, results ) { - var i = 0, - ret = results || []; + "button": function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === "button" || name === "button"; + }, - if ( toString.call(array) === "[object Array]" ) { - Array.prototype.push.apply( ret, array ); + "text": function( elem ) { + var attr; + return elem.nodeName.toLowerCase() === "input" && + elem.type === "text" && - } else { - if ( typeof array.length === "number" ) { - for ( var l = array.length; i < l; i++ ) { - ret.push( array[i] ); - } + ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" ); + }, - } else { - for ( ; array[i]; i++ ) { - ret.push( array[i] ); - } - } - } + "first": createPositionalPseudo(function() { + return [ 0 ]; + }), - return ret; - }; -} + "last": createPositionalPseudo(function( matchIndexes, length ) { + return [ length - 1 ]; + }), -var sortOrder, siblingCheck; + "eq": createPositionalPseudo(function( matchIndexes, length, argument ) { + return [ argument < 0 ? argument + length : argument ]; + }), -if ( document.documentElement.compareDocumentPosition ) { - sortOrder = function( a, b ) { - if ( a === b ) { - hasDuplicate = true; - return 0; - } + "even": createPositionalPseudo(function( matchIndexes, length ) { + var i = 0; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), - if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { - return a.compareDocumentPosition ? -1 : 1; - } + "odd": createPositionalPseudo(function( matchIndexes, length ) { + var i = 1; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), - return a.compareDocumentPosition(b) & 4 ? -1 : 1; - }; + "lt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; --i >= 0; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }), -} else { - sortOrder = function( a, b ) { - if ( a === b ) { - hasDuplicate = true; - return 0; + "gt": createPositionalPseudo(function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; ++i < length; ) { + matchIndexes.push( i ); + } + return matchIndexes; + }) + } +}; - } else if ( a.sourceIndex && b.sourceIndex ) { - return a.sourceIndex - b.sourceIndex; - } +Expr.pseudos["nth"] = Expr.pseudos["eq"]; - var al, bl, - ap = [], - bp = [], - aup = a.parentNode, - bup = b.parentNode, - cur = aup; +for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { + Expr.pseudos[ i ] = createInputPseudo( i ); +} +for ( i in { submit: true, reset: true } ) { + Expr.pseudos[ i ] = createButtonPseudo( i ); +} - if ( aup === bup ) { - return siblingCheck( a, b ); +function setFilters() {} +setFilters.prototype = Expr.filters = Expr.pseudos; +Expr.setFilters = new setFilters(); - } else if ( !aup ) { - return -1; +function tokenize( selector, parseOnly ) { + var matched, match, tokens, type, + soFar, groups, preFilters, + cached = tokenCache[ selector + " " ]; - } else if ( !bup ) { - return 1; - } + if ( cached ) { + return parseOnly ? 0 : cached.slice( 0 ); + } - while ( cur ) { - ap.unshift( cur ); - cur = cur.parentNode; - } + soFar = selector; + groups = []; + preFilters = Expr.preFilter; - cur = bup; + while ( soFar ) { - while ( cur ) { - bp.unshift( cur ); - cur = cur.parentNode; - } - - al = ap.length; - bl = bp.length; - - for ( var i = 0; i < al && i < bl; i++ ) { - if ( ap[i] !== bp[i] ) { - return siblingCheck( ap[i], bp[i] ); + if ( !matched || (match = rcomma.exec( soFar )) ) { + if ( match ) { + soFar = soFar.slice( match[0].length ) || soFar; } + groups.push( (tokens = []) ); } - return i === al ? - siblingCheck( a, bp[i], -1 ) : - siblingCheck( ap[i], b, 1 ); - }; + matched = false; - siblingCheck = function( a, b, ret ) { - if ( a === b ) { - return ret; + if ( (match = rcombinators.exec( soFar )) ) { + matched = match.shift(); + tokens.push({ + value: matched, + type: match[0].replace( rtrim, " " ) + }); + soFar = soFar.slice( matched.length ); } - var cur = a.nextSibling; - - while ( cur ) { - if ( cur === b ) { - return -1; + for ( type in Expr.filter ) { + if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] || + (match = preFilters[ type ]( match ))) ) { + matched = match.shift(); + tokens.push({ + value: matched, + type: type, + matches: match + }); + soFar = soFar.slice( matched.length ); } + } - cur = cur.nextSibling; + if ( !matched ) { + break; } + } - return 1; - }; + return parseOnly ? + soFar.length : + soFar ? + Sizzle.error( selector ) : + tokenCache( selector, groups ).slice( 0 ); } -Sizzle.getText = function( elems ) { - var ret = "", elem; - - for ( var i = 0; elems[i]; i++ ) { - elem = elems[i]; - - if ( elem.nodeType === 3 || elem.nodeType === 4 ) { - ret += elem.nodeValue; - - } else if ( elem.nodeType !== 8 ) { - ret += Sizzle.getText( elem.childNodes ); - } +function toSelector( tokens ) { + var i = 0, + len = tokens.length, + selector = ""; + for ( ; i < len; i++ ) { + selector += tokens[i].value; } + return selector; +} - return ret; -}; +function addCombinator( matcher, combinator, base ) { + var dir = combinator.dir, + checkNonElements = base && dir === "parentNode", + doneName = done++; -(function(){ - var form = document.createElement("div"), - id = "script" + (new Date()).getTime(), - root = document.documentElement; + return combinator.first ? + function( elem, context, xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + return matcher( elem, context, xml ); + } + } + } : - form.innerHTML = ""; + function( elem, context, xml ) { + var oldCache, outerCache, + newCache = [ dirruns, doneName ]; - root.insertBefore( form, root.firstChild ); + if ( xml ) { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + if ( matcher( elem, context, xml ) ) { + return true; + } + } + } + } else { + while ( (elem = elem[ dir ]) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + outerCache = elem[ expando ] || (elem[ expando ] = {}); + if ( (oldCache = outerCache[ dir ]) && + oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { - if ( document.getElementById( id ) ) { - Expr.find.ID = function( match, context, isXML ) { - if ( typeof context.getElementById !== "undefined" && !isXML ) { - var m = context.getElementById(match[1]); + return (newCache[ 2 ] = oldCache[ 2 ]); + } else { + outerCache[ dir ] = newCache; - return m ? - m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? - [m] : - undefined : - []; + if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) { + return true; + } + } + } + } } }; +} - Expr.filter.ID = function( elem, match ) { - var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); +function elementMatcher( matchers ) { + return matchers.length > 1 ? + function( elem, context, xml ) { + var i = matchers.length; + while ( i-- ) { + if ( !matchers[i]( elem, context, xml ) ) { + return false; + } + } + return true; + } : + matchers[0]; +} - return elem.nodeType === 1 && node && node.nodeValue === match; - }; +function multipleContexts( selector, contexts, results ) { + var i = 0, + len = contexts.length; + for ( ; i < len; i++ ) { + Sizzle( selector, contexts[i], results ); } + return results; +} - root.removeChild( form ); - - root = form = null; -})(); - -(function(){ - - var div = document.createElement("div"); - div.appendChild( document.createComment("") ); - - if ( div.getElementsByTagName("*").length > 0 ) { - Expr.find.TAG = function( match, context ) { - var results = context.getElementsByTagName( match[1] ); - - if ( match[1] === "*" ) { - var tmp = []; - - for ( var i = 0; results[i]; i++ ) { - if ( results[i].nodeType === 1 ) { - tmp.push( results[i] ); - } +function condense( unmatched, map, filter, context, xml ) { + var elem, + newUnmatched = [], + i = 0, + len = unmatched.length, + mapped = map != null; + + for ( ; i < len; i++ ) { + if ( (elem = unmatched[i]) ) { + if ( !filter || filter( elem, context, xml ) ) { + newUnmatched.push( elem ); + if ( mapped ) { + map.push( i ); } - - results = tmp; } - - return results; - }; + } } - div.innerHTML = ""; - - if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && - div.firstChild.getAttribute("href") !== "#" ) { + return newUnmatched; +} - Expr.attrHandle.href = function( elem ) { - return elem.getAttribute( "href", 2 ); - }; +function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { + if ( postFilter && !postFilter[ expando ] ) { + postFilter = setMatcher( postFilter ); } + if ( postFinder && !postFinder[ expando ] ) { + postFinder = setMatcher( postFinder, postSelector ); + } + return markFunction(function( seed, results, context, xml ) { + var temp, i, elem, + preMap = [], + postMap = [], + preexisting = results.length, - div = null; -})(); + elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ), -if ( document.querySelectorAll ) { - (function(){ - var oldSizzle = Sizzle, - div = document.createElement("div"), - id = "__sizzle__"; + matcherIn = preFilter && ( seed || !selector ) ? + condense( elems, preMap, preFilter, context, xml ) : + elems, - div.innerHTML = ""; + matcherOut = matcher ? + postFinder || ( seed ? preFilter : preexisting || postFilter ) ? - if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { - return; - } + [] : - Sizzle = function( query, context, extra, seed ) { - context = context || document; + results : + matcherIn; - if ( !seed && !Sizzle.isXML(context) ) { - var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); + if ( matcher ) { + matcher( matcherIn, matcherOut, context, xml ); + } - if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { - if ( match[1] ) { - return makeArray( context.getElementsByTagName( query ), extra ); + if ( postFilter ) { + temp = condense( matcherOut, postMap ); + postFilter( temp, [], context, xml ); - } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { - return makeArray( context.getElementsByClassName( match[2] ), extra ); - } + i = temp.length; + while ( i-- ) { + if ( (elem = temp[i]) ) { + matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem); } + } + } - if ( context.nodeType === 9 ) { - if ( query === "body" && context.body ) { - return makeArray( [ context.body ], extra ); - - } else if ( match && match[3] ) { - var elem = context.getElementById( match[3] ); - - if ( elem && elem.parentNode ) { - if ( elem.id === match[3] ) { - return makeArray( [ elem ], extra ); - } - - } else { - return makeArray( [], extra ); + if ( seed ) { + if ( postFinder || preFilter ) { + if ( postFinder ) { + temp = []; + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) ) { + temp.push( (matcherIn[i] = elem) ); } } + postFinder( null, (matcherOut = []), temp, xml ); + } - try { - return makeArray( context.querySelectorAll(query), extra ); - } catch(qsaError) {} - - } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { - var oldContext = context, - old = context.getAttribute( "id" ), - nid = old || id, - hasParent = context.parentNode, - relativeHierarchySelector = /^\s*[+~]/.test( query ); + i = matcherOut.length; + while ( i-- ) { + if ( (elem = matcherOut[i]) && + (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { - if ( !old ) { - context.setAttribute( "id", nid ); - } else { - nid = nid.replace( /'/g, "\\$&" ); - } - if ( relativeHierarchySelector && hasParent ) { - context = context.parentNode; + seed[temp] = !(results[temp] = elem); } + } + } - try { - if ( !relativeHierarchySelector || hasParent ) { - return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); - } + } else { + matcherOut = condense( + matcherOut === results ? + matcherOut.splice( preexisting, matcherOut.length ) : + matcherOut + ); + if ( postFinder ) { + postFinder( null, results, matcherOut, xml ); + } else { + push.apply( results, matcherOut ); + } + } + }); +} - } catch(pseudoError) { - } finally { - if ( !old ) { - oldContext.removeAttribute( "id" ); - } +function matcherFromTokens( tokens ) { + var checkContext, matcher, j, + len = tokens.length, + leadingRelative = Expr.relative[ tokens[0].type ], + implicitRelative = leadingRelative || Expr.relative[" "], + i = leadingRelative ? 1 : 0, + + matchContext = addCombinator( function( elem ) { + return elem === checkContext; + }, implicitRelative, true ), + matchAnyContext = addCombinator( function( elem ) { + return indexOf.call( checkContext, elem ) > -1; + }, implicitRelative, true ), + matchers = [ function( elem, context, xml ) { + return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( + (checkContext = context).nodeType ? + matchContext( elem, context, xml ) : + matchAnyContext( elem, context, xml ) ); + } ]; + + for ( ; i < len; i++ ) { + if ( (matcher = Expr.relative[ tokens[i].type ]) ) { + matchers = [ addCombinator(elementMatcher( matchers ), matcher) ]; + } else { + matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches ); + + if ( matcher[ expando ] ) { + j = ++i; + for ( ; j < len; j++ ) { + if ( Expr.relative[ tokens[j].type ] ) { + break; } } + return setMatcher( + i > 1 && elementMatcher( matchers ), + i > 1 && toSelector( + tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" }) + ).replace( rtrim, "$1" ), + matcher, + i < j && matcherFromTokens( tokens.slice( i, j ) ), + j < len && matcherFromTokens( (tokens = tokens.slice( j )) ), + j < len && toSelector( tokens ) + ); } - - return oldSizzle(query, context, extra, seed); - }; - - for ( var prop in oldSizzle ) { - Sizzle[ prop ] = oldSizzle[ prop ]; + matchers.push( matcher ); } + } - div = null; - })(); + return elementMatcher( matchers ); } -(function(){ - var html = document.documentElement, - matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; - - if ( matches ) { - var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), - pseudoWorks = false; +function matcherFromGroupMatchers( elementMatchers, setMatchers ) { + var bySet = setMatchers.length > 0, + byElement = elementMatchers.length > 0, + superMatcher = function( seed, context, xml, results, outermost ) { + var elem, j, matcher, + matchedCount = 0, + i = "0", + unmatched = seed && [], + setMatched = [], + contextBackup = outermostContext, + elems = seed || byElement && Expr.find["TAG"]( "*", outermost ), + dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1), + len = elems.length; + + if ( outermost ) { + outermostContext = context !== document && context; + } - try { - matches.call( document.documentElement, "[test!='']:sizzle" ); + for ( ; i !== len && (elem = elems[i]) != null; i++ ) { + if ( byElement && elem ) { + j = 0; + while ( (matcher = elementMatchers[j++]) ) { + if ( matcher( elem, context, xml ) ) { + results.push( elem ); + break; + } + } + if ( outermost ) { + dirruns = dirrunsUnique; + } + } - } catch( pseudoError ) { - pseudoWorks = true; - } + if ( bySet ) { + if ( (elem = !matcher && elem) ) { + matchedCount--; + } - Sizzle.matchesSelector = function( node, expr ) { - expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); + if ( seed ) { + unmatched.push( elem ); + } + } + } - if ( !Sizzle.isXML( node ) ) { - try { - if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { - var ret = matches.call( node, expr ); + matchedCount += i; + if ( bySet && i !== matchedCount ) { + j = 0; + while ( (matcher = setMatchers[j++]) ) { + matcher( unmatched, setMatched, context, xml ); + } - if ( ret || !disconnectedMatch || - node.document && node.document.nodeType !== 11 ) { - return ret; + if ( seed ) { + if ( matchedCount > 0 ) { + while ( i-- ) { + if ( !(unmatched[i] || setMatched[i]) ) { + setMatched[i] = pop.call( results ); + } } } - } catch(e) {} - } - return Sizzle(expr, null, null, [node]).length > 0; - }; - } -})(); + setMatched = condense( setMatched ); + } -(function(){ - var div = document.createElement("div"); + push.apply( results, setMatched ); - div.innerHTML = ""; + if ( outermost && !seed && setMatched.length > 0 && + ( matchedCount + setMatchers.length ) > 1 ) { - if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { - return; - } + Sizzle.uniqueSort( results ); + } + } - div.lastChild.className = "e"; + if ( outermost ) { + dirruns = dirrunsUnique; + outermostContext = contextBackup; + } - if ( div.getElementsByClassName("e").length === 1 ) { - return; - } + return unmatched; + }; + + return bySet ? + markFunction( superMatcher ) : + superMatcher; +} + +compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { + var i, + setMatchers = [], + elementMatchers = [], + cached = compilerCache[ selector + " " ]; - Expr.order.splice(1, 0, "CLASS"); - Expr.find.CLASS = function( match, context, isXML ) { - if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { - return context.getElementsByClassName(match[1]); + if ( !cached ) { + if ( !match ) { + match = tokenize( selector ); + } + i = match.length; + while ( i-- ) { + cached = matcherFromTokens( match[i] ); + if ( cached[ expando ] ) { + setMatchers.push( cached ); + } else { + elementMatchers.push( cached ); + } } - }; - div = null; -})(); + cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); -function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; + cached.selector = selector; + } + return cached; +}; - if ( elem ) { - var match = false; +/** + * A low-level selection function that works with Sizzle's compiled + * selector functions + * @param {String|Function} selector A selector or a pre-compiled + * selector function built with Sizzle.compile + * @param {Element} context + * @param {Array} [results] + * @param {Array} [seed] A set of elements to match against + */ +select = Sizzle.select = function( selector, context, results, seed ) { + var i, tokens, token, type, find, + compiled = typeof selector === "function" && selector, + match = !seed && tokenize( (selector = compiled.selector || selector) ); - elem = elem[dir]; + results = results || []; - while ( elem ) { - if ( elem.sizcache === doneName ) { - match = checkSet[elem.sizset]; - break; - } + if ( match.length === 1 ) { - if ( elem.nodeType === 1 && !isXML ){ - elem.sizcache = doneName; - elem.sizset = i; - } + tokens = match[0] = match[0].slice( 0 ); + if ( tokens.length > 2 && (token = tokens[0]).type === "ID" && + support.getById && context.nodeType === 9 && documentIsHTML && + Expr.relative[ tokens[1].type ] ) { - if ( elem.nodeName.toLowerCase() === cur ) { - match = elem; - break; - } + context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; + if ( !context ) { + return results; - elem = elem[dir]; + } else if ( compiled ) { + context = context.parentNode; } - checkSet[i] = match; + selector = selector.slice( tokens.shift().value.length ); } - } -} - -function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { - for ( var i = 0, l = checkSet.length; i < l; i++ ) { - var elem = checkSet[i]; - - if ( elem ) { - var match = false; - elem = elem[dir]; + i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length; + while ( i-- ) { + token = tokens[i]; - while ( elem ) { - if ( elem.sizcache === doneName ) { - match = checkSet[elem.sizset]; - break; - } - - if ( elem.nodeType === 1 ) { - if ( !isXML ) { - elem.sizcache = doneName; - elem.sizset = i; + if ( Expr.relative[ (type = token.type) ] ) { + break; + } + if ( (find = Expr.find[ type ]) ) { + if ( (seed = find( + token.matches[0].replace( runescape, funescape ), + rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context + )) ) { + + tokens.splice( i, 1 ); + selector = seed.length && toSelector( tokens ); + if ( !selector ) { + push.apply( results, seed ); + return results; } - if ( typeof cur !== "string" ) { - if ( elem === cur ) { - match = true; - break; - } - - } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { - match = elem; - break; - } + break; } - - elem = elem[dir]; } - - checkSet[i] = match; } } -} - -if ( document.documentElement.contains ) { - Sizzle.contains = function( a, b ) { - return a !== b && (a.contains ? a.contains(b) : true); - }; - -} else if ( document.documentElement.compareDocumentPosition ) { - Sizzle.contains = function( a, b ) { - return !!(a.compareDocumentPosition(b) & 16); - }; - -} else { - Sizzle.contains = function() { - return false; - }; -} -Sizzle.isXML = function( elem ) { - var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; - - return documentElement ? documentElement.nodeName !== "HTML" : false; + ( compiled || compile( selector, match ) )( + seed, + context, + !documentIsHTML, + results, + rsibling.test( selector ) && testContext( context.parentNode ) || context + ); + return results; }; -var posProcess = function( selector, context ) { - var match, - tmpSet = [], - later = "", - root = context.nodeType ? [context] : context; - while ( (match = Expr.match.PSEUDO.exec( selector )) ) { - later += match[0]; - selector = selector.replace( Expr.match.PSEUDO, "" ); - } +support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; - selector = Expr.relative[selector] ? selector + "*" : selector; +support.detectDuplicates = !!hasDuplicate; - for ( var i = 0, l = root.length; i < l; i++ ) { - Sizzle( selector, root[i], tmpSet ); - } +setDocument(); - return Sizzle.filter( later, tmpSet ); -}; +support.sortDetached = assert(function( div1 ) { + return div1.compareDocumentPosition( document.createElement("div") ) & 1; +}); +if ( !assert(function( div ) { + div.innerHTML = ""; + return div.firstChild.getAttribute("href") === "#" ; +}) ) { + addHandle( "type|href|height|width", function( elem, name, isXML ) { + if ( !isXML ) { + return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); + } + }); +} -window.Sizzle = Sizzle; +if ( !support.attributes || !assert(function( div ) { + div.innerHTML = ""; + div.firstChild.setAttribute( "value", "" ); + return div.firstChild.getAttribute( "value" ) === ""; +}) ) { + addHandle( "value", function( elem, name, isXML ) { + if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { + return elem.defaultValue; + } + }); +} -})(); +if ( !assert(function( div ) { + return div.getAttribute("disabled") == null; +}) ) { + addHandle( booleans, function( elem, name, isXML ) { + var val; + if ( !isXML ) { + return elem[ name ] === true ? name.toLowerCase() : + (val = elem.getAttributeNode( name )) && val.specified ? + val.value : + null; + } + }); +} -Prototype._original_property = window.Sizzle; +if ( typeof define === "function" && define.amd ) { + define(function() { return Sizzle; }); +} else if ( typeof module !== "undefined" && module.exports ) { + module.exports = Sizzle; +} else { + window.Sizzle = Sizzle; +} + +})( window ); ;(function(engine) { var extendElements = Prototype.Selector.extendElements; @@ -5799,19 +6265,23 @@ var Form = { accumulator = function(result, key, value) { if (key in result) { if (!Object.isArray(result[key])) result[key] = [result[key]]; - result[key].push(value); + result[key] = result[key].concat(value); } else result[key] = value; return result; }; } else { initial = ''; - accumulator = function(result, key, value) { - value = value.gsub(/(\r)?\n/, '\r\n'); - value = encodeURIComponent(value); - //value = value.gsub(/%20/, '+'); // Why reencoding spaces already encoded by encodeURIComponent? - // With scriptaculous, the space where double encoded to %2B and decoded as +. - return result + (result ? '&' : '') + encodeURIComponent(key) + '=' + value; - } + accumulator = function(result, key, values) { + if (!Object.isArray(values)) {values = [values];} + if (!values.length) {return result;} + var encodedKey = encodeURIComponent(key).gsub(/%20/, '+'); + return result + (result ? "&" : "") + values.map(function (value) { + value = value.gsub(/(\r)?\n/, '\r\n'); + value = encodeURIComponent(value); + value = value.gsub(/%20/, '+'); + return encodedKey + "=" + value; + }).join("&"); + }; } return elements.inject(initial, function(result, element) { @@ -6245,17 +6715,14 @@ Form.EventObserver = Class.create(Abstract.EventObserver, { node = currentTarget; } - if (node.nodeType == Node.TEXT_NODE) - node = node.parentNode; - - return Element.extend(node); + return node.nodeType == Node.TEXT_NODE ? node.parentNode : node; } function findElement(event, expression) { - var element = _element(event), match = Prototype.Selector.match; + var element = _element(event), selector = Prototype.Selector; if (!expression) return Element.extend(element); while (element) { - if (Object.isElement(element) && match(element, expression)) + if (Object.isElement(element) && selector.match(element, expression)) return Element.extend(element); element = element.parentNode; } @@ -6536,8 +7003,8 @@ Form.EventObserver = Class.create(Abstract.EventObserver, { function stopObservingElement(element) { - var uid = getUniqueElementID(element), - registry = getRegistryForElement(element, uid); + var uid = getUniqueElementID(element), registry = GLOBAL.Event.cache[uid]; + if (!registry) return; destroyRegistryForElement(element, uid); @@ -6717,9 +7184,9 @@ Form.EventObserver = Class.create(Abstract.EventObserver, { return createMouseEnterLeaveResponder(uid, eventName, handler); return function(event) { - var cacheEntry = Event.cache[uid]; - var element = cacheEntry.element; + if (!Event.cache) return; + var element = Event.cache[uid].element; Event.extend(event, element); handler.call(element, event); }; @@ -6727,7 +7194,7 @@ Form.EventObserver = Class.create(Abstract.EventObserver, { function createResponderForCustomEvent(uid, eventName, handler) { return function(event) { - var cacheEntry = Event.cache[uid], element = cacheEntry.element; + var element = Event.cache[uid].element; if (Object.isUndefined(event.eventName)) return false; @@ -6742,7 +7209,7 @@ Form.EventObserver = Class.create(Abstract.EventObserver, { function createMouseEnterLeaveResponder(uid, eventName, handler) { return function(event) { - var cacheEntry = Event.cache[uid], element = cacheEntry.element; + var element = Event.cache[uid].element; Event.extend(event, element); var parent = event.relatedTarget; @@ -6792,6 +7259,12 @@ Form.EventObserver = Class.create(Abstract.EventObserver, { fireContentLoadedEvent(); } + + if (document.readyState === 'complete') { + fireContentLoadedEvent(); + return; + } + if (document.addEventListener) { document.addEventListener('DOMContentLoaded', fireContentLoadedEvent, false); } else { @@ -7034,4 +7507,4 @@ Object.extend(Element.ClassNames.prototype, Enumerable); return Prototype.Selector.select(selector, element || document); } }); -})(); \ No newline at end of file +})(); diff --git a/Frameworks/Ajax/Ajax/WebServerResources/wondaculous-min.js b/Frameworks/Ajax/Ajax/WebServerResources/wondaculous-min.js index da2f1b333b1..7909f4e2a17 100644 --- a/Frameworks/Ajax/Ajax/WebServerResources/wondaculous-min.js +++ b/Frameworks/Ajax/Ajax/WebServerResources/wondaculous-min.js @@ -1,8 +1,12 @@ -var Prototype={Version:"1.7.1",Browser:(function(){var b=navigator.userAgent;var a=Object.prototype.toString.call(window.opera)=="[object Opera]";return{IE:!!window.attachEvent&&!a,Opera:a,WebKit:b.indexOf("AppleWebKit/")>-1,Gecko:b.indexOf("Gecko")>-1&&b.indexOf("KHTML")===-1,MobileSafari:/Apple.*Mobile/.test(b)}})(),BrowserFeatures:{XPath:!!document.evaluate,SelectorsAPI:!!document.querySelector,ElementExtensions:(function(){var a=window.Element||window.HTMLElement;return !!(a&&a.prototype)})(),SpecificElementExtensions:(function(){if(typeof window.HTMLDivElement!=="undefined"){return true}var c=document.createElement("div"),b=document.createElement("form"),a=false;if(c.__proto__&&(c.__proto__!==b.__proto__)){a=true}c=b=null;return a})()},ScriptFragment:"