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

67 lines
1.2 KiB
JavaScript
Raw Normal View History

import _ from '_';
import $ from '$';
import key from 'key';
import {leftPanelDisabled} from 'Common/Globals';
import {Magics} from 'Common/Enums';
import {view, ViewType, setHash} from 'Knoin/Knoin';
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
@view({
name: 'View/Admin/Settings/Menu',
type: ViewType.Left,
templateID: 'AdminMenu'
})
class MenuSettingsAdminView extends AbstractViewNext
2016-06-30 08:02:45 +08:00
{
/**
* @param {?} screen
*/
constructor(screen) {
super();
this.leftPanelDisabled = leftPanelDisabled;
this.menu = screen.menu;
}
link(route) {
return '#/' + route;
}
onBuild(dom) {
key('up, down', _.throttle((event, handler) => {
const
up = handler && 'up' === handler.shortcut,
$items = $('.b-admin-menu .e-item', dom);
if (event && $items.length)
2016-06-30 08:02:45 +08:00
{
let index = $items.index($items.filter('.selected'));
if (up && 0 < index)
{
index -= 1;
}
else if (!up && index < $items.length - 1)
{
index += 1;
}
2015-02-16 05:55:59 +08:00
const sH = $items.eq(index).attr('href');
if (sH)
{
setHash(sH, false, true);
}
2016-06-30 08:02:45 +08:00
}
2015-02-16 05:55:59 +08:00
}, Magics.Time200ms));
}
}
export {MenuSettingsAdminView, MenuSettingsAdminView as default};