2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import _ from '_';
|
|
|
|
import ko from 'ko';
|
|
|
|
import key from 'key';
|
2014-09-02 08:15:31 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import AppStore from 'Stores/User/App';
|
|
|
|
import AccountStore from 'Stores/User/Account';
|
|
|
|
import MessageStore from 'Stores/User/Message';
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import {Capa, Magics, KeyState} from 'Common/Enums';
|
|
|
|
import {trim, isUnd} from 'Common/Utils';
|
|
|
|
import {settings} from 'Common/Links';
|
2014-08-25 15:10:51 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import * as Events from 'Common/Events';
|
|
|
|
import * as Settings from 'Storage/Settings';
|
2014-08-21 23:08:34 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
import {getApp} from 'Helper/Apps/User';
|
2015-01-28 06:16:00 +08:00
|
|
|
|
2016-09-02 04:41:36 +08:00
|
|
|
import {showScreenPopup, setHash} from 'Knoin/Knoin';
|
2016-08-17 06:01:20 +08:00
|
|
|
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
|
2015-05-20 06:05:54 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
class AbstractSystemDropDownUserView extends AbstractViewNext
|
|
|
|
{
|
|
|
|
constructor() {
|
|
|
|
super();
|
2015-04-10 16:17:49 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.logoImg = trim(Settings.settingsGet('UserLogo'));
|
|
|
|
this.logoTitle = trim(Settings.settingsGet('UserLogoTitle'));
|
2014-04-12 09:05:57 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.mobile = !!Settings.appSettingsGet('mobile');
|
|
|
|
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
|
2014-04-12 09:05:57 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.allowSettings = !!Settings.capa(Capa.Settings);
|
|
|
|
this.allowHelp = !!Settings.capa(Capa.Help);
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.currentAudio = AppStore.currentAudio;
|
2015-04-10 16:17:49 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.accountEmail = AccountStore.email;
|
2015-04-10 16:17:49 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.accounts = AccountStore.accounts;
|
|
|
|
this.accountsUnreadCount = AccountStore.accountsUnreadCount;
|
2015-04-10 16:17:49 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.accountMenuDropdownTrigger = ko.observable(false);
|
|
|
|
this.capaAdditionalAccounts = ko.observable(Settings.capa(Capa.AdditionalAccounts));
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
this.addAccountClick = _.bind(this.addAccountClick, this);
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
Events.sub('audio.stop', () => AppStore.currentAudio(''));
|
|
|
|
Events.sub('audio.start', (sName) => AppStore.currentAudio(sName));
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2015-02-02 04:46:23 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
stopPlay() {
|
|
|
|
Events.pub('audio.api.stop');
|
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
accountClick(oAccount, oEvent) {
|
|
|
|
if (oAccount && oEvent && !isUnd(oEvent.which) && 1 === oEvent.which)
|
|
|
|
{
|
|
|
|
AccountStore.accounts.loading(true);
|
|
|
|
_.delay(() => AccountStore.accounts.loading(false), Magics.Time1s);
|
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
return true;
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
emailTitle() {
|
|
|
|
return AccountStore.email();
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
2014-04-29 23:31:49 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
settingsClick() {
|
|
|
|
if (Settings.capa(Capa.Settings))
|
|
|
|
{
|
|
|
|
setHash(settings());
|
|
|
|
}
|
2016-06-30 08:02:45 +08:00
|
|
|
}
|
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
settingsHelp()
|
|
|
|
{
|
|
|
|
if (Settings.capa(Capa.Help))
|
2015-05-20 06:05:54 +08:00
|
|
|
{
|
2016-08-17 06:01:20 +08:00
|
|
|
showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
|
2015-05-20 06:05:54 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
2013-11-16 06:21:12 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
addAccountClick() {
|
|
|
|
if (this.capaAdditionalAccounts())
|
2013-11-16 06:21:12 +08:00
|
|
|
{
|
2016-08-17 06:01:20 +08:00
|
|
|
showScreenPopup(require('View/Popup/Account'));
|
2013-11-16 06:21:12 +08:00
|
|
|
}
|
2016-08-17 06:01:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
logoutClick() {
|
|
|
|
getApp().logout();
|
|
|
|
}
|
|
|
|
|
|
|
|
onBuild() {
|
|
|
|
key('`', [KeyState.MessageList, KeyState.MessageView, KeyState.Settings], () => {
|
|
|
|
if (this.viewModelVisibility())
|
|
|
|
{
|
|
|
|
MessageStore.messageFullScreenMode(false);
|
|
|
|
this.accountMenuDropdownTrigger(true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// shortcuts help
|
|
|
|
key('shift+/', [KeyState.MessageList, KeyState.MessageView, KeyState.Settings], () => {
|
|
|
|
if (this.viewModelVisibility())
|
|
|
|
{
|
|
|
|
showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2014-04-29 23:31:49 +08:00
|
|
|
|
2016-08-17 06:01:20 +08:00
|
|
|
export {AbstractSystemDropDownUserView, AbstractSystemDropDownUserView as default};
|