Jump to content

User:Bradv/hidenavpanel.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
navpanel = {
	get hidden() {
		return $.cookie('navpanelhidden') == 'true';
	},
	hide: function() {
		$.cookie('navpanelhidden', 'true');
		$("#mw-panel").css('display','none');
		$("#content").css('margin-left','0');
		$("#left-navigation").css('margin-left','0');
		$("#footer").css('margin-left','0');
		$("#togglenavpanel").html('►');
	},
	show: function() {
		$.cookie('navpanelhidden', 'false');
		$("#mw-panel").css('display','');
		$("#content").css('margin-left','');
		$("#left-navigation").css('margin-left','');
		$("#footer").css('margin-left','');
		$("#togglenavpanel").html('◄');
	},
	init: function() {
		if ($('#togglenavpanel').length === 0) {
			$("#p-namespaces").children('ul').prepend("<li><span><a id='togglenavpanel'>◄</a></span></li>");
		}
		$('#togglenavpanel').click(function() {
			if (navpanel.hidden) {
				navpanel.show();
			} else {
				navpanel.hide();
			}
		});
		if (navpanel.hidden) {
			navpanel.hide();
		}
	}
};
$(navpanel.init);