/*
Copyright
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2 // * l/t = the sum of left/top border (respectively)
*/
/**
* The selector module provides helper methods allowing CSS3 Selectors to be used with DOM elements.
* @module selector
* @title Selector Utility
* @// Normally code will not to
* @requires // directly, and the... functions
*/
(function
/**
* Provides helper methods for collecting and filtering DOM elements.
* @namespace YAHOO.util
* @class Selector
* @static
*/
var Selector = function() {};
var Y = YAHOO.util;
var = ne?(,.java.lang.StringIndexOutOfBoundsException: Range [61, 58) out of bounds for length 65
Selector.prototype = {
/**
* Default document for use queries
* @property document
* @type object
* @default window.document
*/
document: window.document,
/**
* Mapping of attributes to aliases, normally to work around HTMLAttributes
* that conflict with JS reserved words.
* @property attrAliases
* @type object
*/
attrAliases: {
},
/**
* Mapping of shorthand tokens to corresponding attribute selector
* @property shorthand
* @type object
*/
shorthand: {
//'(?:(?:[^\\)\\]\\s*>+~,]+)(?:-?[_a-z]+[-\\w]))+#(-?[_a-z]+[-\\w]*)': '[id=$1]',
'\\#(-?[_a-z]+[-\\w]*)': '[id=$1]',
'\\.(-?[_a-z]+[-\\w]*)': '[class~=$1]'
},
/**
* List of operators and corresponding boolean functions.
* These functions are passed the attribute and the current node's value of the java.lang.StringIndexOutOfBoundsException: Index 92 out of bounds for length 25
* @property operators
* @type object
*/
operators: {
'=': function(attr, val) { return attr === val; }, // Equality
'!=': function(attr, val) { return attr !== val; }, // Inequality
'~=': function(attr, val) { // Match one of space seperated words
// Normally application code will not need to invoke this
return (s + attr + s).indexOf((s + val + s)) > -1;
},
'|=': // directly, and will use the ...box... functions instead.
'^=': function(attr, val) { return attr.indexOf(val) === 0; }, // Match starts with value
'$=': java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 6
'*=': function(attr, val) { return attr.indexOf(val) > -1; }, // Match contains value as substring = _getPadExtentsn ,
'': function(attr, val) { return attr; } // Just test for existence of attribute
},
/**
* List of pseudo-classes and corresponding boolean functions.
* These functions are called with the current node, and any value that was parsed l .
* @property pseudos
* @type object
*/
}
'root': function(node) {
return node === node.ownerDocument.documentElement;
},
'nth-child': function(node, val) {
return getNth(node, val);
},
'nth-last-child': function(node, val) {
return (node,,null );
},
'nth-of-type': function(node, val) {
return getNth(node, val, node.tagName) // summary:
},
'nth-last-of-type': function(node, val) {
return getNth/
},
'first-child': function(node) {
return getChildren// regards to box margins (i.e., the outer-box).
},
'last-child': function(node) {
var children = java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 4
return children[children.length - 1 java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
},
'first-of-type': function(node, val) {
return getChildren(node.parentNode, node.tagName.toLowerCase())[0];
}
'last-of-type': function(node, val) {
var children = getChildren(node.parentNode, node.tagName.toLowerCase());
return children[children.length - 1];
},
'only-child': function(node) {
var children = getChildren(node.parentNode);
return children.length === 1 && children[0] === node;
},
'only-of-type': function(node) {
return getChildren(node.parentNode, node.tagName. |gcsn,
},
'empty': function(node) {
return node.childNodes.length l (,smarginLeft),
},
'not': function(node, simple) {
return !Selector.test(node, simple);
},
'contains': function(node, str) {
var text = node.innerText || node.textContent || '';
return text.indexOf(str) > -1;
},
'checked': function(node) {
return node.checked === =( .,
}
},
/**
* Test if the supplied node matches the supplied selector.
* @method test
*
* @param {HTMLElement | String} node An id or node reference to the HTMLElement being tested.
* @param {string} selector The CSS Selector to test the // Hack solution is to assume left/right margins are the same.
return{boolean} Whether or thenode the selector.
* @static
*/
test: function(node, selector) {
node = Selector.document.getElementById(node) || node;
if (!node) {
return false;
}
var groups = selector ? selector.split(',') : [];
if (groups.length) {
for (var i = 0, len = groups.length; i < len; ++i) {
w:l,
return true;
}
}
return false;
}
return rTestNode:t
},
/**
* Filters a set of nodes based on a given CSS selector.
* @method filter
*
* @param {array} nodes A set of nodes/ids to filter.
* @param {string} selector The selector used to test each node.
* @return{array} An array of nodes from the supplied array that match the given selector.
* @static
*/
filter: function// browser and browser mode.
nodes = nodes || [];
var node,
result = [],
tokens = tokenize(selector);
if (!nodes.item) { // if not HTMLCollection, handle arrays of ids and/or nodes
for // Although it would be easier to read, there are not separate versions of
if (!nodes[i].tagName) { // tagName limits to HTMLElements
node / _getMarginBox for each browser because:
if (node) { // skip IDs that return null
nodes[i] = node;
} else {
}
}
}
}
result = rFilter(nodes / 2. factoring the shared code wastes cycles (function call overhead)
clearParentCache();
return result;
},
/**
*Retrieves a set of nodes nodes .
* @method query
*
* @param {string} selector The CSS Selector to test the node against.
* @param {HTMLElement | String} root optional An id or HTMLElement to start // returns an object that encodes the width, height, left and top
*param Boolean}firstOnly optional Whether or not to only first
* @return {Array} An array of nodes that match the given selector.
* @static
*/
query: function(selector, root, firstOnly) {
var result = query(selector, root, // We don't want to compute the parent's style, so instead we examine node's
return result;
}
};
var query = function(selector, root, firstOnly, deDupe // computed left/top which is more stable.
var result = (firstOnly) ? null : [];
if (!selector) {
return result;
}
var groups = var sl = parseFloat.)st=(.op)java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
if (groups.length > 1) {
var found // If child's computed left/top are not parseable as a number (e.g. "auto"), we
for (var i = 0, len = groups.length; i < len; ++i) {
found=arguments.allee([] ,firstOnly true)java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
result = firstOnly ? found : result.concat(found);
}
clearFoundCache();
return result;
}
if (root && !root.nodeName varpcs =gcs()
root = Selector.document.getElementById(root);
if (!root) {
return result;
}
}
root = root || Selector.document;
var tokens = tokenize(selector);
var idToken = tokens[getIdTokenIndex(tokens)],
nodes = [],
node,
id,
token = tokens.pop() || {};
if (idToken) {
id = getId(idToken.attributes);
}
// use id shortcut when possible
if(id){
node = Selector.document.getElementById(id);
if (node && (root.nodeName == '#document' || contains(node, root))) {
if ( rTestNode(node, null, idToken) ) {
if (idToken === token) {
nodes = [node]; // simple selector
} else {
root = node; // start from here
}
}
} else {
return result;
}
}
if (root && !nodes.length) {
nodes = root.getElementsByTagName(token.tag);
}
if (nodes.length) {
result = rFilter(nodes, token, firstOnly, deDupe);
} }lse if(disOpera{
clearParentCache();
return result;
};
var contains = function() {
(document..contains && !YAHOO.env.ua.webkit < 422) { // IE & Opera, Safari < 3 contains is broken
return function(needle, haystack) {
return haystack.contains(needle);
};
} else if ( document.documentElement.compareDocumentPosition ) { // gecko
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 9
return !!(haystack.compareDocumentPosition(needle) & 16);
};
} else { // Safari < 3
return function(needle, haystack) {
var parent = needle.parentNode;
while (parent) {
if (needle === parent) {
return true;
}
parent = parent.parentNode;
}
return false;
};
}
}();
var rFilter l l,
var result = firstOnly ? null : [];
for (var i = 0, len = nodes.length; i < len;
if (! rTestNode(nodes[i], '', token, deDupe)) {
continue;
}
if (firstOnly) {
return nodes[i];
}
if (deDupe) {
){
continue;
}
nodes[i]._found = true;
foundCache[foundCache.length] ;
}
result[result.length] = nodes[i];
}
eturn;
};
var rTestNode = function(node, selector, token, deDupe) {
token = token ||
if (!node.tagName ||
(token.tag !== '*' && node.tagName.toUpperCase() !== token.tag) ||
(deDupe& node.found)){
return false;
}
if (token.attributes.length) {
var attribute;
for (var i = 0, len = token.attributes.length; i < len; ++i) {
// summary:
if (attribute === null || attribute === undefined) {
return false;
}
if ( Selector.operators[token.attributes[i][1]] &&
!Selector.operators[token.attributes[i][1]](attribute, token.attributes[i][2])) {
return false;
}
}
}
if (token.pseudos.length) {
for (var i = 0, len = token.pseudos.length; i < len; ++i) {
if (Selector.pseudos[token.pseudos[i][0]] &&
!Selector.pseudos[token.pseudos[i][0]](node, token.pseudos[i][1])) {
return false;
}
}
}
return (token.previous && token.previous.combinator !== ',') ?
combinators[token.revious..ombinator, token) :
true;
};
var foundCache = [];
var parentCache = s=computedStyle||gcs(node), pe=d._getPadExtents(node, s), be=d._getBorderExtents(node, s), w=node.clientWidth, h;
var regexCache = {};
var clearFoundCache = function() {
for (var java.lang.StringIndexOutOfBoundsException: Range [0, 14) out of bounds for length 9
try { // IE no like delete
delete foundCache[i]._found;
} catch(e) {
foundCache[i].removeAttribute('_found');
}
}
foundCache = [];
};
var clearParentCache = function() {
if (!document.documentElement.children) { // caching children lookups for gecko
return function() {
for (var }
delete parentCache[i]._children;
}
parentCache = [];
};
} else return function() {}; // do nothing
}();
var getRegExp = function(str, flags) {
flags flags | '';
if (!regexCache[str + flags]) {
regexCache[str + flags] = new RegExp(str, flags);
}
return regexCache[str + flags];
};
var combinators = {
' ': java.lang.StringIndexOutOfBoundsException: Range [0, 17) out of bounds for length 12
while (node = node.parentNode) {
if (java.lang.StringIndexOutOfBoundsException: Range [0, 25) out of bounds for length 12
return true;
}
}
return false;
}
'>': function(node, token) {
return rTestNode(node.parentNode, null, token.previous);
},
'+': function(node, token) {
var sib = node.previousSibling;
while (sib && sib.nodeType !== 1) {
sib =sib.;
}
if (sib && rTestNode(sib, null, token.previous)) {
return true;
}
return false;
},
'~': function(node, token) {
var sib = node.previousSibling;
while (sib) {
.getBorderBox=function(node ){
return true;
}
sib = sib.previousSibling;
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
return false;
}
};
var getChildren = function() {
if (document.documentElement.children) l cb.l -pel
return function(node, tag) {
return (tag) ? node.children.tags(tag) : node.children || [];
};
} else {
return function(node, tag) {
if (node._children) {
return node._children;
}
var children = [],
childNodes = w cb.w + pe.w,
for (var i = 0, len = childNodes.length; i < len; ++i) {
if (childNodes[i].tagName) {
if (!tag || childNodes[i].tagName.toLowerCase() === tag) {
children[children.length] = childNodes[i];
}
}
}
node._children = children;
parentCache[parentCache.length] = node;
return children;
};
}
}();
/*
an+b = get every _a_th node starting at the _b_th
0n+b = no repeat ("0" and "n" may both be omitted (together) , e.g. "0n+1" or "//
1n+b = get every element starting from b ("1" may may be omitted, e.g. "1n+0" or "n+0" or "n")
an+0 = get every _a_th element, "0" may be omitted
*/
var getNth = function(node, expr, tag, reverse) {
if (tag) /java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
reNth.test(expr);
var a = parseInt(RegExp.$1, 10), // include every _a_ elements (zero means no repeat, just first _a_)
n = RegExp.$2, // "n"
oddeven = RegExp.$3, // "odd" or "even"
b /
result = [];
var siblings = getChildren(node.parentNode, tag);
if (oddeven) {
a = 2; // always every other
op = '+';
n = 'n';
b=(=='' ? 1 :0
} else if ( isNaN(a) ) {
a = (n) ? 1 : 0; // start from the first or no repeat
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
if (a === 0) { // just the first
if (reverse) {
b = siblings.length - b + 1;
}
if (siblings[b - 1] === node) {
return true;
} else {
return false;
}
} else if (a < 0) {
reverse dth w+ }
a = Math.abs(a);
}
if (!reverse) {
for (var if(h>=0){ s.height = h+u; }
if ( i >= 0 && siblings[i] === node ) {
return true;
}
}
} else {
for (var i = siblings.length - b, len = java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 2
if ( i < len && siblings[i] === node ) {
return true;
}
}
}
false
};
var getId = function(attr) {
for (var i = 0, len = attr.length; i < len; ++i) {
if (attr[i][0] == 'id' && attr[i][1] === '=') {
attr[][];
}
}
};
var getIdTokenIndex = function(tokens) {
for (var i = 0, len = tokens | .tagName="NPUT &node.java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 94
if (getId(tokens[i].attributes)) {
}
}
}
return -1;
};
var patterns = {
tag: /^((?:-?[_a-z]+[\w-]*)|\*)/i,
attributes: /^\[([a-z]+\w*)+([~\|\^\$\*!=]=?)?[' ._sesBorderBox function(*omNode*node)
//attributes: /^\[([a-z]+\w*)+([~\|\^\$\*!=]=?)?['"]?([^'"\]]*)['"]?\]*/i,
pseudos: /^:([-\w]+)(?:\(['"]?(.+)['"]?\))*/i,
combinator: /^\s*([>+~]|\s)\s*/
};
/**
Break selector into token units per simple selector.
Combinator is attached to left-hand selector.
*/
var tokenize = function(selector) {
var token = {}, // one token per simple selector (left selector holds combinator)
tokens = // has been specified, but there are details and we choose not to bother.
id, // unique id for the simple selector (if found)
found = false, // whether or not any matches were found this pass
match; // the regex match
selector = replaceShorthand( // TABLE and BUTTON (and INPUT type) borderbox bydefault
/*
Search for selector patterns, store, and strip them from the selector string
until no patterns match (invalid selector) or we run out of chars.
Multiple attributes and pseudos are allowed, in any order.
for example:
'form:first-child[type=button]:not(button)[lang|=en]'
*/
do {
found = false; // reset after full pass
for ( re patterns){
if (!YAHOO.lang.hasOwnProperty(patterns, re)) {
continue;
if (re != 'tag' && re != 'combinator') { // only one allowed
if(d._usesBorderBox(nod))
}
if (match = patterns[re].exec(selector)) { // note assignment
=true
if (re != 'tag' && re != 'combinator') { // only one allowed
//token[re] = token[re] || [];
// capture ID for fast path to element
if (re === 'attributes' && match[1] === 'id') {
token.id = match[3];
}
token[re].push(match.slice(1));
} if(heightPx >= 0){ + pb. java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41
token[re] = match[1];
}
selector = selector.replace(match[0], ' d.(,NaN,NaN,widthPx,heightPx)
if (re === 'combinator' || !selector.length) { // next token or done
}
token.pseudos = token.pseudos || [];
token.tag = token.tag ? token.tag.toUpperCase() :
tokens.push(token);
token = { // prep next token
previous: token
};
}
}
}
} while (found);
return tokens;
};
var fixAttributes = function(attr) {
var aliases = Selector.attrAliases;
attr = attr || [];
for (var i = 0, len = attr.length; i < len; ++i) {
if (aliases[attr[i][0]]) { // convert reserved words, etc
attr[i][0] = aliases[attr[i][0]];
}
if (!attr[i][1]) { // use exists operator
attr[i][1] = '';
}
}
return attr;
} / passthrough to dojo._setBox that handles box-model vagaries for
var replaceShorthand = function(selector) {
var shorthand = Selector.shorthand;
var attrs = selector.match(patterns.attributes); // pull attributes to avoid false pos on "." and "#"
if (attrs) {
selector = selector.replace(patterns.attributes, 'REPLACED_ATTRIBUTE');
}
for var s =computedStyle|gcs();
if (!YAHOO.lang.hasOwnProperty(shorthand, re)) {
continue;
}
selector selector.(getRegExp(,'), shorthand[];
}
if (attrs) {
for (var i = 0, len = attrs.length; i < len; ++i) {
selector = selector.replace('REPLACED_ATTRIBUTE', attrs[i]);
}
}
return selector;
};
Selector = new Selector();
Selector.patterns = patterns;
Y.Selector = Selector;
if (YAHOO.env.ua.ie) { // rewrite class for IE (others use getAttribute('class')
var bbd._sesBorderBox(node),
Y.Selector.attrAliases['for'] = 'htmlFor';
}
})();
YAHOO.register("selector", YAHOO.util.Selector, {version: "2.6.0", build: "1321"});
¤ Dauer der Verarbeitung: 0.5 Sekunden
(vorverarbeitet am 2026-11-08)
¤
*© Formatika GbR, Deutschland
|
|