Jump to content

MediaWiki:Common.js: Difference between revisions

From International Treaty Law Wiki
Created page with "Any JavaScript here will be loaded for all users on every page load.: PDF- und Share-Buttons oben rechts neben dem Seitentitel: $(function () { // Nur auf Artikelseiten (Namespace 0) if (mw.config.get('wgNamespaceNumber') !== 0) return; // PDF-Button mit Icon var pdfButton = ` <a class="pdf-download-button" href="javascript:window.print()" style="margin-left:10px;"> 📄 PDF </a> `; // Share-Button mit Icon..."
Tag: Recreated
 
No edit summary
Line 1: Line 1:
/* Any JavaScript here will be loaded for all users on every page load. */
/* Any JavaScript here will be loaded for all users on every page load. */
/* PDF- und Share-Buttons oben rechts neben dem Seitentitel */
/* Dezente PDF- und Share-Links im Wikipedia-Stil */
$(function () {
$(function () {


Line 6: Line 6:
     if (mw.config.get('wgNamespaceNumber') !== 0) return;
     if (mw.config.get('wgNamespaceNumber') !== 0) return;


     // PDF-Button mit Icon
     // Container für die Action-Links (rechts oben)
     var pdfButton = `
     var $actions = $('#p-views ul');
        <a class="pdf-download-button" href="javascript:window.print()" style="margin-left:10px;">
            📄 PDF
        </a>
    `;


     // Share-Button mit Icon
     if ($actions.length) {
    var shareButton = `
        <a class="pdf-download-button" href="javascript:navigator.share ? navigator.share({title: document.title, url: location.href}) : alert('Teilen wird von diesem Browser nicht unterstützt.')" style="margin-left:10px; background:#28a745;">
            🔗 Teilen
        </a>
    `;


    // Buttons an die Überschrift anhängen
        // PDF-Link (klein, unauffällig)
    $('.mw-first-heading').append(pdfButton + shareButton);
        $actions.append(
            '<li><a href="javascript:window.print()" title="Als PDF drucken">PDF</a></li>'
        );
 
        // Share-Link (klein, unauffällig)
        $actions.append(
            '<li><a href="javascript:navigator.share ? navigator.share({title: document.title, url: location.href}) : prompt(\'Link kopieren:\', location.href)" title="Seite teilen">Teilen</a></li>'
        );
    }
});
});

Revision as of 22:14, 17 January 2026

/* Any JavaScript here will be loaded for all users on every page load. */
/* Dezente PDF- und Share-Links im Wikipedia-Stil */
$(function () {

    // Nur auf Artikelseiten (Namespace 0)
    if (mw.config.get('wgNamespaceNumber') !== 0) return;

    // Container für die Action-Links (rechts oben)
    var $actions = $('#p-views ul');

    if ($actions.length) {

        // PDF-Link (klein, unauffällig)
        $actions.append(
            '<li><a href="javascript:window.print()" title="Als PDF drucken">PDF</a></li>'
        );

        // Share-Link (klein, unauffällig)
        $actions.append(
            '<li><a href="javascript:navigator.share ? navigator.share({title: document.title, url: location.href}) : prompt(\'Link kopieren:\', location.href)" title="Seite teilen">Teilen</a></li>'
        );
    }
});