MediaWiki:Gadget-ToggleSidebar.js: Difference between revisions

From Zelda Dungeon Wiki
Jump to navigation Jump to search
Want an adless experience? Log in or Create an account.
m (if I remember my javascript, this will resolve the function scoping issue)
(no that wasn't the problem. this should fix it.)
Line 1: Line 1:
var sidebarSwitch;
var sidebarSwitch;
   
   
var sidebarHide = function() {
function sidebarHide() {
document.getElementById("mw-panel").style.visibility = "hidden";
document.getElementById("mw-panel").style.visibility = "hidden";
document.getElementById("mw-head-base").style.marginLeft = "0";
document.getElementById("mw-head-base").style.marginLeft = "0";
Line 10: Line 10:
sidebarSwitch.parentNode.removeChild(sidebarSwitch);
sidebarSwitch.parentNode.removeChild(sidebarSwitch);
}
}
sidebarSwitch = mw.util.addPortletLink("p-cactions", "javascript:sidebarShow()", "Show Sidebar", "ca-sidebar", "Show the navigation links", "a");
sidebarSwitch = mw.util.addPortletLink("p-cactions", "#", "Show Sidebar", "ca-sidebar", "Show the navigation links", "a");
$( sidebarSwitch ).on( 'click', function ( e ) {
sidebarShow();
e.preventDefault();
} );
}
}
   
   
var sidebarShow = function() {
function sidebarShow() {
document.getElementById("mw-panel").style.visibility = "";
document.getElementById("mw-panel").style.visibility = "";
document.getElementById("mw-head-base").style.marginLeft = "";
document.getElementById("mw-head-base").style.marginLeft = "";
Line 22: Line 26:
sidebarSwitch.parentNode.removeChild(sidebarSwitch);
sidebarSwitch.parentNode.removeChild(sidebarSwitch);
}
}
sidebarSwitch = mw.util.addPortletLink("p-cactions", "javascript:sidebarHide()", "Hide Sidebar", "ca-sidebar", "Hide the navigation links", "a");
sidebarSwitch = mw.util.addPortletLink("p-cactions", "#", "Hide Sidebar", "ca-sidebar", "Hide the navigation links", "a");
$( sidebarSwitch ).on( 'click', function ( e ) {
sidebarHide();
e.preventDefault();
} );
}
}
   
   

Revision as of 18:17, April 27, 2021

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", "#", "Show Sidebar", "ca-sidebar", "Show the navigation links", "a");
	$( sidebarSwitch ).on( 'click', function ( e ) {
		sidebarShow();
		e.preventDefault();
	} );
}
 
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", "#", "Hide Sidebar", "ca-sidebar", "Hide the navigation links", "a");
	$( sidebarSwitch ).on( 'click', function ( e ) {
		sidebarHide();
		e.preventDefault();
	} );
}
 
// 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();
	});
}