Jump to content

User:PleaseStand/hide-vector-sidebar.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by PleaseStand (talk | contribs) at 03:02, 2 May 2010 (only activate on Vector). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* hide-vector-sidebar.js: Adds a button to toggle visibility of the Vector sidebar.
   Written by PleaseStand. Public domain; all copyright claims waived as described
   in http://en.wikipedia.org/wiki/Template:PD-self */

/*global document, window, addPortletLink, hookEvent, skin*/

var sidebarSwitch;

function sidebarHide() {
	document.getElementById("panel").style.display = "none";
	document.body.style.marginLeft = "-10em";
	document.getElementById("left-navigation").style.left = "0";
	if(typeof sidebarSwitch == "object") {
		sidebarSwitch.parentNode.removeChild(sidebarSwitch);
	}
	sidebarSwitch = addPortletLink("p-cactions", "javascript:sidebarShow()", "Show sidebar", "ca-sidebar", "Show the navigation links", "a");
}

function sidebarShow() {
	document.getElementById("panel").style.display = "";
	document.body.style.marginLeft = "";
	document.getElementById("left-navigation").style.left = "";
	if(typeof sidebarSwitch == "object") {
		sidebarSwitch.parentNode.removeChild(sidebarSwitch);
	}
	sidebarSwitch = addPortletLink("p-cactions", "javascript:sidebarHide()", "Hide sidebar", "ca-sidebar", "Hide the navigation links", "a");
}

// Only activate on Vector skin
if(skin == "vector") {
	hookEvent("load", function() {
		// Change this if you want to show the sidebar by default
		sidebarHide();
	});
}