Jump to content

User:Technical 13/Scripts/editTemplateNoDoc.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('wgNamespaceNumber') === 10 && mw.config.get('wgAction') === 'edit' &&  $( '.template-documentation' ).length !== -1){
	$( '.template-documentation' ).css( 'display', 'none');
	var tnd = mw.util.addPortletLink(
		'p-tb',
		'#',
		'View doc',
		'pt-temp-doc',
		'View template documentation',
		null,
		null
	);
	$( tnd ).click( function ( e ) {
		e.preventDefault();
		/* Toggle documentation display */
		$( '.template-documentation' ).css( 'display', function (i, val) {
			return val === 'none' ? '' : 'none';
		});
		/* Toggle the link */
		$( 'li#pt-temp-doc a' ).html( function (i, val) {
			return val === 'View doc' ? 'Hide doc' : 'View doc';
		});
		/* Toggle the description */
		$( 'li#pt-temp-doc a' ).attr( 'title', function (i, val) {
			return val === 'View template documentation' ? 'Hide template documentation' : 'View template documentation';
		});
	});
} else {
	/*               Do nothing               */
}