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 (v9) – mit zwei Buttons nebeneinander/untereinander je nach Platz */ | ||
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_v9', // Version hochsetzen, damit alle es 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 17: | Zeile 16: | ||
'<p>Wir würden uns daher sehr freuen, wenn ihr anstatt uns lieber das Projekt vom Whiskywaiter unterstützen würdet.</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><strong>Jede Spende zählt!</strong></p>' + | ||
'<p><a href="https://www. | '<p><a href="https://www.thewhiskywaiter.com/charity-event" target="_blank" rel="noopener" class="mw-ui-button">Mehr erfahren</a></p>', | ||
wikiButton: { | |||
text: 'Mehr auf dem Wiki', | |||
url: 'https://ados-wiki.de/index.php?title=Test2' | |||
}, | |||
showOnNamespaces: 'all', | showOnNamespaces: 'all', | ||
dailyLimit: 1, | dailyLimit: 1, | ||
| Zeile 26: | Zeile 29: | ||
if (!CONFIG.enabled) return; | if (!CONFIG.enabled) return; | ||
var ns = mw.config.get('wgNamespaceNumber'); | var ns = mw.config.get('wgNamespaceNumber'); | ||
if (CONFIG.showOnNamespaces !== 'all' && | if (CONFIG.showOnNamespaces !== 'all' && | ||
| Zeile 34: | Zeile 36: | ||
} | } | ||
var isAnon = mw.config.get('wgUserName') === null; | var isAnon = mw.config.get('wgUserName') === null; | ||
function storageGet(k){ try { return window.localStorage.getItem(k); } catch (e) { return null; } } | function storageGet(k){ try { return window.localStorage.getItem(k); } catch (e) { return null; } } | ||
| Zeile 44: | Zeile 45: | ||
$(function () { | $(function () { | ||
var $overlay = $('<div>', { 'class': 'mw-popup-overlay' }); | var $overlay = $('<div>', { 'class': 'mw-popup-overlay' }); | ||
var $modal = $('<div>', { | var $modal = $('<div>', { | ||
| Zeile 53: | Zeile 53: | ||
}); | }); | ||
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' })) | ||
| Zeile 60: | Zeile 59: | ||
var $title = $('<h2>', { id: 'mw-popup-title' }).text(CONFIG.title); | var $title = $('<h2>', { id: 'mw-popup-title' }).text(CONFIG.title); | ||
var $content = $('<div>', { 'class': 'mw-popup-content' }).html(CONFIG.html); | var $content = $('<div>', { 'class': 'mw-popup-content' }).html(CONFIG.html); | ||
$modal.append($logoWrap, $title, $content, $ | var $btnOk = $('<button>', { 'class': 'mw-popup-close', type: 'button' }).text('OK'); | ||
var $btnWiki = $('<a>', { | |||
'class': 'mw-popup-wiki-button', | |||
'href': CONFIG.wikiButton.url, | |||
'target': '_blank', | |||
'rel': 'noopener' | |||
}).text(CONFIG.wikiButton.text); | |||
var $btnWrapper = $('<div>', { 'class': 'mw-popup-button-row' }).append($btnOk, $btnWiki); | |||
$modal.append($logoWrap, $title, $content, $btnWrapper); | |||
$('body').append($overlay, $modal); | $('body').append($overlay, $modal); | ||
// Fokus setzen | // Fokus setzen | ||
setTimeout(function(){ try { $modal.attr('tabindex','-1').focus(); } catch(e) {} }, 0); | setTimeout(function(){ try { $modal.attr('tabindex','-1').focus(); } catch(e) {} }, 0); | ||
| Zeile 75: | Zeile 83: | ||
} | } | ||
$btnOk.on('click', close); | |||
$ | |||
if (CONFIG.clickBackdropToClose) $overlay.on('click', close); | if (CONFIG.clickBackdropToClose) $overlay.on('click', close); | ||
if (CONFIG.escToClose) { | if (CONFIG.escToClose) { | ||
| Zeile 88: | Zeile 95: | ||
} | } | ||
markSeen(); | markSeen(); | ||
}); | }); | ||
})(jQuery, mw); | })(jQuery, mw); | ||
}); | }); | ||
Version vom 1. September 2025, 22:56 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */
/* Charity-Popup (v9) – mit zwei Buttons nebeneinander/untereinander je nach Platz */
mw.loader.using(['mediawiki.util', 'jquery']).then(function () {
(function ($, mw) {
'use strict';
var CONFIG = {
enabled: true,
id: 'charity_notice_v9', // Version hochsetzen, damit alle es 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>',
wikiButton: {
text: 'Mehr auf dem Wiki',
url: 'https://ados-wiki.de/index.php?title=Test2'
},
showOnNamespaces: 'all',
dailyLimit: 1,
escToClose: true,
clickBackdropToClose: true
};
if (!CONFIG.enabled) return;
var ns = mw.config.get('wgNamespaceNumber');
if (CONFIG.showOnNamespaces !== 'all' &&
$.isArray(CONFIG.showOnNamespaces) &&
$.inArray(ns, CONFIG.showOnNamespaces) === -1) {
return;
}
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 () {
var $overlay = $('<div>', { 'class': 'mw-popup-overlay' });
var $modal = $('<div>', {
'class': 'mw-popup-modal',
'role': 'dialog',
'aria-modal': 'true',
'aria-labelledby': 'mw-popup-title'
});
var $logoWrap = $('<div>', { 'class': 'mw-popup-logo' })
.append($('<div>', { 'class': 'mw-popup-heart' }))
.append($('<img>', { src: CONFIG.logoUrl, alt: 'Kinderherzen Logo' }));
var $title = $('<h2>', { id: 'mw-popup-title' }).text(CONFIG.title);
var $content = $('<div>', { 'class': 'mw-popup-content' }).html(CONFIG.html);
var $btnOk = $('<button>', { 'class': 'mw-popup-close', type: 'button' }).text('OK');
var $btnWiki = $('<a>', {
'class': 'mw-popup-wiki-button',
'href': CONFIG.wikiButton.url,
'target': '_blank',
'rel': 'noopener'
}).text(CONFIG.wikiButton.text);
var $btnWrapper = $('<div>', { 'class': 'mw-popup-button-row' }).append($btnOk, $btnWiki);
$modal.append($logoWrap, $title, $content, $btnWrapper);
$('body').append($overlay, $modal);
// Fokus setzen
setTimeout(function(){ try { $modal.attr('tabindex','-1').focus(); } catch(e) {} }, 0);
function close() {
markSeen();
$overlay.remove();
$modal.remove();
$(document).off('keydown.mwpopup');
}
$btnOk.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();
}
});
}
markSeen();
});
})(jQuery, mw);
});