snappymail/dev/View/User/Settings/Menu.js

50 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-07-05 03:19:24 +08:00
import { KeyState } from 'Common/Enums';
import { leftPanelDisabled } from 'Common/Globals';
import { settings, inbox } from 'Common/Links';
import { getFolderInboxName } from 'Common/Cache';
import * as Settings from 'Storage/Settings';
2019-07-05 03:19:24 +08:00
import { view, ViewType, setHash, settingsMenuKeysHandler } from 'Knoin/Knoin';
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
@view({
name: 'View/User/Settings/Menu',
type: ViewType.Left,
templateID: 'SettingsMenu'
})
2019-07-05 03:19:24 +08:00
class MenuSettingsUserView extends AbstractViewNext {
/**
* @param {Object} screen
*/
constructor(screen) {
super();
this.leftPanelDisabled = leftPanelDisabled;
this.mobile = Settings.appSettingsGet('mobile');
this.menu = screen.menu;
}
onBuild(dom) {
2019-07-05 03:19:24 +08:00
if (this.mobile) {
dom.addEventListener('click', event =>
event.target.closestWithin('.b-settings-menu .e-item.selectable', dom) && leftPanelDisabled(true)
);
}
2016-05-01 09:07:10 +08:00
key('up, down', KeyState.Settings, settingsMenuKeysHandler(dom.querySelectoAll('.b-settings-menu .e-item')));
}
link(route) {
return settings(route);
}
backToMailBoxClick() {
setHash(inbox(getFolderInboxName()));
}
}
2019-07-05 03:19:24 +08:00
export { MenuSettingsUserView, MenuSettingsUserView as default };