MediaWiki:Common.js: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
K |
K |
||
Zeile 38: | Zeile 38: | ||
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */ | /* 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 ) { | if ( $.inArray( mw.config.get( 'wgAction' ), [ 'edit', 'submit' ] ) !== -1 ) { | ||
− | + | $.when( | |
− | + | mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready | |
− | + | ).then( customizeToolbar ); | |
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
Version vom 17. August 2020, 18:32 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 ) {
$.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";
}
}