User:Gryllida/WikiEditorEmoticons.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Gryllida/WikiEditorEmoticons. |
mw.loader.using(['mediawiki.api'], function () {
var customizeToolbar = function () {
// add emotions
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'main',
'group': 'insert',
'tools': {
// smiling
'addSmilingFace': {
label: 'Add a smiling face',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/8/85/Smiley.svg/22px-Smiley.svg.png',
action: {
type: 'encapsulate',
options: {
pre: "[[File:Smiley.svg|x20px|:-)]]" // text to be inserted
}
}
},
// smiling end
// File:Smiley XD.svg
// laughing
'addLaughingFace': {
label: 'Add a laughing face',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Smiley_XD.svg/22px-Smiley_XD.svg.png',
action: {
type: 'encapsulate',
options: {
pre: "[[File:Smiley XD.svg|x20px|:-)]]" // text to be inserted
}
}
},
// frowning
// Frowning-smiley.svg
'addFrowningFace': {
label: 'Add a frowning face',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/thumb/6/62/Frowning-smiley.svg/22px-Frowning-smiley.svg.png',
action: {
type: 'encapsulate',
options: {
pre: "[[File:Frowning-smiley.svg|x20px|:-)]]" // text to be inserted
}
}
},
}
} );
console.log(4);
};
// 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 () {
console.log(1);
// 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 );
}
} );
}
// == WikiEditor codes end ==
});