MediaWiki:Gadget-ToggleSidebar.js: Difference between revisions

Want an adless experience? Log in or Create an account.
no that wasn't the problem. this should fix it.
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();
} );
}
}