The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/packages/rocketchat-ui/client/lib/esc.js

58 lines
1.3 KiB

const escapify = {
init() {
const that = this;
document.addEventListener('keyup', (event) => {
const keyName = event.key;
if (keyName === 'Escape') {
that.sideNavIcon();
that.flextTabButton();
that.videoDialog();
that.sweetAlerts();
}
}, false);
},
getClickEvent() {
return new MouseEvent('click', {
bubbles: true,
cancelable: true,
view: window
});
},
flextTabButton() {
const flextTabButton = document.querySelector('.flex-tab-bar .tab-button.active');
if (flextTabButton) {
flextTabButton.dispatchEvent(this.getClickEvent());
return;
}
},
sideNavIcon() {
const sideNavArrow = document.querySelector('.sidebar .arrow');
if (sideNavArrow && (sideNavArrow.classList.contains('top') || sideNavArrow.classList.contains('close'))) {
SideNav.toggleCurrent();
return;
}
},
videoDialog() {
const vrecDialog = document.querySelector('.vrec-dialog');
if (vrecDialog && Number(window.getComputedStyle(vrecDialog).opacity) === 1) {
VideoRecorder.stop();
VRecDialog.close();
return;
}
},
sweetAlerts() {
const sweetAlert = document.querySelector('.sweet-alert');
if (sweetAlert) {
document.querySelector('.sweet-alert .sa-button-container .cancel').dispatchEvent(this.getClickEvent());
return;
}
}
};
this.escapify = escapify;
this.escapify.init();