User:Robinr78/common.js

From Robin's SM-201 Website
< User:Robinr78
Revision as of 17:46, 6 January 2023 by Robinr78 (talk | contribs) (Replaced content with "var customizeToolbar = function () { →‎2020-0830: →‎Enable section:SM-201: $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'sections': { 'SM-201': { 'type': 'toolbar', // Can also be 'booklet' 'label': 'SM-201' } } } ); →‎Enable section:Other: $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'sections': { 'Other': { 'type': 'toolbar', // Can also be 'booklet' 'label': 'Other' } } } ); →‎Enable Group:Format:: $( '#wpTextbox1'...")
Jump to navigation Jump to search

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)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
var customizeToolbar = function () {
/* 2020-0830 */

/*  Enable section:SM-201 */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'sections': {
		'SM-201': {
			'type': 'toolbar', // Can also be 'booklet'
			'label': 'SM-201'
	}
	}
} );

/* Enable section:Other */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
   'sections': {
		'Other': {
			'type': 'toolbar', // Can also be 'booklet'
			'label': 'Other'
	}
	}
} );



/* Enable Group:Format: */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'SM-201',
	'groups': {
		'Format': {
			'label': 'Format' 
		}
	}
} );

/* --- Enable Format:Comment */

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'SM-201',
	group: 'Format',
	tools: {
		"Comment": {
			label: 'Comment',
			type: 'button',
icon: 'http://www.sm-201.org/a/images/6/66/Editor_!.png',
			action: {
				type: 'encapsulate',
				options: {
					pre:  '<!-- ',
					post: ' -->'
				}
			}
		}
	}
} );

/* --- Enable Format:Apostrophe */
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'SM-201',
	group: 'Format',
	tools: {
		"Apostrope": {
			label: 'Apostrophe',
			type: 'button',
icon: 'http://www.sm-201.org/a/images/3/39/Editor_apos.png',
			action: {
				type: 'encapsulate',
				options: {
					pre:  "'",
					post: "'"
				}
			}
		}
	}
} );

/* --- Enable Format:<clear /> */
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'SM-201',
	group: 'Format',
	tools: {
		"Clear": {
			label: 'Clear',
			type: 'button',
icon: 'http://sm-201.org/a/images/b/be/Editor_c.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: '<br clear="all"> ',
					post: '' 
				}
			}
		}
	}
});

/* --- Enable Format:List Item */
$('#wpTextbox1').wikiEditor('addToToolbar', {
	section: 'SM-201',
	group: 'Format',
	tools: {
		"Item2": {
			label: 'Item2',
			type: 'button',
icon: 'http://sm-201.org/a/images/7/79/Button_item.jpg',
			action: {
				type: 'encapsulate',
				options: {
					pre: '* [[',
					post: ']]' 
				}
			}
		}
	}
});



/* Leave everything below this line alone ===================== */
};

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) {
	mw.loader.using( 'user.options' ).then( function () {
		// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
		if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
			$.when(
				mw.loader.using( 'ext.wikiEditor' ), $.ready
			).then( customizeToolbar );
		}
	} );
}