MediaWiki:Common.js
aus dem Koch-Wiki (kochwiki.org)
Hinweis: Leere nach dem Veröffentlichen den Browser-Cache, um die Änderungen sehen zu können.
- Firefox/Safari: Umschalttaste drücken und gleichzeitig Aktualisieren anklicken oder entweder Strg+F5 oder Strg+R (⌘+R auf dem Mac) drücken
- Google Chrome: Umschalttaste+Strg+R (⌘+Umschalttaste+R auf dem Mac) drücken
- Edge: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
var customizeToolbar = function () {
function createreplacement(namespace){
var textArea = $('#wpTextbox1');
var sel = textArea.textSelection('getSelection');
sel = sel.replace(/\r/g, ''); // IE before 9 doesn't remove the \r's
sel = '[[' + namespace + ':' + sel + '|' + sel + ']]';
textArea.textSelection('encapsulateSelection', {pre: sel, replace: true});
};
$('#wpTextbox1').wikiEditor('addToToolbar', {
'section': 'main',
'group': 'insert',
'tools': {
'Zubereitung': {
label: 'Zubereitung',
type: 'button',
icon: '//kochwiki.org/w/images/d/da/Zubereitung_editor.png',
action: {
type: 'callback',
execute: function () {
createreplacement('Zubereitung');
}
}
},
'Zutat': {
label: 'Zutat',
type: 'button',
icon: '//kochwiki.org/w/images/thumb/8/8b/Zutat_editor.png/22px-Zutat_editor.png',
action: {
type: 'callback',
execute: function () {
createreplacement('Zutat');
}
}
},
'Grad': {
label: 'Grad Celsius',
type: 'button',
icon: '//kochwiki.org/w/images/4/44/Gc.png',
action: {
type: 'encapsulate',
options: {
pre: '{{G|', peri: '<Temperatur>', post: '}}'
}
}
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
'sections': {
'kw': {
'type': 'toolbar',
'label': 'Koch-Wiki'
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
'section': 'kw',
'groups': {
'difficulty': {
'label': 'Schwierigkeit'
},
'links': {
'label': 'Links'
}
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
'section': 'kw',
'group': 'difficulty',
'tools': {
'easy': {
label: 'Leicht',
type: 'button',
icon: '//www.kochwiki.org/w/images/4/4a/1.png',
action: {
type: 'replace',
options: {
pre: 'leicht'
}
}
},
'easymiddle': {
label: 'Leicht bis mittel',
type: 'button',
icon: '//www.kochwiki.org/w/images/f/fb/2.png',
action: {
type: 'replace',
options: {
pre: 'leicht bis mittel'
}
}
},
'middle': {
label: 'Mittel',
type: 'button',
icon: '//www.kochwiki.org/w/images/1/10/3.png',
action: {
type: 'replace',
options: {
pre: 'mittel'
}
}
},
'middlehard': {
label: 'Mittel bis schwierig',
type: 'button',
icon: '//www.kochwiki.org/w/images/0/09/4.png',
action: {
type: 'replace',
options: {
pre: 'mittel bis schwierig'
}
}
},
'hard': {
label: 'Schwierig',
type: 'button',
icon: '//www.kochwiki.org/w/images/8/82/5.png',
action: {
type: 'replace',
options: {
pre: 'schwierig'
}
}
},
}
});
$('#wpTextbox1').wikiEditor('addToToolbar', {
'section': 'kw',
'group': 'links',
'tools': {
'wp': {
label: 'Wikipedia-Artikel verlinken',
type: 'button',
icon: '//kochwiki.org/w/images/thumb/c/c7/Wikipedia_editor.png/22px-Wikipedia_editor.png',
action: {
type: 'encapsulate',
options: {
pre: '[[wikipedia:',
post: '|]]'
}
}
},
'reise': {
label: 'WikiVoyage-Artikel verlinken',
type: 'button',
icon: '//kochwiki.org/w/images/thumb/6/6b/Reise_editor.png/22px-Reise_editor.png',
action: {
type: 'encapsulate',
options: {
pre: '[[Reise:',
post: '|]]'
}
}
},
'kat': {
label: 'Kategorie verlinken',
type: 'button',
icon: '//kochwiki.org/w/images/thumb/e/e9/Kategorie_editor.png/22px-Kategorie_editor.png',
action: {
type: 'encapsulate',
options: {
pre: '[[:Kategorie:',
post: '|]]'
}
}
}
}
});
};
if ($.inArray(mw.config.get('wgAction'), [
'edit',
'submit'
]) !== - 1) {
mw.loader.using( [ 'user.options', 'ext.wikiEditor.toolbar' ], function() { $( function () {
if (mw.user.options.get('usebetatoolbar') == 1) {
customizeToolbar();
}
})});
};