MediaWiki:Common.js: Unterschied zwischen den Versionen
Admin (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Admin (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
/* Das folgende JavaScript wird für alle Benutzer geladen. */ | /* Das folgende JavaScript wird für alle Benutzer geladen. */ | ||
/* Charity-Popup ( | /* Charity-Popup (v6) – angepasst für größeren weißen Bereich & höheres Herz */ | ||
mw.loader.using(['mediawiki.util', 'jquery']).then(function () { | mw.loader.using(['mediawiki.util', 'jquery']).then(function () { | ||
(function ($, mw) { | (function ($, mw) { | ||
| Zeile 7: | Zeile 7: | ||
var CONFIG = { | var CONFIG = { | ||
enabled: true, | enabled: true, | ||
id: ' | id: 'charity_notice_v6', // Version hochgesetzt, damit alle es neu sehen | ||
title: 'Charity für Kinderherzen', | title: 'Charity für Kinderherzen', | ||
logoUrl: 'https://www.kinderherzen.de/wp-content/uploads/logo_kinderherzen.png', | |||
logoUrl: 'https://www.kinderherzen.de/wp-content/uploads/ | |||
html: | html: | ||
'<p>Liebe Whisky, ADoS Heads,</p>' + | '<p>Liebe Whisky, ADoS Heads,</p>' + | ||
| Zeile 43: | Zeile 42: | ||
function markSeen(){ storageSet(key, today); } | function markSeen(){ storageSet(key, today); } | ||
$(function () { | $(function () { | ||
// Overlay | // Overlay | ||
var $overlay = $('<div>', { 'class': 'mw-popup-overlay' }); | var $overlay = $('<div>', { 'class': 'mw-popup-overlay' }); | ||
// Modal | |||
var $modal = $('<div>', { 'class': 'mw-popup-modal', 'role': 'dialog', 'aria-modal': 'true' }); | var $modal = $('<div>', { 'class': 'mw-popup-modal', 'role': 'dialog', 'aria-modal': 'true' }); | ||
// Logo + Herz | |||
var $logoWrap = $('<div>', { 'class': 'mw-popup-logo' }) | var $logoWrap = $('<div>', { 'class': 'mw-popup-logo' }) | ||
.append($('<div>', { 'class': 'mw-popup-heart' })) | .append($('<div>', { 'class': 'mw-popup-heart' })) | ||
.append($('<img>', { src: CONFIG.logoUrl, alt: 'Kinderherzen Logo' })); | .append($('<img>', { src: CONFIG.logoUrl, alt: 'Kinderherzen Logo' })); | ||
// Titel, Inhalt, Button | |||
var $title = $('<h2>').text(CONFIG.title); | var $title = $('<h2>').text(CONFIG.title); | ||
var $content = $('<div>', { 'class': 'mw-popup-content' }).html(CONFIG.html); | var $content = $('<div>', { 'class': 'mw-popup-content' }).html(CONFIG.html); | ||
var $btn = $('<button>', { 'class': 'mw-popup-close', type: 'button' }).text('OK'); | var $btn = $('<button>', { 'class': 'mw-popup-close', type: 'button' }).text('OK'); | ||
// Zusammenbauen | |||
$modal.append($logoWrap, $title, $content, $btn); | $modal.append($logoWrap, $title, $content, $btn); | ||
$('body').append($overlay, $modal); | $('body').append($overlay, $modal); | ||
// Schließen-Funktion | |||
function close() { | function close() { | ||
markSeen(); | markSeen(); | ||
| Zeile 67: | Zeile 71: | ||
} | } | ||
// Events | |||
$btn.on('click', close); | $btn.on('click', close); | ||
if (CONFIG.clickBackdropToClose) $overlay.on('click', close); | if (CONFIG.clickBackdropToClose) $overlay.on('click', close); | ||
if (CONFIG.escToClose) { | if (CONFIG.escToClose) { | ||
$(document).on('keydown.mwpopup', function (e) { | $(document).on('keydown.mwpopup', function (e) { | ||
var key = e.key || e.keyCode; | var key = e.key || e.keyCode; | ||
if (key === 'Escape' || key === 'Esc' || key === 27) { | if (key === 'Escape' || key === 'Esc' || key === 27) { | ||
| Zeile 80: | Zeile 84: | ||
} | } | ||
// | // Direkt als gesehen markieren | ||
markSeen(); | markSeen(); | ||
}); | }); | ||
})(jQuery, mw); | })(jQuery, mw); | ||
}).catch(function (e) { | }).catch(function (e) { | ||
console.error('Popup init error:', e); | |||
}); | }); | ||