Jump to content

User:Skarmenadius/vector.js

From Wikipedia, the free encyclopedia
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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.
/* hide-vector-sidebar.js: Adds a button to toggle visibility of the Vector sidebar.
   Written by PleaseStand. Public domain; all copyright claims waived as described
   in http://en.wikipedia.orghttps://toquery.com/wiki/page/Template:PD-self */

( function ( mw, $ ) {
	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 ( sidebarSwitch ) {
		// 	sidebarSwitch.parentNode.removeChild(sidebarSwitch);
		// }
		// sidebarSwitch = mw.util.addPortletLink( 'p-cactions', '#', 'Show sidebar', 'ca-sidebar', 'Show the navigation links', 'a' );
		// $( sidebarSwitch ).click( function ( e ) {
		// 	e.preventDefault();
		// 	sidebarShow();
		// } );
	}
	
	function sidebarShow() {
		document.getElementById( 'mw-panel' ).style.visibility = 'visible';
		document.getElementById( 'mw-head-base' ).style.marginLeft = '11em';
		document.getElementById( 'content' ).style.marginLeft = '11em';
		document.getElementById( 'left-navigation' ).style.marginLeft = '11em';
		document.getElementById( 'footer' ).style.marginLeft = '11em';
		// if ( sidebarSwitch ) {
		// 	sidebarSwitch.parentNode.removeChild(sidebarSwitch);
		// }
		// sidebarSwitch = mw.util.addPortletLink( 'p-cactions', '#', 'Hide sidebar', 'ca-sidebar', 'Hide the navigation links', 'a' );
		// $( sidebarSwitch ).click( function ( e ) {
		// 	e.preventDefault();
		// 	sidebarHide();
		// } );
	}
	
	// Only activate on Vector skin
	// if ( mw.config.get( 'skin' ) === 'vector' ) {
	// 	$.when($.ready,mw.loader.using('mediawiki.util')).then(function(){
	// 		// Change this if you want to show the sidebar by default
	// 		sidebarHide();
	// 	} );
	// }
	
	content.onmouseover=function(){
	  if (event.clientX < 35){
	    sidebarShow();
	  }
	  else if (event.clientX > 200){
	    sidebarHide();
	
	  }
	};
	
}( mediaWiki, jQuery ) );