es5 -> es2015 (last stage)

Signature plugin fixes
Add view decorator
A large number of fixes
This commit is contained in:
RainLoop Team 2016-08-17 01:01:20 +03:00
parent e88c193334
commit 17669b7be0
153 changed files with 21193 additions and 21115 deletions

View file

@ -1,27 +1,23 @@
var
_ = require('_'),
ko = require('ko'),
import ko from 'ko';
Settings = require('Storage/Settings'),
import * as Settings from 'Storage/Settings';
kn = require('Knoin/Knoin'),
AbstractView = require('Knoin/AbstractView');
import {view, ViewType} from 'Knoin/Knoin';
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
/**
* @constructor
* @extends AbstractView
*/
function AboutUserView()
@view({
name: 'View/User/About',
type: ViewType.Center,
templateID: 'About'
})
class AboutUserView extends AbstractViewNext
{
AbstractView.call(this, 'Center', 'About');
constructor() {
super();
this.version = ko.observable(Settings.appSettingsGet('version'));
kn.constructorEnd(this);
this.version = ko.observable(Settings.appSettingsGet('version'));
}
}
kn.extendAsViewModel(['View/User/About', 'View/App/About', 'AboutViewModel'], AboutUserView);
_.extend(AboutUserView.prototype, AbstractView.prototype);
module.exports = AboutUserView;
export {AboutUserView, AboutUserView as default};

View file

@ -1,138 +1,121 @@
var
_ = require('_'),
ko = require('ko'),
key = require('key'),
import _ from '_';
import ko from 'ko';
import key from 'key';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Links = require('Common/Links'),
Events = require('Common/Events'),
import AppStore from 'Stores/User/App';
import AccountStore from 'Stores/User/Account';
import MessageStore from 'Stores/User/Message';
AppStore = require('Stores/User/App'),
AccountStore = require('Stores/User/Account'),
MessageStore = require('Stores/User/Message'),
import {Capa, Magics, KeyState} from 'Common/Enums';
import {trim, isUnd} from 'Common/Utils';
import {settings} from 'Common/Links';
Settings = require('Storage/Settings'),
import * as Events from 'Common/Events';
import * as Settings from 'Storage/Settings';
AbstractView = require('Knoin/AbstractView');
import {getApp} from 'Helper/Apps/User';
/**
* @constructor
* @extends AbstractView
*/
function AbstractSystemDropDownUserView()
import {view, ViewType, showScreenPopup, setHash} from 'Knoin/Knoin';
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
@view({
type: ViewType.Right,
templateID: 'SystemDropDown'
})
class AbstractSystemDropDownUserView extends AbstractViewNext
{
AbstractView.call(this, 'Right', 'SystemDropDown');
constructor() {
super();
this.logoImg = Utils.trim(Settings.settingsGet('UserLogo'));
this.logoTitle = Utils.trim(Settings.settingsGet('UserLogoTitle'));
this.logoImg = trim(Settings.settingsGet('UserLogo'));
this.logoTitle = trim(Settings.settingsGet('UserLogoTitle'));
this.mobile = !!Settings.appSettingsGet('mobile');
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
this.mobile = !!Settings.appSettingsGet('mobile');
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
this.allowSettings = !!Settings.capa(Enums.Capa.Settings);
this.allowHelp = !!Settings.capa(Enums.Capa.Help);
this.allowSettings = !!Settings.capa(Capa.Settings);
this.allowHelp = !!Settings.capa(Capa.Help);
this.currentAudio = AppStore.currentAudio;
this.currentAudio = AppStore.currentAudio;
this.accountEmail = AccountStore.email;
this.accountEmail = AccountStore.email;
this.accounts = AccountStore.accounts;
this.accountsUnreadCount = AccountStore.accountsUnreadCount;
this.accounts = AccountStore.accounts;
this.accountsUnreadCount = AccountStore.accountsUnreadCount;
this.accountMenuDropdownTrigger = ko.observable(false);
this.capaAdditionalAccounts = ko.observable(Settings.capa(Enums.Capa.AdditionalAccounts));
this.accountMenuDropdownTrigger = ko.observable(false);
this.capaAdditionalAccounts = ko.observable(Settings.capa(Capa.AdditionalAccounts));
this.accountClick = _.bind(this.accountClick, this);
this.addAccountClick = _.bind(this.addAccountClick, this);
this.accountClick = _.bind(this.accountClick, this);
Events.sub('audio.stop', () => AppStore.currentAudio(''));
Events.sub('audio.start', (sName) => AppStore.currentAudio(sName));
}
Events.sub('audio.stop', function() {
AppStore.currentAudio('');
});
stopPlay() {
Events.pub('audio.api.stop');
}
Events.sub('audio.start', function(sName) {
AppStore.currentAudio(sName);
});
accountClick(oAccount, oEvent) {
if (oAccount && oEvent && !isUnd(oEvent.which) && 1 === oEvent.which)
{
AccountStore.accounts.loading(true);
_.delay(() => AccountStore.accounts.loading(false), Magics.Time1s);
}
return true;
}
emailTitle() {
return AccountStore.email();
}
settingsClick() {
if (Settings.capa(Capa.Settings))
{
setHash(settings());
}
}
settingsHelp()
{
if (Settings.capa(Capa.Help))
{
showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
}
}
addAccountClick() {
if (this.capaAdditionalAccounts())
{
showScreenPopup(require('View/Popup/Account'));
}
}
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;
});
}
}
_.extend(AbstractSystemDropDownUserView.prototype, AbstractView.prototype);
AbstractSystemDropDownUserView.prototype.stopPlay = function()
{
Events.pub('audio.api.stop');
};
AbstractSystemDropDownUserView.prototype.accountClick = function(oAccount, oEvent)
{
if (oAccount && oEvent && !Utils.isUnd(oEvent.which) && 1 === oEvent.which)
{
AccountStore.accounts.loading(true);
_.delay(function() {
AccountStore.accounts.loading(false);
}, Enums.Magics.Time1s);
}
return true;
};
AbstractSystemDropDownUserView.prototype.emailTitle = function()
{
return AccountStore.email();
};
AbstractSystemDropDownUserView.prototype.settingsClick = function()
{
if (Settings.capa(Enums.Capa.Settings))
{
require('Knoin/Knoin').setHash(Links.settings());
}
};
AbstractSystemDropDownUserView.prototype.settingsHelp = function()
{
if (Settings.capa(Enums.Capa.Help))
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
}
};
AbstractSystemDropDownUserView.prototype.addAccountClick = function()
{
if (this.capaAdditionalAccounts())
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'));
}
};
AbstractSystemDropDownUserView.prototype.logoutClick = function()
{
require('App/User').default.logout();
};
AbstractSystemDropDownUserView.prototype.onBuild = function()
{
var self = this;
key('`', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function() {
if (self.viewModelVisibility())
{
MessageStore.messageFullScreenMode(false);
self.accountMenuDropdownTrigger(true);
}
});
// shortcuts help
key('shift+/', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function() {
if (self.viewModelVisibility())
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/KeyboardShortcutsHelp'));
return false;
}
return true;
});
};
module.exports = AbstractSystemDropDownUserView;
export {AbstractSystemDropDownUserView, AbstractSystemDropDownUserView as default};

View file

@ -3,487 +3,474 @@ import window from 'window';
import _ from '_';
import ko from 'ko';
var
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Links = require('Common/Links'),
import {
LoginSignMeType,
LoginSignMeTypeAsString,
ClientSideKeyName,
StorageResultType,
Magics,
Notification
} from 'Common/Enums';
Translator = require('Common/Translator'),
import {
trim, inArray, pInt,
convertLangName,
createCommand,
triggerAutocompleteInputChange
} from 'Common/Utils';
Plugins = require('Common/Plugins'),
import {socialFacebook, socialGoogle, socialTwitter} from 'Common/Links';
import {getNotification, getNotificationFromResponse, reload as translatorReload} from 'Common/Translator';
LanguageStore = require('Stores/Language'),
AppStore = require('Stores/User/App'),
import * as Plugins from 'Common/Plugins';
Local = require('Storage/Client'),
Settings = require('Storage/Settings'),
import AppStore from 'Stores/User/App';
import LanguageStore from 'Stores/Language';
Remote = require('Remote/User/Ajax'),
import * as Settings from 'Storage/Settings';
import * as Local from 'Storage/Client';
kn = require('Knoin/Knoin'),
AbstractView = require('Knoin/AbstractView');
import Remote from 'Remote/User/Ajax';
/**
* @constructor
* @extends AbstractView
*/
function LoginUserView()
import {getApp} from 'Helper/Apps/User';
import {view, ViewType, routeOff, showScreenPopup} from 'Knoin/Knoin';
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
@view({
name: 'View/User/Login',
type: ViewType.Center,
templateID: 'Login'
})
class LoginUserView extends AbstractViewNext
{
AbstractView.call(this, 'Center', 'Login');
constructor() {
super();
this.welcome = ko.observable(!!Settings.settingsGet('UseLoginWelcomePage'));
this.welcome = ko.observable(!!Settings.settingsGet('UseLoginWelcomePage'));
this.email = ko.observable('');
this.password = ko.observable('');
this.signMe = ko.observable(false);
this.email = ko.observable('');
this.password = ko.observable('');
this.signMe = ko.observable(false);
this.additionalCode = ko.observable('');
this.additionalCode.error = ko.observable(false);
this.additionalCode.errorAnimation = ko.observable(false).extend({'falseTimeout': 500});
this.additionalCode.focused = ko.observable(false);
this.additionalCode.visibility = ko.observable(false);
this.additionalCodeSignMe = ko.observable(false);
this.additionalCode = ko.observable('');
this.additionalCode.error = ko.observable(false);
this.additionalCode.errorAnimation = ko.observable(false).extend({falseTimeout: 500});
this.additionalCode.focused = ko.observable(false);
this.additionalCode.visibility = ko.observable(false);
this.additionalCodeSignMe = ko.observable(false);
this.logoImg = Utils.trim(Settings.settingsGet('LoginLogo'));
this.logoPowered = !!Settings.settingsGet('LoginPowered');
this.loginDescription = Utils.trim(Settings.settingsGet('LoginDescription'));
this.logoImg = trim(Settings.settingsGet('LoginLogo'));
this.logoPowered = !!Settings.settingsGet('LoginPowered');
this.loginDescription = trim(Settings.settingsGet('LoginDescription'));
this.mobile = !!Settings.appSettingsGet('mobile');
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
this.mobile = !!Settings.appSettingsGet('mobile');
this.mobileDevice = !!Settings.appSettingsGet('mobileDevice');
this.forgotPasswordLinkUrl = Settings.appSettingsGet('forgotPasswordLinkUrl');
this.registrationLinkUrl = Settings.appSettingsGet('registrationLinkUrl');
this.forgotPasswordLinkUrl = Settings.appSettingsGet('forgotPasswordLinkUrl');
this.registrationLinkUrl = Settings.appSettingsGet('registrationLinkUrl');
this.emailError = ko.observable(false);
this.passwordError = ko.observable(false);
this.emailError = ko.observable(false);
this.passwordError = ko.observable(false);
this.emailErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
this.passwordErrorAnimation = ko.observable(false).extend({'falseTimeout': 500});
this.emailErrorAnimation = ko.observable(false).extend({falseTimeout: 500});
this.passwordErrorAnimation = ko.observable(false).extend({falseTimeout: 500});
this.formHidden = ko.observable(false);
this.formHidden = ko.observable(false);
this.formError = ko.computed(function() {
return this.emailErrorAnimation() || this.passwordErrorAnimation() ||
(this.additionalCode.visibility() && this.additionalCode.errorAnimation());
}, this);
this.formError = ko.computed(
() => this.emailErrorAnimation() || this.passwordErrorAnimation() ||
(this.additionalCode.visibility() && this.additionalCode.errorAnimation())
);
this.emailFocus = ko.observable(false);
this.passwordFocus = ko.observable(false);
this.submitFocus = ko.observable(false);
this.emailFocus = ko.observable(false);
this.passwordFocus = ko.observable(false);
this.submitFocus = ko.observable(false);
this.email.subscribe(function() {
this.emailError(false);
this.additionalCode('');
this.additionalCode.visibility(false);
}, this);
this.email.subscribe(() => {
this.emailError(false);
this.additionalCode('');
this.additionalCode.visibility(false);
});
this.password.subscribe(function() {
this.passwordError(false);
}, this);
this.password.subscribe(() => {
this.passwordError(false);
});
this.additionalCode.subscribe(function() {
this.additionalCode.error(false);
}, this);
this.additionalCode.visibility.subscribe(function() {
this.additionalCode.error(false);
}, this);
this.emailError.subscribe(function(bV) {
this.emailErrorAnimation(!!bV);
}, this);
this.passwordError.subscribe(function(bV) {
this.passwordErrorAnimation(!!bV);
}, this);
this.additionalCode.error.subscribe(function(bV) {
this.additionalCode.errorAnimation(!!bV);
}, this);
this.submitRequest = ko.observable(false);
this.submitError = ko.observable('');
this.submitErrorAddidional = ko.observable('');
this.submitError.subscribe(function(sValue) {
if ('' === sValue)
{
this.submitErrorAddidional('');
}
}, this);
this.allowLanguagesOnLogin = AppStore.allowLanguagesOnLogin;
this.langRequest = ko.observable(false);
this.language = LanguageStore.language;
this.languages = LanguageStore.languages;
this.bSendLanguage = false;
this.languageFullName = ko.computed(function() {
return Utils.convertLangName(this.language());
}, this);
this.signMeType = ko.observable(Enums.LoginSignMeType.Unused);
this.signMeType.subscribe(function(iValue) {
this.signMe(Enums.LoginSignMeType.DefaultOn === iValue);
}, this);
this.signMeVisibility = ko.computed(function() {
return Enums.LoginSignMeType.Unused !== this.signMeType();
}, this);
this.submitCommand = Utils.createCommand(this, function() {
Utils.triggerAutocompleteInputChange();
this.emailError(false);
this.passwordError(false);
this.emailError('' === Utils.trim(this.email()));
this.passwordError('' === Utils.trim(this.password()));
if (this.additionalCode.visibility())
{
this.additionalCode.subscribe(() => {
this.additionalCode.error(false);
this.additionalCode.error('' === Utils.trim(this.additionalCode()));
}
});
if (this.emailError() || this.passwordError() ||
(this.additionalCode.visibility() && this.additionalCode.error()))
{
switch (true)
this.additionalCode.visibility.subscribe(() => {
this.additionalCode.error(false);
});
this.emailError.subscribe((bV) => {
this.emailErrorAnimation(!!bV);
});
this.passwordError.subscribe((bV) => {
this.passwordErrorAnimation(!!bV);
});
this.additionalCode.error.subscribe((bV) => {
this.additionalCode.errorAnimation(!!bV);
});
this.submitRequest = ko.observable(false);
this.submitError = ko.observable('');
this.submitErrorAddidional = ko.observable('');
this.submitError.subscribe((value) => {
if ('' === value)
{
case this.emailError():
this.emailFocus(true);
break;
case this.passwordError():
this.passwordFocus(true);
break;
case this.additionalCode.visibility() && this.additionalCode.error():
this.additionalCode.focused(true);
break;
// no default
this.submitErrorAddidional('');
}
});
this.allowLanguagesOnLogin = AppStore.allowLanguagesOnLogin;
this.langRequest = ko.observable(false);
this.language = LanguageStore.language;
this.languages = LanguageStore.languages;
this.bSendLanguage = false;
this.languageFullName = ko.computed(
() => convertLangName(this.language())
);
this.signMeType = ko.observable(LoginSignMeType.Unused);
this.signMeType.subscribe((iValue) => {
this.signMe(LoginSignMeType.DefaultOn === iValue);
});
this.signMeVisibility = ko.computed(
() => LoginSignMeType.Unused !== this.signMeType()
);
this.submitCommand = createCommand(() => {
triggerAutocompleteInputChange();
this.emailError(false);
this.passwordError(false);
this.emailError('' === trim(this.email()));
this.passwordError('' === trim(this.password()));
if (this.additionalCode.visibility())
{
this.additionalCode.error(false);
this.additionalCode.error('' === trim(this.additionalCode()));
}
return false;
}
if (this.emailError() || this.passwordError() ||
(this.additionalCode.visibility() && this.additionalCode.error()))
{
switch (true)
{
case this.emailError():
this.emailFocus(true);
break;
case this.passwordError():
this.passwordFocus(true);
break;
case this.additionalCode.visibility() && this.additionalCode.error():
this.additionalCode.focused(true);
break;
// no default
}
var
iPluginResultCode = 0,
sPluginResultMessage = '',
fSubmitResult = function(iResultCode, sResultMessage) {
iPluginResultCode = iResultCode || 0;
sPluginResultMessage = sResultMessage || '';
};
return false;
}
Plugins.runHook('user-login-submit', [fSubmitResult]);
if (0 < iPluginResultCode)
{
this.submitError(Translator.getNotification(iPluginResultCode));
return false;
}
else if ('' !== sPluginResultMessage)
{
this.submitError(sPluginResultMessage);
return false;
}
let
pluginResultCode = 0,
pluginResultMessage = '';
this.submitRequest(true);
const
fSubmitResult = (iResultCode, sResultMessage) => {
pluginResultCode = iResultCode || 0;
pluginResultMessage = sResultMessage || '';
};
var
self = this,
sPassword = this.password(),
Plugins.runHook('user-login-submit', [fSubmitResult]);
if (0 < pluginResultCode)
{
this.submitError(getNotification(pluginResultCode));
return false;
}
else if ('' !== pluginResultMessage)
{
this.submitError(pluginResultMessage);
return false;
}
fLoginRequest = _.bind(function(sLoginPassword) {
this.submitRequest(true);
Remote.login(_.bind(function(sResult, oData) {
const
fLoginRequest = (sLoginPassword) => {
if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action)
{
if (oData.Result)
Remote.login((sResult, oData) => {
if (StorageResultType.Success === sResult && oData && 'Login' === oData.Action)
{
if (oData.TwoFactorAuth)
if (oData.Result)
{
if (oData.TwoFactorAuth)
{
this.additionalCode('');
this.additionalCode.visibility(true);
this.submitRequest(false);
_.delay(() => this.additionalCode.focused(true), Magics.Time100ms);
}
else if (oData.Admin)
{
getApp().redirectToAdminPanel();
}
else
{
getApp().loginAndLogoutReload(false);
}
}
else if (oData.ErrorCode)
{
this.additionalCode('');
this.additionalCode.visibility(true);
this.submitRequest(false);
if (-1 < inArray(oData.ErrorCode, [Notification.InvalidInputArgument]))
{
oData.ErrorCode = Notification.AuthError;
}
_.delay(function() {
self.additionalCode.focused(true);
}, Enums.Magics.Time100ms);
}
else if (oData.Admin)
{
require('App/User').default.redirectToAdminPanel();
}
else
{
require('App/User').default.loginAndLogoutReload(false);
}
}
else if (oData.ErrorCode)
{
this.submitRequest(false);
if (-1 < Utils.inArray(oData.ErrorCode, [Enums.Notification.InvalidInputArgument]))
{
oData.ErrorCode = Enums.Notification.AuthError;
}
this.submitError(getNotificationFromResponse(oData));
this.submitError(Translator.getNotificationFromResponse(oData));
if ('' === this.submitError())
{
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
}
else
{
if (oData.ErrorMessageAdditional)
if ('' === this.submitError())
{
this.submitError(getNotification(Notification.UnknownError));
}
else if (oData.ErrorMessageAdditional)
{
this.submitErrorAddidional(oData.ErrorMessageAdditional);
}
}
else
{
this.submitRequest(false);
}
}
else
{
this.submitRequest(false);
this.submitError(getNotification(Notification.UnknownError));
}
}
else
{
this.submitRequest(false);
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
}
}, this), this.email(), '', sLoginPassword, !!this.signMe(),
this.bSendLanguage ? this.language() : '',
this.additionalCode.visibility() ? this.additionalCode() : '',
this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
);
}, this.email(), '', sLoginPassword, !!this.signMe(),
this.bSendLanguage ? this.language() : '',
this.additionalCode.visibility() ? this.additionalCode() : '',
this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
);
Local.set(Enums.ClientSideKeyName.LastSignMe, this.signMe() ? '-1-' : '-0-');
Local.set(ClientSideKeyName.LastSignMe, this.signMe() ? '-1-' : '-0-');
}, this);
};
fLoginRequest(sPassword);
fLoginRequest(this.password());
return true;
}, function() {
return !this.submitRequest();
});
return true;
this.facebookLoginEnabled = ko.observable(false);
}, () => !this.submitRequest());
this.facebookCommand = Utils.createCommand(this, function() {
window.open(Links.socialFacebook(), 'Facebook',
'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function() {
return !this.submitRequest() && this.facebookLoginEnabled();
});
this.facebookLoginEnabled = ko.observable(false);
this.googleLoginEnabled = ko.observable(false);
this.googleFastLoginEnabled = ko.observable(false);
this.facebookCommand = createCommand(() => {
window.open(socialFacebook(), 'Facebook',
'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, () => !this.submitRequest() && this.facebookLoginEnabled());
this.googleCommand = Utils.createCommand(this, function() {
window.open(Links.socialGoogle(), 'Google',
'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function() {
return !this.submitRequest() && this.googleLoginEnabled();
});
this.googleLoginEnabled = ko.observable(false);
this.googleFastLoginEnabled = ko.observable(false);
this.googleFastCommand = Utils.createCommand(this, function() {
window.open(Links.socialGoogle(true), 'Google',
'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function() {
return !this.submitRequest() && this.googleFastLoginEnabled();
});
this.googleCommand = createCommand(() => {
window.open(socialGoogle(), 'Google',
'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, () => !this.submitRequest() && this.googleLoginEnabled());
this.twitterLoginEnabled = ko.observable(false);
this.googleFastCommand = createCommand(() => {
window.open(socialGoogle(true), 'Google',
'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, () => !this.submitRequest() && this.googleFastLoginEnabled());
this.twitterCommand = Utils.createCommand(this, function() {
window.open(Links.socialTwitter(), 'Twitter',
'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function() {
return !this.submitRequest() && this.twitterLoginEnabled();
});
this.twitterLoginEnabled = ko.observable(false);
this.socialLoginEnabled = ko.computed(function() {
var
bF = this.facebookLoginEnabled(),
bG = this.googleLoginEnabled(),
bT = this.twitterLoginEnabled();
this.twitterCommand = createCommand(() => {
window.open(socialTwitter(), 'Twitter',
'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, () => !this.submitRequest() && this.twitterLoginEnabled());
return bF || bG || bT;
}, this);
if (Settings.settingsGet('AdditionalLoginError') && !this.submitError())
{
this.submitError(Settings.settingsGet('AdditionalLoginError'));
}
kn.constructorEnd(this);
}
kn.extendAsViewModel(['View/User/Login', 'View/App/Login', 'LoginViewModel'], LoginUserView);
_.extend(LoginUserView.prototype, AbstractView.prototype);
LoginUserView.prototype.displayMainForm = function()
{
this.welcome(false);
};
LoginUserView.prototype.onShow = function()
{
kn.routeOff();
};
LoginUserView.prototype.onShowWithDelay = function()
{
if ('' !== this.email() && '' !== this.password())
{
this.submitFocus(true);
}
else if ('' === this.email())
{
this.emailFocus(true);
}
else if ('' === this.password())
{
this.passwordFocus(true);
}
else
{
this.emailFocus(true);
}
};
LoginUserView.prototype.onHide = function()
{
this.submitFocus(false);
this.emailFocus(false);
this.passwordFocus(false);
};
LoginUserView.prototype.onBuild = function()
{
var
self = this,
sSignMeLocal = Local.get(Enums.ClientSideKeyName.LastSignMe),
sSignMe = (Settings.settingsGet('SignMe') || 'unused').toLowerCase(),
sJsHash = Settings.appSettingsGet('jsHash'),
fSocial = function(iErrorCode) {
iErrorCode = Utils.pInt(iErrorCode);
if (0 === iErrorCode)
{
self.submitRequest(true);
require('App/User').default.loginAndLogoutReload(false);
}
else
{
self.submitError(Translator.getNotification(iErrorCode));
}
};
this.facebookLoginEnabled(!!Settings.settingsGet('AllowFacebookSocial'));
this.twitterLoginEnabled(!!Settings.settingsGet('AllowTwitterSocial'));
this.googleLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
!!Settings.settingsGet('AllowGoogleSocialAuth'));
this.googleFastLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
!!Settings.settingsGet('AllowGoogleSocialAuthFast'));
switch (sSignMe)
{
case Enums.LoginSignMeTypeAsString.DefaultOff:
case Enums.LoginSignMeTypeAsString.DefaultOn:
this.signMeType(Enums.LoginSignMeTypeAsString.DefaultOn === sSignMe ?
Enums.LoginSignMeType.DefaultOn : Enums.LoginSignMeType.DefaultOff);
switch (sSignMeLocal)
{
case '-1-':
this.signMeType(Enums.LoginSignMeType.DefaultOn);
break;
case '-0-':
this.signMeType(Enums.LoginSignMeType.DefaultOff);
break;
// no default
}
break;
case Enums.LoginSignMeTypeAsString.Unused:
default:
this.signMeType(Enums.LoginSignMeType.Unused);
break;
}
this.email(AppStore.devEmail);
this.password(AppStore.devPassword);
if (this.googleLoginEnabled() || this.googleFastLoginEnabled())
{
window['rl_' + sJsHash + '_google_login_service'] = fSocial;
}
if (this.facebookLoginEnabled())
{
window['rl_' + sJsHash + '_facebook_login_service'] = fSocial;
}
if (this.twitterLoginEnabled())
{
window['rl_' + sJsHash + '_twitter_login_service'] = fSocial;
}
_.delay(function() {
LanguageStore.language.subscribe(function(sValue) {
self.langRequest(true);
Translator.reload(false, sValue).then(function() {
self.langRequest(false);
self.bSendLanguage = true;
}, function() {
self.langRequest(false);
});
this.socialLoginEnabled = ko.computed(() => {
const
bF = this.facebookLoginEnabled(),
bG = this.googleLoginEnabled(),
bT = this.twitterLoginEnabled();
return bF || bG || bT;
});
}, Enums.Magics.Time50ms);
Utils.triggerAutocompleteInputChange(true);
};
LoginUserView.prototype.submitForm = function()
{
this.submitCommand();
};
LoginUserView.prototype.selectLanguage = function()
{
kn.showScreenPopup(require('View/Popup/Languages'), [
this.language, this.languages(), LanguageStore.userLanguage()
]);
};
LoginUserView.prototype.selectLanguageOnTab = function(bShift)
{
if (!bShift)
{
var self = this;
_.delay(function() {
self.emailFocus(true);
}, Enums.Magics.Time50ms);
return false;
if (Settings.settingsGet('AdditionalLoginError') && !this.submitError())
{
this.submitError(Settings.settingsGet('AdditionalLoginError'));
}
}
return true;
};
displayMainForm() {
this.welcome(false);
}
module.exports = LoginUserView;
onShow() {
routeOff();
}
onShowWithDelay() {
if ('' !== this.email() && '' !== this.password())
{
this.submitFocus(true);
}
else if ('' === this.email())
{
this.emailFocus(true);
}
else if ('' === this.password())
{
this.passwordFocus(true);
}
else
{
this.emailFocus(true);
}
}
onHide() {
this.submitFocus(false);
this.emailFocus(false);
this.passwordFocus(false);
}
onBuild() {
const
signMeLocal = Local.get(ClientSideKeyName.LastSignMe),
signMe = (Settings.settingsGet('SignMe') || 'unused').toLowerCase(),
jsHash = Settings.appSettingsGet('jsHash'),
fSocial = (iErrorCode) => {
iErrorCode = pInt(iErrorCode);
if (0 === iErrorCode)
{
this.submitRequest(true);
getApp().loginAndLogoutReload(false);
}
else
{
this.submitError(getNotification(iErrorCode));
}
};
this.facebookLoginEnabled(!!Settings.settingsGet('AllowFacebookSocial'));
this.twitterLoginEnabled(!!Settings.settingsGet('AllowTwitterSocial'));
this.googleLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
!!Settings.settingsGet('AllowGoogleSocialAuth'));
this.googleFastLoginEnabled(!!Settings.settingsGet('AllowGoogleSocial') &&
!!Settings.settingsGet('AllowGoogleSocialAuthFast'));
switch (signMe)
{
case LoginSignMeTypeAsString.DefaultOff:
case LoginSignMeTypeAsString.DefaultOn:
this.signMeType(LoginSignMeTypeAsString.DefaultOn === signMe ?
LoginSignMeType.DefaultOn : LoginSignMeType.DefaultOff);
switch (signMeLocal)
{
case '-1-':
this.signMeType(LoginSignMeType.DefaultOn);
break;
case '-0-':
this.signMeType(LoginSignMeType.DefaultOff);
break;
// no default
}
break;
case LoginSignMeTypeAsString.Unused:
default:
this.signMeType(LoginSignMeType.Unused);
break;
}
this.email(AppStore.devEmail);
this.password(AppStore.devPassword);
if (this.googleLoginEnabled() || this.googleFastLoginEnabled())
{
window['rl_' + jsHash + '_google_login_service'] = fSocial;
}
if (this.facebookLoginEnabled())
{
window['rl_' + jsHash + '_facebook_login_service'] = fSocial;
}
if (this.twitterLoginEnabled())
{
window['rl_' + jsHash + '_twitter_login_service'] = fSocial;
}
_.delay(() => {
LanguageStore.language.subscribe((sValue) => {
this.langRequest(true);
translatorReload(false, sValue).then(() => {
this.langRequest(false);
this.bSendLanguage = true;
}, () => {
this.langRequest(false);
});
});
}, Magics.Time50ms);
triggerAutocompleteInputChange(true);
}
submitForm() {
this.submitCommand();
}
selectLanguage() {
showScreenPopup(require('View/Popup/Languages'), [
this.language, this.languages(), LanguageStore.userLanguage()
]);
}
selectLanguageOnTab(bShift) {
if (!bShift)
{
_.delay(() => {
this.emailFocus(true);
}, Magics.Time50ms);
return false;
}
return true;
}
}
export {LoginUserView, LoginUserView as default};

View file

@ -1,306 +1,290 @@
var
window = require('window'),
_ = require('_'),
$ = require('$'),
ko = require('ko'),
key = require('key'),
import window from 'window';
import $ from '$';
import ko from 'ko';
import key from 'key';
Utils = require('Common/Utils'),
Enums = require('Common/Enums'),
Globals = require('Common/Globals'),
Links = require('Common/Links'),
import {trim, isNormal, isArray, windowResize} from 'Common/Utils';
import {Capa, Focused, Layout, KeyState, EventKeyCode, Magics} from 'Common/Enums';
import {$html, leftPanelDisabled} from 'Common/Globals';
import {mailBox, settings} from 'Common/Links';
import {setFolderHash} from 'Common/Cache';
Cache = require('Common/Cache'),
import AppStore from 'Stores/User/App';
import SettingsStore from 'Stores/User/Settings';
import FolderStore from 'Stores/User/Folder';
import MessageStore from 'Stores/User/Message';
AppStore = require('Stores/User/App'),
SettingsStore = require('Stores/User/Settings'),
FolderStore = require('Stores/User/Folder'),
MessageStore = require('Stores/User/Message'),
import * as Settings from 'Storage/Settings';
Settings = require('Storage/Settings'),
import {getApp} from 'Helper/Apps/User';
kn = require('Knoin/Knoin'),
AbstractView = require('Knoin/AbstractView');
import {view, ViewType, showScreenPopup, setHash} from 'Knoin/Knoin';
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
/**
* @constructor
* @extends AbstractView
*/
function FolderListMailBoxUserView()
@view({
name: 'View/User/MailBox/FolderList',
type: ViewType.Left,
templateID: 'MailFolderList'
})
class FolderListMailBoxUserView extends AbstractViewNext
{
AbstractView.call(this, 'Left', 'MailFolderList');
constructor() {
super();
this.oContentVisible = null;
this.oContentScrollable = null;
this.oContentVisible = null;
this.oContentScrollable = null;
this.composeInEdit = AppStore.composeInEdit;
this.composeInEdit = AppStore.composeInEdit;
this.messageList = MessageStore.messageList;
this.folderList = FolderStore.folderList;
this.folderListSystem = FolderStore.folderListSystem;
this.foldersChanging = FolderStore.foldersChanging;
this.messageList = MessageStore.messageList;
this.folderList = FolderStore.folderList;
this.folderListSystem = FolderStore.folderListSystem;
this.foldersChanging = FolderStore.foldersChanging;
this.foldersListWithSingleInboxRootFolder = FolderStore.foldersListWithSingleInboxRootFolder;
this.foldersListWithSingleInboxRootFolder = FolderStore.foldersListWithSingleInboxRootFolder;
this.leftPanelDisabled = Globals.leftPanelDisabled;
this.leftPanelDisabled = leftPanelDisabled;
this.iDropOverTimer = 0;
this.iDropOverTimer = 0;
this.allowComposer = !!Settings.capa(Enums.Capa.Composer);
this.allowContacts = !!AppStore.contactsIsAllowed();
this.allowFolders = !!Settings.capa(Enums.Capa.Folders);
this.allowComposer = !!Settings.capa(Capa.Composer);
this.allowContacts = !!AppStore.contactsIsAllowed();
this.allowFolders = !!Settings.capa(Capa.Folders);
this.folderListFocused = ko.computed(function() {
return Enums.Focused.FolderList === AppStore.focusedState();
});
this.folderListFocused = ko.computed(() => Focused.FolderList === AppStore.focusedState());
this.isInboxStarred = ko.computed(function() {
return FolderStore.currentFolder() &&
FolderStore.currentFolder().isInbox() &&
-1 < Utils.trim(MessageStore.messageListSearch()).indexOf('is:flagged');
});
this.isInboxStarred = ko.computed(
() => FolderStore.currentFolder() &&
FolderStore.currentFolder().isInbox() &&
-1 < trim(MessageStore.messageListSearch()).indexOf('is:flagged')
);
}
kn.constructorEnd(this);
}
onBuild(dom) {
kn.extendAsViewModel(['View/User/MailBox/FolderList', 'View/App/MailBox/FolderList', 'MailBoxFolderListViewModel'], FolderListMailBoxUserView);
_.extend(FolderListMailBoxUserView.prototype, AbstractView.prototype);
this.oContentVisible = $('.b-content', dom);
this.oContentScrollable = $('.content', this.oContentVisible);
FolderListMailBoxUserView.prototype.onBuild = function(oDom)
{
this.oContentVisible = $('.b-content', oDom);
this.oContentScrollable = $('.content', this.oContentVisible);
const
self = this,
isMobile = Settings.appSettingsGet('mobile'),
fSelectFolder = (el, event, starred) => {
var
self = this,
bMobile = Settings.appSettingsGet('mobile'),
fSelectFolder = function(oEvent, bStarred) {
if (bMobile)
{
Globals.leftPanelDisabled(true);
}
oEvent.preventDefault();
if (bStarred)
{
oEvent.stopPropagation();
}
var
oFolder = ko.dataFor(this);
if (oFolder)
{
if (Enums.Layout.NoPreview === SettingsStore.layout())
if (isMobile)
{
MessageStore.message(null);
leftPanelDisabled(true);
}
if (oFolder.fullNameRaw === FolderStore.currentFolderFullNameRaw())
event.preventDefault();
if (starred)
{
Cache.setFolderHash(oFolder.fullNameRaw, '');
event.stopPropagation();
}
if (bStarred)
const folder = ko.dataFor(el);
if (folder)
{
kn.setHash(Links.mailBox(oFolder.fullNameHash, 1, 'is:flagged'));
if (Layout.NoPreview === SettingsStore.layout())
{
MessageStore.message(null);
}
if (folder.fullNameRaw === FolderStore.currentFolderFullNameRaw())
{
setFolderHash(folder.fullNameRaw, '');
}
if (starred)
{
setHash(mailBox(folder.fullNameHash, 1, 'is:flagged'));
}
else
{
setHash(mailBox(folder.fullNameHash));
}
}
else
};
dom
.on('click', '.b-folders .e-item .e-link .e-collapsed-sign', function(event) { // eslint-disable-line prefer-arrow-callback
const folder = ko.dataFor(this); // eslint-disable-line no-invalid-this
if (folder && event)
{
kn.setHash(Links.mailBox(oFolder.fullNameHash));
const collapsed = folder.collapsed();
getApp().setExpandedFolder(folder.fullNameHash, collapsed);
folder.collapsed(!collapsed);
event.preventDefault();
event.stopPropagation();
}
}
};
})
.on('click', '.b-folders .e-item .e-link.selectable .inbox-star-icon', function(event) { // eslint-disable-line prefer-arrow-callback
fSelectFolder(this, event, !self.isInboxStarred()); // eslint-disable-line no-invalid-this
})
.on('click', '.b-folders .e-item .e-link.selectable', function(event) { // eslint-disable-line prefer-arrow-callback
fSelectFolder(this, event, false); // eslint-disable-line no-invalid-this
});
oDom
.on('click', '.b-folders .e-item .e-link .e-collapsed-sign', function(oEvent) {
key('up, down', KeyState.FolderList, (event, handler) => {
var oFolder = ko.dataFor(this);
if (oFolder && oEvent)
const
keyCode = handler && 'up' === handler.shortcut ? EventKeyCode.Up : EventKeyCode.Down,
$items = $('.b-folders .e-item .e-link:not(.hidden):visible', dom);
if (event && $items.length)
{
var bCollapsed = oFolder.collapsed();
require('App/User').default.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
let index = $items.index($items.filter('.focused'));
if (-1 < index)
{
$items.eq(index).removeClass('focused');
}
oFolder.collapsed(!bCollapsed);
oEvent.preventDefault();
oEvent.stopPropagation();
if (EventKeyCode.Up === keyCode && 0 < index)
{
index -= 1;
}
else if (EventKeyCode.Down === keyCode && index < $items.length - 1)
{
index += 1;
}
$items.eq(index).addClass('focused');
self.scrollToFocused();
}
})
.on('click', '.b-folders .e-item .e-link.selectable .inbox-star-icon', function(oEvent) {
fSelectFolder.call(this, oEvent, !self.isInboxStarred());
})
.on('click', '.b-folders .e-item .e-link.selectable', function(oEvent) {
fSelectFolder.call(this, oEvent, false);
return false;
});
key('up, down', Enums.KeyState.FolderList, function(event, handler) {
var
iKeyCode = handler && 'up' === handler.shortcut ? Enums.EventKeyCode.Up : Enums.EventKeyCode.Down,
$items = $('.b-folders .e-item .e-link:not(.hidden):visible', oDom);
if (event && $items.length)
{
var iIndex = $items.index($items.filter('.focused'));
if (-1 < iIndex)
key('enter', KeyState.FolderList, () => {
const $items = $('.b-folders .e-item .e-link:not(.hidden).focused', dom);
if ($items.length && $items[0])
{
$items.eq(iIndex).removeClass('focused');
AppStore.focusedState(Focused.MessageList);
$items.click();
}
if (Enums.EventKeyCode.Up === iKeyCode && 0 < iIndex)
return false;
});
key('space', KeyState.FolderList, () => {
const $items = $('.b-folders .e-item .e-link:not(.hidden).focused', dom);
if ($items.length && $items[0])
{
iIndex -= 1;
}
else if (Enums.EventKeyCode.Down === iKeyCode && iIndex < $items.length - 1)
{
iIndex += 1;
const folder = ko.dataFor($items[0]);
if (folder)
{
const collapsed = folder.collapsed();
getApp().setExpandedFolder(folder.fullNameHash, collapsed);
folder.collapsed(!collapsed);
}
}
$items.eq(iIndex).addClass('focused');
self.scrollToFocused();
}
return false;
});
return false;
});
key('esc, tab, shift+tab, right', KeyState.FolderList, () => {
AppStore.focusedState(Focused.MessageList);
return false;
});
key('enter', Enums.KeyState.FolderList, function() {
var $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
if ($items.length && $items[0])
{
AppStore.focusedState(Enums.Focused.MessageList);
$items.click();
}
return false;
});
key('space', Enums.KeyState.FolderList, function() {
var $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
if ($items.length && $items[0])
{
var oFolder = ko.dataFor($items[0]);
if (oFolder)
AppStore.focusedState.subscribe((value) => {
$('.b-folders .e-item .e-link.focused', dom).removeClass('focused');
if (Focused.FolderList === value)
{
var bCollapsed = oFolder.collapsed();
require('App/User').default.setExpandedFolder(oFolder.fullNameHash, bCollapsed);
oFolder.collapsed(!bCollapsed);
$('.b-folders .e-item .e-link.selected', dom).addClass('focused');
}
});
}
messagesDropOver(folder) {
window.clearTimeout(this.iDropOverTimer);
if (folder && folder.collapsed())
{
this.iDropOverTimer = window.setTimeout(() => {
folder.collapsed(false);
getApp().setExpandedFolder(folder.fullNameHash, true);
windowResize();
}, Magics.Time500ms);
}
}
messagesDropOut() {
window.clearTimeout(this.iDropOverTimer);
}
scrollToFocused() {
if (!this.oContentVisible || !this.oContentScrollable)
{
return false;
}
const
offset = 20,
focused = $('.e-item .e-link.focused', this.oContentScrollable),
pos = focused.position(),
visibleHeight = this.oContentVisible.height(),
focusedHeight = focused.outerHeight();
if (pos && (0 > pos.top || pos.top + focusedHeight > visibleHeight))
{
if (0 > pos.top)
{
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + pos.top - offset);
}
else
{
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + pos.top - visibleHeight + focusedHeight + offset);
}
return true;
}
return false;
}
/**
* @param {FolderModel} toFolder
* @param {{helper:jQuery}} ui
* @returns {void}
*/
messagesDrop(toFolder, ui) {
if (toFolder && ui && ui.helper)
{
const
fromFolderFullNameRaw = ui.helper.data('rl-folder'),
copy = $html.hasClass('rl-ctrl-key-pressed'),
uids = ui.helper.data('rl-uids');
if (isNormal(fromFolderFullNameRaw) && '' !== fromFolderFullNameRaw && isArray(uids))
{
getApp().moveMessagesToFolder(fromFolderFullNameRaw, uids, toFolder.fullNameRaw, copy);
}
}
return false;
});
key('esc, tab, shift+tab, right', Enums.KeyState.FolderList, function() {
AppStore.focusedState(Enums.Focused.MessageList);
return false;
});
AppStore.focusedState.subscribe(function(mValue) {
$('.b-folders .e-item .e-link.focused', oDom).removeClass('focused');
if (Enums.Focused.FolderList === mValue)
{
$('.b-folders .e-item .e-link.selected', oDom).addClass('focused');
}
});
};
FolderListMailBoxUserView.prototype.messagesDropOver = function(oFolder)
{
window.clearTimeout(this.iDropOverTimer);
if (oFolder && oFolder.collapsed())
{
this.iDropOverTimer = window.setTimeout(function() {
oFolder.collapsed(false);
require('App/User').default.setExpandedFolder(oFolder.fullNameHash, true);
Utils.windowResize();
}, Enums.Magics.Time500ms);
}
};
FolderListMailBoxUserView.prototype.messagesDropOut = function()
{
window.clearTimeout(this.iDropOverTimer);
};
FolderListMailBoxUserView.prototype.scrollToFocused = function()
{
if (!this.oContentVisible || !this.oContentScrollable)
{
return false;
}
var
iOffset = 20,
oFocused = $('.e-item .e-link.focused', this.oContentScrollable),
oPos = oFocused.position(),
iVisibleHeight = this.oContentVisible.height(),
iFocusedHeight = oFocused.outerHeight();
if (oPos && (0 > oPos.top || oPos.top + iFocusedHeight > iVisibleHeight))
{
if (0 > oPos.top)
composeClick() {
if (Settings.capa(Capa.Composer))
{
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iOffset);
}
else
{
this.oContentScrollable.scrollTop(this.oContentScrollable.scrollTop() + oPos.top - iVisibleHeight + iFocusedHeight + iOffset);
}
return true;
}
return false;
};
/**
* @param {FolderModel} oToFolder
* @param {{helper:jQuery}} oUi
* @returns {void}
*/
FolderListMailBoxUserView.prototype.messagesDrop = function(oToFolder, oUi)
{
if (oToFolder && oUi && oUi.helper)
{
var
sFromFolderFullNameRaw = oUi.helper.data('rl-folder'),
bCopy = Globals.$html.hasClass('rl-ctrl-key-pressed'),
aUids = oUi.helper.data('rl-uids');
if (Utils.isNormal(sFromFolderFullNameRaw) && '' !== sFromFolderFullNameRaw && Utils.isArray(aUids))
{
require('App/User').default.moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy);
showScreenPopup(require('View/Popup/Compose'));
}
}
};
FolderListMailBoxUserView.prototype.composeClick = function()
{
if (Settings.capa(Enums.Capa.Composer))
{
kn.showScreenPopup(require('View/Popup/Compose'));
createFolder() {
showScreenPopup(require('View/Popup/FolderCreate'));
}
};
FolderListMailBoxUserView.prototype.createFolder = function()
{
kn.showScreenPopup(require('View/Popup/FolderCreate'));
};
FolderListMailBoxUserView.prototype.configureFolders = function()
{
kn.setHash(Links.settings('folders'));
};
FolderListMailBoxUserView.prototype.contactsClick = function()
{
if (this.allowContacts)
{
kn.showScreenPopup(require('View/Popup/Contacts'));
configureFolders() {
setHash(settings('folders'));
}
};
module.exports = FolderListMailBoxUserView;
contactsClick() {
if (this.allowContacts)
{
showScreenPopup(require('View/Popup/Contacts'));
}
}
}
export {FolderListMailBoxUserView, FolderListMailBoxUserView as default};

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,21 +1,10 @@
var
_ = require('_'),
import {view} from 'Knoin/Knoin';
import {AbstractSystemDropDownUserView} from 'View/User/AbstractSystemDropDown';
kn = require('Knoin/Knoin'),
AbstractSystemDropDownViewModel = require('View/User/AbstractSystemDropDown');
@view({
name: 'View/User/MailBox/SystemDropDown'
})
class SystemDropDownMailBoxUserView extends AbstractSystemDropDownUserView {}
/**
* @constructor
* @extends AbstractSystemDropDownViewModel
*/
function SystemDropDownMailBoxUserView()
{
AbstractSystemDropDownViewModel.call(this);
kn.constructorEnd(this);
}
kn.extendAsViewModel(['View/User/MailBox/SystemDropDown', 'View/App/MailBox/SystemDropDown', 'MailBoxSystemDropDownViewModel'], SystemDropDownMailBoxUserView);
_.extend(SystemDropDownMailBoxUserView.prototype, AbstractSystemDropDownViewModel.prototype);
module.exports = SystemDropDownMailBoxUserView;
export {SystemDropDownMailBoxUserView, SystemDropDownMailBoxUserView as default};

View file

@ -1,85 +1,81 @@
var
_ = require('_'),
$ = require('$'),
key = require('key'),
import _ from '_';
import $ from '$';
import key from 'key';
Enums = require('Common/Enums'),
Globals = require('Common/Globals'),
Links = require('Common/Links'),
import {KeyState, Magics} from 'Common/Enums';
import {leftPanelDisabled} from 'Common/Globals';
import {settings, inbox} from 'Common/Links';
import {getFolderInboxName} from 'Common/Cache';
Cache = require('Common/Cache'),
Settings = require('Storage/Settings'),
import * as Settings from 'Storage/Settings';
kn = require('Knoin/Knoin'),
AbstractView = require('Knoin/AbstractView');
import {view, ViewType, setHash} from 'Knoin/Knoin';
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
/**
* @constructor
* @param {Object} oScreen
*/
function MenuSettingsUserView(oScreen)
@view({
name: 'View/User/Settings/Menu',
type: ViewType.Left,
templateID: 'SettingsMenu'
})
class MenuSettingsUserView extends AbstractViewNext
{
AbstractView.call(this, 'Left', 'SettingsMenu');
/**
* @param {Object} screen
*/
constructor(screen) {
super();
this.leftPanelDisabled = Globals.leftPanelDisabled;
this.leftPanelDisabled = leftPanelDisabled;
this.mobile = Settings.appSettingsGet('mobile');
this.mobile = Settings.appSettingsGet('mobile');
this.menu = oScreen.menu;
kn.constructorEnd(this);
}
kn.extendAsViewModel(['View/User/Settings/Menu', 'View/App/Settings/Menu', 'SettingsMenuViewModel'], MenuSettingsUserView);
_.extend(MenuSettingsUserView.prototype, AbstractView.prototype);
MenuSettingsUserView.prototype.onBuild = function(oDom)
{
if (this.mobile)
{
oDom
.on('click', '.b-settings-menu .e-item.selectable', function() {
Globals.leftPanelDisabled(true);
});
this.menu = screen.menu;
}
key('up, down', Enums.KeyState.Settings, _.throttle(function(event, handler) {
var
bUp = handler && 'up' === handler.shortcut,
$items = $('.b-settings-menu .e-item', oDom);
if (event && $items.length)
onBuild(dom) {
if (this.mobile)
{
var iIndex = $items.index($items.filter('.selected'));
if (bUp && 0 < iIndex)
{
iIndex -= 1;
}
else if (!bUp && iIndex < $items.length - 1)
{
iIndex += 1;
}
var sH = $items.eq(iIndex).attr('href');
if (sH)
{
kn.setHash(sH, false, true);
}
dom.on('click', '.b-settings-menu .e-item.selectable', () => {
leftPanelDisabled(true);
});
}
}, 200)); // eslint-disable-line no-magic-numbers
};
key('up, down', KeyState.Settings, _.throttle((event, handler) => {
MenuSettingsUserView.prototype.link = function(sRoute)
{
return Links.settings(sRoute);
};
const
up = handler && 'up' === handler.shortcut,
$items = $('.b-settings-menu .e-item', dom);
MenuSettingsUserView.prototype.backToMailBoxClick = function()
{
kn.setHash(Links.inbox(Cache.getFolderInboxName()));
};
if (event && $items.length)
{
let iIndex = $items.index($items.filter('.selected'));
if (up && 0 < iIndex)
{
iIndex -= 1;
}
else if (!up && iIndex < $items.length - 1)
{
iIndex += 1;
}
module.exports = MenuSettingsUserView;
const sH = $items.eq(iIndex).attr('href');
if (sH)
{
setHash(sH, false, true);
}
}
}, Magics.Time200ms));
}
link(sRoute) {
return settings(sRoute);
}
backToMailBoxClick() {
setHash(inbox(getFolderInboxName()));
}
}
export {MenuSettingsUserView, MenuSettingsUserView as default};

View file

@ -1,68 +1,60 @@
var
_ = require('_'),
import {inbox} from 'Common/Links';
import {getFolderInboxName} from 'Common/Cache';
import {leftPanelDisabled} from 'Common/Globals';
Globals = require('Common/Globals'),
import * as Settings from 'Storage/Settings';
Settings = require('Storage/Settings'),
import MessageStore from 'Stores/User/Message';
kn = require('Knoin/Knoin'),
AbstractView = require('Knoin/AbstractView');
import {view, ViewType, setHash} from 'Knoin/Knoin';
import {AbstractViewNext} from 'Knoin/AbstractViewNext';
/**
* @constructor
* @extends AbstractView
*/
function PaneSettingsUserView()
@view({
name: 'View/User/Settings/Pane',
type: ViewType.Right,
templateID: 'SettingsPane'
})
class PaneSettingsUserView extends AbstractViewNext
{
AbstractView.call(this, 'Right', 'SettingsPane');
constructor() {
super();
this.mobile = Settings.appSettingsGet('mobile');
this.mobile = Settings.appSettingsGet('mobile');
this.leftPanelDisabled = Globals.leftPanelDisabled;
this.leftPanelDisabled = leftPanelDisabled;
}
kn.constructorEnd(this);
onShow() {
MessageStore.message(null);
}
hideLeft(oItem, oEvent) {
oEvent.preventDefault();
oEvent.stopPropagation();
leftPanelDisabled(true);
}
showLeft(oItem, oEvent) {
oEvent.preventDefault();
oEvent.stopPropagation();
leftPanelDisabled(false);
}
onBuild(dom) {
if (this.mobile)
{
dom.on('click', () => {
leftPanelDisabled(true);
});
}
}
backToMailBoxClick() {
setHash(inbox(getFolderInboxName()));
}
}
kn.extendAsViewModel(['View/User/Settings/Pane', 'View/App/Settings/Pane', 'SettingsPaneViewModel'], PaneSettingsUserView);
_.extend(PaneSettingsUserView.prototype, AbstractView.prototype);
PaneSettingsUserView.prototype.onShow = function()
{
require('Stores/User/Message').message(null);
};
PaneSettingsUserView.prototype.hideLeft = function(oItem, oEvent)
{
oEvent.preventDefault();
oEvent.stopPropagation();
Globals.leftPanelDisabled(true);
};
PaneSettingsUserView.prototype.showLeft = function(oItem, oEvent)
{
oEvent.preventDefault();
oEvent.stopPropagation();
Globals.leftPanelDisabled(false);
};
PaneSettingsUserView.prototype.onBuild = function(oDom)
{
if (this.mobile)
{
oDom
.on('click', function() {
Globals.leftPanelDisabled(true);
});
}
};
PaneSettingsUserView.prototype.backToMailBoxClick = function()
{
kn.setHash(require('Common/Links').inbox(
require('Common/Cache').getFolderInboxName()));
};
module.exports = PaneSettingsUserView;
export {PaneSettingsUserView, PaneSettingsUserView as default};

View file

@ -1,21 +1,10 @@
var
_ = require('_'),
import {view} from 'Knoin/Knoin';
import {AbstractSystemDropDownUserView} from 'View/User/AbstractSystemDropDown';
kn = require('Knoin/Knoin'),
AbstractSystemDropDownUserView = require('View/User/AbstractSystemDropDown');
@view({
name: 'View/User/Settings/SystemDropDown'
})
class SystemDropDownSettingsUserView extends AbstractSystemDropDownUserView {}
/**
* @constructor
* @extends AbstractSystemDropDownUserView
*/
function SystemDropDownSettingsUserView()
{
AbstractSystemDropDownUserView.call(this);
kn.constructorEnd(this);
}
kn.extendAsViewModel(['View/User/Settings/SystemDropDown', 'View/App/Settings/SystemDropDown', 'SettingsSystemDropDownViewModel'], SystemDropDownSettingsUserView);
_.extend(SystemDropDownSettingsUserView.prototype, AbstractSystemDropDownUserView.prototype);
module.exports = SystemDropDownSettingsUserView;
export {SystemDropDownSettingsUserView, SystemDropDownSettingsUserView as default};