Bruger:HP/common.js: Forskelle mellem versioner

Spring til navigation Spring til søgning
mNo edit summary
mNo edit summary
Linje 2: Linje 2:


$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'main',
'section': 'info',
groups: {
'pages': {
list: {
'colors': {
tools: {
'layout': 'table',
templates: {
'label': 'Colors',
label: 'Skabeloner',
'headings': [
type: 'select',
{ text: 'Name' }, // or use textMsg for localization, see also above
list: {
{ text: 'Temperature' },
'Wikipedia-opslag': {
{ text: 'Swatch' }
label: '{{w}}',
],
action: {
'rows': [
type: 'encapsulate',
{
options: {
'name': { text: 'Red' },
pre: '{{w',
'temp': { text: 'Warm' },
post: '}}'
'swatch': { html: '<div style="width:10px;height:10px;background-color:red;">' }
}
},
}
{
},
'name': { text: 'Blue' },
'Den Danske Ordbog': {
'temp': { text: 'Cold' },
label: 'DDO',
'swatch': { html: '<div style="width:10px;height:10px;background-color:blue;">' }
action: {
},
type: 'encapsulate',
{
options: {
'name': { text: 'Silver' },
pre: '{{ddo}}'
'temp': { text: 'Neutral' },
}
'swatch': { html: '<div style="width:10px;height:10px;background-color:silver;">' }
}
},
'Skib': {
label: 'Done',
action: {
type: 'encapsulate',
options: {
pre: '{{sk'
}
}
}
}
}
}
}
]
}
}
}
}

Versionen fra 3. sep. 2021, 01:15

var customizeToolbar = function () {

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	'section': 'info',
	'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 );
		}
	} );
}