MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
m Move guide link to the toolbar tabs row as an 'Editor's Guide' tab-link (more prominent, opens in new tab) |
m Relabel toolbar tab-link 'Editor's Guide' -> 'Guide' |
||
| Line 16: | Line 16: | ||
rel: 'noopener' | rel: 'noopener' | ||
} ) | } ) | ||
.text( " | .text( "Guide" ) | ||
.on( 'click', function ( e ) { | .on( 'click', function ( e ) { | ||
// Prevent WikiEditor's tab-toggle handler from intercepting; | // Prevent WikiEditor's tab-toggle handler from intercepting; | ||
Latest revision as of 00:35, 29 July 2026
/* 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( "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 );
} );
} );