MediaWiki:Gadget-bottomtabs.js

Wikisource, a biblioteca livre

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)
  • Internet Explorer / Edge: Pressione Ctrl enquanto clica Recarregar, ou pressione Ctrl-F5
  • Opera: 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
                http://opensource.org/licenses/gpl-license.php

    version:    1.0.1
\* ------------------------------------------------------------------------ */
function copyUpperActions(output_id)
{
	var as = document.getElementById('p-cactions').getElementsByTagName('div')[0].getElementsByTagName('a');
	
	//
	// create new tabs element (bottom actions bar)
	var tabs = document.createElement('div');
	tabs.id = output_id;
	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(/&amp;/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').offsetHeight>650)
	{
		var tabs;
		tabs = copyUpperActions('btm-actions');
		document.getElementById('column-content').appendChild(tabs);
	}
}
$(copyUpperActionsInit);