Jump to content

MediaWiki:Vector.js

From wikiNonStop
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* All JavaScript here will be loaded for users of the Vector skin */

mw.hook('wikipage.content').add(function($content) {
    // Prüft, ob es sich um ein Touch-Gerät handelt
    if ('ontouchstart' in window || navigator.maxTouchPoints > 0) {
        
        // Sucht nach der Tooltip-Klasse und lauscht auf Klicks
        $content.find('.wiki-tooltip').on('click', function(e) {
            e.preventDefault();
            e.stopPropagation();
            
            var $tooltipContent = $(this).find('.tooltip-content');
            
            // Schließt alle anderen eventuell geöffneten Tooltips
            $('.tooltip-content').not($tooltipContent).hide();
            
            // Zeigt das aktuelle Tooltip an oder versteckt es (Toggle)
            $tooltipContent.toggle();
        });

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