MediaWiki:Common.js: Difference between revisions
Appearance
Content deleted Content added
No edit summary |
No edit summary |
||
| (2 intermediate revisions 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 () { |
|||
$(document).ready(function() { |
|||
// Code zum Anzeigen des Tooltips |
|||
if ('ontouchstart' in window || navigator.maxTouchPoints > 0) { |
|||
$('.custom-tooltip, abbr[title]').on('click', function(e) { |
|||
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. |
|||
} |
|||
}); |
|||
} |
|||
}); |
|||
mw.hook('wikipage.content').add(function($content) { |
|||
// Erkennt mobile Touch-Gesten |
|||
if ('ontouchstart' in window || navigator.maxTouchPoints > 0) { |
|||
// Sucht nach Ihrer CSS-Klasse (z. B. .wiki-tooltip) |
|||
$content.find('.wiki-tooltip').on('click', function(e) { |
|||
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(); |
|||
}); |
|||
} |
|||
}); |
}); |
||