|
@@ -64,7 +64,7 @@ export default async function init(playlist) { |
|
|
menuEl = html` |
|
|
menuEl = html` |
|
|
<ul class="context-menu" style="top: ${top}; left: ${left};"> |
|
|
<ul class="context-menu" style="top: ${top}; left: ${left};"> |
|
|
<li> |
|
|
<li> |
|
|
<button onclick=${createBookmark}> |
|
|
|
|
|
|
|
|
<button onclick=${() => { hideMenu(); createBookmark(); }}> |
|
|
${browser.i18n.getMessage(end !== undefined |
|
|
${browser.i18n.getMessage(end !== undefined |
|
|
? 'bookmarkSelectionContextMenuItemForFragment' |
|
|
? 'bookmarkSelectionContextMenuItemForFragment' |
|
|
: 'bookmarkSelectionContextMenuItemForSingleMoment' |
|
|
: 'bookmarkSelectionContextMenuItemForSingleMoment' |
|
@@ -76,7 +76,13 @@ export default async function init(playlist) { |
|
|
document.body.appendChild(menuEl); |
|
|
document.body.appendChild(menuEl); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
document.addEventListener('contextmenu', onContextMenu, false); |
|
|
|
|
|
|
|
|
function onMouseDown(event) { |
|
|
|
|
|
// A mouse-down outside the menu hides the menu. |
|
|
|
|
|
if (menuEl && !menuEl.contains(event.target)) { // note nodeX.contains(nodeX) === true |
|
|
|
|
|
hideMenu(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
document.addEventListener('click', event => { hideMenu(); }); |
|
|
|
|
|
|
|
|
document.addEventListener('contextmenu', onContextMenu); |
|
|
|
|
|
document.addEventListener('mousedown', onMouseDown); |
|
|
} |
|
|
} |