MediaWiki:Gadget-removeAccessKeys.js: Difference between revisions

Content deleted Content added
Random832 (talk | contribs)
support for modern skin
m fix formatting
 
(10 intermediate revisions by 4 users not shown)
Line 6:
// **********************************************************************
// Imported from version as of: 2007-04-17T22:22:27
// Deactivating access keys, see [[Wikipedia talk:WikiProject User scripts/Scripts/removeAccessKeys|talk page]]
jQuery(document).ready(function($) {
if (mw.config.get('skin') == 'vector') {
var cactionshead = document.getElementById('pmw-cactionshead');
if (cactionshead) removeKeys(cactionshead.getElementsByTagName('a'));
var personalpanel = document.getElementById('pmw-personalpanel');
if (personalpanel) removeKeys(personalpanel.getElementsByTagName('a'));
} else {
var columnOne = document.getElementById('column-one');
if (!columnOne) columnOne = document.getElementById('mw_portlets');
if (!columnOne) return;
removeKeys(columnOne.getElementsByTagName('a'));
var cactions = document.getElementById('p-cactions');
if (cactions) removeKeys(columnOnecactions.getElementsByTagName('a'));
var personal = document.getElementById('p-personal');
if (personal) removeKeys(documentpersonal.getElementsByTagName('inputa'));
}
removeKeys(document.getElementsByTagName('labelinput'));
removeKeys(columnOne.getElementById('p-cactions')document.getElementsByTagName('alabel'));
});
 
addOnloadHook(function removeKeys(nodeList) {
var el;
var columnOne = document.getElementById('column-one');
for (var i = 0; i < nodeList.length; i++) {
if (!columnOne) columnOne = document.getElementById('mw_portlets');
el = nodeList[i];
if (!columnOne) return;
if (!el.accessKey) continue;
removeKeys(columnOne.getElementsByTagName('a'));
if (!window.removeAccessKeys || removeAccessKeys.indexOf(el.accessKey) >= 0) {
var cactions = document.getElementById('p-cactions');
el.accessKey = ''; // el.setAttribute('accessKey', '');
if(cactions) removeKeys(cactions.getElementsByTagName('a'));
$(el).updateTooltipAccessKeys();
var personal = document.getElementById('p-personal');
}
if(personal) removeKeys(personal.getElementsByTagName('a'));
removeKeys(columnOne.getElementsByTagName('a'));
removeKeys(columnOne.getElementById('p-cactions').getElementsByTagName('a'));
removeKeys(document.getElementsByTagName('input'));
removeKeys(document.getElementsByTagName('label'));
})
 
function removeKeys(nodeList){
var el;
for (var i = 0; i < nodeList.length; i++) {
el = nodeList[i];
if (!el.accessKey) continue;
if (!window.removeAccessKeys || removeAccessKeys.indexOf(el.accessKey) >= 0) {
el.accessKey = ''; //el.setAttribute('accessKey', '');
if (el.title) el.title = el.title.replace(tooltipAccessKeyRegexp, '');
}
}
}
 
//