/** This initializes the mod actions button on the article show page (app/views/articles/show.html.erb). */ export default function initializeActionsPanel(user, path) { const modActionsMenuHTML = ` `; const modActionsMenuIconHTML = ` `; function toggleModActionsMenu() { document.querySelector('.mod-actions-menu').classList.toggle('showing'); document.querySelector('.mod-actions-menu-btn').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; panelDocument .querySelector('.close-actions-panel') .classList.remove('hidden'); } document.querySelector('.mod-actions-menu').innerHTML = modActionsMenuHTML; // eslint-disable-next-line no-restricted-globals if (!top.document.location.pathname.includes('/mod')) { // don't show mod button in mod center page document.getElementById( 'mod-actions-menu-btn-area', ).innerHTML = modActionsMenuIconHTML; document .querySelector('.mod-actions-menu-btn') .addEventListener('click', toggleModActionsMenu); } }