Popup for touch devices

This commit is contained in:
Claude Brisson
2024-08-03 16:07:28 +02:00
parent c9a51fdf57
commit 01a6e05e73
4 changed files with 44 additions and 1 deletions

View File

@@ -194,6 +194,12 @@ function downloadFile(blob, filename) {
document.body.removeChild(link);
}
function isTouchDevice() {
return (('ontouchstart' in window) ||
(navigator.maxTouchPoints > 0) ||
(navigator.msMaxTouchPoints > 0));
}
onLoad(() => {
$('button.close').on('click', e => {
close_modal();
@@ -342,4 +348,17 @@ onLoad(() => {
let dialog = e.target.closest('.popup');
if (!dialog) close_modal();
});
if (isTouchDevice()) {
$("[title]").on('click', e => {
let item = e.target.closest('[title]');
let title = item.getAttribute('title');
let popup = item.find('.title-popup')
if (popup.length === 0) {
item.insertAdjacentHTML('beforeend', `<span class="title-popup">${title}</span>`);
} else {
item.removeChild(popup[0]);
}
});
}
});