From fddab51ae49cc11c8ca7bd1a5a6d3da50f20c732 Mon Sep 17 00:00:00 2001 From: Ilmari Karonen Date: Mon, 15 Jan 2007 02:34:21 +0000 Subject: [PATCH] replace Simetrical's hack from r19269+r19270 with a slightly less ugly hack --- skins/common/wikibits.js | 48 +++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/skins/common/wikibits.js b/skins/common/wikibits.js index d295ee46c1..06a07d17f1 100644 --- a/skins/common/wikibits.js +++ b/skins/common/wikibits.js @@ -490,43 +490,35 @@ if (is_opera) { tooltipAccessKeyPrefix = 'alt-shift-'; } var tooltipAccessKeyRegexp = /\[(ctrl-)?(alt-)?(shift-)?(esc-)?.\]$/; -var parentNode = null; /** * Add the appropriate prefix to the accesskey shown in the tooltip. * If the nodeList parameter is given, only those nodes are updated; - * otherwise, all the nodes that will probably have accesskeys by default - * are updated. + * otherwise, all the nodes that will probably have accesskeys by + * default are updated. * * @param Array nodeList -- list of elements to update */ function updateTooltipAccessKeys( nodeList ) { if ( !nodeList ) { - if ( !parentNode ) { - if ( !document.getElementById( "wpSave" ) && !document.getElementById( "pagehistory" ) ) { - // If this is an edit page, we need to go through the whole page. - // Otherwise we can just do non-content stuff. - // Note: hacky heuristic! Any better? - parentNode = document.getElementById( "column-one" ); - } - if (!parentNode) { - // Presumably non-Monobook, have to go through the whole page - parentNode = document; - } - } - updateTooltipAccessKeys( parentNode.getElementsByTagName("a") ); - updateTooltipAccessKeys( parentNode.getElementsByTagName("input") ); - updateTooltipAccessKeys( parentNode.getElementsByTagName("label") ); - } else { - for ( var i = 0; i < nodeList.length; i++ ) { - var element = nodeList[i]; - var tip = element.getAttribute("title"); - var key = element.getAttribute("accesskey"); - if ( key && tooltipAccessKeyRegexp.exec(tip) ) { - tip = tip.replace(tooltipAccessKeyRegexp, - "["+tooltipAccessKeyPrefix+key+"]"); - element.setAttribute("title", tip ); - } + // skins without a "column-one" element don't seem to have links with accesskeys either + var columnOne = document.getElementById("column-one"); + if ( columnOne ) + updateTooltipAccessKeys( columnOne.getElementsByTagName("a") ); + // these are rare enough that no such optimization is needed + updateTooltipAccessKeys( document.getElementsByTagName("input") ); + updateTooltipAccessKeys( document.getElementsByTagName("label") ); + return; + } + + for ( var i = 0; i < nodeList.length; i++ ) { + var element = nodeList[i]; + var tip = element.getAttribute("title"); + var key = element.getAttribute("accesskey"); + if ( key && tooltipAccessKeyRegexp.exec(tip) ) { + tip = tip.replace(tooltipAccessKeyRegexp, + "["+tooltipAccessKeyPrefix+key+"]"); + element.setAttribute("title", tip ); } } } -- 2.20.1