feat: support middle-click on bookmark open buttons

This commit is contained in:
2026-03-02 16:56:48 +01:00
parent 7ee22b6c8f
commit 438c0ce77c
3 changed files with 41 additions and 5 deletions

View File

@@ -1512,6 +1512,32 @@ function openBookmarkQueries(baseQuery) {
return opened;
}
function bindMiddleMouseOpen(element, handler) {
if (!element || typeof handler !== 'function') {
return;
}
// Prevent browser auto-scroll so middle click behaves like link-open here.
element.addEventListener('mousedown', (event) => {
if (event.button === 1) {
event.preventDefault();
}
});
element.addEventListener('auxclick', (event) => {
if (event.button !== 1) {
return;
}
event.preventDefault();
event.stopPropagation();
handler();
});
}
if (typeof window !== 'undefined') {
window.bindMiddleMouseOpen = bindMiddleMouseOpen;
}
function openBookmark(bookmark) {
if (!bookmark) {
return;
@@ -1611,7 +1637,9 @@ function createBookmarkRow(bookmark) {
openButton.title = searchVariants.map((variant) => `${variant}`).join('\n');
}
openButton.addEventListener('click', () => openBookmark(bookmark));
const handleOpenBookmark = () => openBookmark(bookmark);
openButton.addEventListener('click', handleOpenBookmark);
bindMiddleMouseOpen(openButton, handleOpenBookmark);
const label = document.createElement('span');
label.className = 'bookmark-row__label';

View File

@@ -808,13 +808,17 @@
openBtn.textContent = '🔗';
openBtn.title = isActive ? 'Öffnen' : 'Deaktiviert';
openBtn.disabled = !isActive;
openBtn.addEventListener('click', () => {
const handleOpenBookmark = () => {
const target = item.resolved_url || item.url_template;
if (!isActive) return;
if (target) {
window.open(target, '_blank', 'noopener');
}
});
};
openBtn.addEventListener('click', handleOpenBookmark);
if (typeof window.bindMiddleMouseOpen === 'function') {
window.bindMiddleMouseOpen(openBtn, handleOpenBookmark);
}
actionsTd.appendChild(openBtn);
const toggleBtn = document.createElement('button');

View File

@@ -1650,13 +1650,17 @@
button.className = 'bookmark-subpage__messe-link';
button.textContent = query;
button.title = getTradeFairHoverTitle(row);
button.addEventListener('click', () => {
const handleOpenTradeFair = () => {
const opened = openTradeFairSearch(row, query);
if (opened > 0) {
button.title = getTradeFairHoverTitle(row);
render();
}
});
};
button.addEventListener('click', handleOpenTradeFair);
if (typeof window.bindMiddleMouseOpen === 'function') {
window.bindMiddleMouseOpen(button, handleOpenTradeFair);
}
linksWrap.appendChild(button);
if (index < bookmarkQueries.length - 1) {