feat: support middle-click on bookmark open buttons
This commit is contained in:
30
web/app.js
30
web/app.js
@@ -1512,6 +1512,32 @@ function openBookmarkQueries(baseQuery) {
|
|||||||
return opened;
|
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) {
|
function openBookmark(bookmark) {
|
||||||
if (!bookmark) {
|
if (!bookmark) {
|
||||||
return;
|
return;
|
||||||
@@ -1611,7 +1637,9 @@ function createBookmarkRow(bookmark) {
|
|||||||
openButton.title = searchVariants.map((variant) => `• ${variant}`).join('\n');
|
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');
|
const label = document.createElement('span');
|
||||||
label.className = 'bookmark-row__label';
|
label.className = 'bookmark-row__label';
|
||||||
|
|||||||
@@ -808,13 +808,17 @@
|
|||||||
openBtn.textContent = '🔗';
|
openBtn.textContent = '🔗';
|
||||||
openBtn.title = isActive ? 'Öffnen' : 'Deaktiviert';
|
openBtn.title = isActive ? 'Öffnen' : 'Deaktiviert';
|
||||||
openBtn.disabled = !isActive;
|
openBtn.disabled = !isActive;
|
||||||
openBtn.addEventListener('click', () => {
|
const handleOpenBookmark = () => {
|
||||||
const target = item.resolved_url || item.url_template;
|
const target = item.resolved_url || item.url_template;
|
||||||
if (!isActive) return;
|
if (!isActive) return;
|
||||||
if (target) {
|
if (target) {
|
||||||
window.open(target, '_blank', 'noopener');
|
window.open(target, '_blank', 'noopener');
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
openBtn.addEventListener('click', handleOpenBookmark);
|
||||||
|
if (typeof window.bindMiddleMouseOpen === 'function') {
|
||||||
|
window.bindMiddleMouseOpen(openBtn, handleOpenBookmark);
|
||||||
|
}
|
||||||
actionsTd.appendChild(openBtn);
|
actionsTd.appendChild(openBtn);
|
||||||
|
|
||||||
const toggleBtn = document.createElement('button');
|
const toggleBtn = document.createElement('button');
|
||||||
|
|||||||
@@ -1650,13 +1650,17 @@
|
|||||||
button.className = 'bookmark-subpage__messe-link';
|
button.className = 'bookmark-subpage__messe-link';
|
||||||
button.textContent = query;
|
button.textContent = query;
|
||||||
button.title = getTradeFairHoverTitle(row);
|
button.title = getTradeFairHoverTitle(row);
|
||||||
button.addEventListener('click', () => {
|
const handleOpenTradeFair = () => {
|
||||||
const opened = openTradeFairSearch(row, query);
|
const opened = openTradeFairSearch(row, query);
|
||||||
if (opened > 0) {
|
if (opened > 0) {
|
||||||
button.title = getTradeFairHoverTitle(row);
|
button.title = getTradeFairHoverTitle(row);
|
||||||
render();
|
render();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
button.addEventListener('click', handleOpenTradeFair);
|
||||||
|
if (typeof window.bindMiddleMouseOpen === 'function') {
|
||||||
|
window.bindMiddleMouseOpen(button, handleOpenTradeFair);
|
||||||
|
}
|
||||||
linksWrap.appendChild(button);
|
linksWrap.appendChild(button);
|
||||||
|
|
||||||
if (index < bookmarkQueries.length - 1) {
|
if (index < bookmarkQueries.length - 1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user