snappymail/dev/View/User/Settings/Menu.js
2020-09-26 10:20:24 +02:00

48 lines
1.2 KiB
JavaScript

import { KeyState } from 'Common/Enums';
import { leftPanelDisabled } from 'Common/Globals';
import { settings, inbox } from 'Common/Links';
import { getFolderInboxName } from 'Common/Cache';
import { view, ViewType, settingsMenuKeysHandler } from 'Knoin/Knoin';
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
@view({
name: 'View/User/Settings/Menu',
type: ViewType.Left,
templateID: 'SettingsMenu'
})
class MenuSettingsUserView extends AbstractViewNext {
/**
* @param {Object} screen
*/
constructor(screen) {
super();
this.leftPanelDisabled = leftPanelDisabled;
this.mobile = rl.settings.app('mobile');
this.menu = screen.menu;
}
onBuild(dom) {
if (this.mobile) {
dom.addEventListener('click', event =>
event.target.closestWithin('.b-settings-menu .e-item.selectable', dom) && leftPanelDisabled(true)
);
}
shortcuts.add('arrowup,arrowdown', '', KeyState.Settings,
settingsMenuKeysHandler(dom.querySelectorAll('.b-settings-menu .e-item')));
}
link(route) {
return settings(route);
}
backToMailBoxClick() {
rl.route.setHash(inbox(getFolderInboxName()));
}
}
export { MenuSettingsUserView, MenuSettingsUserView as default };