MediaWiki:Gadget-btm-actions.js
Nota: Depois de publicar, poderá ter de contornar a cache do seu navegador para ver as alterações.
- Firefox / Safari: Pressione Shift enquanto clica Recarregar, ou pressione Ctrl-F5 ou Ctrl-R (⌘-R no Mac)
- Google Chrome: Pressione Ctrl-Shift-R (⌘-Shift-R no Mac)
- Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5.
/**
* Copy upper tabs (actions) to bottom
* Works for IE6+, FF2+... (see also [[MediaWiki:Gadget-btm-actions.css]])
*
* Copyright: ©2008 Maciej Jaros (pl:User:Nux, en:User:EcceNux)
* Licencja: GNU General Public License v2
* https://opensource.org/licenses/gpl-license.php
* Version: 1.0.2
*/
function copyUpperActions(output_id) {
if(!document.getElementById('p-cactions')) return; // not present in some skins e.g. Minerva
var as = document.getElementById('p-cactions').getElementsByTagName('div')[0];
if(!as) return; // Cologne Blue
as = as.getElementsByTagName('a');
//
// create new tabs element (bottom actions bar)
var tabs = document.createElement('div');
tabs.id = output_id;
tabs.className = 'noprint';
var stabs = document.createElement('div');
stabs.id = 'post-' + output_id; // for proper width:100% handling
tabs.appendChild(stabs);
//
// copy
for (var i = 0; i < as.length; i++) {
var nel = document.createElement('a');
nel.title = as[i].title;
nel.innerHTML = as[i].innerHTML.toLowerCase(); // not sure why is this needed
// normal browser
//nel.href = as[i].href;
// you just got to love IE...
nel.href = as[i].parentNode.innerHTML.replace(/^.+ href=(["'])([^"']+)\1.+$/g, '$2').replace(/&/g, '&');
// copy class and id from <li>
if (as[i].parentNode.nodeName.toLowerCase() == 'li') {
if (as[i].parentNode.id) {
nel.id = output_id + '-' + as[i].parentNode.id;
}
if (as[i].parentNode.className) {
nel.className = as[i].parentNode.className;
}
}
stabs.appendChild(nel);
}
//
// done
return tabs;
}
function copyUpperActionsInit() {
if (document.getElementById('content') && document.getElementById('content').offsetHeight > 650) {
var tabs = copyUpperActions('btm-actions'),
content = document.getElementById('column-content');
if (content && tabs) {
document.getElementById('column-content').appendChild(tabs);
}
}
}
$(copyUpperActionsInit);