MediaWiki:Common.js

Revision as of 00:34, 29 July 2026 by MDGarcia (talk | contribs) (Move guide link to the toolbar tabs row as an 'Editor's Guide' tab-link (more prominent, opens in new tab))

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Add an "Editor's Guide" tab-link to the WikiEditor toolbar tabs row
   (next to Advanced / Special characters / Help). Opens the guide in a new
   tab; it is a plain link, not a section toggle. */
mw.loader.using( [ 'ext.wikiEditor', 'mediawiki.util' ] ).then( function () {
	mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
		var $tabs = $textarea.closest( '.wikiEditor-ui' )
			.find( '.wikiEditor-ui-toolbar .tabs' ).first();
		if ( !$tabs.length || $tabs.find( '.tab-guide' ).length ) {
			return;
		}
		var $link = $( '<a>' )
			.addClass( 'skin-invert' )
			.attr( {
				href: mw.util.getUrl( "TenthFleet:Contributor's guide" ),
				target: '_blank',
				rel: 'noopener'
			} )
			.text( "Editor's Guide" )
			.on( 'click', function ( e ) {
				// Prevent WikiEditor's tab-toggle handler from intercepting;
				// let the native link open the guide in a new tab.
				e.stopPropagation();
			} );
		$( '<span>' ).addClass( 'tab tab-guide' ).append( $link ).appendTo( $tabs );
	} );
} );