MediaWiki:Common.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K |
K |
||
Zeile 7: | Zeile 7: | ||
'section': 'advanced', | 'section': 'advanced', | ||
'groups': { | 'groups': { | ||
− | ' | + | 'templates': { |
− | 'label': ' | + | 'label': 'Vorlagen' // or use labelMsg for a localized label, see above |
} | } | ||
} | } | ||
Zeile 16: | Zeile 16: | ||
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { | ||
'section': 'advanced', | 'section': 'advanced', | ||
− | 'group': ' | + | 'group': 'templates', |
'tools': { | 'tools': { | ||
− | ' | + | 'spoiler': { |
label: 'Spoiler', | label: 'Spoiler', | ||
type: 'button', | type: 'button', | ||
− | icon: '/images/buttons/spoiler.png', | + | icon: 'https://waterlands.boxofcare.de/images/buttons/spoiler.png', |
action: { | action: { | ||
type: 'encapsulate', | type: 'encapsulate', |
Version vom 17. August 2020, 18:20 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */
/* Zusätzliche Toolbarbuttons */
var customizeToolbar = function () {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'advanced',
'groups': {
'templates': {
'label': 'Vorlagen' // or use labelMsg for a localized label, see above
}
}
}
);
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
'section': 'advanced',
'group': 'templates',
'tools': {
'spoiler': {
label: 'Spoiler',
type: 'button',
icon: 'https://waterlands.boxofcare.de/images/buttons/spoiler.png',
action: {
type: 'encapsulate',
options: {
pre: "{{Spoiler|",
periMsg: 'Spoilerinhalt',
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 );
}
} );
}
/* Spoiler-Funktionen */
spoilerButtons = document.getElementsByClassName("showSpoilerButton");
for(var i = 0; i < spoilerButtons.length; i++) {
spoilerButtons[i].addEventListener("click", toggleSpoiler);
}
function toggleSpoiler(e) {
var button = e.target;
var container = e.target.parentElement;
var innerSpoiler = container.querySelector(".spoilerInner");
if(innerSpoiler.classList.contains("spoilerHidden")) {
innerSpoiler.classList.remove("spoilerHidden");
button.innerText = "Zuklappen";
} else {
innerSpoiler.classList.add("spoilerHidden");
button.innerText = "Aufklappen";
}
}