MediaWiki:Common.js : Différence entre versions

De Canard Wiki
Sauter à la navigation Sauter à la recherche
(Page créée avec « var customizeToolbar = function () { $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { section: 'advanced', group: 'format', tools: { "comment": { label: 'Comment'... »)
 
Ligne 4 : Ligne 4 :
 
group: 'format',
 
group: 'format',
 
tools: {
 
tools: {
"comment": {
+
"youtube": {
label: 'Comment',
+
label: 'youtube',
 
type: 'button',
 
type: 'button',
 
icon: '//upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png',
 
icon: '//upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png',
Ligne 11 : Ligne 11 :
 
type: 'encapsulate',
 
type: 'encapsulate',
 
options: {
 
options: {
pre: "<!-- ",
+
pre: "<youtube> ",
post: " -->"
+
post: " </youtube>"
 
}
 
}
 
}
 
}

Version du 25 mars 2018 à 13:16

var customizeToolbar = function () {
	$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
	section: 'advanced',
	group: 'format',
	tools: {
		"youtube": {
			label: 'youtube',
			type: 'button',
			icon: '//upload.wikimedia.org/wikipedia/commons/3/37/Btn_toolbar_commentaire.png',
			action: {
				type: 'encapsulate',
				options: {
					pre: "<youtube> ",
					post: " </youtube>"
				}
			}
		}
	}
} );
};

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