cordis/client/webapp/elements/events-server-title.ts

21 lines
943 B
TypeScript
Raw Normal View History

2021-11-07 21:57:09 +00:00
import Q from '../q-module';
import UI from '../ui';
import createServerTitleContextMenu from './context-menu-srv-title';
import ElementsUtil from './require/elements-util';
2021-10-30 17:26:41 +00:00
export default function bindAddServerTitleEvents(document: Document, q: Q, ui: UI) {
q.$('#server-name-container').addEventListener('click', () => {
if (ui.activeConnection === null) return;
if (ui.activeServer === null) return;
if (!ui.activeServer.isVerified) return;
2021-10-30 17:26:41 +00:00
if (
!ui.activeConnection.privileges.includes('modify_profile') &&
!ui.activeConnection.privileges.includes('modify_members')
) return;
let contextMenu = createServerTitleContextMenu(document, q, ui, ui.activeServer);
2021-10-30 17:26:41 +00:00
document.body.appendChild(contextMenu);
ElementsUtil.alignContextElement(contextMenu, q.$('#server-name-container'), { top: 'bottom', centerX: 'centerX' });
2021-10-30 17:26:41 +00:00
});
}