mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Code refactoring (Translator, Stores, ko)
This commit is contained in:
parent
929bffccef
commit
b42ce01e7e
102 changed files with 6775 additions and 6511 deletions
|
|
@ -13,8 +13,12 @@
|
|||
Utils = require('Common/Utils'),
|
||||
Links = require('Common/Links'),
|
||||
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
Plugins = require('Common/Plugins'),
|
||||
|
||||
UserSettingsStore = require('Stores/UserSettings'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Data = require('Storage/User/Data'),
|
||||
Remote = require('Storage/User/Remote'),
|
||||
|
|
@ -87,11 +91,12 @@
|
|||
this.allowLanguagesOnLogin = Data.allowLanguagesOnLogin;
|
||||
|
||||
this.langRequest = ko.observable(false);
|
||||
this.mainLanguage = Data.mainLanguage;
|
||||
this.language = UserSettingsStore.language;
|
||||
|
||||
this.bSendLanguage = false;
|
||||
|
||||
this.mainLanguageFullName = ko.computed(function () {
|
||||
return Utils.convertLangName(this.mainLanguage());
|
||||
this.languageFullName = ko.computed(function () {
|
||||
return Utils.convertLangName(this.language());
|
||||
}, this);
|
||||
|
||||
this.signMeType = ko.observable(Enums.LoginSignMeType.Unused);
|
||||
|
|
@ -133,7 +138,7 @@
|
|||
Plugins.runHook('user-login-submit', [fSubmitResult]);
|
||||
if (0 < iPluginResultCode)
|
||||
{
|
||||
this.submitError(Utils.getNotification(iPluginResultCode));
|
||||
this.submitError(Translator.getNotification(iPluginResultCode));
|
||||
return false;
|
||||
}
|
||||
else if ('' !== sPluginResultMessage)
|
||||
|
|
@ -180,11 +185,11 @@
|
|||
oData.ErrorCode = Enums.Notification.AuthError;
|
||||
}
|
||||
|
||||
this.submitError(Utils.getNotification(oData.ErrorCode));
|
||||
this.submitError(Translator.getNotification(oData.ErrorCode));
|
||||
|
||||
if ('' === this.submitError())
|
||||
{
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -202,11 +207,11 @@
|
|||
else
|
||||
{
|
||||
this.submitRequest(false);
|
||||
this.submitError(Utils.getNotification(Enums.Notification.UnknownError));
|
||||
this.submitError(Translator.getNotification(Enums.Notification.UnknownError));
|
||||
}
|
||||
|
||||
}, this), this.email(), '', sPassword, !!this.signMe(),
|
||||
this.bSendLanguage ? this.mainLanguage() : '',
|
||||
this.bSendLanguage ? this.language() : '',
|
||||
this.additionalCode.visibility() ? this.additionalCode() : '',
|
||||
this.additionalCode.visibility() ? !!this.additionalCodeSignMe() : false
|
||||
);
|
||||
|
|
@ -302,7 +307,7 @@
|
|||
|
||||
if (Settings.settingsGet('UserLanguage'))
|
||||
{
|
||||
$.cookie('rllang', Data.language(), {'expires': 30});
|
||||
$.cookie('rllang', UserSettingsStore.language(), {'expires': 30});
|
||||
}
|
||||
|
||||
}, this), 100);
|
||||
|
|
@ -328,7 +333,7 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
self.submitError(Utils.getNotification(iErrorCode));
|
||||
self.submitError(Translator.getNotification(iErrorCode));
|
||||
}
|
||||
}
|
||||
;
|
||||
|
|
@ -371,11 +376,11 @@
|
|||
}
|
||||
|
||||
_.delay(function () {
|
||||
Data.language.subscribe(function (sValue) {
|
||||
UserSettingsStore.language.subscribe(function (sValue) {
|
||||
|
||||
self.langRequest(true);
|
||||
|
||||
Utils.reloadLanguage(sValue, function() {
|
||||
Translator.reload(sValue, function() {
|
||||
self.langRequest(false);
|
||||
self.bSendLanguage = true;
|
||||
$.cookie('rllang', sValue, {'expires': 30});
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@
|
|||
Globals = require('Common/Globals'),
|
||||
Links = require('Common/Links'),
|
||||
|
||||
UserSettingsStore = require('Stores/UserSettings'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Cache = require('Storage/User/Cache'),
|
||||
Data = require('Storage/User/Data'),
|
||||
|
|
@ -88,7 +90,7 @@
|
|||
|
||||
if (oFolder)
|
||||
{
|
||||
if (Enums.Layout.NoPreview === Data.layout())
|
||||
if (Enums.Layout.NoPreview === UserSettingsStore.layout())
|
||||
{
|
||||
Data.message(null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@
|
|||
Links = require('Common/Links'),
|
||||
Events = require('Common/Events'),
|
||||
Selector = require('Common/Selector'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
QuotaStore = require('Stores/Quota'),
|
||||
UserSettingsStore = require('Stores/UserSettings'),
|
||||
|
||||
Settings = require('Storage/Settings'),
|
||||
Cache = require('Storage/User/Cache'),
|
||||
|
|
@ -63,13 +67,13 @@
|
|||
this.messageListCheckedOrSelectedUidsWithSubMails = Data.messageListCheckedOrSelectedUidsWithSubMails;
|
||||
this.messageListCompleteLoadingThrottle = Data.messageListCompleteLoadingThrottle;
|
||||
|
||||
Utils.initOnStartOrLangChange(function () {
|
||||
this.emptySubjectValue = Utils.i18n('MESSAGE_LIST/EMPTY_SUBJECT_TEXT');
|
||||
Translator.initOnStartOrLangChange(function () {
|
||||
this.emptySubjectValue = Translator.i18n('MESSAGE_LIST/EMPTY_SUBJECT_TEXT');
|
||||
}, this);
|
||||
|
||||
this.userQuota = Data.userQuota;
|
||||
this.userUsageSize = Data.userUsageSize;
|
||||
this.userUsageProc = Data.userUsageProc;
|
||||
this.userQuota = QuotaStore.quota;
|
||||
this.userUsageSize = QuotaStore.usage;
|
||||
this.userUsageProc = QuotaStore.percentage;
|
||||
|
||||
this.moveDropdownTrigger = ko.observable(false);
|
||||
this.moreDropdownTrigger = ko.observable(false);
|
||||
|
|
@ -81,13 +85,13 @@
|
|||
this.dragOverBodyArea = ko.observable(null);
|
||||
|
||||
this.messageListItemTemplate = ko.computed(function () {
|
||||
return Enums.Layout.SidePreview === Data.layout() ?
|
||||
return Enums.Layout.SidePreview === UserSettingsStore.layout() ?
|
||||
'MailMessageListItem' : 'MailMessageListItemNoPreviewPane';
|
||||
});
|
||||
|
||||
this.messageListSearchDesc = ko.computed(function () {
|
||||
var sValue = Data.messageListEndSearch();
|
||||
return '' === sValue ? '' : Utils.i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', {'SEARCH': sValue});
|
||||
return '' === sValue ? '' : Translator.i18n('MESSAGE_LIST/SEARCH_RESULT_FOR', {'SEARCH': sValue});
|
||||
});
|
||||
|
||||
this.messageListPagenator = ko.computed(Utils.computedPagenatorHelper(Data.messageListPage, Data.messageListPageCount));
|
||||
|
|
@ -227,7 +231,7 @@
|
|||
Data.message(Data.staticMessageList.populateByMessageListItem(oMessage));
|
||||
this.populateMessageBody(Data.message());
|
||||
|
||||
if (Enums.Layout.NoPreview === Data.layout())
|
||||
if (Enums.Layout.NoPreview === UserSettingsStore.layout())
|
||||
{
|
||||
kn.setHash(Links.messagePreview(), true);
|
||||
Data.message.focused(true);
|
||||
|
|
@ -247,11 +251,11 @@
|
|||
this.selector.scrollToTop();
|
||||
}, this);
|
||||
|
||||
Data.layout.subscribe(function (mValue) {
|
||||
UserSettingsStore.layout.subscribe(function (mValue) {
|
||||
this.selector.autoSelect(Enums.Layout.NoPreview !== mValue);
|
||||
}, this);
|
||||
|
||||
Data.layout.valueHasMutated();
|
||||
UserSettingsStore.layout.valueHasMutated();
|
||||
|
||||
Events
|
||||
.sub('mailbox.message-list.selector.go-down', function () {
|
||||
|
|
@ -360,8 +364,8 @@
|
|||
{
|
||||
Data.message(null);
|
||||
Data.messageError((oData && oData.ErrorCode ?
|
||||
Utils.getNotification(oData.ErrorCode) :
|
||||
Utils.getNotification(Enums.Notification.UnknownError)));
|
||||
Translator.getNotification(oData.ErrorCode) :
|
||||
Translator.getNotification(Enums.Notification.UnknownError)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -869,7 +873,7 @@
|
|||
|
||||
MessageListMailBoxUserView.prototype.quotaTooltip = function ()
|
||||
{
|
||||
return Utils.i18n('MESSAGE_LIST/QUOTA_SIZE', {
|
||||
return Translator.i18n('MESSAGE_LIST/QUOTA_SIZE', {
|
||||
'SIZE': Utils.friendlySize(this.userUsageSize()),
|
||||
'PROC': this.userUsageProc(),
|
||||
'LIMIT': Utils.friendlySize(this.userQuota())
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@
|
|||
Globals = require('Common/Globals'),
|
||||
Utils = require('Common/Utils'),
|
||||
Events = require('Common/Events'),
|
||||
Translator = require('Common/Translator'),
|
||||
|
||||
UserSettingsStore = require('Stores/UserSettings'),
|
||||
|
||||
Local = require('Storage/Local'),
|
||||
Cache = require('Storage/User/Cache'),
|
||||
|
|
@ -61,8 +64,8 @@
|
|||
this.messagesBodiesDom = Data.messagesBodiesDom;
|
||||
this.useThreads = Data.useThreads;
|
||||
this.replySameFolder = Data.replySameFolder;
|
||||
this.layout = Data.layout;
|
||||
this.usePreviewPane = Data.usePreviewPane;
|
||||
this.layout = UserSettingsStore.layout;
|
||||
this.usePreviewPane = UserSettingsStore.usePreviewPane;
|
||||
this.isMessageSelected = Data.isMessageSelected;
|
||||
this.messageActiveDom = Data.messageActiveDom;
|
||||
this.messageError = Data.messageError;
|
||||
|
|
@ -329,19 +332,19 @@
|
|||
switch (this.viewPgpSignedVerifyStatus())
|
||||
{
|
||||
case Enums.SignedVerifyStatus.UnknownPublicKeys:
|
||||
sResult = Utils.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND');
|
||||
sResult = Translator.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND');
|
||||
break;
|
||||
case Enums.SignedVerifyStatus.UnknownPrivateKey:
|
||||
sResult = Utils.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND');
|
||||
sResult = Translator.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND');
|
||||
break;
|
||||
case Enums.SignedVerifyStatus.Unverified:
|
||||
sResult = Utils.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE');
|
||||
sResult = Translator.i18n('PGP_NOTIFICATIONS/UNVERIFIRED_SIGNATURE');
|
||||
break;
|
||||
case Enums.SignedVerifyStatus.Error:
|
||||
sResult = Utils.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR');
|
||||
sResult = Translator.i18n('PGP_NOTIFICATIONS/DECRYPTION_ERROR');
|
||||
break;
|
||||
case Enums.SignedVerifyStatus.Success:
|
||||
sResult = Utils.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
sResult = Translator.i18n('PGP_NOTIFICATIONS/GOOD_SIGNATURE', {
|
||||
'USER': this.viewPgpSignedVerifyUser()
|
||||
});
|
||||
break;
|
||||
|
|
@ -382,7 +385,7 @@
|
|||
{
|
||||
var
|
||||
self = this,
|
||||
sErrorMessage = Utils.i18n('PREVIEW_POPUP/IMAGE_ERROR'),
|
||||
sErrorMessage = Translator.i18n('PREVIEW_POPUP/IMAGE_ERROR'),
|
||||
fCheckHeaderHeight = function () {
|
||||
if (self.oHeaderDom)
|
||||
{
|
||||
|
|
@ -561,7 +564,7 @@
|
|||
{
|
||||
this.fullScreenMode(false);
|
||||
}
|
||||
else if (Enums.Layout.NoPreview === Data.layout())
|
||||
else if (Enums.Layout.NoPreview === this.layout())
|
||||
{
|
||||
this.message(null);
|
||||
}
|
||||
|
|
@ -590,7 +593,7 @@
|
|||
});
|
||||
|
||||
key('enter', Enums.KeyState.MessageList, function () {
|
||||
if (Enums.Layout.NoPreview !== Data.layout() && self.message())
|
||||
if (Enums.Layout.NoPreview !== self.layout() && self.message())
|
||||
{
|
||||
self.toggleFullScreen();
|
||||
return false;
|
||||
|
|
@ -681,7 +684,7 @@
|
|||
|
||||
// change focused state
|
||||
key('tab, shift+tab, left', Enums.KeyState.MessageView, function (event, handler) {
|
||||
if (!self.fullScreenMode() && self.message() && Enums.Layout.NoPreview !== Data.layout())
|
||||
if (!self.fullScreenMode() && self.message() && Enums.Layout.NoPreview !== self.layout())
|
||||
{
|
||||
if (event && handler && 'left' === handler.shortcut)
|
||||
{
|
||||
|
|
@ -697,7 +700,7 @@
|
|||
self.message.focused(false);
|
||||
}
|
||||
}
|
||||
else if (self.message() && Enums.Layout.NoPreview === Data.layout() && event && handler && 'left' === handler.shortcut)
|
||||
else if (self.message() && Enums.Layout.NoPreview === self.layout() && event && handler && 'left' === handler.shortcut)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -856,8 +859,8 @@
|
|||
{
|
||||
Remote.sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid,
|
||||
oMessage.readReceipt(),
|
||||
Utils.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}),
|
||||
Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': Data.accountEmail()}));
|
||||
Translator.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}),
|
||||
Translator.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': Data.accountEmail()}));
|
||||
|
||||
oMessage.isReadReceipt(true);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue