Jump to content

MediaWiki:Common.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 52: Line 52:
});
});


// Mobil-Fix für Template-Tooltips mit title-Attribut
$(document.body).on('mouseenter touchstart', '[rel=tooltip]', function (e) {
⚫
$(document).ready(function() {
// Verhindert, dass der mobile Browser das Event als normalen Klick/Link-Öffnung wertet
if ('ontouchstart' in window || navigator.maxTouchPoints > 0) {
if (e.type === 'touchstart') {
$('.custom-tooltip, abbr[title]').on('click', function(e) {
e.preventDefault();
e.preventDefault();
var titleText = $(this).attr('title');
if (titleText) {
// Erstellt ein temporäres mobiles Mini-Popup über dem Element
alert(titleText); // Einfachste Variante.
// Alternativ kann hier ein schickeres div-Popup eingeblendet werden.
⚫
}
});
}
}

// --- HIER IHR CODE ZUM ANZEIGEN DES TOOLTIPS ---
// Beispiel:
⚫
$(this).find('.tooltip-content').show();
});
});


mw.hook('wikipage.content').add(function($content) {
// Optional: Schließen des Tooltips, wenn man auf Android irgendwo anders hintippt
// Erkennt mobile Touch-Gesten
⚫
$(document).on('touchstart', function (e) {
if ('ontouchstart' in window || navigator.maxTouchPoints > 0) {
if (!$(e.target).closest('[rel=tooltip]').length) {
// --- HIER IHR CODE ZUM VERSTECKEN DES TOOLTIPS ---
// Sucht nach Ihrer CSS-Klasse (z. B. .wiki-tooltip)
$content.find('.wiki-tooltip').on('click', function(e) {
⚫
// Beispiel:
$('.tooltip-content').hide();
e.preventDefault();
e.stopPropagation();
// Holt sich das versteckte Kind-Element (den Tooltip-Text)
var $tooltipContent = $(this).find('.tooltip-content');
// Wechselt die Sichtbarkeit bei jedem Klick/Tippen
$('.tooltip-content').not($tooltipContent).hide(); // Schließt andere offene Tooltips
$tooltipContent.toggle();
});

// Schließt das Tooltip-Fenster, wenn man irgendwo anders hinklickt
$(document).on('click', function() {
⚫
$('.tooltip-content').hide();
});
}
}
});
});



/**
/**