MediaWiki:Gadget-ToggleSidebar.js

From Zelda Dungeon Wiki
Revision as of 18:03, April 27, 2021 by Locke (talk | contribs) (skin -> mw.config.values["skin"])
Jump to navigation Jump to search
Want an adless experience? Log in or Create an account.

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: hold Shift while clicking Reload, or press either Ctrl+F5 or Ctrl+R (Command+R on a Mac)
  • Google Chrome: press Ctrl+Shift+R (Command+Shift+R on a Mac)
  • Internet Explorer: hold Ctrl while clicking Refresh, or press Ctrl+F5
  • Konqueror: click Reload or press F5
  • Opera: clear the cache in Tools → Preferences
var sidebarSwitch;
 
function sidebarHide() {
	document.getElementById("mw-panel").style.visibility = "hidden";
	document.getElementById("mw-head-base").style.marginLeft = "0";
	document.getElementById("content").style.marginLeft = "0";
	document.getElementById("left-navigation").style.left = "0";
	document.getElementById("footer").style.marginLeft = "0";
	if(typeof sidebarSwitch == "object") {
		sidebarSwitch.parentNode.removeChild(sidebarSwitch);
	}
	sidebarSwitch = mw.util.addPortletLink("p-cactions", "javascript:sidebarShow()", "Show Sidebar", "ca-sidebar", "Show the navigation links", "a");
}
 
function sidebarShow() {
	document.getElementById("mw-panel").style.visibility = "";
	document.getElementById("mw-head-base").style.marginLeft = "";
	document.getElementById("content").style.marginLeft = "";
	document.getElementById("left-navigation").style.left = "";
	document.getElementById("footer").style.marginLeft = "";
	if(typeof sidebarSwitch == "object") {
		sidebarSwitch.parentNode.removeChild(sidebarSwitch);
	}
	sidebarSwitch = mw.util.addPortletLink("p-cactions", "javascript:sidebarHide()", "Hide Sidebar", "ca-sidebar", "Hide the navigation links", "a");
}
 
// Only activate on Vector skin
if(mw.config.values["skin"] == "vector") {
	jQuery(function() {
		// Change this if you want to show the sidebar by default
		sidebarShow();
	});
}