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 02:24, 2 May 2010 (moving button under drop-down arrow). 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 sidebarSwitch*/
function sidebarHide() {
	jQuery("#panel").css("display", "none");
	jQuery("body").css("margin-left", "-10em");
	jQuery("#left-navigation").css("left", "0");
	if(sidebarSwitch) {
		sidebarSwitch.parentNode.removeChild(sidebarSwitch);
	}
	sidebarSwitch = addPortletLink("p-views", "javascript:sidebarShow()", "Show sidebar", "p-cactions", "Show the navigation links", "h");
}
function sidebarShow() {
	jQuery("#panel").css("display", "");
	jQuery("body").css("margin-left", "");
	jQuery("#left-navigation").css("left", "");
	if(sidebarSwitch) {
		sidebarSwitch.parentNode.removeChild(sidebarSwitch);
	}
	sidebarSwitch = addPortletLink("p-views", "javascript:sidebarHide()", "Hide sidebar", "p-cactions", "Hide the navigation links", "h");
}
hookEvent("load", function() {
	// Change if you want the sidebar hidden by default
	sidebarShow();
});