Bruger:HP/common.js

Spring til navigation Spring til søgning

Bemærk: Efter at have gemt er du måske nødt til at tømme din browsers cache for at kunne se ændringerne.

  • Firefox / Safari: Hold Shift nede og klik på Reload, eller tryk enten Ctrl-F5 eller Ctrl-R (⌘-R på en Mac).
  • Google Chrome: Tryk Ctrl-Shift-R (⌘-Shift-R på en Mac).
  • Internet Explorer / Edge: Hold Ctrl nede og klik på Refresh, eller tryk på Ctrl-F5.
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files
// Se også [[MediaWiki:Common.js]] 
// aktiveres i Localsettings.php med $wgAllowUserJs  = true; 

var customizeToolbar = function () {

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'group',
	'pages': {
		'colors': {
			'layout': 'table',
			'label': 'Colors',
			'headings': [
				{ text: 'Name' }, // or use textMsg for localization, see also above
				{ text: 'Temperature' },
				{ text: 'Swatch' }
			],
			'rows': [
				{
					'name': { text: 'Red' },
					'temp': { text: 'Warm' },
					'swatch': { html: '<div style="width:10px;height:10px;background-color:red;">' }
				},
				{
					'name': { text: 'Blue' },
					'temp': { text: 'Cold' },
					'swatch': { html: '<div style="width:10px;height:10px;background-color:blue;">' }
				},
				{
					'name': { text: 'Silver' },
					'temp': { text: 'Neutral' },
					'swatch': { html: '<div style="width:10px;height:10px;background-color:silver;">' }
				}
			]
		}
	}
} );

};

/* 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 );
		}
	} );
}