import { isModerationPage } from '@utilities/moderation'; /** This initializes the mod actions button on the article show page (app/views/articles/show.html.erb). */ export function initializeActionsPanel(user, path) { const modActionsMenuHTML = ` `; const modActionsMenuIconHTML = ` `; function toggleModActionsMenu() { document .getElementsByClassName('mod-actions-menu')[0] .classList.toggle('showing'); document .getElementsByClassName('mod-actions-menu-btn')[0] .classList.toggle('hidden'); // showing close icon in the mod panel if it is opened by clicking the button const modContainer = document.getElementById('mod-container'); const panelDocument = modContainer.contentDocument; if (panelDocument) { panelDocument .getElementsByClassName('close-actions-panel')[0] .classList.remove('hidden'); } } document.getElementsByClassName('mod-actions-menu')[0].innerHTML = modActionsMenuHTML; // eslint-disable-next-line no-restricted-globals if (!isModerationPage()) { // don't show mod button in mod center page document.getElementById('mod-actions-menu-btn-area').innerHTML = modActionsMenuIconHTML; document .getElementsByClassName('mod-actions-menu-btn')[0] .addEventListener('click', toggleModActionsMenu); } }