Difference between revisions of "User:Suicide machine/common.js"
From PCGamingWiki, the wiki about fixing PC games
m |
m |
||
Line 1: | Line 1: | ||
− | var | + | var customizeToolbar2 = function() { |
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
sections: { | sections: { | ||
'templates': { | 'templates': { | ||
− | type: ' | + | type: 'toolbar', |
label: 'Extended Templates', | label: 'Extended Templates', | ||
groups: { | groups: { | ||
Line 37: | Line 37: | ||
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 && mw.user.options.get( 'showtoolbar' ) == 1 ) { | if ( mw.user.options.get( 'usebetatoolbar' ) == 1 && mw.user.options.get( 'showtoolbar' ) == 1 ) { | ||
$.when( | $.when( | ||
− | mw.loader.using( 'ext.wikiEditor. | + | mw.loader.using( 'ext.wikiEditor.toolbar' ), |
$.ready | $.ready | ||
− | ).then( | + | ).then( customizeToolbar2 ); |
} | } | ||
} ); | } ); |
Revision as of 21:26, 14 July 2018
var customizeToolbar2 = function() { $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { sections: { 'templates': { type: 'toolbar', label: 'Extended Templates', groups: { templates: { 'label': 'Extended Templates', 'tools': { 'testrow': { label: 'Test row', type: 'button', icon: '//pcgamingwiki.com/images/6/67/Editor_Icon_-_Availability_Table_Row.svg', action: { type: 'encapsulate', options: { pre: "{{Availability/row| ", peri: "store", post: " | id | DRM | notes | Key | OS }}", ownline: true } } }, } } } } } } ); }; /* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar . . . */ if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) { mw.loader.using( 'user.options', function () { // This can be the string "0" if the user disabled the preference ([[bugzilla:52542#c3]]) if ( mw.user.options.get( 'usebetatoolbar' ) == 1 && mw.user.options.get( 'showtoolbar' ) == 1 ) { $.when( mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready ).then( customizeToolbar2 ); } } ); } function addAnchorInHeaders() { $('span.mw-headline', '#mw-content-text').each(function() { var $this = $(this); if ($this.attr('id') !== undefined) { $('<span class="mw-linkhere"></span>').text(' • ').append( $('<a></a>').text('Link').attr({title: 'Link', href: '#'+$this.attr('id')}) ).appendTo(this); } }); } $(addAnchorInHeaders);