MediaWiki:Gadget-btm-actions.js

Uwaga: aby zobaczyć zmiany po opublikowaniu, może zajść potrzeba wyczyszczenia pamięci podręcznej przeglądarki.

  • Firefox / Safari: Przytrzymaj Shift podczas klikania Odśwież bieżącą stronę, lub naciśnij klawisze Ctrl+F5, lub Ctrl+R (⌘-R na komputerze Mac)
  • Google Chrome: Naciśnij Ctrl-Shift-R (⌘-Shift-R na komputerze Mac)
  • Internet Explorer / Edge: Przytrzymaj Ctrl, jednocześnie klikając Odśwież, lub naciśnij klawisze Ctrl+F5
  • Opera: Naciśnij klawisze 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.3
\* ------------------------------------------------------------------------ */
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;
	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(/&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 copyUpperActionsInitMonobook() {
	if (document.getElementById('content').offsetHeight>650)
	{
		var tabs;
		tabs = copyUpperActions('btm-actions');
		document.getElementById('column-content').appendChild(tabs);
	}
}

function copyUpperActionsInitVector() {
	var div = jQuery('<div/>').insertAfter('#bodyContent');
	var r = jQuery('#right-navigation').clone().attr('id', 'right-b');
	r.css({ 'float' : 'right', 'margin-right' : '-1em' });
	r.find('#p-cactions').remove();

	var l = jQuery('#left-navigation').clone().attr('id', 'left-b');
	l.css({ 'float' : 'left', 'margin-left' : '-1em' });

	div.append(l).append(r).append('<br style="clear: both; background-color: white"/>');
}

if ( mw.config.get( 'skin' ) == "monobook" ) {
	jQuery( document ).ready( function() {
		copyUpperActionsInitMonobook();
	} );
} else if ( mw.config.get( 'skin' ) == "vector" ) {
	jQuery( document ).ready( function() {
		copyUpperActionsInitVector();
	} );
}