post-hover.js: enable only if the device supports hovering

This commit is contained in:
Zankaria 2025-01-03 16:12:59 +01:00 committed by Zankaria
parent 6b3e578013
commit dffc22ddf3

View File

@ -13,7 +13,13 @@
* *
*/ */
onReady(function() { /*
* Unknown media types always return false, so old browsers (css media 3 or prior to css media) which do support
* any-hover or css media queries may return false negatives.
* Handle it by checking if the query is explicitly NOT supported.
*/
if (!window.matchMedia('(any-hover: none)').matches) {
onReady(function() {
let dontFetchAgain = []; let dontFetchAgain = [];
initHover = function() { initHover = function() {
let link = $(this); let link = $(this);
@ -174,4 +180,5 @@ onReady(function() {
$(document).on('new_post', function(e, post) { $(document).on('new_post', function(e, post) {
$(post).find('div.body a:not([rel="nofollow"])').each(initHover); $(post).find('div.body a:not([rel="nofollow"])').each(initHover);
}); });
}); });
}