Difference between revisions of "MediaWiki:Common.js"
From GATE
Line 1: | Line 1: | ||
− | /* Any JavaScript here will be | + | /* Any JavaScript here will be loaded for all users on every page load. */ |
− | |||
− | |||
− | |||
− | |||
− | |||
var customizeToolbar = function () { | var customizeToolbar = function () { | ||
Line 11: | Line 6: | ||
'annotation': { | 'annotation': { | ||
'type': 'toolbar', // Can also be 'booklet' | 'type': 'toolbar', // Can also be 'booklet' | ||
+ | 'filters': [ 'body:not(.ns-2, .ns-10)' ], | ||
'label': 'Annotation' | 'label': 'Annotation' | ||
// or 'labelMsg': 'section-emoticons-label' for a localized label | // or 'labelMsg': 'section-emoticons-label' for a localized label |
Revision as of 11:01, 16 January 2017
/* Any JavaScript here will be loaded for all users on every page load. */
var customizeToolbar = function () {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'sections': {
'annotation': {
'type': 'toolbar', // Can also be 'booklet'
'filters': [ 'body:not(.ns-2, .ns-10)' ],
'label': 'Annotation'
// or 'labelMsg': 'section-emoticons-label' for a localized label
}
}
} );
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'annotation',
groups: {
'text': {
'label': 'TEI'
}
}
} );
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'text',
tools: {
"head": {
label: 'Header',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/d/db/TEI_Head22px.png',
action: {
type: 'encapsulate',
options: {
pre: '<head>',
post: "</head>"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'text',
tools: {
"paragraph": {
label: 'Paragraph',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/b/b3/TEI_P22px.png',
action: {
type: 'encapsulate',
options: {
pre: '<p>',
post: "</p>"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'text',
tools: {
"lb": {
label: 'Line-break',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/1/1b/TEI_Lb22px.png',
action: {
type: 'encapsulate',
options: {
pre: '<lb/>',
ownline: true
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'text',
tools: {
"pb": {
label: 'Page-break',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/2/28/TEI_Pb22px.png',
action: {
type: 'encapsulate',
options: {
pre: '<pb/>',
ownline: true
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'text',
tools: {
"add": {
label: 'Addition',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/0/09/TEI_Add22px.png',
action: {
type: 'encapsulate',
options: {
pre: '<add>',
post: "</add>"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'text',
tools: {
"del": {
label: 'Deletion',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/b/bb/TEI_Del22px.png',
action: {
type: 'encapsulate',
options: {
pre: '<del>',
post: "</del>"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'text',
tools: {
"gap": {
label: 'Gap',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/3/3e/TEI_Gap22px.png',
action: {
type: 'encapsulate',
options: {
pre: '<gap/>',
ownline: true
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'text',
tools: {
"unclear": {
label: 'Unclear',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/c/c7/TEI_Unclear22px.png',
action: {
type: 'encapsulate',
options: {
pre: '<unclear>',
post: "</unclear>"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'text',
tools: {
"sic": {
label: 'Sic',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/9/91/TEI_Sic22px.png',
action: {
type: 'encapsulate',
options: {
pre: '<sic>',
post: "</sic>"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'text',
tools: {
"underline": {
label: 'Underline',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/b/b5/TEI_Und22px.png',
action: {
type: 'encapsulate',
options: {
pre: '<hi rend="underline">',
post: "</hi>"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'text',
tools: {
"superscript": {
label: 'Superscript',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/9/92/TEI_Sup22px.png',
action: {
type: 'encapsulate',
options: {
pre: '<hi rend="superscript">',
post: "</hi>"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'text',
tools: {
"note": {
label: 'Note',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/f/f1/TEI_Note22px.png',
action: {
type: 'encapsulate',
options: {
pre: '<note>',
post: "</note>"
}
}
}
}
});
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
section: 'annotation',
groups: {
'entities': {
'label': 'Entities'
}
}
} );
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'entities',
tools: {
"name": {
label: 'Name',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/5/57/Icon_Users.png',
action: {
type: 'encapsulate',
options: {
pre: '[[citesName::',
post: "]]"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'entities',
tools: {
"place": {
label: 'Place',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/7/76/Icon_Placeholder.png',
action: {
type: 'encapsulate',
options: {
pre: '[[citesPlace::',
post: "]]"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'entities',
tools: {
"work": {
label: 'Work',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/e/e0/Icon_work.png',
action: {
type: 'encapsulate',
options: {
pre: '[[citesWork::',
post: "]]"
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
section: 'annotation',
group: 'entities',
tools: {
"object": {
label: 'Object',
type: 'button',
icon: 'http://mediawikiarchivio.unigre.it/mediawiki/images/7/7e/Icon_object.png',
action: {
type: 'encapsulate',
options: {
pre: '[[citesObject::',
post: "]]"
}
}
}
}
});
};
/* 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.toolbar' ), $.ready
).then( customizeToolbar );
}
} );
}