User:Blue-Haired Lawyer/wide skin.js

From Wikisource
Jump to navigation Jump to search
Note: After saving, changes may not occur immediately. Click here to learn how to bypass your browser's cache.
  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (Cmd-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (Cmd-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Clear the cache in Tools → Preferences

For details and instructions about other browsers, see Wikipedia:Bypass your cache.

// To make this script work you need to add the following to you style sheet (vector.css):
//  +--------------------------------------------------+
//  |   #mw-panel { visibility: hidden !important; }   |
//  |   #mw-head-base { margin-left: 0 !important; }   |
//  |   #content { margin-left: 0 !important; }        |
//  |   #left-navigation { left: 0 !important; }       |
//  |   #footer { margin-left: 0 !important; }         |
//  +--------------------------------------------------+

// ie or firefox
var whichText = document.body.textContent ? 'textContent' : 'innerText';

if ( mw.config.get( 'skin' ) == 'vector' ) {
	// Insert head banner
	myDiv = document.createElement("DIV");
	myLink = document.createElement("A");
	myDiv.appendChild(myLink);
	
	myDiv.id = 'myNewBanner';
	myDiv.setAttribute("style", "position: absolute; top: 5px; left: 15px; font: 31pt Georgia; font-variant: small-caps; z-index: 999999;");
	
	myLink.href = mw.config.get( 'wgArticlePath' ).replace('$1',  mw.config.get( 'wgMainPageTitle' ));
	myLink.setAttribute("style", "color: black; text-decoration: none;");
	myLink.innerHTML = mw.config.get( 'wgSiteName' );
	
	document.body.appendChild(myDiv);

	// place certain links in the footer
	// This is for less used links
	var forFoot = document.querySelectorAll("#t-permalink, #t-cite, #p-coll-print_export UL LI");
	var foot = document.getElementById('footer-places');
	var len = forFoot.length;
	
	for(var i = 0; i < len; i++) {
		var n = forFoot[i].parentNode.removeChild(forFoot[i]);
		n.id = null;
		n.className = 'noprint';
		foot.appendChild(n);
	}
	
	// move toolbox to drop down menu
	// do this before creating icon menu
	transferChildren("#p-tb LI A", "p-cactions");

	// language links
	var lang = document.querySelector("#p-lang UL");
	if(lang != null) {
		var list = lang.parentNode.removeChild(lang);
		list.style.MozColumnWidth = "133px";
		list.style.fontSize = "0.8em";

		var nele = document.createElement("DIV");
		nele.id = "languages-banner";
		nele.className = "catlinks noprint";
		nele.appendChild(list);
	
		document.getElementById("content").appendChild(nele);
	}
	
	// Create a wiki menu for navigation and interactions links
	var newMenu = document.createElement("DIV");
	newMenu.id = 'faviconMenu';
	newMenu.className = 'vectorMenu';
	newMenu.innerHTML = '<h5><a href="#"></a></h5><div class="menu"><ul></ul></div>';
	newMenu.style.position = 'relative';
	newMenu.style.top = '12px';
	newMenu.style.background = 'url(/favicon.ico) no-repeat 38% 38%';

	// Insert new menu
	var vectorMenu = document.getElementById('p-cactions');
	document.getElementById('right-navigation').insertBefore(newMenu, vectorMenu);
	
	// Extract help n-help
	var help = document.getElementById('n-help');
	help = help.parentNode.removeChild(help);
	
	// add menu items
	transferChildren(".portal LI A", "faviconMenu");
	
	// Now append help at end of icon menu
	mw.util.addPortletLink("faviconMenu", help.href, help[whichText], null, help.title, help.accesskey);
}

function transferChildren(fromSelect, toID) {
	var from = document.querySelectorAll(fromSelect);
	var to = document.getElementById(toID);
	var len = from.length;

	for(var i = 0; i < len; i++) {
		mw.util.addPortletLink(toID, from[i].href, from[i][whichText], null, from[i].title, from[i].accesskey);
		from[i].parentNode.removeChild(from[i]);
	}
}