2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import _ from '_';
|
|
|
|
import $ from '$';
|
|
|
|
import key from 'key';
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import {leftPanelDisabled} from 'Common/Globals';
|
|
|
|
import {Magics} from 'Common/Enums';
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import {view, ViewType, setHash} from 'Knoin/Knoin';
|
|
|
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
@view({
|
|
|
|
name: 'View/Admin/Settings/Menu',
|
|
|
|
type: ViewType.Left,
|
|
|
|
templateID: 'AdminMenu'
|
|
|
|
})
|
|
|
|
class MenuSettingsAdminView extends AbstractViewNext
|
2016-06-30 08:02:45 +08:00
|
|
|
{
|
2016-08-17 06:01:20 +08:00
|
|
|
/**
|
|
|
|
* @param {?} screen
|
|
|
|
*/
|
|
|
|
constructor(screen) {
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
super();
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.leftPanelDisabled = leftPanelDisabled;
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.menu = screen.menu;
|
|
|
|
}
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
link(route) {
|
|
|
|
return '#/' + route;
|
|
|
|
}
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
onBuild(dom) {
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
key('up, down', _.throttle((event, handler) => {
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
const
|
|
|
|
up = handler && 'up' === handler.shortcut,
|
|
|
|
$items = $('.b-admin-menu .e-item', dom);
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
if (event && $items.length)
|
2016-06-30 08:02:45 +08:00
|
|
|
{
|
2016-08-17 06:01:20 +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
|
|
|
|
2016-08-17 06:01:20 +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
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
}, Magics.Time200ms));
|
|
|
|
}
|
|
|
|
}
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
export {MenuSettingsAdminView, MenuSettingsAdminView as default};
|