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

26 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-10-30 17:26:41 +00:00
import ClientController from '../client-controller';
import Elements from '../elements';
import IState from "./require/elements-state";
import ElementsUtil from './require/elements-util.js';
import { $, $$, $$$, $$$$ } from './require/q-module';
export default function bindAddServerTitleEvents(state: IState) {
const { document, ui } = state;
$.setDocument(document);
$('#server-name-container').addEventListener('click', () => {
if (!ui.hasActiveConnection() || !ui.activeConnection) return;
if (!ui.hasActiveServer()) return;
if (!(ui.activeServer as ClientController).isVerified) return;
if (
!ui.activeConnection.privileges.includes('modify_profile') &&
!ui.activeConnection.privileges.includes('modify_members')
) return;
let contextMenu = Elements.createServerTitleContextMenu(ui.activeServer as ClientController);
document.body.appendChild(contextMenu);
ElementsUtil.alignContextElement(contextMenu, $('#server-name-container'), { top: 'bottom', centerX: 'centerX' });
});
}