const event_actions_popup_width = 100; const event_actions_popup_height = 260; const event_actions_popup_styling = ` #eventactionspopup { position: fixed; max-width: 90%; overflow-x: auto; z-index: 100; background: inherit; overflow: hidden; border: 1px solid var(--border-normal); padding: 0.5rem; visibility: hidden; display: none; opacity: 0; } #eventactionspopup[data-shown] { visibility: visible; display: block; opacity: 1; } #eventactionspopup .icon.close { float: right; margin: 0.1rem; } #eventactionspopup button.event-action { display: block; cursor: pointer; width: 3rem; height: 3rem; vertical-align: top; margin: 0.5rem; } #eventactionspopup button .action-name { display: block; margin-top: 0.33rem; text-transform: uppercase; font-size: xx-small; } `; let event_actions_popup; let event_actions_popup_form; let event_actions_popup_search_input; let event_actions_popup_parent_id_input; let event_actions_popup_emojis_list; let event_actions_popup_reaction_input; function open_event_actions_popup(event) { const event_id = event.target?.closest("[data-event_id]")?.dataset?.event_id; const position = get_best_coords_for_popup({ target_element: event.target, popup: { width: event_actions_popup_width, height: event_actions_popup_height, }, offset: { x: 4, y: 4, }, }); event_actions_popup.dataset.current_event_id = event_id; event_actions_popup.style.left = position.x + "px"; event_actions_popup.style.top = position.y + "px"; event_actions_popup.dataset.shown = true; } function clear_event_actions_popup() { if (!event_actions_popup) { return; } delete event_actions_popup.dataset.shown; } document.addEventListener("DOMContentLoaded", () => { if (!document.getElementById("event-actions-styling")) { const style = document.createElement("style"); style.id = "event-actions-styling"; style.innerHTML = event_actions_popup_styling; document.head.appendChild(style); } event_actions_popup = document.createElement("div"); event_actions_popup.id = "eventactionspopup"; event_actions_popup.innerHTML = `
`; document.body.appendChild(event_actions_popup); document.querySelector("body").addEventListener("click", (event) => { const is_in_the_event_actions_popup = event?.target?.closest("#eventactionspopup"); if (is_in_the_event_actions_popup) { return; } const is_an_event_actions_button = event?.target?.matches("button[commandfor]") || event?.target?.closest("button[commandfor]"); if (!is_an_event_actions_button) { clear_event_actions_popup(); return; } event.preventDefault(); open_event_actions_popup(event); }); });