Jump to content

User:Equazcion/ToggleEditNotices.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.
if ((mw.config.get('wgAction') == "edit") || (mw.config.get('wgAction') == "submit")){ 
	
	// If option is not set, display edit notices by default
	if (typeof HideEditNotices == 'undefined'){
		var HideEditNotices = false;	
	}
	
	// Add toggle link and set initial state
	if (HideEditNotices == true){
		$('.editnotice-area').attr('hidden',''); 
		$('#firstHeading span:first').after(' <a style="font-weight:bold;font-size:10px" class="enTog" href="#aza">Show Edit Notice</a>');
	} else {
		$('#firstHeading span:first').after(' <a style="font-weight:bold;font-size:10px" class="enTog" href="#aza">Hide Edit Notice</a>');
	}

	// Set link function
	$('.enTog').click(function(){
		if ($('.editnotice-area').attr('hidden') == "hidden"){
			$('.editnotice-area').prop('hidden', false);
			$('.enTog').html('Hide Edit Notice');
		} else {
			$('.editnotice-area').attr('hidden','');
			$('.enTog').html('Show Edit Notice');
		}
	});
	
}