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.
(addPortletLink -> mw.util.addPortletLink)
m (fix left-navigation margin)
 
(4 intermediate revisions by the same user not shown)
Line 5: Line 5:
document.getElementById("mw-head-base").style.marginLeft = "0";
document.getElementById("mw-head-base").style.marginLeft = "0";
document.getElementById("content").style.marginLeft = "0";
document.getElementById("content").style.marginLeft = "0";
document.getElementById("left-navigation").style.left = "0";
document.getElementById("left-navigation").style.marginLeft = "0";
document.getElementById("footer").style.marginLeft = "0";
document.getElementById("footer").style.marginLeft = "0";
if(typeof sidebarSwitch == "object") {
if(typeof sidebarSwitch == "object") {
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();
} );
}
}
   
   
Line 17: Line 21:
document.getElementById("mw-head-base").style.marginLeft = "";
document.getElementById("mw-head-base").style.marginLeft = "";
document.getElementById("content").style.marginLeft = "";
document.getElementById("content").style.marginLeft = "";
document.getElementById("left-navigation").style.left = "";
document.getElementById("left-navigation").style.marginLeft = "";
document.getElementById("footer").style.marginLeft = "";
document.getElementById("footer").style.marginLeft = "";
if(typeof sidebarSwitch == "object") {
if(typeof sidebarSwitch == "object") {
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();
} );
}
}
   
   
// Only activate on Vector skin
// Only activate on Vector skin
if(skin == "vector") {
if(mw.config.values["skin"] == "vector") {
addOnloadHook(function() {
jQuery(function() {
// Change this if you want to show the sidebar by default
// Change this if you want to show the sidebar by default
sidebarShow();
sidebarShow();
});
});
}
}

Latest revision as of 18:19, 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.marginLeft = "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.marginLeft = "";
	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();
	});
}