26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
|
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' });
|
||
|
});
|
||
|
}
|