2009-01-11 20:45:04 +01:00
|
|
|
/*!
|
2009-02-20 20:52:38 +01:00
|
|
|
* Sizzle CSS Selector Engine - v1.0
|
2009-01-11 20:45:04 +01:00
|
|
|
* Copyright 2009, The Dojo Foundation
|
|
|
|
* Released under the MIT, BSD, and GPL Licenses.
|
|
|
|
* More information: http://sizzlejs.com/
|
2008-12-20 02:19:17 +01:00
|
|
|
*/
|
|
|
|
(function(){
|
|
|
|
|
2009-02-15 23:46:54 +01:00
|
|
|
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,
|
2009-01-11 20:45:04 +01:00
|
|
|
done = 0,
|
2009-05-04 02:05:04 +02:00
|
|
|
toString = Object.prototype.toString,
|
|
|
|
hasDuplicate = false;
|
2008-12-20 02:19:17 +01:00
|
|
|
|
|
|
|
var Sizzle = function(selector, context, results, seed) {
|
|
|
|
results = results || [];
|
2009-02-25 05:08:04 +01:00
|
|
|
var origContext = context = context || document;
|
2008-12-20 02:19:17 +01:00
|
|
|
|
2009-02-25 05:08:04 +01:00
|
|
|
if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
|
2008-12-20 02:19:17 +01:00
|
|
|
return [];
|
2009-02-25 05:08:04 +01:00
|
|
|
}
|
2009-05-04 02:05:04 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( !selector || typeof selector !== "string" ) {
|
|
|
|
return results;
|
|
|
|
}
|
|
|
|
|
2009-02-25 05:08:04 +01:00
|
|
|
var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context);
|
2009-05-04 02:05:04 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
// Reset the position of the chunker regexp (start from head)
|
|
|
|
chunker.lastIndex = 0;
|
2009-05-04 02:05:04 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
while ( (m = chunker.exec(selector)) !== null ) {
|
|
|
|
parts.push( m[1] );
|
2009-05-04 02:05:04 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( m[2] ) {
|
|
|
|
extra = RegExp.rightContext;
|
|
|
|
break;
|
2008-04-30 00:52:36 +02:00
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2009-01-19 19:09:11 +01:00
|
|
|
if ( parts.length > 1 && origPOS.exec( selector ) ) {
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
|
2009-01-19 19:09:11 +01:00
|
|
|
set = posProcess( parts[0] + parts[1], context );
|
2008-12-20 02:19:17 +01:00
|
|
|
} else {
|
2008-12-20 23:45:11 +01:00
|
|
|
set = Expr.relative[ parts[0] ] ?
|
2008-12-20 02:19:17 +01:00
|
|
|
[ context ] :
|
|
|
|
Sizzle( parts.shift(), context );
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
while ( parts.length ) {
|
|
|
|
selector = parts.shift();
|
2009-01-19 19:09:11 +01:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( Expr.relative[ selector ] )
|
|
|
|
selector += parts.shift();
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2009-01-19 19:09:11 +01:00
|
|
|
set = posProcess( selector, set );
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2009-02-25 05:08:04 +01:00
|
|
|
// Take a shortcut and set the context if the root selector is an ID
|
|
|
|
// (but not if it'll be faster if the inner selector is an ID)
|
|
|
|
if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
|
|
|
|
Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
|
|
|
|
var ret = Sizzle.find( parts.shift(), context, contextXML );
|
|
|
|
context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2009-02-25 05:08:04 +01:00
|
|
|
if ( context ) {
|
|
|
|
var ret = seed ?
|
|
|
|
{ expr: parts.pop(), set: makeArray(seed) } :
|
2009-02-26 02:15:54 +01:00
|
|
|
Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
|
2009-02-25 05:08:04 +01:00
|
|
|
set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2009-02-25 05:08:04 +01:00
|
|
|
if ( parts.length > 0 ) {
|
|
|
|
checkSet = makeArray(set);
|
2008-12-20 02:19:17 +01:00
|
|
|
} else {
|
2009-02-25 05:08:04 +01:00
|
|
|
prune = false;
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2009-02-25 05:08:04 +01:00
|
|
|
while ( parts.length ) {
|
|
|
|
var cur = parts.pop(), pop = cur;
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2009-02-25 05:08:04 +01:00
|
|
|
if ( !Expr.relative[ cur ] ) {
|
|
|
|
cur = "";
|
|
|
|
} else {
|
|
|
|
pop = parts.pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( pop == null ) {
|
|
|
|
pop = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
Expr.relative[ cur ]( checkSet, pop, contextXML );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
checkSet = parts = [];
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
2008-12-20 23:45:11 +01:00
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 23:45:11 +01:00
|
|
|
if ( !checkSet ) {
|
|
|
|
checkSet = set;
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( !checkSet ) {
|
|
|
|
throw "Syntax error, unrecognized expression: " + (cur || selector);
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2009-01-11 20:45:04 +01:00
|
|
|
if ( toString.call(checkSet) === "[object Array]" ) {
|
2009-01-07 01:13:57 +01:00
|
|
|
if ( !prune ) {
|
2009-03-17 21:39:29 +01:00
|
|
|
results.push.apply( results, checkSet );
|
2009-02-25 05:08:04 +01:00
|
|
|
} else if ( context && context.nodeType === 1 ) {
|
2008-12-20 02:19:17 +01:00
|
|
|
for ( var i = 0; checkSet[i] != null; i++ ) {
|
|
|
|
if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
|
2009-03-17 21:39:29 +01:00
|
|
|
results.push( set[i] );
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for ( var i = 0; checkSet[i] != null; i++ ) {
|
|
|
|
if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
|
2009-03-17 21:39:29 +01:00
|
|
|
results.push( set[i] );
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
makeArray( checkSet, results );
|
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( extra ) {
|
2009-02-25 05:08:04 +01:00
|
|
|
Sizzle( extra, origContext, results, seed );
|
2009-02-25 16:19:08 +01:00
|
|
|
Sizzle.uniqueSort( results );
|
|
|
|
}
|
|
|
|
|
|
|
|
return results;
|
|
|
|
};
|
2009-02-14 17:59:10 +01:00
|
|
|
|
2009-02-25 16:19:08 +01:00
|
|
|
Sizzle.uniqueSort = function(results){
|
|
|
|
if ( sortOrder ) {
|
|
|
|
hasDuplicate = false;
|
2009-03-17 21:39:29 +01:00
|
|
|
results.sort(sortOrder);
|
2009-02-14 17:59:10 +01:00
|
|
|
|
2009-02-25 16:19:08 +01:00
|
|
|
if ( hasDuplicate ) {
|
|
|
|
for ( var i = 1; i < results.length; i++ ) {
|
|
|
|
if ( results[i] === results[i-1] ) {
|
2009-03-17 21:39:29 +01:00
|
|
|
results.splice(i--, 1);
|
2009-02-14 17:59:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
};
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
Sizzle.matches = function(expr, set){
|
|
|
|
return Sizzle(expr, null, null, set);
|
|
|
|
};
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2009-01-22 00:19:30 +01:00
|
|
|
Sizzle.find = function(expr, context, isXML){
|
2008-12-20 02:19:17 +01:00
|
|
|
var set, match;
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( !expr ) {
|
|
|
|
return [];
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
|
2009-01-05 01:21:13 +01:00
|
|
|
var type = Expr.order[i], match;
|
2009-05-04 02:05:04 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( (match = Expr.match[ type ].exec( expr )) ) {
|
|
|
|
var left = RegExp.leftContext;
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( left.substr( left.length - 1 ) !== "\\" ) {
|
|
|
|
match[1] = (match[1] || "").replace(/\\/g, "");
|
2009-01-22 00:19:30 +01:00
|
|
|
set = Expr.find[ type ]( match, context, isXML );
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( set != null ) {
|
|
|
|
expr = expr.replace( Expr.match[ type ], "" );
|
|
|
|
break;
|
2008-04-30 00:52:36 +02:00
|
|
|
}
|
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( !set ) {
|
|
|
|
set = context.getElementsByTagName("*");
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
return {set: set, expr: expr};
|
|
|
|
};
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2009-01-07 01:13:57 +01:00
|
|
|
Sizzle.filter = function(expr, set, inplace, not){
|
2009-02-16 19:23:59 +01:00
|
|
|
var old = expr, result = [], curLoop = set, match, anyFound,
|
|
|
|
isXMLFilter = set && set[0] && isXML(set[0]);
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
while ( expr && set.length ) {
|
|
|
|
for ( var type in Expr.filter ) {
|
|
|
|
if ( (match = Expr.match[ type ].exec( expr )) != null ) {
|
2009-01-19 19:09:11 +01:00
|
|
|
var filter = Expr.filter[ type ], found, item;
|
2009-01-05 01:21:13 +01:00
|
|
|
anyFound = false;
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( curLoop == result ) {
|
|
|
|
result = [];
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( Expr.preFilter[ type ] ) {
|
2009-02-16 19:23:59 +01:00
|
|
|
match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2009-01-07 01:13:57 +01:00
|
|
|
if ( !match ) {
|
|
|
|
anyFound = found = true;
|
2009-01-12 15:45:58 +01:00
|
|
|
} else if ( match === true ) {
|
|
|
|
continue;
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2009-01-07 01:13:57 +01:00
|
|
|
if ( match ) {
|
2009-01-19 19:09:11 +01:00
|
|
|
for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
|
2009-01-07 01:13:57 +01:00
|
|
|
if ( item ) {
|
2009-01-19 19:09:11 +01:00
|
|
|
found = filter( item, match, i, curLoop );
|
2009-01-07 01:13:57 +01:00
|
|
|
var pass = not ^ !!found;
|
|
|
|
|
|
|
|
if ( inplace && found != null ) {
|
|
|
|
if ( pass ) {
|
|
|
|
anyFound = true;
|
|
|
|
} else {
|
|
|
|
curLoop[i] = false;
|
|
|
|
}
|
|
|
|
} else if ( pass ) {
|
|
|
|
result.push( item );
|
2008-12-20 02:19:17 +01:00
|
|
|
anyFound = true;
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( found !== undefined ) {
|
|
|
|
if ( !inplace ) {
|
|
|
|
curLoop = result;
|
2008-04-30 00:52:36 +02:00
|
|
|
}
|
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
expr = expr.replace( Expr.match[ type ], "" );
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( !anyFound ) {
|
|
|
|
return [];
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
break;
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
// Improper expression
|
|
|
|
if ( expr == old ) {
|
2009-01-05 01:21:13 +01:00
|
|
|
if ( anyFound == null ) {
|
|
|
|
throw "Syntax error, unrecognized expression: " + expr;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
old = expr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return curLoop;
|
|
|
|
};
|
|
|
|
|
|
|
|
var Expr = Sizzle.selectors = {
|
|
|
|
order: [ "ID", "NAME", "TAG" ],
|
|
|
|
match: {
|
2009-01-11 20:45:04 +01:00
|
|
|
ID: /#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
|
|
|
|
CLASS: /\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,
|
|
|
|
NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,
|
2009-01-13 17:40:19 +01:00
|
|
|
ATTR: /\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
|
2009-01-11 20:45:04 +01:00
|
|
|
TAG: /^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,
|
|
|
|
CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
|
|
|
|
POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
|
|
|
|
PSEUDO: /:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/
|
2008-04-30 00:52:36 +02:00
|
|
|
},
|
2008-12-20 02:19:17 +01:00
|
|
|
attrMap: {
|
2009-01-11 20:45:04 +01:00
|
|
|
"class": "className",
|
|
|
|
"for": "htmlFor"
|
2008-12-20 02:19:17 +01:00
|
|
|
},
|
2009-01-13 17:40:19 +01:00
|
|
|
attrHandle: {
|
|
|
|
href: function(elem){
|
|
|
|
return elem.getAttribute("href");
|
|
|
|
}
|
|
|
|
},
|
2008-12-20 02:19:17 +01:00
|
|
|
relative: {
|
2009-02-10 01:28:38 +01:00
|
|
|
"+": function(checkSet, part, isXML){
|
2009-02-16 16:36:42 +01:00
|
|
|
var isPartStr = typeof part === "string",
|
2009-02-10 01:28:38 +01:00
|
|
|
isTag = isPartStr && !/\W/.test(part),
|
|
|
|
isPartStrNotTag = isPartStr && !isTag;
|
2009-02-16 16:36:42 +01:00
|
|
|
|
|
|
|
if ( isTag && !isXML ) {
|
|
|
|
part = part.toUpperCase();
|
|
|
|
}
|
|
|
|
|
2009-02-10 01:28:38 +01:00
|
|
|
for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
|
2009-02-16 16:36:42 +01:00
|
|
|
if ( (elem = checkSet[i]) ) {
|
|
|
|
while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
|
|
|
|
|
2009-02-10 01:28:38 +01:00
|
|
|
checkSet[i] = isPartStrNotTag || elem && elem.nodeName === part ?
|
2009-02-16 16:36:42 +01:00
|
|
|
elem || false :
|
|
|
|
elem === part;
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
}
|
2009-02-16 16:36:42 +01:00
|
|
|
|
|
|
|
if ( isPartStrNotTag ) {
|
2008-12-20 02:19:17 +01:00
|
|
|
Sizzle.filter( part, checkSet, true );
|
|
|
|
}
|
|
|
|
},
|
2009-01-11 20:45:04 +01:00
|
|
|
">": function(checkSet, part, isXML){
|
2009-02-16 16:36:42 +01:00
|
|
|
var isPartStr = typeof part === "string";
|
|
|
|
|
|
|
|
if ( isPartStr && !/\W/.test(part) ) {
|
2009-01-11 20:45:04 +01:00
|
|
|
part = isXML ? part : part.toUpperCase();
|
2008-12-20 02:19:17 +01:00
|
|
|
|
|
|
|
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
|
|
|
var elem = checkSet[i];
|
|
|
|
if ( elem ) {
|
|
|
|
var parent = elem.parentNode;
|
|
|
|
checkSet[i] = parent.nodeName === part ? parent : false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
|
|
|
var elem = checkSet[i];
|
|
|
|
if ( elem ) {
|
2009-02-16 16:36:42 +01:00
|
|
|
checkSet[i] = isPartStr ?
|
2008-12-20 02:19:17 +01:00
|
|
|
elem.parentNode :
|
|
|
|
elem.parentNode === part;
|
|
|
|
}
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2009-02-16 16:36:42 +01:00
|
|
|
if ( isPartStr ) {
|
2008-12-20 02:19:17 +01:00
|
|
|
Sizzle.filter( part, checkSet, true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2009-01-11 20:45:04 +01:00
|
|
|
"": function(checkSet, part, isXML){
|
2009-02-10 01:28:38 +01:00
|
|
|
var doneName = done++, checkFn = dirCheck;
|
2008-12-20 02:19:17 +01:00
|
|
|
|
|
|
|
if ( !part.match(/\W/) ) {
|
2009-01-11 20:45:04 +01:00
|
|
|
var nodeCheck = part = isXML ? part : part.toUpperCase();
|
2008-12-20 02:19:17 +01:00
|
|
|
checkFn = dirNodeCheck;
|
|
|
|
}
|
|
|
|
|
2009-01-13 17:40:19 +01:00
|
|
|
checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
|
2008-12-20 02:19:17 +01:00
|
|
|
},
|
2009-01-11 20:45:04 +01:00
|
|
|
"~": function(checkSet, part, isXML){
|
2009-02-10 01:28:38 +01:00
|
|
|
var doneName = done++, checkFn = dirCheck;
|
2008-12-20 02:19:17 +01:00
|
|
|
|
|
|
|
if ( typeof part === "string" && !part.match(/\W/) ) {
|
2009-01-11 20:45:04 +01:00
|
|
|
var nodeCheck = part = isXML ? part : part.toUpperCase();
|
2008-12-20 02:19:17 +01:00
|
|
|
checkFn = dirNodeCheck;
|
|
|
|
}
|
|
|
|
|
2009-01-13 17:40:19 +01:00
|
|
|
checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
find: {
|
2009-01-22 00:19:30 +01:00
|
|
|
ID: function(match, context, isXML){
|
|
|
|
if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
2008-12-20 02:19:17 +01:00
|
|
|
var m = context.getElementById(match[1]);
|
|
|
|
return m ? [m] : [];
|
|
|
|
}
|
|
|
|
},
|
2009-01-22 00:19:30 +01:00
|
|
|
NAME: function(match, context, isXML){
|
2009-02-14 23:24:55 +01:00
|
|
|
if ( typeof context.getElementsByName !== "undefined" ) {
|
2009-02-15 23:33:19 +01:00
|
|
|
var ret = [], results = context.getElementsByName(match[1]);
|
|
|
|
|
|
|
|
for ( var i = 0, l = results.length; i < l; i++ ) {
|
|
|
|
if ( results[i].getAttribute("name") === match[1] ) {
|
|
|
|
ret.push( results[i] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-14 23:24:55 +01:00
|
|
|
return ret.length === 0 ? null : ret;
|
2009-01-22 00:19:30 +01:00
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
},
|
|
|
|
TAG: function(match, context){
|
|
|
|
return context.getElementsByTagName(match[1]);
|
2008-04-30 00:52:36 +02:00
|
|
|
}
|
|
|
|
},
|
2008-12-20 02:19:17 +01:00
|
|
|
preFilter: {
|
2009-02-16 19:23:59 +01:00
|
|
|
CLASS: function(match, curLoop, inplace, result, not, isXML){
|
2009-01-07 01:13:57 +01:00
|
|
|
match = " " + match[1].replace(/\\/g, "") + " ";
|
|
|
|
|
2009-02-16 19:23:59 +01:00
|
|
|
if ( isXML ) {
|
|
|
|
return match;
|
|
|
|
}
|
|
|
|
|
2009-02-10 01:28:38 +01:00
|
|
|
for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
|
2009-01-20 20:47:15 +01:00
|
|
|
if ( elem ) {
|
2009-02-10 01:28:38 +01:00
|
|
|
if ( not ^ (elem.className && (" " + elem.className + " ").indexOf(match) >= 0) ) {
|
2009-01-19 19:09:11 +01:00
|
|
|
if ( !inplace )
|
2009-01-20 20:47:15 +01:00
|
|
|
result.push( elem );
|
2009-01-19 19:09:11 +01:00
|
|
|
} else if ( inplace ) {
|
|
|
|
curLoop[i] = false;
|
|
|
|
}
|
2009-01-07 01:13:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2008-12-20 02:19:17 +01:00
|
|
|
},
|
|
|
|
ID: function(match){
|
2009-01-11 20:45:04 +01:00
|
|
|
return match[1].replace(/\\/g, "");
|
2008-12-20 02:19:17 +01:00
|
|
|
},
|
2009-01-11 20:45:04 +01:00
|
|
|
TAG: function(match, curLoop){
|
2009-01-19 19:09:11 +01:00
|
|
|
for ( var i = 0; curLoop[i] === false; i++ ){}
|
|
|
|
return curLoop[i] && isXML(curLoop[i]) ? match[1] : match[1].toUpperCase();
|
2008-12-20 02:19:17 +01:00
|
|
|
},
|
|
|
|
CHILD: function(match){
|
|
|
|
if ( match[1] == "nth" ) {
|
|
|
|
// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
|
|
|
|
var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
|
|
|
|
match[2] == "even" && "2n" || match[2] == "odd" && "2n+1" ||
|
|
|
|
!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
|
|
|
|
|
|
|
|
// calculate the numbers (first)n+(last) including if they are negative
|
|
|
|
match[2] = (test[1] + (test[2] || 1)) - 0;
|
|
|
|
match[3] = test[3] - 0;
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
// TODO: Move to normal caching system
|
2009-02-10 01:28:38 +01:00
|
|
|
match[0] = done++;
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
return match;
|
|
|
|
},
|
2009-02-16 19:23:59 +01:00
|
|
|
ATTR: function(match, curLoop, inplace, result, not, isXML){
|
2009-01-19 19:09:11 +01:00
|
|
|
var name = match[1].replace(/\\/g, "");
|
2009-05-04 02:05:04 +02:00
|
|
|
|
2009-02-16 19:23:59 +01:00
|
|
|
if ( !isXML && Expr.attrMap[name] ) {
|
2008-12-20 02:19:17 +01:00
|
|
|
match[1] = Expr.attrMap[name];
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( match[2] === "~=" ) {
|
|
|
|
match[4] = " " + match[4] + " ";
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
return match;
|
|
|
|
},
|
2009-01-07 01:13:57 +01:00
|
|
|
PSEUDO: function(match, curLoop, inplace, result, not){
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( match[1] === "not" ) {
|
2009-01-05 01:21:13 +01:00
|
|
|
// If we're dealing with a complex expression, or a simple one
|
2009-02-15 22:13:33 +01:00
|
|
|
if ( match[3].match(chunker).length > 1 || /^\w/.test(match[3]) ) {
|
2009-01-07 01:13:57 +01:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2009-02-16 18:58:33 +01:00
|
|
|
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
|
2009-01-12 15:45:58 +01:00
|
|
|
return true;
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
2009-05-04 02:05:04 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
return match;
|
|
|
|
},
|
|
|
|
POS: function(match){
|
|
|
|
match.unshift( true );
|
|
|
|
return match;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
filters: {
|
|
|
|
enabled: function(elem){
|
|
|
|
return elem.disabled === false && elem.type !== "hidden";
|
|
|
|
},
|
|
|
|
disabled: function(elem){
|
|
|
|
return elem.disabled === true;
|
|
|
|
},
|
|
|
|
checked: function(elem){
|
|
|
|
return elem.checked === true;
|
|
|
|
},
|
|
|
|
selected: function(elem){
|
|
|
|
// Accessing this property makes selected-by-default
|
|
|
|
// options in Safari work properly
|
|
|
|
elem.parentNode.selectedIndex;
|
|
|
|
return elem.selected === true;
|
|
|
|
},
|
|
|
|
parent: function(elem){
|
|
|
|
return !!elem.firstChild;
|
|
|
|
},
|
|
|
|
empty: function(elem){
|
|
|
|
return !elem.firstChild;
|
|
|
|
},
|
|
|
|
has: function(elem, i, match){
|
|
|
|
return !!Sizzle( match[3], elem ).length;
|
|
|
|
},
|
|
|
|
header: function(elem){
|
|
|
|
return /h\d/i.test( elem.nodeName );
|
|
|
|
},
|
|
|
|
text: function(elem){
|
|
|
|
return "text" === elem.type;
|
|
|
|
},
|
|
|
|
radio: function(elem){
|
|
|
|
return "radio" === elem.type;
|
|
|
|
},
|
|
|
|
checkbox: function(elem){
|
|
|
|
return "checkbox" === elem.type;
|
|
|
|
},
|
|
|
|
file: function(elem){
|
|
|
|
return "file" === elem.type;
|
|
|
|
},
|
|
|
|
password: function(elem){
|
|
|
|
return "password" === elem.type;
|
|
|
|
},
|
|
|
|
submit: function(elem){
|
|
|
|
return "submit" === elem.type;
|
|
|
|
},
|
|
|
|
image: function(elem){
|
|
|
|
return "image" === elem.type;
|
|
|
|
},
|
|
|
|
reset: function(elem){
|
|
|
|
return "reset" === elem.type;
|
|
|
|
},
|
|
|
|
button: function(elem){
|
|
|
|
return "button" === elem.type || elem.nodeName.toUpperCase() === "BUTTON";
|
|
|
|
},
|
|
|
|
input: function(elem){
|
|
|
|
return /input|select|textarea|button/i.test(elem.nodeName);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
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;
|
|
|
|
},
|
|
|
|
lt: function(elem, i, match){
|
|
|
|
return i < match[3] - 0;
|
|
|
|
},
|
|
|
|
gt: function(elem, i, match){
|
|
|
|
return i > match[3] - 0;
|
|
|
|
},
|
|
|
|
nth: function(elem, i, match){
|
|
|
|
return match[3] - 0 == i;
|
|
|
|
},
|
|
|
|
eq: function(elem, i, match){
|
|
|
|
return match[3] - 0 == i;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
filter: {
|
2009-02-16 18:58:33 +01:00
|
|
|
PSEUDO: function(elem, match, i, array){
|
|
|
|
var name = match[1], filter = Expr.filters[ name ];
|
|
|
|
|
|
|
|
if ( filter ) {
|
|
|
|
return filter( elem, i, match, array );
|
|
|
|
} else if ( name === "contains" ) {
|
|
|
|
return (elem.textContent || elem.innerText || "").indexOf(match[3]) >= 0;
|
|
|
|
} else if ( name === "not" ) {
|
|
|
|
var not = match[3];
|
|
|
|
|
|
|
|
for ( var i = 0, l = not.length; i < l; i++ ) {
|
|
|
|
if ( not[i] === elem ) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
},
|
2008-12-20 02:19:17 +01:00
|
|
|
CHILD: function(elem, match){
|
2009-02-10 01:28:38 +01:00
|
|
|
var type = match[1], node = elem;
|
|
|
|
switch (type) {
|
|
|
|
case 'only':
|
|
|
|
case 'first':
|
|
|
|
while (node = node.previousSibling) {
|
|
|
|
if ( node.nodeType === 1 ) return false;
|
|
|
|
}
|
|
|
|
if ( type == 'first') return true;
|
|
|
|
node = elem;
|
|
|
|
case 'last':
|
|
|
|
while (node = node.nextSibling) {
|
|
|
|
if ( node.nodeType === 1 ) return false;
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
return true;
|
2009-02-10 01:28:38 +01:00
|
|
|
case 'nth':
|
|
|
|
var first = match[2], last = match[3];
|
2008-12-20 02:19:17 +01:00
|
|
|
|
2009-02-10 01:28:38 +01:00
|
|
|
if ( first == 1 && last == 0 ) {
|
|
|
|
return true;
|
|
|
|
}
|
2009-05-04 02:05:04 +02:00
|
|
|
|
2009-02-10 01:28:38 +01:00
|
|
|
var doneName = match[0],
|
|
|
|
parent = elem.parentNode;
|
2009-05-04 02:05:04 +02:00
|
|
|
|
2009-02-10 01:28:38 +01:00
|
|
|
if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
|
|
|
|
var count = 0;
|
|
|
|
for ( node = parent.firstChild; node; node = node.nextSibling ) {
|
|
|
|
if ( node.nodeType === 1 ) {
|
|
|
|
node.nodeIndex = ++count;
|
|
|
|
}
|
2009-05-04 02:05:04 +02:00
|
|
|
}
|
2009-02-10 01:28:38 +01:00
|
|
|
parent.sizcache = doneName;
|
|
|
|
}
|
2009-05-04 02:05:04 +02:00
|
|
|
|
2009-02-10 01:28:38 +01:00
|
|
|
var diff = elem.nodeIndex - last;
|
|
|
|
if ( first == 0 ) {
|
|
|
|
return diff == 0;
|
|
|
|
} else {
|
|
|
|
return ( diff % first == 0 && diff / first >= 0 );
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ID: function(elem, match){
|
|
|
|
return elem.nodeType === 1 && elem.getAttribute("id") === match;
|
|
|
|
},
|
|
|
|
TAG: function(elem, match){
|
|
|
|
return (match === "*" && elem.nodeType === 1) || elem.nodeName === match;
|
|
|
|
},
|
|
|
|
CLASS: function(elem, match){
|
2009-02-16 19:23:59 +01:00
|
|
|
return (" " + (elem.className || elem.getAttribute("class")) + " ")
|
|
|
|
.indexOf( match ) > -1;
|
2008-12-20 02:19:17 +01:00
|
|
|
},
|
|
|
|
ATTR: function(elem, match){
|
2009-02-09 16:18:07 +01:00
|
|
|
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];
|
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
return result == null ?
|
2009-01-21 23:36:21 +01:00
|
|
|
type === "!=" :
|
2008-12-20 02:19:17 +01:00
|
|
|
type === "=" ?
|
|
|
|
value === check :
|
|
|
|
type === "*=" ?
|
|
|
|
value.indexOf(check) >= 0 :
|
|
|
|
type === "~=" ?
|
|
|
|
(" " + value + " ").indexOf(check) >= 0 :
|
2009-02-09 16:01:23 +01:00
|
|
|
!check ?
|
2009-02-09 16:18:07 +01:00
|
|
|
value && result !== false :
|
2008-12-20 02:19:17 +01:00
|
|
|
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;
|
|
|
|
},
|
|
|
|
POS: function(elem, match, i, array){
|
|
|
|
var name = match[2], filter = Expr.setFilters[ name ];
|
|
|
|
|
|
|
|
if ( filter ) {
|
|
|
|
return filter( elem, i, match, array );
|
2008-04-30 00:52:36 +02:00
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-01-19 19:09:11 +01:00
|
|
|
var origPOS = Expr.match.POS;
|
|
|
|
|
2009-01-05 01:21:13 +01:00
|
|
|
for ( var type in Expr.match ) {
|
2009-02-26 19:00:41 +01:00
|
|
|
Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
|
2009-01-05 01:21:13 +01:00
|
|
|
}
|
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
var makeArray = function(array, results) {
|
|
|
|
array = Array.prototype.slice.call( array );
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( results ) {
|
2009-03-17 21:39:29 +01:00
|
|
|
results.push.apply( results, array );
|
2008-12-20 02:19:17 +01:00
|
|
|
return results;
|
|
|
|
}
|
2009-05-04 02:05:04 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
return array;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Perform a simple check to determine if the browser is capable of
|
|
|
|
// converting a NodeList to an array using builtin methods.
|
|
|
|
try {
|
|
|
|
Array.prototype.slice.call( document.documentElement.childNodes );
|
|
|
|
|
|
|
|
// Provide a fallback method if it does not work
|
|
|
|
} catch(e){
|
|
|
|
makeArray = function(array, results) {
|
|
|
|
var ret = results || [];
|
|
|
|
|
2009-01-11 20:45:04 +01:00
|
|
|
if ( toString.call(array) === "[object Array]" ) {
|
2008-12-20 02:19:17 +01:00
|
|
|
Array.prototype.push.apply( ret, array );
|
|
|
|
} else {
|
|
|
|
if ( typeof array.length === "number" ) {
|
|
|
|
for ( var i = 0, l = array.length; i < l; i++ ) {
|
|
|
|
ret.push( array[i] );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for ( var i = 0; array[i]; i++ ) {
|
|
|
|
ret.push( array[i] );
|
2008-04-30 00:52:36 +02:00
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2009-02-14 17:59:10 +01:00
|
|
|
var sortOrder;
|
|
|
|
|
2009-02-17 18:43:05 +01:00
|
|
|
if ( document.documentElement.compareDocumentPosition ) {
|
|
|
|
sortOrder = function( a, b ) {
|
|
|
|
var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
|
|
|
|
if ( ret === 0 ) {
|
|
|
|
hasDuplicate = true;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
};
|
2009-02-17 18:51:50 +01:00
|
|
|
} else if ( "sourceIndex" in document.documentElement ) {
|
2009-02-14 17:59:10 +01:00
|
|
|
sortOrder = function( a, b ) {
|
2009-02-17 18:51:50 +01:00
|
|
|
var ret = a.sourceIndex - b.sourceIndex;
|
2009-02-14 17:59:10 +01:00
|
|
|
if ( ret === 0 ) {
|
|
|
|
hasDuplicate = true;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
};
|
2009-02-17 18:51:50 +01:00
|
|
|
} else if ( document.createRange ) {
|
2009-02-14 17:59:10 +01:00
|
|
|
sortOrder = function( a, b ) {
|
2009-02-17 18:51:50 +01:00
|
|
|
var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
|
|
|
|
aRange.selectNode(a);
|
|
|
|
aRange.collapse(true);
|
|
|
|
bRange.selectNode(b);
|
|
|
|
bRange.collapse(true);
|
|
|
|
var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
|
2009-02-14 17:59:10 +01:00
|
|
|
if ( ret === 0 ) {
|
|
|
|
hasDuplicate = true;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
// Check to see if the browser returns elements by name when
|
|
|
|
// querying by getElementById (and provide a workaround)
|
|
|
|
(function(){
|
|
|
|
// We're going to inject a fake input element with a specified name
|
2009-03-17 21:39:29 +01:00
|
|
|
var form = document.createElement("div"),
|
2008-12-20 02:19:17 +01:00
|
|
|
id = "script" + (new Date).getTime();
|
2009-03-17 21:39:29 +01:00
|
|
|
form.innerHTML = "<a name='" + id + "'/>";
|
2008-12-20 02:19:17 +01:00
|
|
|
|
|
|
|
// Inject it into the root element, check its status, and remove it quickly
|
|
|
|
var root = document.documentElement;
|
|
|
|
root.insertBefore( form, root.firstChild );
|
|
|
|
|
|
|
|
// The workaround has to do additional checks after a getElementById
|
|
|
|
// Which slows things down for other browsers (hence the branching)
|
|
|
|
if ( !!document.getElementById( id ) ) {
|
2009-01-22 00:56:15 +01:00
|
|
|
Expr.find.ID = function(match, context, isXML){
|
|
|
|
if ( typeof context.getElementById !== "undefined" && !isXML ) {
|
2008-12-20 02:19:17 +01:00
|
|
|
var m = context.getElementById(match[1]);
|
2009-01-22 00:56:15 +01:00
|
|
|
return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Expr.filter.ID = function(elem, match){
|
2009-01-22 00:56:15 +01:00
|
|
|
var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
|
2008-12-20 02:19:17 +01:00
|
|
|
return elem.nodeType === 1 && node && node.nodeValue === match;
|
|
|
|
};
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
root.removeChild( form );
|
2009-05-04 02:05:04 +02:00
|
|
|
root = form = null; // release memory in IE
|
2008-12-20 02:19:17 +01:00
|
|
|
})();
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
(function(){
|
2009-01-13 17:40:19 +01:00
|
|
|
// Check to see if the browser returns only elements
|
|
|
|
// when doing getElementsByTagName("*")
|
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
// Create a fake element
|
|
|
|
var div = document.createElement("div");
|
|
|
|
div.appendChild( document.createComment("") );
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
// Make sure no comments are found
|
|
|
|
if ( div.getElementsByTagName("*").length > 0 ) {
|
|
|
|
Expr.find.TAG = function(match, context){
|
|
|
|
var results = context.getElementsByTagName(match[1]);
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
// Filter out possible comments
|
|
|
|
if ( match[1] === "*" ) {
|
|
|
|
var tmp = [];
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
for ( var i = 0; results[i]; i++ ) {
|
|
|
|
if ( results[i].nodeType === 1 ) {
|
|
|
|
tmp.push( results[i] );
|
2008-04-30 00:52:36 +02:00
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
results = tmp;
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
return results;
|
|
|
|
};
|
|
|
|
}
|
2009-01-13 17:40:19 +01:00
|
|
|
|
|
|
|
// Check to see if an attribute returns normalized href attributes
|
|
|
|
div.innerHTML = "<a href='#'></a>";
|
2009-01-23 20:36:59 +01:00
|
|
|
if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
|
|
|
|
div.firstChild.getAttribute("href") !== "#" ) {
|
2009-01-13 17:40:19 +01:00
|
|
|
Expr.attrHandle.href = function(elem){
|
|
|
|
return elem.getAttribute("href", 2);
|
|
|
|
};
|
|
|
|
}
|
2009-05-04 02:05:04 +02:00
|
|
|
|
|
|
|
div = null; // release memory in IE
|
2008-12-20 02:19:17 +01:00
|
|
|
})();
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( document.querySelectorAll ) (function(){
|
2009-01-21 23:57:07 +01:00
|
|
|
var oldSizzle = Sizzle, div = document.createElement("div");
|
|
|
|
div.innerHTML = "<p class='TEST'></p>";
|
|
|
|
|
|
|
|
// Safari can't handle uppercase or unicode characters when
|
|
|
|
// in quirks mode.
|
|
|
|
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
|
|
|
|
return;
|
|
|
|
}
|
2009-05-04 02:05:04 +02:00
|
|
|
|
2009-01-05 03:45:20 +01:00
|
|
|
Sizzle = function(query, context, extra, seed){
|
2008-12-20 02:19:17 +01:00
|
|
|
context = context || document;
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2009-01-22 00:31:29 +01:00
|
|
|
// Only use querySelectorAll on non-XML documents
|
|
|
|
// (ID selectors don't work in non-HTML documents)
|
|
|
|
if ( !seed && context.nodeType === 9 && !isXML(context) ) {
|
2008-12-20 02:19:17 +01:00
|
|
|
try {
|
2009-01-07 15:31:28 +01:00
|
|
|
return makeArray( context.querySelectorAll(query), extra );
|
2008-12-20 02:19:17 +01:00
|
|
|
} catch(e){}
|
|
|
|
}
|
2009-05-04 02:05:04 +02:00
|
|
|
|
2009-01-05 03:45:20 +01:00
|
|
|
return oldSizzle(query, context, extra, seed);
|
2008-12-20 02:19:17 +01:00
|
|
|
};
|
|
|
|
|
2009-02-27 16:20:59 +01:00
|
|
|
for ( var prop in oldSizzle ) {
|
|
|
|
Sizzle[ prop ] = oldSizzle[ prop ];
|
|
|
|
}
|
2009-05-04 02:05:04 +02:00
|
|
|
|
|
|
|
div = null; // release memory in IE
|
2008-12-20 02:19:17 +01:00
|
|
|
})();
|
|
|
|
|
2009-02-07 17:54:11 +01:00
|
|
|
if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){
|
|
|
|
var div = document.createElement("div");
|
|
|
|
div.innerHTML = "<div class='test e'></div><div class='test'></div>";
|
|
|
|
|
|
|
|
// Opera can't find a second classname (in 9.6)
|
|
|
|
if ( div.getElementsByClassName("e").length === 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Safari caches class attributes, doesn't catch changes (in 3.2)
|
|
|
|
div.lastChild.className = "e";
|
|
|
|
|
|
|
|
if ( div.getElementsByClassName("e").length === 1 )
|
|
|
|
return;
|
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
Expr.order.splice(1, 0, "CLASS");
|
2009-02-16 19:23:59 +01:00
|
|
|
Expr.find.CLASS = function(match, context, isXML) {
|
|
|
|
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
|
|
|
|
return context.getElementsByClassName(match[1]);
|
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
};
|
2009-05-04 02:05:04 +02:00
|
|
|
|
|
|
|
div = null; // release memory in IE
|
2009-02-07 17:54:11 +01:00
|
|
|
})();
|
2008-12-20 02:19:17 +01:00
|
|
|
|
2009-01-13 17:40:19 +01:00
|
|
|
function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
2009-02-10 01:28:38 +01:00
|
|
|
var sibDir = dir == "previousSibling" && !isXML;
|
2008-12-20 02:19:17 +01:00
|
|
|
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
|
|
|
var elem = checkSet[i];
|
|
|
|
if ( elem ) {
|
2009-02-10 01:28:38 +01:00
|
|
|
if ( sibDir && elem.nodeType === 1 ){
|
|
|
|
elem.sizcache = doneName;
|
|
|
|
elem.sizset = i;
|
|
|
|
}
|
2009-01-05 01:21:13 +01:00
|
|
|
elem = elem[dir];
|
2008-12-20 02:19:17 +01:00
|
|
|
var match = false;
|
|
|
|
|
2009-02-10 01:28:38 +01:00
|
|
|
while ( elem ) {
|
|
|
|
if ( elem.sizcache === doneName ) {
|
|
|
|
match = checkSet[elem.sizset];
|
2008-12-20 02:19:17 +01:00
|
|
|
break;
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2009-02-10 01:28:38 +01:00
|
|
|
if ( elem.nodeType === 1 && !isXML ){
|
|
|
|
elem.sizcache = doneName;
|
|
|
|
elem.sizset = i;
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( elem.nodeName === cur ) {
|
|
|
|
match = elem;
|
|
|
|
break;
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
elem = elem[dir];
|
2008-04-30 00:52:36 +02:00
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
|
|
|
|
checkSet[i] = match;
|
2008-04-30 00:52:36 +02:00
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-13 17:40:19 +01:00
|
|
|
function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
|
2009-02-10 01:28:38 +01:00
|
|
|
var sibDir = dir == "previousSibling" && !isXML;
|
2008-12-20 02:19:17 +01:00
|
|
|
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
|
|
|
|
var elem = checkSet[i];
|
|
|
|
if ( elem ) {
|
2009-02-10 01:28:38 +01:00
|
|
|
if ( sibDir && elem.nodeType === 1 ) {
|
|
|
|
elem.sizcache = doneName;
|
|
|
|
elem.sizset = i;
|
|
|
|
}
|
2009-01-05 01:21:13 +01:00
|
|
|
elem = elem[dir];
|
2008-12-20 02:19:17 +01:00
|
|
|
var match = false;
|
|
|
|
|
2009-02-10 01:28:38 +01:00
|
|
|
while ( elem ) {
|
|
|
|
if ( elem.sizcache === doneName ) {
|
|
|
|
match = checkSet[elem.sizset];
|
2008-12-20 02:19:17 +01:00
|
|
|
break;
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( elem.nodeType === 1 ) {
|
2009-02-10 01:28:38 +01:00
|
|
|
if ( !isXML ) {
|
|
|
|
elem.sizcache = doneName;
|
|
|
|
elem.sizset = i;
|
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( typeof cur !== "string" ) {
|
|
|
|
if ( elem === cur ) {
|
|
|
|
match = true;
|
|
|
|
break;
|
|
|
|
}
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
|
|
|
|
match = elem;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
elem = elem[dir];
|
|
|
|
}
|
|
|
|
|
|
|
|
checkSet[i] = match;
|
2008-04-30 00:52:36 +02:00
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var contains = document.compareDocumentPosition ? function(a, b){
|
|
|
|
return a.compareDocumentPosition(b) & 16;
|
|
|
|
} : function(a, b){
|
2009-01-05 23:02:20 +01:00
|
|
|
return a !== b && (a.contains ? a.contains(b) : true);
|
2008-12-20 02:19:17 +01:00
|
|
|
};
|
|
|
|
|
2009-01-11 20:45:04 +01:00
|
|
|
var isXML = function(elem){
|
2009-01-19 22:57:18 +01:00
|
|
|
return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" ||
|
2009-02-25 16:37:09 +01:00
|
|
|
!!elem.ownerDocument && elem.ownerDocument.documentElement.nodeName !== "HTML";
|
2009-01-11 20:45:04 +01:00
|
|
|
};
|
|
|
|
|
2009-01-19 19:09:11 +01:00
|
|
|
var posProcess = function(selector, context){
|
|
|
|
var tmpSet = [], later = "", match,
|
|
|
|
root = context.nodeType ? [context] : context;
|
|
|
|
|
|
|
|
// Position selectors must be done after the filter
|
|
|
|
// And so must :not(positional) so we move all PSEUDOs to the end
|
|
|
|
while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
|
|
|
|
later += match[0];
|
|
|
|
selector = selector.replace( Expr.match.PSEUDO, "" );
|
|
|
|
}
|
|
|
|
|
|
|
|
selector = Expr.relative[selector] ? selector + "*" : selector;
|
|
|
|
|
|
|
|
for ( var i = 0, l = root.length; i < l; i++ ) {
|
|
|
|
Sizzle( selector, root[i], tmpSet );
|
|
|
|
}
|
|
|
|
|
|
|
|
return Sizzle.filter( later, tmpSet );
|
2009-01-20 20:58:19 +01:00
|
|
|
};
|
2009-01-19 19:09:11 +01:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
// EXPOSE
|
|
|
|
jQuery.find = Sizzle;
|
|
|
|
jQuery.expr = Sizzle.selectors;
|
|
|
|
jQuery.expr[":"] = jQuery.expr.filters;
|
|
|
|
|
|
|
|
Sizzle.selectors.filters.hidden = function(elem){
|
2009-05-04 02:19:57 +02:00
|
|
|
return elem.offsetWidth === 0 && elem.offsetHeight === 0;
|
2008-12-20 02:19:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Sizzle.selectors.filters.visible = function(elem){
|
2009-02-16 16:55:06 +01:00
|
|
|
return elem.offsetWidth > 0 || elem.offsetHeight > 0;
|
2008-12-20 02:19:17 +01:00
|
|
|
};
|
|
|
|
|
2009-01-05 01:21:13 +01:00
|
|
|
Sizzle.selectors.filters.animated = function(elem){
|
|
|
|
return jQuery.grep(jQuery.timers, function(fn){
|
|
|
|
return elem === fn.elem;
|
|
|
|
}).length;
|
|
|
|
};
|
|
|
|
|
2009-02-20 20:52:38 +01:00
|
|
|
jQuery.filter = jQuery.multiFilter = function( expr, elems, not ) {
|
2008-12-20 02:19:17 +01:00
|
|
|
if ( not ) {
|
2009-01-05 01:21:13 +01:00
|
|
|
expr = ":not(" + expr + ")";
|
2008-12-20 02:19:17 +01:00
|
|
|
}
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2009-01-05 01:21:13 +01:00
|
|
|
return Sizzle.matches(expr, elems);
|
2008-12-20 02:19:17 +01:00
|
|
|
};
|
2008-05-13 03:45:58 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
jQuery.dir = function( elem, dir ){
|
|
|
|
var matched = [], cur = elem[dir];
|
|
|
|
while ( cur && cur != document ) {
|
|
|
|
if ( cur.nodeType == 1 )
|
|
|
|
matched.push( cur );
|
|
|
|
cur = cur[dir];
|
|
|
|
}
|
|
|
|
return matched;
|
|
|
|
};
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
jQuery.nth = function(cur, result, dir, elem){
|
|
|
|
result = result || 1;
|
|
|
|
var num = 0;
|
|
|
|
|
|
|
|
for ( ; cur; cur = cur[dir] )
|
|
|
|
if ( cur.nodeType == 1 && ++num == result )
|
|
|
|
break;
|
|
|
|
|
|
|
|
return cur;
|
|
|
|
};
|
|
|
|
|
|
|
|
jQuery.sibling = function(n, elem){
|
|
|
|
var r = [];
|
2008-04-30 00:52:36 +02:00
|
|
|
|
2008-12-20 02:19:17 +01:00
|
|
|
for ( ; n; n = n.nextSibling ) {
|
|
|
|
if ( n.nodeType == 1 && n != elem )
|
|
|
|
r.push( n );
|
2008-04-30 00:52:36 +02:00
|
|
|
}
|
2008-12-20 02:19:17 +01:00
|
|
|
|
|
|
|
return r;
|
|
|
|
};
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
window.Sizzle = Sizzle;
|
|
|
|
|
|
|
|
})();
|