REVIEW [[:Category:User-',
post: '|', post: ']]
MediaWiki:Common.js
Aus Afterbuy-Wiki
Hinweis: Leere nach dem Speichern 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
- Internet Explorer: Strg+F5 drücken oder Strg drücken und gleichzeitig Aktualisieren anklicken
- Opera: Gehe zu Menü → Einstellungen (Opera → Einstellungen auf dem Mac) und dann auf Datenschutz & Sicherheit → Browserdaten löschen → Gespeicherte Bilder und Dateien.
console.log('actual js version is: 1.10.13');
/* gif player */
const nodes = document.querySelectorAll('img[src$=".gif"]');
var gifs = [];
for (var i = 0; i < nodes.length; i++) {
var gifObject = { imgNode: nodes[i], overlayNode: document.createElement("div"), image: new Image() };
gifObject.image.src = nodes[i].src;
gifObject.overlayNode.innerHTML ='<span title="Video erneut abspielen"><i class="fa fa-play" aria-hidden="true"></i></span>';
gifObject.overlayNode.classList.add("overlay");
gifObject.imgNode.parentNode.append(gifObject.overlayNode);
gifs.push(gifObject);
gifObject.overlayNode.childNodes[0].addEventListener("click", clickHandler);
}
function clickHandler(event) {
event.preventDefault();
event.stopPropagation();
event.stopImmediatePropagation();
var gif = find(gifs, function (gif, index) { return gif.overlayNode === event.target.parentNode.parentNode; });
if (gif !== null) {
gif.imgNode.src = gif.image.src;
}
}
function find(arr, callback) {
for (var i = 0; i < arr.length; i++) {
var result = callback(arr[i], i);
if (result) return arr[i];
}
return null;
}
/* this is the list of afterbuy-elements that should be available in the editor */
var abElements = {
'button': {
label: 'button',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Button|',
post: '}}'
}
}
},
'buttondark': {
label: 'button dark',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Button:Dark|',
post: '}}'
}
}
},
'buttonlight': {
label: 'button light',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Button:Light|',
post: '}}'
}
}
},
'check': {
label: 'check',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Check|',
post: '}}'
}
}
},
'checknot': {
label: 'check not checked',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Check:Unchecked|',
post: '}}'
}
}
},
'checkgrey': {
label: 'check grey',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Check:Grey|',
post: '}}'
}
}
},
'checkgreynot': {
label: 'check grey not checked',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Check:Grey:Unchecked|',
post: '}}'
}
}
},
'code': {
label: 'code',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Code|',
post: '}}'
}
}
},
'footerlink': {
label: 'footer-link',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Link:Footer|',
post: '}}'
}
}
},
'groupleft': {
label: 'group left',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Group:Left|',
post: '|}}'
}
}
},
'groupright': {
label: 'group right',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Group:Right|',
post: '}}'
}
}
},
'input': {
label: 'input',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Input|',
post: '}}'
}
}
},
'key': {
label: 'key',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Key|',
post: '}}'
}
}
},
'label': {
label: 'label',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Label|',
post: '}}'
}
}
},
'link': {
label: 'link',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Link|',
post: '}}'
}
}
},
'option': {
label: 'option',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Option|',
post: '}}'
}
}
},
'section': {
label: 'section',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Section|',
post: '}}'
}
}
},
'select': {
label: 'select',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:Select|',
post: '}}'
}
}
},
'topmenueheader': {
label: 'top menue header',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:TopMenue:Header|',
post: '}}'
}
}
},
'topmenueentry': {
label: 'top menue entry',
action: {
type: 'encapsulate',
options: {
pre: '{{AB:TopMenue:Entry|',
post: '}}'
}
}
}
};
var state = {
'statuswip': {
label: 'in arbeit',
action: {
type: 'encapsulate',
options: {
pre: '{{Status|wip|',
post: '}}'
}
}
},
'statusreview': {
label: 'review',
action: {
type: 'encapsulate',
options: {
pre: '{{Status|review|',
post: '}}'
}
}
}
};
var letterboxes = {
'lb_red_black': {
label: 'red black',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_red_black">',
post: '</span>'
}
}
},
'lb_red_light': {
label: 'red light',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_lightred">',
post: '</span>'
}
}
},
'lb_red_dark': {
label: 'red dark',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_darkred">',
post: '</span>'
}
}
},
'lb_red_white': {
label: 'red white',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_whitered">',
post: '</span>'
}
}
},
'lb_grey': {
label: 'grey',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_grey">',
post: '</span>'
}
}
},
'lb_yellow_light': {
label: 'yellow light',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_lightyellow">',
post: '</span>'
}
}
},
'lb_yellow_dark': {
label: 'yellow dark',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_darkyellow">',
post: '</span>'
}
}
},
'lb_yellow_white': {
label: 'yellow white',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_whiteyellow">',
post: '</span>'
}
}
},
'lb_blue_light': {
label: 'blue light',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_lightblue">',
post: '</span>'
}
}
},
'lb_blue_dark': {
label: 'blue dark',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_darkblue">',
post: '</span>'
}
}
},
'lb_blue_white': {
label: 'blue white',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_whiteblue">',
post: '</span>'
}
}
},
'lb_green_light': {
label: 'green light',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_lightgreen">',
post: '</span>'
}
}
},
'lb_green_dark': {
label: 'green dark',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_darkgreen">',
post: '</span>'
}
}
},
'lb_green_white': {
label: 'green white',
action: {
type: 'encapsulate',
options: {
pre: '<span class="ab_letterbox ab_whitegreen">',
post: '</span>'
}
}
}
};
/* this is the list of templates that should be available in the editor */
var specialsObject = {
'Artikel:Start': {
label: 'Artikel:Start',
action: {
type: 'encapsulate',
options: {
pre: '{{Artikel:Start|title=',
post: '|text=}}'
}
}
},
'Aufruf': {
label: 'Aufruf/Target',
action: {
type: 'encapsulate',
options: {
pre: '{{Target|Aufruf',
post: '|1|2}}'
}
}
},
'Ausblenden': {
label: 'Ausblenden',
action: {
type: 'encapsulate',
options: {
pre: '{{Collapse|text=',
post: '|class=light|label=Einblenden}}'
}
}
},
'BreadcrumbOutline': {
label: 'Breadcrumb outline',
action: {
type: 'encapsulate',
options: {
pre: '{{Breadcrumb|',
post: '}}'
}
}
},
'BreadcrumbInner': {
label: 'Breadcrumb inline',
action: {
type: 'encapsulate',
options: {
pre: '{{Breadcrumb|',
post: '|x}}'
}
}
},
'Card': {
label: 'Card',
action: {
type: 'encapsulate',
options: {
pre: '{{Card|title=|text=|link=',
post: '}}'
}
}
},
'Einblenden': {
label: 'Einblenden',
action: {
type: 'encapsulate',
options: {
pre: '{{Collapsed|text=',
post: '|class=light|label=Einblenden}}'
}
}
},
'FAQ': {
label: 'FAQ',
action: {
type: 'encapsulate',
options: {
pre: '{{FAQ|',
post: '}}'
}
}
},
'Image': {
label: 'Image',
action: {
type: 'encapsulate',
options: {
pre: '{{Img|filename=',
post: '|head=|breadcrumb=|foot=|alt=|align=|height=|headclasses=|footclasses=|imgclasses=}}'
}
}
},
'Legende': {
label: 'Legende',
action: {
type: 'encapsulate',
options: {
pre: '{{Legende| >> Feld :: Inhalt',
post: '| name=Name| description=Beschreibung}}'
}
}
},
'Steps': {
label: 'Steps',
action: {
type: 'encapsulate',
options: {
pre: '{{Steps|>>',
post: '1 :: content :: headline}}'
}
}
},
'ReviewComment': {
label: 'Review Comment',
action: {
type: 'encapsulate',
options: {
pre: '{{Review|',
post: '|comment|user}}'
}
}
},
'Youtube': {
label: 'Youtube',
action: {
type: 'encapsulate',
options: {
pre: '{{Youtube|',
post: '}}'
}
}
}
};
var sectionsObject = {
'Section': {
label: 'Section',
action: {
type: 'encapsulate',
options: {
pre: '{{Section|title=',
post: '|level=|subtitle=|include=|intent=|subintent=}}'
}
}
},
'Section1': {
label: 'Section1',
action: {
type: 'encapsulate',
options: {
pre: '{{Section1|title=',
post: '|subtitle=|include=|intent=|subintent=}}'
}
}
},
'Section2': {
label: 'Section2',
action: {
type: 'encapsulate',
options: {
pre: '{{Section2|title=',
post: '|subtitle=|include=|intent=|subintent=}}'
}
}
},
'Section3': {
label: 'Section3',
action: {
type: 'encapsulate',
options: {
pre: '{{Section3|title=',
post: '|subtitle=|include=|intent=|subintent=}}'
}
}
},
'Section4': {
label: 'Section4',
action: {
type: 'encapsulate',
options: {
pre: '{{Section4|title=',
post: '|subtitle=|include=|intent=|subintent=}}'
}
}
},
'Section5': {
label: 'Section5',
action: {
type: 'encapsulate',
options: {
pre: '{{Section5|title=',
post: '|subtitle=|include=|intent=|subintent=}}'
}
}
},
'Section6': {
label: 'Section6',
action: {
type: 'encapsulate',
options: {
pre: '{{Section6|title=',
post: '|subtitle=|include=|intent=|subintent=}}'
}
}
}
};
var panelsObject = {
'Beispiel': {
label: 'Beispiel',
action: {
type: 'encapsulate',
options: {
pre: '{{Beispiel|',
post: '}}'
}
}
},
'Info': {
label: 'Info',
action: {
type: 'encapsulate',
options: {
pre: '{{Info|',
post: '}}'
}
}
},
'Quote': {
label: 'Quote',
action: {
type: 'encapsulate',
options: {
pre: '{{Quote|',
post: '}}'
}
}
},
'BeispielCode': {
label: 'Beispiel - Code',
action: {
type: 'encapsulate',
options: {
pre: '{{CodeExample|',
post: '}}'
}
}
},
'Code': {
label: 'CodeBlock',
action: {
type: 'encapsulate',
options: {
pre: '{{Code|',
post: '}}'
}
}
},
'Tip': {
label: 'Tip',
action: {
type: 'encapsulate',
options: {
pre: '{{Tip|',
post: '}}'
}
}
},
'Warnung': {
label: 'Warnung',
action: {
type: 'encapsulate',
options: {
pre: '{{Warnung|',
post: '}}'
}
}
},
'wip': {
label: 'WIP',
action: {
type: 'encapsulate',
options: {
pre: '{{WIP|',
post: '}}'
}
}
},
'wipimage': {
label: 'WIP - Image',
action: {
type: 'encapsulate',
options: {
pre: '{{WIP|Image missing}}',
post: ''
}
}
}
};
/* here the function for adding the templates in the editor as a dropdown */
var customizeToolbar = function () {
$('#wpTextbox1').wikiEditor('addToToolbar', {
'sections': {
'afterbuy': {
'type': 'toolbar',
'label': 'Afterbuy'
}
},
'section': 'afterbuy',
groups: {
list: {
tools: {
panels: {
label: 'Panels',
type: 'select',
list: panelsObject,
},
sections: {
label: 'Sections',
type: 'select',
list: sectionsObject,
},
specials: {
label: 'Specials',
type: 'select',
list: specialsObject,
},
abelements: {
label: 'Afterbuy-Elements',
type: 'select',
list: abElements,
},
letterboxes: {
label: 'Letter-Boxes',
type: 'select',
list: letterboxes,
},
state: {
label: 'Bearbeitungsstatus',
type: 'select',
list: state,
},
newline: {
label: 'BR',
icon: '//upload.wikimedia.org/wikipedia/commons/3/3c/OOjs_UI_icon_newline-ltr.svg',
type: 'button',
action: {
type: 'encapsulate',
options: {
pre: "<br />"
}
}
},
simpleimage: {
label: 'IMG',
icon: "data:image/svg+xml,%0A%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Ctitle%3E add image %3C/title%3E%3Cpath d='M16 17H2l3.5-4.5 2.5 3 3.5-4.5.5.67V8H8V6H2a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-6h-5.75z'/%3E%3Cpath d='M16 4V0h-2v4h-4v2h4v4h2V6h4V4h-4z'/%3E%3C/svg%3E%0A",
type: 'button',
action: {
type: 'encapsulate',
options: {
pre: "{{Img|filename=",
post: "}}"
}
}
}
}
}
}
});
};
/* 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) {
mw.loader.using('user.options').then(function () {
if (mw.user.options.get('usebetatoolbar') == 1) {
$.when(
mw.loader.using('ext.wikiEditor'), $.ready).then(customizeToolbar);
}
});
};
/* enable editing of section and draw.io diagrams when logged in */
if (typeof(document.getElementById('pt-logout')) != 'undefined' && document.getElementById('pt-logout') != null) {
$('body').append('<style>.mw-editsection, .mw-editdrawio{ display:block !important; }</style>');
if (document.getElementById('contentSub')) {
document.getElementById('contentSub').setAttribute('style', 'display:block !important');
}
};
$(window).on("scroll", function () {
if ($(this).scrollTop() > 800) {
$( "#backtotop" ).removeClass( "d-none" ).addClass( "d-flex" );
} else {
$( "#backtotop" ).removeClass( "d-flex" ).addClass( "d-none" );
}
});