2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import _ from '_';
|
|
|
|
import $ from '$';
|
|
|
|
import key from 'key';
|
|
|
|
|
|
|
|
import {KeyState, Magics} 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';
|
|
|
|
|
|
|
|
import {view, ViewType, setHash} from 'Knoin/Knoin';
|
|
|
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
|
|
|
|
|
|
|
@view({
|
|
|
|
name: 'View/User/Settings/Menu',
|
|
|
|
type: ViewType.Left,
|
|
|
|
templateID: 'SettingsMenu'
|
|
|
|
})
|
|
|
|
class MenuSettingsUserView extends AbstractViewNext
|
2016-06-30 08:02:45 +08:00
|
|
|
{
|
2016-08-17 06:01:20 +08:00
|
|
|
/**
|
|
|
|
* @param {Object} screen
|
|
|
|
*/
|
|
|
|
constructor(screen) {
|
|
|
|
super();
|
2014-10-18 05:02:19 +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.mobile = Settings.appSettingsGet('mobile');
|
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
|
|
|
onBuild(dom) {
|
|
|
|
if (this.mobile)
|
|
|
|
{
|
|
|
|
dom.on('click', '.b-settings-menu .e-item.selectable', () => {
|
|
|
|
leftPanelDisabled(true);
|
2016-06-30 08:02:45 +08:00
|
|
|
});
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2016-05-01 09:07:10 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
key('up, down', KeyState.Settings, _.throttle((event, handler) => {
|
2015-02-16 05:55:59 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
const
|
|
|
|
up = handler && 'up' === handler.shortcut,
|
|
|
|
$items = $('.b-settings-menu .e-item', dom);
|
2015-02-16 05:55:59 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
if (event && $items.length)
|
2015-02-16 05:55:59 +08:00
|
|
|
{
|
2016-08-17 06:01:20 +08:00
|
|
|
let iIndex = $items.index($items.filter('.selected'));
|
|
|
|
if (up && 0 < iIndex)
|
|
|
|
{
|
|
|
|
iIndex -= 1;
|
|
|
|
}
|
|
|
|
else if (!up && iIndex < $items.length - 1)
|
|
|
|
{
|
|
|
|
iIndex += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
const sH = $items.eq(iIndex).attr('href');
|
|
|
|
if (sH)
|
|
|
|
{
|
|
|
|
setHash(sH, false, true);
|
|
|
|
}
|
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
|
|
|
link(sRoute) {
|
|
|
|
return settings(sRoute);
|
|
|
|
}
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
backToMailBoxClick() {
|
|
|
|
setHash(inbox(getFolderInboxName()));
|
|
|
|
}
|
|
|
|
}
|
2014-09-06 05:44:29 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
export {MenuSettingsUserView, MenuSettingsUserView as default};
|