an anon child
}
}
if (control) {
control.labelElement = this;
}
var afterLabel = document.getAnonymousElementByAttribute(this, "anonid", "accessKeyParens");
afterLabel.textContent = ""; // This does not clear real nodes!
var oldAccessKey = this.getElementsByAttribute('class', 'accesskey').item(0);
if (oldAccessKey) { // Clear old accesskey
if (oldAccessKey.previousSibling instanceof Text) {
oldAccessKey.previousSibling.appendData(oldAccessKey.textContent)
}
else {
oldAccessKey.parentNode.insertBefore(oldAccessKey.firstChild, oldAccessKey);
}
oldAccessKey.parentNode.removeChild(oldAccessKey);
}
var accessKey = this.accessKey;
var labelText = this.textContent;
if (!accessKey || !labelText || !control) {
return;
}
var accessKeyIndex = labelText.indexOf(accessKey);
if (accessKeyIndex < 0) { // Try again in upper case
accessKeyIndex = labelText.toUpperCase().indexOf(accessKey.toUpperCase());
}
var span = document.createElementNS("http://www.w3.org/1999/xhtml", "span");
span.className = "accesskey";
if (accessKeyIndex < 0) {
// If accesskey is not in string, append in parentheses
afterLabel.textContent = " (";
span.textContent = accessKey.toUpperCase();
afterLabel.appendChild(span);
afterLabel.appendChild(document.createTextNode(")"));
return;
}
var treeWalker = document.createTreeWalker(this, NodeFilter.SHOW_TEXT, null, true);
var accessKeyNode = treeWalker.nextNode();
while (accessKeyIndex >= accessKeyNode.length) {
accessKeyIndex -= accessKeyNode.length;
accessKeyNode = treeWalker.nextNode();
}
// Now wrap the access key in a
if (accessKeyIndex) {
accessKeyNode = accessKeyNode.splitText(accessKeyIndex); // returns 2nd node from split
}
accessKeyNode.parentNode.insertBefore(span, accessKeyNode);
if (accessKeyNode.length > 1) {
accessKeyNode.splitText(1);
}
span.appendChild(accessKeyNode);
]]>