User:ACDW/modern.js

/* hide-vector-sidebar.js: Adds a button to toggle visibility of the Modern sidebar. Written by PleaseStand. Public domain; all copyright claims waived as described in http://en.wikipedia.org/wiki/Template:PD-self (Adapted to Modern by mahatman2)                */ /*global document, window, addOnloadHook, addPortletLink, skin*/ var sidebarSwitch; var minWidth = 932; function sidebarHide { document.getElementById("mw_portlets").style.visibility = "hidden"; document.getElementById("p-cactions").style.marginLeft = "0"; document.getElementById("mw_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_portlets").style.visibility = ""; document.getElementById("p-cactions").style.marginLeft = ""; document.getElementById("mw_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"); }

function testSbExec { if (window.innerWidth < minWidth) { sidebarHide; } else { sidebarShow; } }

// Only activate on Modern skin if(skin == "modern") { addOnloadHook(testSbExec); addEventListener("resize", testSbExec); }