MediaWiki:Common.js: Unterschied zwischen den Versionen
Erscheinungsbild
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); | |||
}); | }); | ||
Version vom 1. September 2025, 22:28 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */
/* Charity-Popup (v6) – angepasst für größeren weißen Bereich & höheres Herz */
mw.loader.using(['mediawiki.util', 'jquery']).then(function () {
(function ($, mw) {
'use strict';
var CONFIG = {
enabled: true,
id: 'charity_notice_v6', // Version hochgesetzt, damit alle es neu sehen
title: 'Charity für Kinderherzen',
logoUrl: 'https://www.kinderherzen.de/wp-content/uploads/logo_kinderherzen.png',
html:
'<p>Liebe Whisky, ADoS Heads,</p>' +
'<p>wir wurden jetzt schon gefragt, ob ihr dieses Wiki-Projekt unterstützen könnt.</p>' +
'<p>Wir freuen uns sehr, dass dieses Projekt so gut angenommen wurde.</p>' +
'<p>Wir würden uns daher sehr freuen, wenn ihr anstatt uns lieber das Projekt vom Whiskywaiter unterstützen würdet.</p>' +
'<p><strong>Jede Spende zählt!</strong></p>' +
'<p><a href="https://www.thewhiskywaiter.com/charity-event" target="_blank" rel="noopener" class="mw-ui-button">Mehr erfahren</a></p>',
showOnNamespaces: 'all', // 'all' oder z.B. [0,4]
dailyLimit: 1,
escToClose: true,
clickBackdropToClose: true
};
if (!CONFIG.enabled) return;
// Namespace-Filter
var ns = mw.config.get('wgNamespaceNumber');
if (CONFIG.showOnNamespaces !== 'all' &&
$.isArray(CONFIG.showOnNamespaces) &&
$.inArray(ns, CONFIG.showOnNamespaces) === -1) {
return;
}
// Einmal-pro-Tag
var isAnon = mw.config.get('wgUserName') === null;
function storageGet(k){ try { return window.localStorage.getItem(k); } catch (e) { return null; } }
function storageSet(k,v){ try { window.localStorage.setItem(k, v); } catch (e) {} }
var key = 'popup_' + CONFIG.id + (isAnon ? ':anon' : ':user');
var today = (function(d){ return d.getFullYear() + '-' + ('0'+(d.getMonth()+1)).slice(-2) + '-' + ('0'+d.getDate()).slice(-2); })(new Date());
if (storageGet(key) === today) return;
function markSeen(){ storageSet(key, today); }
$(function () {
// Overlay
var $overlay = $('<div>', { 'class': 'mw-popup-overlay' });
// Modal
var $modal = $('<div>', { 'class': 'mw-popup-modal', 'role': 'dialog', 'aria-modal': 'true' });
// Logo + Herz
var $logoWrap = $('<div>', { 'class': 'mw-popup-logo' })
.append($('<div>', { 'class': 'mw-popup-heart' }))
.append($('<img>', { src: CONFIG.logoUrl, alt: 'Kinderherzen Logo' }));
// Titel, Inhalt, Button
var $title = $('<h2>').text(CONFIG.title);
var $content = $('<div>', { 'class': 'mw-popup-content' }).html(CONFIG.html);
var $btn = $('<button>', { 'class': 'mw-popup-close', type: 'button' }).text('OK');
// Zusammenbauen
$modal.append($logoWrap, $title, $content, $btn);
$('body').append($overlay, $modal);
// Schließen-Funktion
function close() {
markSeen();
$overlay.remove();
$modal.remove();
$(document).off('keydown.mwpopup');
}
// Events
$btn.on('click', close);
if (CONFIG.clickBackdropToClose) $overlay.on('click', close);
if (CONFIG.escToClose) {
$(document).on('keydown.mwpopup', function (e) {
var key = e.key || e.keyCode;
if (key === 'Escape' || key === 'Esc' || key === 27) {
e.preventDefault();
close();
}
});
}
// Direkt als gesehen markieren
markSeen();
});
})(jQuery, mw);
}).catch(function (e) {
console.error('Popup init error:', e);
});