MediaWiki:Common.js: Unterschied zwischen den Versionen

Keine Bearbeitungszusammenfassung
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 (v5) – einmal pro Tag, mit Herz-Logo-Effekt */
/* 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: 'charity_notice_v5', // Bei Änderungen erhöhen
       id: 'charity_notice_v6', // Version hochgesetzt, damit alle es neu sehen
       title: 'Charity für Kinderherzen',
       title: 'Charity für Kinderherzen',
      // Tipp: Logo besser lokal im Wiki hosten, falls externe Bilder blockiert werden:
       logoUrl: 'https://www.kinderherzen.de/wp-content/uploads/logo_kinderherzen.png',
       logoUrl: 'https://www.kinderherzen.de/wp-content/uploads/2019/03/kinderherzen.de_orange_RGB.jpg',
       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); }


    // DOM erst nach Render
     $(function () {
     $(function () {
       // Overlay + Modal
       // 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) {
          e = e || window.event;
           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:
       }
       }


       // Als gesehen markieren (damit Reload am selben Tag nicht erneut zeigt)
       // Direkt als gesehen markieren
       markSeen();
       markSeen();
     });
     });
   })(jQuery, mw);
   })(jQuery, mw);
}).catch(function (e) {
}).catch(function (e) {
   // Fallback: falls Loader scheitert, leise ignorieren
   console.error('Popup init error:', e);
  // console.error('Popup init error:', e);
});
});