Bruger:HP/common.js: Forskelle mellem versioner

Spring til navigation Spring til søgning
mNo edit summary
mNo edit summary
Linje 7: Linje 7:
tools: {
tools: {
templates: {
templates: {
label: 'Templates',
label: 'Skabeloner',
type: 'select',
type: 'select',
list: {
list: {
'Ping-button': {
'Wikipedia-opslag': {
label: '{{Ping}}',
label: '{{w}}',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',
options: {
options: {
pre: '{{Ping|',
pre: '{{w',
post: '}}'
post: '}}'
}
}
}
}
},
},
'Clear-button': {
'Den Danske Ordbog': {
label: 'Clear',
label: 'DDO',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',
options: {
options: {
pre: '{{Clear}}'
pre: '{{ddo}}'
}
}
}
}
},
},
'Done-button': {
'Skib': {
label: 'Done',
label: 'Done',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',
options: {
options: {
pre: '{{Done}}'
pre: '{{sk'
post: '}}'
}
}
}
}

Versionen fra 3. sep. 2021, 00:57

var customizeToolbar = function () {

$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'main',
	groups: {
		list: {
			tools: {
				templates: {
					label: 'Skabeloner',
					type: 'select',
					list: {
						'Wikipedia-opslag': {
							label: '{{w}}',
							action: {
								type: 'encapsulate',
								options: {
									pre: '{{w',
									post: '}}'
								}
							}
						},
						'Den Danske Ordbog': {
							label: 'DDO',
							action: {
								type: 'encapsulate',
								options: {
									pre: '{{ddo}}'
								}
							}
						},
						'Skib': {
							label: 'Done',
							action: {
								type: 'encapsulate',
								options: {
									pre: '{{sk'
									post: '}}'
								}
							}
						}
					}
				}
			}
		}
	}
} );

};

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