MediaWiki:Common.js: Unterschied zwischen den Versionen
Aus Infopedia
Zeile 13: | Zeile 13: | ||
touch_div[i].classList.add('hasHover'); | touch_div[i].classList.add('hasHover'); | ||
} | } | ||
+ | $('[data-toggle="popover"][data-trigger="hover"]').popover(); | ||
} | } | ||
Zeile 21: | Zeile 22: | ||
touch_div[i].classList.remove('hasHover'); | touch_div[i].classList.remove('hasHover'); | ||
} | } | ||
+ | $('[data-toggle="popover"][data-trigger="hover"]').popover('dispose'); | ||
} | } | ||
Version vom 7. November 2022, 22:13 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */ var lastTouchTime = 0; var isTouched = false; var isTouchDevice = false; var timer = null;; var touchduration = 500; function addHover() { var touch_div = document.getElementsByClassName("touch-dev"); for(var i = 0; i < touch_div.length; i++) { touch_div[i].classList.add('hasHover'); } $('[data-toggle="popover"][data-trigger="hover"]').popover(); } function removeHover() { var touch_div = document.getElementsByClassName("touch-dev"); for(var i = 0; i < touch_div.length; i++) { touch_div[i].classList.remove('hasHover'); } $('[data-toggle="popover"][data-trigger="hover"]').popover('dispose'); } function mousemove_event() { if (isTouched || (new Date() - lastTouchTime < 500)) return addHover(); isTouchDevice = false; } function touchstart_event() { if (!isTouchDevice) removeHover(); isTouched = true; isTouchDevice = true; } function touchend_event() { isTouched = false; lastTouchTime = new Date(); } document.addEventListener('touchstart', touchstart_event, true); document.addEventListener('touchend', touchend_event, true); document.addEventListener('mousemove', mousemove_event, true); addHover(); function touchstart_element_event() { this.classList.add('touchDevice-hovered'); if (!timer) { timer = setTimeout(onlongtouch.bind(this), touchduration); } } function touchend_element_event() { this.classList.remove('touchDevice-hovered'); this.classList.remove('touchDevice-longpress') cancel_timer(); } function cancel_timer() { if (timer) { clearTimeout(timer); timer = null; } } function onlongtouch() { timer = null; this.classList.add('touchDevice-longpress'); } var touch_div = document.getElementsByClassName("touch-dev"); for(var i = 0; i < touch_div.length; i++) { touch_div[i].addEventListener('touchstart', touchstart_element_event, true); touch_div[i].addEventListener('touchend', touchend_element_event, true); touch_div[i].addEventListener('touchmove', cancel_timer, true); touch_div[i].addEventListener('touchcancel', cancel_timer, true); touch_div[i].addEventListener("contextmenu", function(event) { if (isTouchDevice) { event.preventDefault(); event.stopPropagation(); return false; } }); } /* Enable Popover on all Pages */ $(function () { $('[data-toggle="popover"]').popover(); $('[data-toggle="popover"] > a').removeAttr("title"); })