MediaWiki:Common.js: Difference between revisions

no edit summary
No edit summary
No edit summary
 
(78 intermediate revisions by the same user not shown)
Line 1: Line 1:
var customizeToolbar = function() {
var customizeToolbar = function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'sections': {
'manual': {
'type': 'toolbar', // Can also be 'booklet'
'label': 'Manual'
// or 'labelMsg': 'section-manual-label' for a localized label
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'manual',
'groups': {
'tags': {
'label': 'Tags' // or use labelMsg for a localized label, see above
}
}
} );
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: 'long dash',
type: 'button',
icon: 'https://jollycontrarian.com/images/5/55/Dash.png',
action: {
type: 'encapsulate',
options: {
pre: "—",
post: ""
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: 'scarequotes',
type: 'button',
icon: 'https://jollycontrarian.com/images/b/ba/Scare.png',
action: {
type: 'encapsulate',
options: {
pre: "“",
post: "”"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: 'apostrophe',
type: 'button',
icon: 'https://jollycontrarian.com/images/5/5b/Apo.png',
action: {
type: 'encapsulate',
options: {
pre: "’",
post: ""
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: '{{ - }}',
type: 'button',
icon: 'https://jollycontrarian.com/images/3/30/Template.png',
action: {
type: 'encapsulate',
options: {
pre: "{{",
post: "}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"Substitute": {
label: 'subst:',
type: 'button',
icon: 'https://jollycontrarian.com/images/0/03/Sbs.png',
action: {
type: 'encapsulate',
options: {
pre: "{{subst:",
post: "}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"redirect": {
label: '==>',
type: 'button',
icon: 'https://jollycontrarian.com/images/9/91/Redirect.png',
action: {
type: 'encapsulate',
options: {
pre: "#redirect[[",
post: "]]"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
section: 'advanced',
group: 'format',
group: 'format',
tools: {
tools: {
"strikethrough": {
"template": {
label: 'strike',
label: 'tag',
type: 'button',
type: 'button',
icon: '//upload.wikimedia.org/wikipedia/commons/3/30/Btn_toolbar_rayer.png',
icon: 'https://jollycontrarian.com/images/7/76/Tag.png',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',
options: {
options: {
pre: "<s>",
pre: "{{t|",
post: "</s>"
post: "}}"
}
}
}
}
Line 18: Line 150:
}
}
});
});
};


var customizeToolbar = function() {
$('#wpTextbox1').wikiEditor('addToToolbar', {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
section: 'advanced',
group: 'format',
group: 'format',
tools: {
tools: {
"ISDAprov": {
"Prov": {
label: 'isdaprov',
label: 'isdaprov',
type: 'button',
type: 'button',
icon: 'http://amwellclear.co.uk/w/images/e/ed/Button_I.PNG',
icon: 'https://jollycontrarian.com/images/5/50/Isd.png',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',
Line 38: Line 168:
}
}
}
}
});
});
};


var customizeToolbar = function() {
$('#wpTextbox1').wikiEditor('addToToolbar', {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
section: 'advanced',
group: 'format',
group: 'format',
tools: {
tools: {
"gmslaprov": {
"Prov": {
label: 'gmslaprov',
label: 'euaprov',
type: 'button',
type: 'button',
icon: 'http://amwellclear.co.uk/w/images/f/f7/G.png',
icon: 'https://jollycontrarian.com/images/5/50/eua.png',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',
options: {
options: {
pre: "{{gmslaprov|",
pre: "{{euaprov|",
post: "}}"
post: "}}"
}
}
Line 60: Line 188:
}
}
});
});
};
var customizeToolbar = function() {
$('#wpTextbox1').wikiEditor('addToToolbar', {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
section: 'advanced',
group: 'format',
group: 'format',
tools: {
tools: {
"gmraprov": {
"ietaprov": {
label: 'grmaprov',
label: 'ietaprov',
type: 'button',
type: 'button',
icon: 'http://amwellclear.co.uk/w/images/4/49/Gmr.png',
icon: 'https://jollycontrarian.com/images/e/e9/Gms.png',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',
options: {
options: {
pre: "{{gmraprov|",
pre: "{{ietaprov|",
post: "}}"
post: "}}"
}
}
Line 81: Line 206:
}
}
});
});
};


var customizeToolbar = function() {
$('#wpTextbox1').wikiEditor('addToToolbar', {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
section: 'advanced',
group: 'format',
group: 'format',
tools: {
tools: {
"Substitute": {
"gmraprov": {
label: 'subst:',
label: '{{{1}}}|',
type: 'button',
type: 'button',
icon: 'http://amwellclear.co.uk/w/images/e/ed/Sbs.png',
icon: 'https://jollycontrarian.com/images/4/49/blank.png',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',
options: {
options: {
pre: "{{subst:",
pre: "{{{{{1}}}|",
post: "}}"
post: "}}"
}
}
Line 102: Line 225:
}
}
});
});
};


var customizeToolbar = function() {
$('#wpTextbox1').wikiEditor('addToToolbar', {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
section: 'advanced',
Line 112: Line 233:
label: 'eqderivprov',
label: 'eqderivprov',
type: 'button',
type: 'button',
icon: 'http://amwellclear.co.uk/w/images/1/1a/Eq.png',
icon: 'https://jollycontrarian.com/images/c/c3/Eqd.png',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',
Line 123: Line 244:
}
}
});
});
};


var customizeToolbar = function() {
 
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: 'vmcsaprov',
type: 'button',
icon: 'https://jollycontrarian.com/images/3/37/Csa.png',
action: {
type: 'encapsulate',
options: {
pre: "{{vmcsaprov|",
post: "}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: 'top trumps',
type: 'button',
icon: 'http://jollycontrarian.com/w/images/7/7d/Tag2.png',
action: {
type: 'encapsulate',
options: {
pre: "{{fwmdtt|nickname=",
post: "| imagetype=png| tagline= | documentation= | docscore=0| amendability= |amendscore=0| collateral= | collateralscore =0| transferability= | transferscore =0| leverage= | leveragescore =0| frightometer= | frightscore=0}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: 'wasteprov',
type: 'button',
icon: 'https://jollycontrarian.com/images/2/27/Wp.png',
action: {
type: 'encapsulate',
options: {
pre: "{{wasteprov|",
post: "}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: 'cddprov',
type: 'button',
icon: 'https://jollycontrarian.com/images/e/ec/Cp.png',
action: {
type: 'encapsulate',
options: {
pre: "{{cddprov|",
post: "}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: '{{g}}',
type: 'button',
icon: 'https://jollycontrarian.com/images/a/a7/Gl.PNG',
action: {
type: 'encapsulate',
options: {
pre: "{{g}}",
post: ""
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: '{{sa}}',
type: 'button',
icon: 'https://jollycontrarian.com/images/7/7c/Sa.PNG',
action: {
type: 'encapsulate',
options: {
pre: "{{sa}}",
post: ""
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'format',
tools: {
"template": {
label: '{{ucits5prov|}}',
type: 'button',
icon: 'https://jollycontrarian.com/images/d/d7/U.PNG',
action: {
type: 'encapsulate',
options: {
pre: "{{ucits5prov|",
post: "}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
section: 'advanced',
Line 131: Line 377:
tools: {
tools: {
"template": {
"template": {
label: 'template',
label: '{{strike|}}',
type: 'button',
icon: 'https://jollycontrarian.com/images/8/83/Aif.PNG',
action: {
type: 'encapsulate',
options: {
pre: "{{strike|",
post: "|}}"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'advanced',
group: 'tags',
tools: {
"template": {
label: 'isdamanual',
type: 'button',
type: 'button',
icon: 'http://amwellclear.co.uk/w/images/3/30/Template.png',
icon: 'https://jollycontrarian.com/images/c/c2/MI2002.png',
action: {
action: {
type: 'encapsulate',
type: 'encapsulate',
options: {
options: {
pre: "{{",
pre: "{{isdamanual|",
post: "}}"
post: "}}"
}
}
Line 143: Line 407:
}
}
}
}
});
});
 
};
};


/* 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 ) {
if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) {
mw.loader.using( 'user.options' ).then( function () {
mw.loader.using( 'user.options', function () {
// This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
$.when(
$.when(
mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready
mw.loader.using( 'ext.wikiEditor' ), $.ready
).then( customizeToolbar );
).then( customizeToolbar );
}
}
} );
} );
}
}
// Add the customizations to LiquidThreads' edit toolbar, if available
// Add the customizations to LiquidThreads' edit toolbar, if available
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );
mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );