app/assets/javascripts/jquery.js in kit_cms-2.3.15 vs app/assets/javascripts/jquery.js in kit_cms-2.3.16
- old
+ new
@@ -1,17 +1,17 @@
/*!
- * jQuery JavaScript Library v1.8.1
+ * jQuery JavaScript Library v1.8.3
* http://jquery.com/
*
* Includes Sizzle.js
* http://sizzlejs.com/
*
* Copyright 2012 jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*
- * Date: Thu Aug 30 2012 17:17:22 GMT-0400 (Eastern Daylight Time)
+ * Date: Tue Nov 13 2012 08:20:33 GMT-0500 (Eastern Standard Time)
*/
(function( window, undefined ) {
var
// A central reference to the root jQuery(document)
rootjQuery,
@@ -184,11 +184,11 @@
// Start with an empty selector
selector: "",
// The current version of jQuery being used
- jquery: "1.8.1",
+ jquery: "1.8.3",
// The default length of a jQuery object is 0
length: 0,
// The number of elements contained in the matched element set
@@ -571,11 +571,11 @@
camelCase: function( string ) {
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
},
nodeName: function( elem, name ) {
- return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
+ return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
},
// args is for internal usage only
each: function( obj, callback, args ) {
var name,
@@ -628,11 +628,11 @@
// Otherwise use our own trimming functionality
function( text ) {
return text == null ?
"" :
- text.toString().replace( rtrim, "" );
+ ( text + "" ).replace( rtrim, "" );
},
// results is for internal usage only
makeArray: function( arr, results ) {
var type,
@@ -774,11 +774,11 @@
proxy = function() {
return fn.apply( context, args.concat( core_slice.call( arguments ) ) );
};
// Set the guid of unique handler to the same of original handler, so it can be removed
- proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
+ proxy.guid = fn.guid = fn.guid || jQuery.guid++;
return proxy;
},
// Multifunctional method to get and set values of a collection
@@ -997,12 +997,14 @@
// First, we save the current length
var start = list.length;
(function add( args ) {
jQuery.each( args, function( _, arg ) {
var type = jQuery.type( arg );
- if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) {
- list.push( arg );
+ if ( type === "function" ) {
+ if ( !options.unique || !self.has( arg ) ) {
+ list.push( arg );
+ }
} else if ( arg && arg.length && type !== "string" ) {
// Inspect recursively
add( arg );
}
});
@@ -1141,11 +1143,11 @@
}).promise();
},
// Get a promise for this deferred
// If obj is provided, the promise aspect is added to the object
promise: function( obj ) {
- return typeof obj === "object" ? jQuery.extend( obj, promise ) : promise;
+ return obj != null ? jQuery.extend( obj, promise ) : promise;
}
},
deferred = {};
// Keep pipe for back-compat
@@ -1251,28 +1253,27 @@
i,
isSupported,
clickFn,
div = document.createElement("div");
- // Preliminary tests
+ // Setup
div.setAttribute( "className", "t" );
div.innerHTML = " <link/><table></table><a href='/a'>a</a><input type='checkbox'/>";
+ // Support tests won't run in some limited or non-browser environments
all = div.getElementsByTagName("*");
a = div.getElementsByTagName("a")[ 0 ];
- a.style.cssText = "top:1px;float:left;opacity:.5";
-
- // Can't get basic test support
- if ( !all || !all.length || !a ) {
+ if ( !all || !a || !all.length ) {
return {};
}
- // First batch of supports tests
+ // First batch of tests
select = document.createElement("select");
opt = select.appendChild( document.createElement("option") );
input = div.getElementsByTagName("input")[ 0 ];
+ a.style.cssText = "top:1px;float:left;opacity:.5";
support = {
// IE strips leading whitespace when .innerHTML is used
leadingWhitespace: ( div.firstChild.nodeType === 3 ),
// Make sure that tbody elements aren't automatically inserted
@@ -1310,11 +1311,11 @@
optSelected: opt.selected,
// Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7)
getSetAttribute: div.className !== "t",
- // Tests for enctype support on a form(#6743)
+ // Tests for enctype support on a form (#6743)
enctype: !!document.createElement("form").enctype,
// Makes sure cloning an html5 element does not cause problems
// Where outerHTML is undefined, this still works
html5Clone: document.createElement("nav").cloneNode( true ).outerHTML !== "<:nav></:nav>",
@@ -1511,11 +1512,11 @@
jQuery.extend({
cache: {},
deletedIds: [],
- // Please use with caution
+ // Remove at next major release (1.9/2.0)
uuid: 0,
// Unique for each copy of jQuery on the page
// Non-digits removed to match rinlinejQuery
expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
@@ -1563,11 +1564,11 @@
if ( !id ) {
// Only DOM nodes need a new unique ID for each element since their data
// ends up in the global cache
if ( isNode ) {
- elem[ internalKey ] = id = jQuery.deletedIds.pop() || ++jQuery.uuid;
+ elem[ internalKey ] = id = jQuery.deletedIds.pop() || jQuery.guid++;
} else {
id = internalKey;
}
}
@@ -1737,11 +1738,11 @@
if ( elem.nodeType === 1 && !jQuery._data( elem, "parsedAttrs" ) ) {
attr = elem.attributes;
for ( l = attr.length; i < l; i++ ) {
name = attr[i].name;
- if ( name.indexOf( "data-" ) === 0 ) {
+ if ( !name.indexOf( "data-" ) ) {
name = jQuery.camelCase( name.substring(5) );
dataAttr( elem, name, data[ name ] );
}
}
@@ -2047,11 +2048,11 @@
} else {
setClass = " " + elem.className + " ";
for ( c = 0, cl = classNames.length; c < cl; c++ ) {
- if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) {
+ if ( setClass.indexOf( " " + classNames[ c ] + " " ) < 0 ) {
setClass += classNames[ c ] + " ";
}
}
elem.className = jQuery.trim( setClass );
}
@@ -2080,11 +2081,11 @@
className = (" " + elem.className + " ").replace( rclass, " " );
// loop over each item in the removal list
for ( c = 0, cl = removes.length; c < cl; c++ ) {
// Remove until there is nothing to remove,
- while ( className.indexOf(" " + removes[ c ] + " ") > -1 ) {
+ while ( className.indexOf(" " + removes[ c ] + " ") >= 0 ) {
className = className.replace( " " + removes[ c ] + " " , " " );
}
}
elem.className = value ? jQuery.trim( className ) : "";
}
@@ -2134,11 +2135,11 @@
hasClass: function( selector ) {
var className = " " + selector + " ",
i = 0,
l = this.length;
for ( ; i < l; i++ ) {
- if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+ if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) >= 0 ) {
return true;
}
}
return false;
@@ -2215,30 +2216,29 @@
return !val || val.specified ? elem.value : elem.text;
}
},
select: {
get: function( elem ) {
- var value, i, max, option,
- index = elem.selectedIndex,
- values = [],
+ var value, option,
options = elem.options,
- one = elem.type === "select-one";
+ index = elem.selectedIndex,
+ one = elem.type === "select-one" || index < 0,
+ values = one ? null : [],
+ max = one ? index + 1 : options.length,
+ i = index < 0 ?
+ max :
+ one ? index : 0;
- // Nothing was selected
- if ( index < 0 ) {
- return null;
- }
-
// Loop through all the selected options
- i = one ? index : 0;
- max = one ? index + 1 : options.length;
for ( ; i < max; i++ ) {
option = options[ i ];
- // Don't return options that are disabled or in a disabled optgroup
- if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
- (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
+ // oldIE doesn't update selected after form reset (#2551)
+ if ( ( option.selected || i === index ) &&
+ // Don't return options that are disabled or in a disabled optgroup
+ ( jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null ) &&
+ ( !option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" ) ) ) {
// Get the specific value for the option
value = jQuery( option ).val();
// We don't need an array for one selects
@@ -2249,15 +2249,10 @@
// Multi-Selects return an array
values.push( value );
}
}
- // Fixes Bug #2551 -- select.val() broken in IE after form.reset()
- if ( one && !values.length && options.length ) {
- return jQuery( options[ index ] ).val();
- }
-
return values;
},
set: function( elem, value ) {
var values = jQuery.makeArray( value );
@@ -2312,11 +2307,11 @@
} else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) {
return ret;
} else {
- elem.setAttribute( name, "" + value );
+ elem.setAttribute( name, value + "" );
return value;
}
} else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) {
return ret;
@@ -2576,11 +2571,11 @@
// Return undefined in the case of empty string
// Normalize to lowercase since IE uppercases css property names
return elem.style.cssText.toLowerCase() || undefined;
},
set: function( elem, value ) {
- return ( elem.style.cssText = "" + value );
+ return ( elem.style.cssText = value + "" );
}
};
}
// Safari mis-reports the default selected property of an option
@@ -2709,10 +2704,11 @@
origType: tns[1],
data: data,
handler: handler,
guid: handler.guid,
selector: selector,
+ needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
namespace: namespaces.join(".")
}, handleObjIn );
// Init the event handler queue if we're the first
handlers = events[ type ];
@@ -2944,11 +2940,11 @@
if ( handle ) {
handle.apply( cur, data );
}
// Note that this is a bare JS function and not a jQuery handler
handle = ontype && cur[ ontype ];
- if ( handle && jQuery.acceptData( cur ) && handle.apply( cur, data ) === false ) {
+ if ( handle && jQuery.acceptData( cur ) && handle.apply && handle.apply( cur, data ) === false ) {
event.preventDefault();
}
}
event.type = type;
@@ -2992,11 +2988,11 @@
event = jQuery.event.fix( event || window.event );
var i, j, cur, ret, selMatch, matched, matches, handleObj, sel, related,
handlers = ( (jQuery._data( this, "events" ) || {} )[ event.type ] || []),
delegateCount = handlers.delegateCount,
- args = [].slice.call( arguments ),
+ args = core_slice.call( arguments ),
run_all = !event.exclusive && !event.namespace,
special = jQuery.event.special[ event.type ] || {},
handlerQueue = [];
// Use the fix-ed jQuery.Event rather than the (read-only) native event
@@ -3021,11 +3017,13 @@
for ( i = 0; i < delegateCount; i++ ) {
handleObj = handlers[ i ];
sel = handleObj.selector;
if ( selMatch[ sel ] === undefined ) {
- selMatch[ sel ] = jQuery( sel, this ).index( cur ) >= 0;
+ selMatch[ sel ] = handleObj.needsContext ?
+ jQuery( sel, this ).index( cur ) >= 0 :
+ jQuery.find( sel, this, null, [ cur ] ).length;
}
if ( selMatch[ sel ] ) {
matches.push( handleObj );
}
}
@@ -3228,11 +3226,11 @@
function( elem, type, handle ) {
var name = "on" + type;
if ( elem.detachEvent ) {
- // #8545, #7054, preventing memory leaks for custom events in IE6-8 –
+ // #8545, #7054, preventing memory leaks for custom events in IE6-8
// detachEvent needed property on element, by name of that event, to properly expose it to GC
if ( typeof elem[ name ] === "undefined" ) {
elem[ name ] = null;
}
@@ -3591,11 +3589,11 @@
delegate: function( selector, types, data, fn ) {
return this.on( types, selector, data, fn );
},
undelegate: function( selector, types, fn ) {
// ( namespace ) or ( selector, types [, fn] )
- return arguments.length == 1? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
+ return arguments.length === 1 ? this.off( selector, "**" ) : this.off( types, selector || "**", fn );
},
trigger: function( type, data ) {
return this.each(function() {
jQuery.event.trigger( type, data, this );
@@ -3662,41 +3660,55 @@
jQuery.event.fixHooks[ name ] = jQuery.event.mouseHooks;
}
});
/*!
* Sizzle CSS Selector Engine
- * Copyright 2012 jQuery Foundation and other contributors
- * Released under the MIT license
- * http://sizzlejs.com/
+ * Copyright 2012 jQuery Foundation and other contributors
+ * Released under the MIT license
+ * http://sizzlejs.com/
*/
(function( window, undefined ) {
-var dirruns,
- cachedruns,
+var cachedruns,
assertGetIdNotName,
Expr,
getText,
isXML,
contains,
compile,
sortOrder,
hasDuplicate,
+ outermostContext,
baseHasDuplicate = true,
strundefined = "undefined",
expando = ( "sizcache" + Math.random() ).replace( ".", "" ),
+ Token = String,
document = window.document,
docElem = document.documentElement,
+ dirruns = 0,
done = 0,
- slice = [].slice,
+ pop = [].pop,
push = [].push,
+ slice = [].slice,
+ // Use a stripped-down indexOf if a native one is unavailable
+ indexOf = [].indexOf || function( elem ) {
+ var i = 0,
+ len = this.length;
+ for ( ; i < len; i++ ) {
+ if ( this[i] === elem ) {
+ return i;
+ }
+ }
+ return -1;
+ },
// Augment a function for special use by Sizzle
markFunction = function( fn, value ) {
- fn[ expando ] = value || true;
+ fn[ expando ] = value == null || value;
return fn;
},
createCache = function() {
var cache = {},
@@ -3706,11 +3718,12 @@
// Only keep the most recent entries
if ( keys.push( key ) > Expr.cacheLength ) {
delete cache[ keys.shift() ];
}
- return (cache[ key ] = value);
+ // Retrieve with (key + " ") to avoid collision with native Object.prototype properties (see Issue #157)
+ return (cache[ key + " " ] = value);
}, cache );
},
classCache = createCache(),
tokenCache = createCache(),
@@ -3739,11 +3752,12 @@
// These preferences are here to reduce the number of selectors
// needing tokenize in the PSEUDO preFilter
pseudos = ":(" + characterEncoding + ")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:" + attributes + ")|[^:]|\\\\.)*|.*))\\)|)",
// For matchExpr.POS and matchExpr.needsContext
- pos = ":(nth|eq|gt|lt|first|last|even|odd)(?:\\(((?:-\\d)?\\d*)\\)|)(?=[^-]|$)",
+ pos = ":(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace +
+ "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)",
// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
@@ -3767,14 +3781,14 @@
"CLASS": new RegExp( "^\\.(" + characterEncoding + ")" ),
"NAME": new RegExp( "^\\[name=['\"]?(" + characterEncoding + ")['\"]?\\]" ),
"TAG": new RegExp( "^(" + characterEncoding.replace( "w", "w*" ) + ")" ),
"ATTR": new RegExp( "^" + attributes ),
"PSEUDO": new RegExp( "^" + pseudos ),
- "CHILD": new RegExp( "^:(only|nth|last|first)-child(?:\\(" + whitespace +
+ "POS": new RegExp( pos, "i" ),
+ "CHILD": new RegExp( "^:(only|nth|first|last)-child(?:\\(" + whitespace +
"*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
"*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
- "POS": new RegExp( pos, "ig" ),
// For use in libraries implementing .is()
"needsContext": new RegExp( "^" + whitespace + "*[>+~]|" + pos, "i" )
},
// Support
@@ -3852,11 +3866,12 @@
// If slice is not available, provide a backup
try {
slice.call( docElem.childNodes, 0 )[0].nodeType;
} catch ( e ) {
slice = function( i ) {
- var elem, results = [];
+ var elem,
+ results = [];
for ( ; (elem = this[i]); i++ ) {
results.push( elem );
}
return results;
};
@@ -3866,18 +3881,18 @@
results = results || [];
context = context || document;
var match, elem, xml, m,
nodeType = context.nodeType;
- if ( nodeType !== 1 && nodeType !== 9 ) {
- return [];
- }
-
if ( !selector || typeof selector !== "string" ) {
return results;
}
+ if ( nodeType !== 1 && nodeType !== 9 ) {
+ return [];
+ }
+
xml = isXML( context );
if ( !xml && !seed ) {
if ( (match = rquickExpr.exec( selector )) ) {
// Speed-up: Sizzle("#ID")
@@ -3917,11 +3932,11 @@
}
}
}
// All others
- return select( selector, context, results, seed, xml );
+ return select( selector.replace( rtrim, "$1" ), context, results, seed, xml );
}
Sizzle.matches = function( expr, elements ) {
return Sizzle( expr, null, null, elements );
};
@@ -3944,10 +3959,29 @@
var name = elem.nodeName.toLowerCase();
return (name === "input" || name === "button") && elem.type === type;
};
}
+// Returns a function to use in pseudos for positionals
+function createPositionalPseudo( fn ) {
+ return markFunction(function( argument ) {
+ argument = +argument;
+ return markFunction(function( seed, matches ) {
+ var j,
+ matchIndexes = fn( [], seed.length, argument ),
+ i = matchIndexes.length;
+
+ // Match elements found at the specified indexes
+ while ( i-- ) {
+ if ( seed[ (j = matchIndexes[i]) ] ) {
+ seed[j] = !(matches[j] = seed[j]);
+ }
+ }
+ });
+ });
+}
+
/**
* Utility function for retrieving the text value of an array of DOM nodes
* @param {Array|Element} elem
*/
getText = Sizzle.getText = function( elem ) {
@@ -3981,11 +4015,11 @@
}
}
return ret;
};
-isXML = Sizzle.isXML = function isXML( elem ) {
+isXML = Sizzle.isXML = function( elem ) {
// documentElement is verified for cases where it doesn't yet exist
// (such as loading iframes in IE - #4833)
var documentElement = elem && (elem.ownerDocument || elem).documentElement;
return documentElement ? documentElement.nodeName !== "HTML" : false;
};
@@ -4009,27 +4043,27 @@
}
return false;
};
Sizzle.attr = function( elem, name ) {
- var attr,
+ var val,
xml = isXML( elem );
if ( !xml ) {
name = name.toLowerCase();
}
- if ( Expr.attrHandle[ name ] ) {
- return Expr.attrHandle[ name ]( elem );
+ if ( (val = Expr.attrHandle[ name ]) ) {
+ return val( elem );
}
- if ( assertAttributes || xml ) {
+ if ( xml || assertAttributes ) {
return elem.getAttribute( name );
}
- attr = elem.getAttributeNode( name );
- return attr ?
+ val = elem.getAttributeNode( name );
+ return val ?
typeof elem[ name ] === "boolean" ?
elem[ name ] ? name : null :
- attr.specified ? attr.value : null :
+ val.specified ? val.value : null :
null;
};
Expr = Sizzle.selectors = {
@@ -4038,15 +4072,10 @@
createPseudo: markFunction,
match: matchExpr,
- order: new RegExp( "ID|TAG" +
- (assertUsableName ? "|NAME" : "") +
- (assertUsableClassName ? "|CLASS" : "")
- ),
-
// IE6/7 return a modified href
attrHandle: assertHrefNotNormalized ?
{} :
{
"href": function( elem ) {
@@ -4103,17 +4132,17 @@
return tmp;
}
return results;
},
- "NAME": function( tag, context ) {
+ "NAME": assertUsableName && function( tag, context ) {
if ( typeof context.getElementsByName !== strundefined ) {
return context.getElementsByName( name );
}
},
- "CLASS": function( className, context, xml ) {
+ "CLASS": assertUsableClassName && function( className, context, xml ) {
if ( typeof context.getElementsByClassName !== strundefined && !xml ) {
return context.getElementsByClassName( className );
}
}
},
@@ -4138,11 +4167,11 @@
return match.slice( 0, 4 );
},
"CHILD": function( match ) {
- /* matches from matchExpr.CHILD
+ /* matches from matchExpr["CHILD"]
1 type (only|nth|...)
2 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
3 xn-component of xn+y argument ([+-]?\d*n|)
4 sign of xn-component
5 x of xn-component
@@ -4168,11 +4197,11 @@
}
return match;
},
- "PSEUDO": function( match, context, xml ) {
+ "PSEUDO": function( match ) {
var unquoted, excess;
if ( matchExpr["CHILD"].test( match[0] ) ) {
return null;
}
@@ -4180,11 +4209,11 @@
match[2] = match[3];
} else if ( (unquoted = match[4]) ) {
// Only check arguments that contain a pseudo
if ( rpseudo.test(unquoted) &&
// Get excess from tokenize (recursively)
- (excess = tokenize( unquoted, context, xml, true )) &&
+ (excess = tokenize( unquoted, true )) &&
// advance to the next closing parenthesis
(excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
// excess is a negative index
unquoted = unquoted.slice( 0, excess );
@@ -4224,90 +4253,69 @@
return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
};
},
"CLASS": function( className ) {
- var pattern = classCache[ expando ][ className ];
- if ( !pattern ) {
- pattern = classCache( className, new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)") );
- }
- return function( elem ) {
- return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
- };
+ var pattern = classCache[ expando ][ className + " " ];
+
+ return pattern ||
+ (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
+ classCache( className, function( elem ) {
+ return pattern.test( elem.className || (typeof elem.getAttribute !== strundefined && elem.getAttribute("class")) || "" );
+ });
},
"ATTR": function( name, operator, check ) {
- if ( !operator ) {
- return function( elem ) {
- return Sizzle.attr( elem, name ) != null;
- };
- }
+ return function( elem, context ) {
+ var result = Sizzle.attr( elem, name );
- return function( elem ) {
- var result = Sizzle.attr( elem, name ),
- value = result + "";
-
if ( result == null ) {
return operator === "!=";
}
-
- switch ( operator ) {
- case "=":
- return value === check;
- case "!=":
- return value !== check;
- case "^=":
- return check && value.indexOf( check ) === 0;
- case "*=":
- return check && value.indexOf( check ) > -1;
- case "$=":
- return check && value.substr( value.length - check.length ) === check;
- case "~=":
- return ( " " + value + " " ).indexOf( check ) > -1;
- case "|=":
- return value === check || value.substr( 0, check.length + 1 ) === check + "-";
+ if ( !operator ) {
+ return true;
}
+
+ result += "";
+
+ return operator === "=" ? result === check :
+ operator === "!=" ? result !== check :
+ operator === "^=" ? check && result.indexOf( check ) === 0 :
+ operator === "*=" ? check && result.indexOf( check ) > -1 :
+ operator === "$=" ? check && result.substr( result.length - check.length ) === check :
+ operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 :
+ operator === "|=" ? result === check || result.substr( 0, check.length + 1 ) === check + "-" :
+ false;
};
},
"CHILD": function( type, argument, first, last ) {
if ( type === "nth" ) {
- var doneName = done++;
-
return function( elem ) {
- var parent, diff,
- count = 0,
- node = elem;
+ var node, diff,
+ parent = elem.parentNode;
if ( first === 1 && last === 0 ) {
return true;
}
- parent = elem.parentNode;
-
- if ( parent && (parent[ expando ] !== doneName || !elem.sizset) ) {
+ if ( parent ) {
+ diff = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) {
- node.sizset = ++count;
- if ( node === elem ) {
+ diff++;
+ if ( elem === node ) {
break;
}
}
}
-
- parent[ expando ] = doneName;
}
- diff = elem.sizset - last;
-
- if ( first === 0 ) {
- return diff === 0;
-
- } else {
- return ( diff % first === 0 && diff / first >= 0 );
- }
+ // Incorporate the offset (or cast to NaN), then check against cycle size
+ diff -= last;
+ return diff === first || ( diff % first === 0 && diff / first >= 0 );
};
}
return function( elem ) {
var node = elem;
@@ -4338,49 +4346,89 @@
return true;
}
};
},
- "PSEUDO": function( pseudo, argument, context, xml ) {
+ "PSEUDO": function( pseudo, argument ) {
// pseudo-class names are case-insensitive
// http://www.w3.org/TR/selectors/#pseudo-classes
// Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
+ // Remember that setFilters inherits from pseudos
var args,
- fn = Expr.pseudos[ pseudo ] || Expr.pseudos[ pseudo.toLowerCase() ];
+ fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
+ Sizzle.error( "unsupported pseudo: " + pseudo );
- if ( !fn ) {
- Sizzle.error( "unsupported pseudo: " + pseudo );
- }
-
// The user may use createPseudo to indicate that
// arguments are needed to create the filter function
// just as Sizzle does
- if ( !fn[ expando ] ) {
- if ( fn.length > 1 ) {
- args = [ pseudo, pseudo, "", argument ];
- return function( elem ) {
+ if ( fn[ expando ] ) {
+ return fn( argument );
+ }
+
+ // But maintain support for old signatures
+ 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;
}
- return fn( argument, context, xml );
+ return fn;
}
},
pseudos: {
- "not": markFunction(function( selector, context, xml ) {
+ "not": markFunction(function( selector ) {
// Trim the selector passed to compile
// to avoid treating leading and trailing
// spaces as combinators
- var matcher = compile( selector.replace( rtrim, "$1" ), context, xml );
+ 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;
+
+ // Match elements unmatched by `matcher`
+ 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 !matcher( elem );
+ return Sizzle( selector, elem ).length > 0;
};
}),
+ "contains": markFunction(function( text ) {
+ return function( elem ) {
+ return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
+ };
+ }),
+
"enabled": function( elem ) {
return elem.disabled === false;
},
"disabled": function( elem ) {
@@ -4423,22 +4471,10 @@
elem = elem.nextSibling;
}
return true;
},
- "contains": markFunction(function( text ) {
- return function( elem ) {
- return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
- };
- }),
-
- "has": markFunction(function( selector ) {
- return function( elem ) {
- return Sizzle( selector, elem ).length > 0;
- };
- }),
-
"header": function( elem ) {
return rheader.test( elem.nodeName );
},
"text": function( elem ) {
@@ -4469,60 +4505,57 @@
return rinputs.test( elem.nodeName );
},
"focus": function( elem ) {
var doc = elem.ownerDocument;
- return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href);
+ return elem === doc.activeElement && (!doc.hasFocus || doc.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
},
"active": function( elem ) {
return elem === elem.ownerDocument.activeElement;
- }
- },
-
- setFilters: {
- "first": function( elements, argument, not ) {
- return not ? elements.slice( 1 ) : [ elements[0] ];
},
- "last": function( elements, argument, not ) {
- var elem = elements.pop();
- return not ? elements : [ elem ];
- },
+ // Positional types
+ "first": createPositionalPseudo(function() {
+ return [ 0 ];
+ }),
- "even": function( elements, argument, not ) {
- var results = [],
- i = not ? 1 : 0,
- len = elements.length;
- for ( ; i < len; i = i + 2 ) {
- results.push( elements[i] );
+ "last": createPositionalPseudo(function( matchIndexes, length ) {
+ return [ length - 1 ];
+ }),
+
+ "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ return [ argument < 0 ? argument + length : argument ];
+ }),
+
+ "even": createPositionalPseudo(function( matchIndexes, length ) {
+ for ( var i = 0; i < length; i += 2 ) {
+ matchIndexes.push( i );
}
- return results;
- },
+ return matchIndexes;
+ }),
- "odd": function( elements, argument, not ) {
- var results = [],
- i = not ? 0 : 1,
- len = elements.length;
- for ( ; i < len; i = i + 2 ) {
- results.push( elements[i] );
+ "odd": createPositionalPseudo(function( matchIndexes, length ) {
+ for ( var i = 1; i < length; i += 2 ) {
+ matchIndexes.push( i );
}
- return results;
- },
+ return matchIndexes;
+ }),
- "lt": function( elements, argument, not ) {
- return not ? elements.slice( +argument ) : elements.slice( 0, +argument );
- },
+ "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ for ( var i = argument < 0 ? argument + length : argument; --i >= 0; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ }),
- "gt": function( elements, argument, not ) {
- return not ? elements.slice( 0, +argument + 1 ) : elements.slice( +argument + 1 );
- },
-
- "eq": function( elements, argument, not ) {
- var elem = elements.splice( +argument, 1 );
- return not ? elements : elem;
- }
+ "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
+ for ( var i = argument < 0 ? argument + length : argument; ++i < length; ) {
+ matchIndexes.push( i );
+ }
+ return matchIndexes;
+ })
}
};
function siblingCheck( a, b, ret ) {
if ( a === b ) {
@@ -4620,430 +4653,544 @@
baseHasDuplicate = !hasDuplicate;
// Document sorting and removing duplicates
Sizzle.uniqueSort = function( results ) {
var elem,
- i = 1;
+ duplicates = [],
+ i = 1,
+ j = 0;
hasDuplicate = baseHasDuplicate;
results.sort( sortOrder );
if ( hasDuplicate ) {
for ( ; (elem = results[i]); i++ ) {
if ( elem === results[ i - 1 ] ) {
- results.splice( i--, 1 );
+ j = duplicates.push( i );
}
}
+ while ( j-- ) {
+ results.splice( duplicates[ j ], 1 );
+ }
}
return results;
};
Sizzle.error = function( msg ) {
throw new Error( "Syntax error, unrecognized expression: " + msg );
};
-function tokenize( selector, context, xml, parseOnly ) {
+function tokenize( selector, parseOnly ) {
var matched, match, tokens, type,
- soFar, groups, group, i,
- preFilters, filters,
- checkContext = !xml && context !== document,
- // Token cache should maintain spaces
- key = ( checkContext ? "<s>" : "" ) + selector.replace( rtrim, "$1<s>" ),
- cached = tokenCache[ expando ][ key ];
+ soFar, groups, preFilters,
+ cached = tokenCache[ expando ][ selector + " " ];
if ( cached ) {
- return parseOnly ? 0 : slice.call( cached, 0 );
+ return parseOnly ? 0 : cached.slice( 0 );
}
soFar = selector;
groups = [];
- i = 0;
preFilters = Expr.preFilter;
- filters = Expr.filter;
while ( soFar ) {
// Comma and first run
if ( !matched || (match = rcomma.exec( soFar )) ) {
if ( match ) {
- soFar = soFar.slice( match[0].length );
- tokens.selector = group;
+ // Don't consume trailing commas as valid
+ soFar = soFar.slice( match[0].length ) || soFar;
}
groups.push( tokens = [] );
- group = "";
-
- // Need to make sure we're within a narrower context if necessary
- // Adding a descendant combinator will generate what is needed
- if ( checkContext ) {
- soFar = " " + soFar;
- }
}
matched = false;
// Combinators
if ( (match = rcombinators.exec( soFar )) ) {
- group += match[0];
- soFar = soFar.slice( match[0].length );
+ tokens.push( matched = new Token( match.shift() ) );
+ soFar = soFar.slice( matched.length );
// Cast descendant combinators to space
- matched = tokens.push({
- part: match.pop().replace( rtrim, " " ),
- string: match[0],
- captures: match
- });
+ matched.type = match[0].replace( rtrim, " " );
}
// Filters
- for ( type in filters ) {
+ for ( type in Expr.filter ) {
if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
- ( match = preFilters[ type ](match, context, xml) )) ) {
+ (match = preFilters[ type ]( match ))) ) {
- group += match[0];
- soFar = soFar.slice( match[0].length );
- matched = tokens.push({
- part: type,
- string: match.shift(),
- captures: match
- });
+ tokens.push( matched = new Token( match.shift() ) );
+ soFar = soFar.slice( matched.length );
+ matched.type = type;
+ matched.matches = match;
}
}
if ( !matched ) {
break;
}
}
- // Attach the full group as a selector
- if ( group ) {
- tokens.selector = group;
- }
-
// Return the length of the invalid excess
// if we're just parsing
// Otherwise, throw an error or return tokens
return parseOnly ?
soFar.length :
soFar ?
Sizzle.error( selector ) :
// Cache the tokens
- slice.call( tokenCache(key, groups), 0 );
+ tokenCache( selector, groups ).slice( 0 );
}
-function addCombinator( matcher, combinator, context, xml ) {
+function addCombinator( matcher, combinator, base ) {
var dir = combinator.dir,
+ checkNonElements = base && combinator.dir === "parentNode",
doneName = done++;
- if ( !matcher ) {
- // If there is no matcher to check, check against the context
- matcher = function( elem ) {
- return elem === context;
- };
- }
return combinator.first ?
- function( elem ) {
+ // Check against closest ancestor/preceding element
+ function( elem, context, xml ) {
while ( (elem = elem[ dir ]) ) {
- if ( elem.nodeType === 1 ) {
- return matcher( elem ) && elem;
+ if ( checkNonElements || elem.nodeType === 1 ) {
+ return matcher( elem, context, xml );
}
}
} :
- xml ?
- function( elem ) {
- while ( (elem = elem[ dir ]) ) {
- if ( elem.nodeType === 1 ) {
- if ( matcher( elem ) ) {
- return elem;
- }
- }
- }
- } :
- function( elem ) {
+
+ // Check against all ancestor/preceding elements
+ function( elem, context, xml ) {
+ // We can't set arbitrary data on XML nodes, so they don't benefit from dir caching
+ if ( !xml ) {
var cache,
- dirkey = doneName + "." + dirruns,
- cachedkey = dirkey + "." + cachedruns;
+ dirkey = dirruns + " " + doneName + " ",
+ cachedkey = dirkey + cachedruns;
while ( (elem = elem[ dir ]) ) {
- if ( elem.nodeType === 1 ) {
+ if ( checkNonElements || elem.nodeType === 1 ) {
if ( (cache = elem[ expando ]) === cachedkey ) {
return elem.sizset;
} else if ( typeof cache === "string" && cache.indexOf(dirkey) === 0 ) {
if ( elem.sizset ) {
return elem;
}
} else {
elem[ expando ] = cachedkey;
- if ( matcher( elem ) ) {
+ if ( matcher( elem, context, xml ) ) {
elem.sizset = true;
return elem;
}
elem.sizset = false;
}
}
}
- };
+ } else {
+ while ( (elem = elem[ dir ]) ) {
+ if ( checkNonElements || elem.nodeType === 1 ) {
+ if ( matcher( elem, context, xml ) ) {
+ return elem;
+ }
+ }
+ }
+ }
+ };
}
-function addMatcher( higher, deeper ) {
- return higher ?
- function( elem ) {
- var result = deeper( elem );
- return result && higher( result === true ? elem : result );
+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;
} :
- deeper;
+ matchers[0];
}
-// ["TAG", ">", "ID", " ", "CLASS"]
-function matcherFromTokens( tokens, context, xml ) {
- var token, matcher,
- i = 0;
+function condense( unmatched, map, filter, context, xml ) {
+ var elem,
+ newUnmatched = [],
+ i = 0,
+ len = unmatched.length,
+ mapped = map != null;
- for ( ; (token = tokens[i]); i++ ) {
- if ( Expr.relative[ token.part ] ) {
- matcher = addCombinator( matcher, Expr.relative[ token.part ], context, xml );
- } else {
- matcher = addMatcher( matcher, Expr.filter[ token.part ].apply(null, token.captures.concat( context, xml )) );
+ for ( ; i < len; i++ ) {
+ if ( (elem = unmatched[i]) ) {
+ if ( !filter || filter( elem, context, xml ) ) {
+ newUnmatched.push( elem );
+ if ( mapped ) {
+ map.push( i );
+ }
+ }
}
}
- return matcher;
+ return newUnmatched;
}
-function matcherFromGroupMatchers( matchers ) {
- return function( elem ) {
- var matcher,
- j = 0;
- for ( ; (matcher = matchers[j]); j++ ) {
- if ( matcher(elem) ) {
- return true;
+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,
+
+ // Get initial elements from seed or context
+ elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
+
+ // Prefilter to get matcher input, preserving a map for seed-results synchronization
+ matcherIn = preFilter && ( seed || !selector ) ?
+ condense( elems, preMap, preFilter, context, xml ) :
+ elems,
+
+ matcherOut = matcher ?
+ // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
+ postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
+
+ // ...intermediate processing is necessary
+ [] :
+
+ // ...otherwise use results directly
+ results :
+ matcherIn;
+
+ // Find primary matches
+ if ( matcher ) {
+ matcher( matcherIn, matcherOut, context, xml );
+ }
+
+ // Apply postFilter
+ if ( postFilter ) {
+ temp = condense( matcherOut, postMap );
+ postFilter( temp, [], context, xml );
+
+ // Un-match failing elements by moving them back to matcherIn
+ i = temp.length;
+ while ( i-- ) {
+ if ( (elem = temp[i]) ) {
+ matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
+ }
}
}
- return false;
- };
-}
-compile = Sizzle.compile = function( selector, context, xml ) {
- var group, i, len,
- cached = compilerCache[ expando ][ selector ];
+ if ( seed ) {
+ if ( postFinder || preFilter ) {
+ if ( postFinder ) {
+ // Get the final matcherOut by condensing this intermediate into postFinder contexts
+ temp = [];
+ i = matcherOut.length;
+ while ( i-- ) {
+ if ( (elem = matcherOut[i]) ) {
+ // Restore matcherIn since elem is not yet a final match
+ temp.push( (matcherIn[i] = elem) );
+ }
+ }
+ postFinder( null, (matcherOut = []), temp, xml );
+ }
- // Return a cached group function if already generated (context dependent)
- if ( cached && cached.context === context ) {
- return cached;
- }
+ // Move matched elements from seed to results to keep them synchronized
+ i = matcherOut.length;
+ while ( i-- ) {
+ if ( (elem = matcherOut[i]) &&
+ (temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) {
- // Generate a function of recursive functions that can be used to check each element
- group = tokenize( selector, context, xml );
- for ( i = 0, len = group.length; i < len; i++ ) {
- group[i] = matcherFromTokens(group[i], context, xml);
- }
+ seed[temp] = !(results[temp] = elem);
+ }
+ }
+ }
- // Cache the compiled function
- cached = compilerCache( selector, matcherFromGroupMatchers(group) );
- cached.context = context;
- cached.runs = cached.dirruns = 0;
- return cached;
-};
+ // Add elements to results, through postFinder if defined
+ } else {
+ matcherOut = condense(
+ matcherOut === results ?
+ matcherOut.splice( preexisting, matcherOut.length ) :
+ matcherOut
+ );
+ if ( postFinder ) {
+ postFinder( null, results, matcherOut, xml );
+ } else {
+ push.apply( results, matcherOut );
+ }
+ }
+ });
+}
-function multipleContexts( selector, contexts, results, seed ) {
- var i = 0,
- len = contexts.length;
+function matcherFromTokens( tokens ) {
+ var checkContext, matcher, j,
+ len = tokens.length,
+ leadingRelative = Expr.relative[ tokens[0].type ],
+ implicitRelative = leadingRelative || Expr.relative[" "],
+ i = leadingRelative ? 1 : 0,
+
+ // The foundational matcher ensures that elements are reachable from top-level context(s)
+ 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++ ) {
- Sizzle( selector, contexts[i], results, seed );
+ if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
+ matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ];
+ } else {
+ matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
+
+ // Return special upon seeing a positional matcher
+ if ( matcher[ expando ] ) {
+ // Find the next relative operator (if any) for proper handling
+ j = ++i;
+ for ( ; j < len; j++ ) {
+ if ( Expr.relative[ tokens[j].type ] ) {
+ break;
+ }
+ }
+ return setMatcher(
+ i > 1 && elementMatcher( matchers ),
+ i > 1 && tokens.slice( 0, i - 1 ).join("").replace( rtrim, "$1" ),
+ matcher,
+ i < j && matcherFromTokens( tokens.slice( i, j ) ),
+ j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
+ j < len && tokens.join("")
+ );
+ }
+ matchers.push( matcher );
+ }
}
+
+ return elementMatcher( matchers );
}
-function handlePOSGroup( selector, posfilter, argument, contexts, seed, not ) {
- var results,
- fn = Expr.setFilters[ posfilter.toLowerCase() ];
+function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
+ var bySet = setMatchers.length > 0,
+ byElement = elementMatchers.length > 0,
+ superMatcher = function( seed, context, xml, results, expandContext ) {
+ var elem, j, matcher,
+ setMatched = [],
+ matchedCount = 0,
+ i = "0",
+ unmatched = seed && [],
+ outermost = expandContext != null,
+ contextBackup = outermostContext,
+ // We must always have either seed elements or context
+ elems = seed || byElement && Expr.find["TAG"]( "*", expandContext && context.parentNode || context ),
+ // Nested matchers should use non-integer dirruns
+ dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.E);
- if ( !fn ) {
- Sizzle.error( posfilter );
- }
+ if ( outermost ) {
+ outermostContext = context !== document && context;
+ cachedruns = superMatcher.el;
+ }
- if ( selector || !(results = seed) ) {
- multipleContexts( selector || "*", contexts, (results = []), seed );
- }
+ // Add elements passing elementMatchers directly to results
+ for ( ; (elem = elems[i]) != null; i++ ) {
+ if ( byElement && elem ) {
+ for ( j = 0; (matcher = elementMatchers[j]); j++ ) {
+ if ( matcher( elem, context, xml ) ) {
+ results.push( elem );
+ break;
+ }
+ }
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ cachedruns = ++superMatcher.el;
+ }
+ }
- return results.length > 0 ? fn( results, argument, not ) : [];
-}
+ // Track unmatched elements for set filters
+ if ( bySet ) {
+ // They will have gone through all possible matchers
+ if ( (elem = !matcher && elem) ) {
+ matchedCount--;
+ }
-function handlePOS( groups, context, results, seed ) {
- var group, part, j, groupLen, token, selector,
- anchor, elements, match, matched,
- lastIndex, currentContexts, not,
- i = 0,
- len = groups.length,
- rpos = matchExpr["POS"],
- // This is generated here in case matchExpr["POS"] is extended
- rposgroups = new RegExp( "^" + rpos.source + "(?!" + whitespace + ")", "i" ),
- // This is for making sure non-participating
- // matching groups are represented cross-browser (IE6-8)
- setUndefined = function() {
- var i = 1,
- len = arguments.length - 2;
- for ( ; i < len; i++ ) {
- if ( arguments[i] === undefined ) {
- match[i] = undefined;
+ // Lengthen the array for every element, matched or not
+ if ( seed ) {
+ unmatched.push( elem );
+ }
}
}
- };
- for ( ; i < len; i++ ) {
- group = groups[i];
- part = "";
- elements = seed;
- for ( j = 0, groupLen = group.length; j < groupLen; j++ ) {
- token = group[j];
- selector = token.string;
- if ( token.part === "PSEUDO" ) {
- // Reset regex index to 0
- rpos.exec("");
- anchor = 0;
- while ( (match = rpos.exec( selector )) ) {
- matched = true;
- lastIndex = rpos.lastIndex = match.index + match[0].length;
- if ( lastIndex > anchor ) {
- part += selector.slice( anchor, match.index );
- anchor = lastIndex;
- currentContexts = [ context ];
+ // Apply set filters to unmatched elements
+ matchedCount += i;
+ if ( bySet && i !== matchedCount ) {
+ for ( j = 0; (matcher = setMatchers[j]); j++ ) {
+ matcher( unmatched, setMatched, context, xml );
+ }
- if ( rcombinators.test(part) ) {
- if ( elements ) {
- currentContexts = elements;
+ if ( seed ) {
+ // Reintegrate element matches to eliminate the need for sorting
+ if ( matchedCount > 0 ) {
+ while ( i-- ) {
+ if ( !(unmatched[i] || setMatched[i]) ) {
+ setMatched[i] = pop.call( results );
}
- elements = seed;
}
-
- if ( (not = rendsWithNot.test( part )) ) {
- part = part.slice( 0, -5 ).replace( rcombinators, "$&*" );
- anchor++;
- }
-
- if ( match.length > 1 ) {
- match[0].replace( rposgroups, setUndefined );
- }
- elements = handlePOSGroup( part, match[1], match[2], currentContexts, elements, not );
}
- part = "";
+
+ // Discard index placeholder values to get only actual matches
+ setMatched = condense( setMatched );
}
+ // Add matches to results
+ push.apply( results, setMatched );
+
+ // Seedless set matches succeeding multiple successful matchers stipulate sorting
+ if ( outermost && !seed && setMatched.length > 0 &&
+ ( matchedCount + setMatchers.length ) > 1 ) {
+
+ Sizzle.uniqueSort( results );
+ }
}
- if ( !matched ) {
- part += selector;
+ // Override manipulation of globals by nested matchers
+ if ( outermost ) {
+ dirruns = dirrunsUnique;
+ outermostContext = contextBackup;
}
- matched = false;
- }
- if ( part ) {
- if ( rcombinators.test(part) ) {
- multipleContexts( part, elements || [ context ], results, seed );
+ return unmatched;
+ };
+
+ superMatcher.el = 0;
+ return bySet ?
+ markFunction( superMatcher ) :
+ superMatcher;
+}
+
+compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
+ var i,
+ setMatchers = [],
+ elementMatchers = [],
+ cached = compilerCache[ expando ][ selector + " " ];
+
+ if ( !cached ) {
+ // Generate a function of recursive functions that can be used to check each element
+ if ( !group ) {
+ group = tokenize( selector );
+ }
+ i = group.length;
+ while ( i-- ) {
+ cached = matcherFromTokens( group[i] );
+ if ( cached[ expando ] ) {
+ setMatchers.push( cached );
} else {
- Sizzle( part, context, results, seed ? seed.concat(elements) : elements );
+ elementMatchers.push( cached );
}
- } else {
- push.apply( results, elements );
}
+
+ // Cache the compiled function
+ cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
}
+ return cached;
+};
- // Do not sort if this is a single filter
- return len === 1 ? results : Sizzle.uniqueSort( results );
+function multipleContexts( selector, contexts, results ) {
+ var i = 0,
+ len = contexts.length;
+ for ( ; i < len; i++ ) {
+ Sizzle( selector, contexts[i], results );
+ }
+ return results;
}
function select( selector, context, results, seed, xml ) {
- // Remove excessive whitespace
- selector = selector.replace( rtrim, "$1" );
- var elements, matcher, cached, elem,
- i, tokens, token, lastToken, findContext, type,
- match = tokenize( selector, context, xml ),
- contextNodeType = context.nodeType;
+ var i, tokens, token, type, find,
+ match = tokenize( selector ),
+ j = match.length;
- // POS handling
- if ( matchExpr["POS"].test(selector) ) {
- return handlePOS( match, context, results, seed );
- }
+ if ( !seed ) {
+ // Try to minimize operations if there is only one group
+ if ( match.length === 1 ) {
- if ( seed ) {
- elements = slice.call( seed, 0 );
+ // Take a shortcut and set the context if the root selector is an ID
+ tokens = match[0] = match[0].slice( 0 );
+ if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
+ context.nodeType === 9 && !xml &&
+ Expr.relative[ tokens[1].type ] ) {
- // To maintain document order, only narrow the
- // set if there is one group
- } else if ( match.length === 1 ) {
+ context = Expr.find["ID"]( token.matches[0].replace( rbackslash, "" ), context, xml )[0];
+ if ( !context ) {
+ return results;
+ }
- // Take a shortcut and set the context if the root selector is an ID
- if ( (tokens = slice.call( match[0], 0 )).length > 2 &&
- (token = tokens[0]).part === "ID" &&
- contextNodeType === 9 && !xml &&
- Expr.relative[ tokens[1].part ] ) {
-
- context = Expr.find["ID"]( token.captures[0].replace( rbackslash, "" ), context, xml )[0];
- if ( !context ) {
- return results;
+ selector = selector.slice( tokens.shift().length );
}
- selector = selector.slice( tokens.shift().string.length );
- }
+ // Fetch a seed set for right-to-left matching
+ for ( i = matchExpr["POS"].test( selector ) ? -1 : tokens.length - 1; i >= 0; i-- ) {
+ token = tokens[i];
- findContext = ( (match = rsibling.exec( tokens[0].string )) && !match.index && context.parentNode ) || context;
+ // Abort if we hit a combinator
+ if ( Expr.relative[ (type = token.type) ] ) {
+ break;
+ }
+ if ( (find = Expr.find[ type ]) ) {
+ // Search, expanding context for leading sibling combinators
+ if ( (seed = find(
+ token.matches[0].replace( rbackslash, "" ),
+ rsibling.test( tokens[0].type ) && context.parentNode || context,
+ xml
+ )) ) {
- // Reduce the set if possible
- lastToken = "";
- for ( i = tokens.length - 1; i >= 0; i-- ) {
- token = tokens[i];
- type = token.part;
- lastToken = token.string + lastToken;
- if ( Expr.relative[ type ] ) {
- break;
- }
- if ( Expr.order.test(type) ) {
- elements = Expr.find[ type ]( token.captures[0].replace( rbackslash, "" ), findContext, xml );
- if ( elements == null ) {
- continue;
- } else {
- selector = selector.slice( 0, selector.length - lastToken.length ) +
- lastToken.replace( matchExpr[ type ], "" );
+ // If seed is empty or no tokens remain, we can return early
+ tokens.splice( i, 1 );
+ selector = seed.length && tokens.join("");
+ if ( !selector ) {
+ push.apply( results, slice.call( seed, 0 ) );
+ return results;
+ }
- if ( !selector ) {
- push.apply( results, slice.call(elements, 0) );
+ break;
}
-
- break;
}
}
}
}
- // Only loop over the given elements once
- if ( selector ) {
- matcher = compile( selector, context, xml );
- dirruns = matcher.dirruns++;
- if ( elements == null ) {
- elements = Expr.find["TAG"]( "*", (rsibling.test( selector ) && context.parentNode) || context );
- }
-
- for ( i = 0; (elem = elements[i]); i++ ) {
- cachedruns = matcher.runs++;
- if ( matcher(elem) ) {
- results.push( elem );
- }
- }
- }
-
+ // Compile and execute a filtering function
+ // Provide `match` to avoid retokenization if we modified the selector above
+ compile( selector, match )(
+ seed,
+ context,
+ xml,
+ results,
+ rsibling.test( selector )
+ );
return results;
}
if ( document.querySelectorAll ) {
(function() {
var disconnectedMatch,
oldSelect = select,
rescape = /'|\\/g,
rattributeQuotes = /\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,
- rbuggyQSA = [],
+
+ // qSa(:focus) reports false when true (Chrome 21), no need to also add to buggyMatches since matches checks buggyQSA
+ // A support test would require too much code (would include document ready)
+ rbuggyQSA = [ ":focus" ],
+
// matchesSelector(:active) reports false when true (IE9/Opera 11.5)
// A support test would require too much code (would include document ready)
// just skip matchesSelector for :active
- rbuggyMatches = [":active"],
+ rbuggyMatches = [ ":active" ],
matches = docElem.matchesSelector ||
docElem.mozMatchesSelector ||
docElem.webkitMatchesSelector ||
docElem.oMatchesSelector ||
docElem.msMatchesSelector;
@@ -5086,48 +5233,50 @@
if ( !div.querySelectorAll(":enabled").length ) {
rbuggyQSA.push(":enabled", ":disabled");
}
});
- rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
+ // rbuggyQSA always contains :focus, so no need for a length check
+ rbuggyQSA = /* rbuggyQSA.length && */ new RegExp( rbuggyQSA.join("|") );
select = function( selector, context, results, seed, xml ) {
// Only use querySelectorAll when not filtering,
// when this is not xml,
// and when no QSA bugs apply
- if ( !seed && !xml && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
- if ( context.nodeType === 9 ) {
- try {
- push.apply( results, slice.call(context.querySelectorAll( selector ), 0) );
- return results;
- } catch(qsaError) {}
+ if ( !seed && !xml && !rbuggyQSA.test( selector ) ) {
+ var groups, i,
+ old = true,
+ nid = expando,
+ newContext = context,
+ newSelector = context.nodeType === 9 && selector;
+
// qSA works strangely on Element-rooted queries
// We can work around this by specifying an extra ID on the root
// and working up from there (Thanks to Andrew Dupont for the technique)
// IE 8 doesn't work on object elements
- } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
- var groups, i, len,
- old = context.getAttribute("id"),
- nid = old || expando,
- newContext = rsibling.test( selector ) && context.parentNode || context;
+ if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
+ groups = tokenize( selector );
- if ( old ) {
- nid = nid.replace( rescape, "\\$&" );
+ if ( (old = context.getAttribute("id")) ) {
+ nid = old.replace( rescape, "\\$&" );
} else {
context.setAttribute( "id", nid );
}
+ nid = "[id='" + nid + "'] ";
- groups = tokenize(selector, context, xml);
- // Trailing space is unnecessary
- // There is always a context check
- nid = "[id='" + nid + "']";
- for ( i = 0, len = groups.length; i < len; i++ ) {
- groups[i] = nid + groups[i].selector;
+ i = groups.length;
+ while ( i-- ) {
+ groups[i] = nid + groups[i].join("");
}
+ newContext = rsibling.test( selector ) && context.parentNode || context;
+ newSelector = groups.join(",");
+ }
+
+ if ( newSelector ) {
try {
push.apply( results, slice.call( newContext.querySelectorAll(
- groups.join(",")
+ newSelector
), 0 ) );
return results;
} catch(qsaError) {
} finally {
if ( !old ) {
@@ -5148,23 +5297,23 @@
// This should fail with an exception
// Gecko does not error, returns false instead
try {
matches.call( div, "[test!='']:sizzle" );
- rbuggyMatches.push( matchExpr["PSEUDO"].source, matchExpr["POS"].source, "!=" );
+ rbuggyMatches.push( "!=", pseudos );
} catch ( e ) {}
});
- // rbuggyMatches always contains :active, so no need for a length check
+ // rbuggyMatches always contains :active and :focus, so no need for a length check
rbuggyMatches = /* rbuggyMatches.length && */ new RegExp( rbuggyMatches.join("|") );
Sizzle.matchesSelector = function( elem, expr ) {
// Make sure that attribute selectors are quoted
expr = expr.replace( rattributeQuotes, "='$1']" );
// rbuggyMatches always contains :active, so no need for an existence check
- if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && (!rbuggyQSA || !rbuggyQSA.test( expr )) ) {
+ if ( !isXML( elem ) && !rbuggyMatches.test( expr ) && !rbuggyQSA.test( expr ) ) {
try {
var ret = matches.call( elem, expr );
// IE 9's matchesSelector returns false on disconnected nodes
if ( ret || disconnectedMatch ||
@@ -5181,14 +5330,16 @@
}
})();
}
// Deprecated
-Expr.setFilters["nth"] = Expr.setFilters["eq"];
+Expr.pseudos["nth"] = Expr.pseudos["eq"];
// Back-compat
-Expr.filters = Expr.pseudos;
+function setFilters() {}
+Expr.filters = setFilters.prototype = Expr.pseudos;
+Expr.setFilters = new setFilters();
// Override sizzle attribute retrieval
Sizzle.attr = jQuery.attr;
jQuery.find = Sizzle;
jQuery.expr = Sizzle.selectors;
@@ -6393,11 +6544,11 @@
rdisplayswap = /^(none|table(?!-c[ea]).+)/,
rmargin = /^margin/,
rnumsplit = new RegExp( "^(" + core_pnum + ")(.*)$", "i" ),
rnumnonpx = new RegExp( "^(" + core_pnum + ")(?!px)[a-z%]+$", "i" ),
rrelNum = new RegExp( "^([-+])=(" + core_pnum + ")", "i" ),
- elemdisplay = {},
+ elemdisplay = { BODY: "block" },
cssShow = { position: "absolute", visibility: "hidden", display: "block" },
cssNormalTransform = {
letterSpacing: 0,
fontWeight: 400
@@ -6674,11 +6825,13 @@
computed = window.getComputedStyle( elem, null ),
style = elem.style;
if ( computed ) {
- ret = computed[ name ];
+ // getPropertyValue is only needed for .css('filter') in IE9, see #12537
+ ret = computed.getPropertyValue( name ) || computed[ name ];
+
if ( ret === "" && !jQuery.contains( elem.ownerDocument, elem ) ) {
ret = jQuery.style( elem, name );
}
// A tribute to the "awesome hack by Dean Edwards"
@@ -7121,14 +7274,14 @@
} else {
// Serialize scalar item.
add( prefix, obj );
}
}
-var // Document location
- ajaxLocation,
- // Document location segments
+var
+ // Document location
ajaxLocParts,
+ ajaxLocation,
rhash = /#.*$/,
rheaders = /^(.*?):[ \t]*([^\r\n]*)\r?$/mg, // IE leaves an \r character at EOL
// #7653, #8125, #8152: local protocol detection
rlocalProtocol = /^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,
@@ -7641,11 +7794,11 @@
}
}
// Set data for the fake xhr object
jqXHR.status = status;
- jqXHR.statusText = "" + ( nativeStatusText || statusText );
+ jqXHR.statusText = ( nativeStatusText || statusText ) + "";
// Success/Error
if ( isSuccess ) {
deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
} else {
@@ -7701,15 +7854,15 @@
s.url = ( ( url || s.url ) + "" ).replace( rhash, "" ).replace( rprotocol, ajaxLocParts[ 1 ] + "//" );
// Extract dataTypes list
s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( core_rspace );
- // Determine if a cross-domain request is in order
+ // A cross-domain request is in order when we have a protocol:host:port mismatch
if ( s.crossDomain == null ) {
parts = rurl.exec( s.url.toLowerCase() );
s.crossDomain = !!( parts &&
- ( parts[ 1 ] != ajaxLocParts[ 1 ] || parts[ 2 ] != ajaxLocParts[ 2 ] ||
+ ( parts[ 1 ] !== ajaxLocParts[ 1 ] || parts[ 2 ] !== ajaxLocParts[ 2 ] ||
( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
( ajaxLocParts[ 3 ] || ( ajaxLocParts[ 1 ] === "http:" ? 80 : 443 ) ) )
);
}
@@ -8327,11 +8480,11 @@
// When requesting binary data, IE6-9 will throw an exception
// on any attempt to access responseText (#11426)
try {
responses.text = xhr.responseText;
- } catch( _ ) {
+ } catch( e ) {
}
// Firefox throws an exception when accessing
// statusText for faulty cross-domain requests
try {
@@ -8403,16 +8556,17 @@
rfxnum = new RegExp( "^(?:([-+])=|)(" + core_pnum + ")([a-z%]*)$", "i" ),
rrun = /queueHooks$/,
animationPrefilters = [ defaultPrefilter ],
tweeners = {
"*": [function( prop, value ) {
- var end, unit, prevScale,
+ var end, unit,
tween = this.createTween( prop, value ),
parts = rfxnum.exec( value ),
target = tween.cur(),
start = +target || 0,
- scale = 1;
+ scale = 1,
+ maxIterations = 20;
if ( parts ) {
end = +parts[2];
unit = parts[3] || ( jQuery.cssNumber[ prop ] ? "" : "px" );
@@ -8424,21 +8578,19 @@
start = jQuery.css( tween.elem, prop, true ) || end || 1;
do {
// If previous iteration zeroed out, double until we get *something*
// Use a string for doubling factor so we don't accidentally see scale as unchanged below
- prevScale = scale = scale || ".5";
+ scale = scale || ".5";
// Adjust and apply
start = start / scale;
jQuery.style( tween.elem, prop, start + unit );
- // Update scale, tolerating zeroes from tween.cur()
- scale = tween.cur() / target;
-
- // Stop looping if we've hit the mark or scale is unchanged
- } while ( scale !== 1 && scale !== prevScale );
+ // Update scale, tolerating zero or NaN from tween.cur()
+ // And breaking the loop if scale is unchanged or perfect, or if we've just had enough
+ } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
}
tween.unit = unit;
tween.start = start;
// If a +=/-= token was provided, we're doing a relative animation
@@ -8481,11 +8633,13 @@
delete tick.elem;
}),
tick = function() {
var currentTime = fxNow || createFxNow(),
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
- percent = 1 - ( remaining / animation.duration || 0 ),
+ // archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
+ temp = remaining / animation.duration || 0,
+ percent = 1 - temp,
index = 0,
length = animation.tweens.length;
for ( ; index < length ; index++ ) {
animation.tweens[ index ].run( percent );
@@ -8633,11 +8787,11 @@
}
}
});
function defaultPrefilter( elem, props, opts ) {
- var index, prop, value, length, dataShow, tween, hooks, oldfire,
+ var index, prop, value, length, dataShow, toggle, tween, hooks, oldfire,
anim = this,
style = elem.style,
orig = {},
handled = [],
hidden = elem.nodeType && isHidden( elem );
@@ -8707,20 +8861,29 @@
// show/hide pass
for ( index in props ) {
value = props[ index ];
if ( rfxtypes.exec( value ) ) {
delete props[ index ];
+ toggle = toggle || value === "toggle";
if ( value === ( hidden ? "hide" : "show" ) ) {
continue;
}
handled.push( index );
}
}
length = handled.length;
if ( length ) {
dataShow = jQuery._data( elem, "fxshow" ) || jQuery._data( elem, "fxshow", {} );
+ if ( "hidden" in dataShow ) {
+ hidden = dataShow.hidden;
+ }
+
+ // store state if its toggle - enables .stop().toggle() to "reverse"
+ if ( toggle ) {
+ dataShow.hidden = !hidden;
+ }
if ( hidden ) {
jQuery( elem ).show();
} else {
anim.done(function() {
jQuery( elem ).hide();
@@ -9013,10 +9176,12 @@
jQuery.fx.tick = function() {
var timer,
timers = jQuery.timers,
i = 0;
+ fxNow = jQuery.now();
+
for ( ; i < timers.length; i++ ) {
timer = timers[ i ];
// Checks the timer has not already been removed
if ( !timer() && timers[ i ] === timer ) {
timers.splice( i--, 1 );
@@ -9024,10 +9189,11 @@
}
if ( !timers.length ) {
jQuery.fx.stop();
}
+ fxNow = undefined;
};
jQuery.fx.timer = function( timer ) {
if ( timer() && jQuery.timers.push( timer ) && !timerId ) {
timerId = setInterval( jQuery.fx.tick, jQuery.fx.interval );
@@ -9067,11 +9233,12 @@
this.each(function( i ) {
jQuery.offset.setOffset( this, options, i );
});
}
- var box, docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft, top, left,
+ var docElem, body, win, clientTop, clientLeft, scrollTop, scrollLeft,
+ box = { top: 0, left: 0 },
elem = this[ 0 ],
doc = elem && elem.ownerDocument;
if ( !doc ) {
return;
@@ -9081,24 +9248,28 @@
return jQuery.offset.bodyOffset( elem );
}
docElem = doc.documentElement;
- // Make sure we're not dealing with a disconnected DOM node
+ // Make sure it's not a disconnected DOM node
if ( !jQuery.contains( docElem, elem ) ) {
- return { top: 0, left: 0 };
+ return box;
}
- box = elem.getBoundingClientRect();
+ // If we don't have gBCR, just use 0,0 rather than error
+ // BlackBerry 5, iOS 3 (original iPhone)
+ if ( typeof elem.getBoundingClientRect !== "undefined" ) {
+ box = elem.getBoundingClientRect();
+ }
win = getWindow( doc );
clientTop = docElem.clientTop || body.clientTop || 0;
clientLeft = docElem.clientLeft || body.clientLeft || 0;
scrollTop = win.pageYOffset || docElem.scrollTop;
scrollLeft = win.pageXOffset || docElem.scrollLeft;
- top = box.top + scrollTop - clientTop;
- left = box.left + scrollLeft - clientLeft;
-
- return { top: top, left: left };
+ return {
+ top: box.top + scrollTop - clientTop,
+ left: box.left + scrollLeft - clientLeft
+ };
};
jQuery.offset = {
bodyOffset: function( body ) {