mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 13:09:21 +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
|
|
@ -208,7 +208,7 @@
|
|||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
Enums.DesktopNotifications = {
|
||||
Enums.DesktopNotification = {
|
||||
'Allowed': 0,
|
||||
'NotAllowed': 1,
|
||||
'Denied': 2,
|
||||
|
|
|
|||
|
|
@ -40,11 +40,6 @@
|
|||
*/
|
||||
Globals.tooltipTrigger = ko.observable(false).extend({'rateLimit': 0});
|
||||
|
||||
/**
|
||||
* @type {?}
|
||||
*/
|
||||
Globals.langChangeTrigger = ko.observable(true);
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
|
|
@ -189,10 +184,6 @@
|
|||
});
|
||||
}
|
||||
|
||||
Globals.oI18N = window['rainloopI18N'] || {};
|
||||
|
||||
Globals.oNotificationI18N = {};
|
||||
|
||||
Globals.aBootstrapDropdowns = [];
|
||||
|
||||
Globals.aViewModels = {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
Utils = require('Common/Utils')
|
||||
;
|
||||
|
||||
|
|
@ -326,7 +327,7 @@
|
|||
sPrefix = '';
|
||||
}
|
||||
|
||||
return sPrefix + 'themes/' + encodeURI(sTheme) + '/images/preview.png';
|
||||
return sPrefix + 'themes/' + window.encodeURI(sTheme) + '/images/preview.png';
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
306
dev/Common/Translator.js
Normal file
306
dev/Common/Translator.js
Normal file
|
|
@ -0,0 +1,306 @@
|
|||
|
||||
(function () {
|
||||
|
||||
'use strict';
|
||||
|
||||
var
|
||||
window = require('window'),
|
||||
$ = require('$'),
|
||||
_ = require('_'),
|
||||
ko = require('ko'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Globals = require('Common/Globals')
|
||||
;
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
*/
|
||||
function Translator()
|
||||
{
|
||||
this.data = window['rainloopI18N'] || {};
|
||||
this.notificationI18N = {};
|
||||
|
||||
this.trigger = ko.observable(false);
|
||||
|
||||
this.i18n = _.bind(this.i18n, this);
|
||||
}
|
||||
|
||||
Translator.prototype.data = {};
|
||||
Translator.prototype.notificationI18N = {};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @param {Object=} oValueList
|
||||
* @param {string=} sDefaulValue
|
||||
* @return {string}
|
||||
*/
|
||||
Translator.prototype.i18n = function (sKey, oValueList, sDefaulValue)
|
||||
{
|
||||
var
|
||||
sValueName = '',
|
||||
sResult = _.isUndefined(this.data[sKey]) ? (_.isUndefined(sDefaulValue) ? sKey : sDefaulValue) : this.data[sKey]
|
||||
;
|
||||
|
||||
if (!_.isUndefined(oValueList) && !_.isNull(oValueList))
|
||||
{
|
||||
for (sValueName in oValueList)
|
||||
{
|
||||
if (_.has(oValueList, sValueName))
|
||||
{
|
||||
sResult = sResult.replace('%' + sValueName + '%', oValueList[sValueName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oElement
|
||||
* @param {boolean=} bAnimate = false
|
||||
*/
|
||||
Translator.prototype.i18nToNode = function (oElement, bAnimate)
|
||||
{
|
||||
var self = this;
|
||||
_.defer(function () {
|
||||
$('.i18n', oElement).each(function () {
|
||||
var
|
||||
jqThis = $(this),
|
||||
sKey = ''
|
||||
;
|
||||
|
||||
sKey = jqThis.data('i18n-text');
|
||||
if (sKey)
|
||||
{
|
||||
jqThis.text(self.i18n(sKey));
|
||||
}
|
||||
else
|
||||
{
|
||||
sKey = jqThis.data('i18n-html');
|
||||
if (sKey)
|
||||
{
|
||||
jqThis.html(self.i18n(sKey));
|
||||
}
|
||||
|
||||
sKey = jqThis.data('i18n-placeholder');
|
||||
if (sKey)
|
||||
{
|
||||
jqThis.attr('placeholder', self.i18n(sKey));
|
||||
}
|
||||
|
||||
sKey = jqThis.data('i18n-title');
|
||||
if (sKey)
|
||||
{
|
||||
jqThis.attr('title', self.i18n(sKey));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (bAnimate && Globals.bAnimationSupported)
|
||||
{
|
||||
$('.i18n-animation.i18n', oElement).letterfx({
|
||||
'fx': 'fall fade', 'backwards': false, 'timing': 50, 'fx_duration': '50ms', 'letter_end': 'restore', 'element_end': 'restore'
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Translator.prototype.reloadData = function ()
|
||||
{
|
||||
if (window['rainloopI18N'])
|
||||
{
|
||||
this.data = window['rainloopI18N'] || {};
|
||||
|
||||
this.i18nToNode($(window.document), true);
|
||||
this.trigger(!this.trigger());
|
||||
}
|
||||
|
||||
window['rainloopI18N'] = null;
|
||||
};
|
||||
|
||||
Translator.prototype.initNotificationLanguage = function ()
|
||||
{
|
||||
var oN = this.notificationI18N || {};
|
||||
|
||||
oN[Enums.Notification.InvalidToken] = this.i18n('NOTIFICATIONS/INVALID_TOKEN');
|
||||
oN[Enums.Notification.AuthError] = this.i18n('NOTIFICATIONS/AUTH_ERROR');
|
||||
oN[Enums.Notification.AccessError] = this.i18n('NOTIFICATIONS/ACCESS_ERROR');
|
||||
oN[Enums.Notification.ConnectionError] = this.i18n('NOTIFICATIONS/CONNECTION_ERROR');
|
||||
oN[Enums.Notification.CaptchaError] = this.i18n('NOTIFICATIONS/CAPTCHA_ERROR');
|
||||
oN[Enums.Notification.SocialFacebookLoginAccessDisable] = this.i18n('NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE');
|
||||
oN[Enums.Notification.SocialTwitterLoginAccessDisable] = this.i18n('NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE');
|
||||
oN[Enums.Notification.SocialGoogleLoginAccessDisable] = this.i18n('NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE');
|
||||
oN[Enums.Notification.DomainNotAllowed] = this.i18n('NOTIFICATIONS/DOMAIN_NOT_ALLOWED');
|
||||
oN[Enums.Notification.AccountNotAllowed] = this.i18n('NOTIFICATIONS/ACCOUNT_NOT_ALLOWED');
|
||||
|
||||
oN[Enums.Notification.AccountTwoFactorAuthRequired] = this.i18n('NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED');
|
||||
oN[Enums.Notification.AccountTwoFactorAuthError] = this.i18n('NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR');
|
||||
|
||||
oN[Enums.Notification.CouldNotSaveNewPassword] = this.i18n('NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD');
|
||||
oN[Enums.Notification.CurrentPasswordIncorrect] = this.i18n('NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT');
|
||||
oN[Enums.Notification.NewPasswordShort] = this.i18n('NOTIFICATIONS/NEW_PASSWORD_SHORT');
|
||||
oN[Enums.Notification.NewPasswordWeak] = this.i18n('NOTIFICATIONS/NEW_PASSWORD_WEAK');
|
||||
oN[Enums.Notification.NewPasswordForbidden] = this.i18n('NOTIFICATIONS/NEW_PASSWORD_FORBIDDENT');
|
||||
|
||||
oN[Enums.Notification.ContactsSyncError] = this.i18n('NOTIFICATIONS/CONTACTS_SYNC_ERROR');
|
||||
|
||||
oN[Enums.Notification.CantGetMessageList] = this.i18n('NOTIFICATIONS/CANT_GET_MESSAGE_LIST');
|
||||
oN[Enums.Notification.CantGetMessage] = this.i18n('NOTIFICATIONS/CANT_GET_MESSAGE');
|
||||
oN[Enums.Notification.CantDeleteMessage] = this.i18n('NOTIFICATIONS/CANT_DELETE_MESSAGE');
|
||||
oN[Enums.Notification.CantMoveMessage] = this.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE');
|
||||
oN[Enums.Notification.CantCopyMessage] = this.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE');
|
||||
|
||||
oN[Enums.Notification.CantSaveMessage] = this.i18n('NOTIFICATIONS/CANT_SAVE_MESSAGE');
|
||||
oN[Enums.Notification.CantSendMessage] = this.i18n('NOTIFICATIONS/CANT_SEND_MESSAGE');
|
||||
oN[Enums.Notification.InvalidRecipients] = this.i18n('NOTIFICATIONS/INVALID_RECIPIENTS');
|
||||
|
||||
oN[Enums.Notification.CantSaveFilters] = this.i18n('NOTIFICATIONS/CANT_SAVE_FILTERS');
|
||||
oN[Enums.Notification.FiltersAreNotCorrect] = this.i18n('NOTIFICATIONS/FILTERS_ARE_NOT_CORRECT');
|
||||
|
||||
oN[Enums.Notification.CantCreateFolder] = this.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER');
|
||||
oN[Enums.Notification.CantRenameFolder] = this.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER');
|
||||
oN[Enums.Notification.CantDeleteFolder] = this.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER');
|
||||
oN[Enums.Notification.CantDeleteNonEmptyFolder] = this.i18n('NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER');
|
||||
oN[Enums.Notification.CantSubscribeFolder] = this.i18n('NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER');
|
||||
oN[Enums.Notification.CantUnsubscribeFolder] = this.i18n('NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER');
|
||||
|
||||
oN[Enums.Notification.CantSaveSettings] = this.i18n('NOTIFICATIONS/CANT_SAVE_SETTINGS');
|
||||
oN[Enums.Notification.CantSavePluginSettings] = this.i18n('NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS');
|
||||
|
||||
oN[Enums.Notification.DomainAlreadyExists] = this.i18n('NOTIFICATIONS/DOMAIN_ALREADY_EXISTS');
|
||||
|
||||
oN[Enums.Notification.CantInstallPackage] = this.i18n('NOTIFICATIONS/CANT_INSTALL_PACKAGE');
|
||||
oN[Enums.Notification.CantDeletePackage] = this.i18n('NOTIFICATIONS/CANT_DELETE_PACKAGE');
|
||||
oN[Enums.Notification.InvalidPluginPackage] = this.i18n('NOTIFICATIONS/INVALID_PLUGIN_PACKAGE');
|
||||
oN[Enums.Notification.UnsupportedPluginPackage] = this.i18n('NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE');
|
||||
|
||||
oN[Enums.Notification.LicensingServerIsUnavailable] = this.i18n('NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE');
|
||||
oN[Enums.Notification.LicensingExpired] = this.i18n('NOTIFICATIONS/LICENSING_EXPIRED');
|
||||
oN[Enums.Notification.LicensingBanned] = this.i18n('NOTIFICATIONS/LICENSING_BANNED');
|
||||
|
||||
oN[Enums.Notification.DemoSendMessageError] = this.i18n('NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR');
|
||||
|
||||
oN[Enums.Notification.AccountAlreadyExists] = this.i18n('NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS');
|
||||
oN[Enums.Notification.AccountDoesNotExist] = this.i18n('NOTIFICATIONS/ACCOUNT_DOES_NOT_EXIST');
|
||||
|
||||
oN[Enums.Notification.MailServerError] = this.i18n('NOTIFICATIONS/MAIL_SERVER_ERROR');
|
||||
oN[Enums.Notification.InvalidInputArgument] = this.i18n('NOTIFICATIONS/INVALID_INPUT_ARGUMENT');
|
||||
oN[Enums.Notification.UnknownNotification] = this.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
|
||||
oN[Enums.Notification.UnknownError] = this.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} fCallback
|
||||
* @param {Object} oScope
|
||||
* @param {Function=} fLangCallback
|
||||
*/
|
||||
Translator.prototype.initOnStartOrLangChange = function (fCallback, oScope, fLangCallback)
|
||||
{
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback.call(oScope);
|
||||
}
|
||||
|
||||
if (fLangCallback)
|
||||
{
|
||||
this.trigger.subscribe(function () {
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback.call(oScope);
|
||||
}
|
||||
|
||||
fLangCallback.call(oScope);
|
||||
});
|
||||
}
|
||||
else if (fCallback)
|
||||
{
|
||||
this.trigger.subscribe(fCallback, oScope);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} iCode
|
||||
* @param {*=} mMessage = ''
|
||||
* @return {string}
|
||||
*/
|
||||
Translator.prototype.getNotification = function (iCode, mMessage)
|
||||
{
|
||||
iCode = window.parseInt(iCode, 10) || 0;
|
||||
if (Enums.Notification.ClientViewError === iCode && mMessage)
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
return _.isUndefined(this.notificationI18N[iCode]) ? '' : this.notificationI18N[iCode];
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {*} mCode
|
||||
* @return {string}
|
||||
*/
|
||||
Translator.prototype.getUploadErrorDescByCode = function (mCode)
|
||||
{
|
||||
var sResult = '';
|
||||
switch (window.parseInt(mCode, 10) || 0) {
|
||||
case Enums.UploadErrorCode.FileIsTooBig:
|
||||
sResult = this.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG');
|
||||
break;
|
||||
case Enums.UploadErrorCode.FilePartiallyUploaded:
|
||||
sResult = this.i18n('UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED');
|
||||
break;
|
||||
case Enums.UploadErrorCode.FileNoUploaded:
|
||||
sResult = this.i18n('UPLOAD/ERROR_NO_FILE_UPLOADED');
|
||||
break;
|
||||
case Enums.UploadErrorCode.MissingTempFolder:
|
||||
sResult = this.i18n('UPLOAD/ERROR_MISSING_TEMP_FOLDER');
|
||||
break;
|
||||
case Enums.UploadErrorCode.FileOnSaveingError:
|
||||
sResult = this.i18n('UPLOAD/ERROR_ON_SAVING_FILE');
|
||||
break;
|
||||
case Enums.UploadErrorCode.FileType:
|
||||
sResult = this.i18n('UPLOAD/ERROR_FILE_TYPE');
|
||||
break;
|
||||
default:
|
||||
sResult = this.i18n('UPLOAD/ERROR_UNKNOWN');
|
||||
break;
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sLanguage
|
||||
* @param {Function=} fDone
|
||||
* @param {Function=} fFail
|
||||
*/
|
||||
Translator.prototype.reload = function (sLanguage, fDone, fFail)
|
||||
{
|
||||
var
|
||||
self = this,
|
||||
$html = $('html'),
|
||||
fEmptyFunction = function () {},
|
||||
iStart = (new Date()).getTime()
|
||||
;
|
||||
|
||||
$html.addClass('rl-changing-language');
|
||||
|
||||
$.ajax({
|
||||
'url': require('Common/Links').langLink(sLanguage),
|
||||
'dataType': 'script',
|
||||
'cache': true
|
||||
})
|
||||
.fail(fFail || fEmptyFunction)
|
||||
.done(function () {
|
||||
_.delay(function () {
|
||||
self.reloadData();
|
||||
(fDone || fEmptyFunction)();
|
||||
$html.removeClass('rl-changing-language');
|
||||
}, 500 < (new Date()).getTime() - iStart ? 1 : 500);
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
module.exports = new Translator();
|
||||
|
||||
}());
|
||||
|
|
@ -18,7 +18,6 @@
|
|||
Mime = require('Common/Mime'),
|
||||
|
||||
Enums = require('Common/Enums'),
|
||||
Consts = require('Common/Consts'),
|
||||
Globals = require('Common/Globals')
|
||||
;
|
||||
|
||||
|
|
@ -108,14 +107,6 @@
|
|||
return Utils.isArray(aValue) && 0 < aValue.length;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {*|null}
|
||||
*/
|
||||
Utils.notificationClass = function ()
|
||||
{
|
||||
return window.Notification && window.Notification.requestPermission ? window.Notification : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sQueryString
|
||||
* @return {Object}
|
||||
|
|
@ -380,125 +371,6 @@
|
|||
return oObject && window.Object && window.Object.hasOwnProperty ? window.Object.hasOwnProperty.call(oObject, sProp) : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sKey
|
||||
* @param {Object=} oValueList
|
||||
* @param {string=} sDefaulValue
|
||||
* @return {string}
|
||||
*/
|
||||
Utils.i18n = function (sKey, oValueList, sDefaulValue)
|
||||
{
|
||||
var
|
||||
sValueName = '',
|
||||
sResult = Utils.isUnd(Globals.oI18N[sKey]) ? (Utils.isUnd(sDefaulValue) ? sKey : sDefaulValue) : Globals.oI18N[sKey]
|
||||
;
|
||||
|
||||
if (!Utils.isUnd(oValueList) && !Utils.isNull(oValueList))
|
||||
{
|
||||
for (sValueName in oValueList)
|
||||
{
|
||||
if (Utils.hos(oValueList, sValueName))
|
||||
{
|
||||
sResult = sResult.replace('%' + sValueName + '%', oValueList[sValueName]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oElement
|
||||
* @param {boolean=} bAnimate = false
|
||||
*/
|
||||
Utils.i18nToNode = function (oElement, bAnimate)
|
||||
{
|
||||
_.defer(function () {
|
||||
$('.i18n', oElement).each(function () {
|
||||
var
|
||||
jqThis = $(this),
|
||||
sKey = ''
|
||||
;
|
||||
|
||||
sKey = jqThis.data('i18n-text');
|
||||
if (sKey)
|
||||
{
|
||||
jqThis.text(Utils.i18n(sKey));
|
||||
}
|
||||
else
|
||||
{
|
||||
sKey = jqThis.data('i18n-html');
|
||||
if (sKey)
|
||||
{
|
||||
jqThis.html(Utils.i18n(sKey));
|
||||
}
|
||||
|
||||
sKey = jqThis.data('i18n-placeholder');
|
||||
if (sKey)
|
||||
{
|
||||
jqThis.attr('placeholder', Utils.i18n(sKey));
|
||||
}
|
||||
|
||||
sKey = jqThis.data('i18n-title');
|
||||
if (sKey)
|
||||
{
|
||||
jqThis.attr('title', Utils.i18n(sKey));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (bAnimate && Globals.bAnimationSupported)
|
||||
{
|
||||
$('.i18n-animation.i18n', oElement).letterfx({
|
||||
'fx': 'fall fade', 'backwards': false, 'timing': 50, 'fx_duration': '50ms', 'letter_end': 'restore', 'element_end': 'restore'
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Utils.i18nReload = function ()
|
||||
{
|
||||
if (window['rainloopI18N'])
|
||||
{
|
||||
Globals.oI18N = window['rainloopI18N'] || {};
|
||||
|
||||
Utils.i18nToNode(Globals.$doc, true);
|
||||
|
||||
Globals.langChangeTrigger(!Globals.langChangeTrigger());
|
||||
}
|
||||
|
||||
window['rainloopI18N'] = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Function} fCallback
|
||||
* @param {Object} oScope
|
||||
* @param {Function=} fLangCallback
|
||||
*/
|
||||
Utils.initOnStartOrLangChange = function (fCallback, oScope, fLangCallback)
|
||||
{
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback.call(oScope);
|
||||
}
|
||||
|
||||
if (fLangCallback)
|
||||
{
|
||||
Globals.langChangeTrigger.subscribe(function () {
|
||||
if (fCallback)
|
||||
{
|
||||
fCallback.call(oScope);
|
||||
}
|
||||
|
||||
fLangCallback.call(oScope);
|
||||
});
|
||||
}
|
||||
else if (fCallback)
|
||||
{
|
||||
Globals.langChangeTrigger.subscribe(fCallback, oScope);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
|
|
@ -649,126 +521,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} iCode
|
||||
* @param {*=} mMessage = ''
|
||||
* @return {string}
|
||||
*/
|
||||
Utils.getNotification = function (iCode, mMessage)
|
||||
{
|
||||
iCode = Utils.pInt(iCode);
|
||||
if (Enums.Notification.ClientViewError === iCode && mMessage)
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
return Utils.isUnd(Globals.oNotificationI18N[iCode]) ? '' : Globals.oNotificationI18N[iCode];
|
||||
};
|
||||
|
||||
Utils.initNotificationLanguage = function ()
|
||||
{
|
||||
var oN = Globals.oNotificationI18N || {};
|
||||
oN[Enums.Notification.InvalidToken] = Utils.i18n('NOTIFICATIONS/INVALID_TOKEN');
|
||||
oN[Enums.Notification.AuthError] = Utils.i18n('NOTIFICATIONS/AUTH_ERROR');
|
||||
oN[Enums.Notification.AccessError] = Utils.i18n('NOTIFICATIONS/ACCESS_ERROR');
|
||||
oN[Enums.Notification.ConnectionError] = Utils.i18n('NOTIFICATIONS/CONNECTION_ERROR');
|
||||
oN[Enums.Notification.CaptchaError] = Utils.i18n('NOTIFICATIONS/CAPTCHA_ERROR');
|
||||
oN[Enums.Notification.SocialFacebookLoginAccessDisable] = Utils.i18n('NOTIFICATIONS/SOCIAL_FACEBOOK_LOGIN_ACCESS_DISABLE');
|
||||
oN[Enums.Notification.SocialTwitterLoginAccessDisable] = Utils.i18n('NOTIFICATIONS/SOCIAL_TWITTER_LOGIN_ACCESS_DISABLE');
|
||||
oN[Enums.Notification.SocialGoogleLoginAccessDisable] = Utils.i18n('NOTIFICATIONS/SOCIAL_GOOGLE_LOGIN_ACCESS_DISABLE');
|
||||
oN[Enums.Notification.DomainNotAllowed] = Utils.i18n('NOTIFICATIONS/DOMAIN_NOT_ALLOWED');
|
||||
oN[Enums.Notification.AccountNotAllowed] = Utils.i18n('NOTIFICATIONS/ACCOUNT_NOT_ALLOWED');
|
||||
|
||||
oN[Enums.Notification.AccountTwoFactorAuthRequired] = Utils.i18n('NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_REQUIRED');
|
||||
oN[Enums.Notification.AccountTwoFactorAuthError] = Utils.i18n('NOTIFICATIONS/ACCOUNT_TWO_FACTOR_AUTH_ERROR');
|
||||
|
||||
oN[Enums.Notification.CouldNotSaveNewPassword] = Utils.i18n('NOTIFICATIONS/COULD_NOT_SAVE_NEW_PASSWORD');
|
||||
oN[Enums.Notification.CurrentPasswordIncorrect] = Utils.i18n('NOTIFICATIONS/CURRENT_PASSWORD_INCORRECT');
|
||||
oN[Enums.Notification.NewPasswordShort] = Utils.i18n('NOTIFICATIONS/NEW_PASSWORD_SHORT');
|
||||
oN[Enums.Notification.NewPasswordWeak] = Utils.i18n('NOTIFICATIONS/NEW_PASSWORD_WEAK');
|
||||
oN[Enums.Notification.NewPasswordForbidden] = Utils.i18n('NOTIFICATIONS/NEW_PASSWORD_FORBIDDENT');
|
||||
|
||||
oN[Enums.Notification.ContactsSyncError] = Utils.i18n('NOTIFICATIONS/CONTACTS_SYNC_ERROR');
|
||||
|
||||
oN[Enums.Notification.CantGetMessageList] = Utils.i18n('NOTIFICATIONS/CANT_GET_MESSAGE_LIST');
|
||||
oN[Enums.Notification.CantGetMessage] = Utils.i18n('NOTIFICATIONS/CANT_GET_MESSAGE');
|
||||
oN[Enums.Notification.CantDeleteMessage] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_MESSAGE');
|
||||
oN[Enums.Notification.CantMoveMessage] = Utils.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE');
|
||||
oN[Enums.Notification.CantCopyMessage] = Utils.i18n('NOTIFICATIONS/CANT_MOVE_MESSAGE');
|
||||
|
||||
oN[Enums.Notification.CantSaveMessage] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_MESSAGE');
|
||||
oN[Enums.Notification.CantSendMessage] = Utils.i18n('NOTIFICATIONS/CANT_SEND_MESSAGE');
|
||||
oN[Enums.Notification.InvalidRecipients] = Utils.i18n('NOTIFICATIONS/INVALID_RECIPIENTS');
|
||||
|
||||
oN[Enums.Notification.CantSaveFilters] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_FILTERS');
|
||||
oN[Enums.Notification.FiltersAreNotCorrect] = Utils.i18n('NOTIFICATIONS/FILTERS_ARE_NOT_CORRECT');
|
||||
|
||||
oN[Enums.Notification.CantCreateFolder] = Utils.i18n('NOTIFICATIONS/CANT_CREATE_FOLDER');
|
||||
oN[Enums.Notification.CantRenameFolder] = Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER');
|
||||
oN[Enums.Notification.CantDeleteFolder] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER');
|
||||
oN[Enums.Notification.CantDeleteNonEmptyFolder] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_NON_EMPTY_FOLDER');
|
||||
oN[Enums.Notification.CantSubscribeFolder] = Utils.i18n('NOTIFICATIONS/CANT_SUBSCRIBE_FOLDER');
|
||||
oN[Enums.Notification.CantUnsubscribeFolder] = Utils.i18n('NOTIFICATIONS/CANT_UNSUBSCRIBE_FOLDER');
|
||||
|
||||
oN[Enums.Notification.CantSaveSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_SETTINGS');
|
||||
oN[Enums.Notification.CantSavePluginSettings] = Utils.i18n('NOTIFICATIONS/CANT_SAVE_PLUGIN_SETTINGS');
|
||||
|
||||
oN[Enums.Notification.DomainAlreadyExists] = Utils.i18n('NOTIFICATIONS/DOMAIN_ALREADY_EXISTS');
|
||||
|
||||
oN[Enums.Notification.CantInstallPackage] = Utils.i18n('NOTIFICATIONS/CANT_INSTALL_PACKAGE');
|
||||
oN[Enums.Notification.CantDeletePackage] = Utils.i18n('NOTIFICATIONS/CANT_DELETE_PACKAGE');
|
||||
oN[Enums.Notification.InvalidPluginPackage] = Utils.i18n('NOTIFICATIONS/INVALID_PLUGIN_PACKAGE');
|
||||
oN[Enums.Notification.UnsupportedPluginPackage] = Utils.i18n('NOTIFICATIONS/UNSUPPORTED_PLUGIN_PACKAGE');
|
||||
|
||||
oN[Enums.Notification.LicensingServerIsUnavailable] = Utils.i18n('NOTIFICATIONS/LICENSING_SERVER_IS_UNAVAILABLE');
|
||||
oN[Enums.Notification.LicensingExpired] = Utils.i18n('NOTIFICATIONS/LICENSING_EXPIRED');
|
||||
oN[Enums.Notification.LicensingBanned] = Utils.i18n('NOTIFICATIONS/LICENSING_BANNED');
|
||||
|
||||
oN[Enums.Notification.DemoSendMessageError] = Utils.i18n('NOTIFICATIONS/DEMO_SEND_MESSAGE_ERROR');
|
||||
|
||||
oN[Enums.Notification.AccountAlreadyExists] = Utils.i18n('NOTIFICATIONS/ACCOUNT_ALREADY_EXISTS');
|
||||
oN[Enums.Notification.AccountDoesNotExist] = Utils.i18n('NOTIFICATIONS/ACCOUNT_DOES_NOT_EXIST');
|
||||
|
||||
oN[Enums.Notification.MailServerError] = Utils.i18n('NOTIFICATIONS/MAIL_SERVER_ERROR');
|
||||
oN[Enums.Notification.InvalidInputArgument] = Utils.i18n('NOTIFICATIONS/INVALID_INPUT_ARGUMENT');
|
||||
oN[Enums.Notification.UnknownNotification] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
|
||||
oN[Enums.Notification.UnknownError] = Utils.i18n('NOTIFICATIONS/UNKNOWN_ERROR');
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {*} mCode
|
||||
* @return {string}
|
||||
*/
|
||||
Utils.getUploadErrorDescByCode = function (mCode)
|
||||
{
|
||||
var sResult = '';
|
||||
switch (Utils.pInt(mCode)) {
|
||||
case Enums.UploadErrorCode.FileIsTooBig:
|
||||
sResult = Utils.i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG');
|
||||
break;
|
||||
case Enums.UploadErrorCode.FilePartiallyUploaded:
|
||||
sResult = Utils.i18n('UPLOAD/ERROR_FILE_PARTIALLY_UPLOADED');
|
||||
break;
|
||||
case Enums.UploadErrorCode.FileNoUploaded:
|
||||
sResult = Utils.i18n('UPLOAD/ERROR_NO_FILE_UPLOADED');
|
||||
break;
|
||||
case Enums.UploadErrorCode.MissingTempFolder:
|
||||
sResult = Utils.i18n('UPLOAD/ERROR_MISSING_TEMP_FOLDER');
|
||||
break;
|
||||
case Enums.UploadErrorCode.FileOnSaveingError:
|
||||
sResult = Utils.i18n('UPLOAD/ERROR_ON_SAVING_FILE');
|
||||
break;
|
||||
case Enums.UploadErrorCode.FileType:
|
||||
sResult = Utils.i18n('UPLOAD/ERROR_FILE_TYPE');
|
||||
break;
|
||||
default:
|
||||
sResult = Utils.i18n('UPLOAD/ERROR_UNKNOWN');
|
||||
break;
|
||||
}
|
||||
|
||||
return sResult;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {?} oObject
|
||||
* @param {string} sMethodName
|
||||
|
|
@ -876,7 +628,6 @@
|
|||
*/
|
||||
Utils.initDataConstructorBySettings = function (oData)
|
||||
{
|
||||
oData.editorDefaultType = ko.observable(Enums.EditorDefaultType.Html);
|
||||
oData.showImages = ko.observable(false);
|
||||
oData.contactsAutosave = ko.observable(false);
|
||||
oData.interfaceAnimation = ko.observable(true);
|
||||
|
|
@ -888,16 +639,10 @@
|
|||
|
||||
oData.useLocalProxyForExternalImages = ko.observable(false);
|
||||
|
||||
oData.desktopNotifications = ko.observable(false);
|
||||
oData.useThreads = ko.observable(true);
|
||||
oData.replySameFolder = ko.observable(true);
|
||||
oData.useCheckboxesInList = ko.observable(true);
|
||||
|
||||
oData.layout = ko.observable(Enums.Layout.SidePreview);
|
||||
oData.usePreviewPane = ko.computed(function () {
|
||||
return Enums.Layout.NoPreview !== oData.layout();
|
||||
});
|
||||
|
||||
oData.interfaceAnimation.subscribe(function (bValue) {
|
||||
if (Globals.bMobileDevice || !bValue)
|
||||
{
|
||||
|
|
@ -911,146 +656,6 @@
|
|||
|
||||
oData.interfaceAnimation.valueHasMutated();
|
||||
|
||||
oData.desktopNotificationsPermisions = ko.computed(function () {
|
||||
|
||||
oData.desktopNotifications();
|
||||
|
||||
var
|
||||
NotificationClass = Utils.notificationClass(),
|
||||
iResult = Enums.DesktopNotifications.NotSupported
|
||||
;
|
||||
|
||||
if (NotificationClass && NotificationClass.permission)
|
||||
{
|
||||
switch (NotificationClass.permission.toLowerCase())
|
||||
{
|
||||
case 'granted':
|
||||
iResult = Enums.DesktopNotifications.Allowed;
|
||||
break;
|
||||
case 'denied':
|
||||
iResult = Enums.DesktopNotifications.Denied;
|
||||
break;
|
||||
case 'default':
|
||||
iResult = Enums.DesktopNotifications.NotAllowed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (window.webkitNotifications && window.webkitNotifications.checkPermission)
|
||||
{
|
||||
iResult = window.webkitNotifications.checkPermission();
|
||||
}
|
||||
|
||||
return iResult;
|
||||
});
|
||||
|
||||
oData.useDesktopNotifications = ko.computed({
|
||||
'read': function () {
|
||||
return oData.desktopNotifications() &&
|
||||
Enums.DesktopNotifications.Allowed === oData.desktopNotificationsPermisions();
|
||||
},
|
||||
'write': function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
var
|
||||
NotificationClass = Utils.notificationClass(),
|
||||
iPermission = oData.desktopNotificationsPermisions()
|
||||
;
|
||||
|
||||
if (NotificationClass && Enums.DesktopNotifications.Allowed === iPermission)
|
||||
{
|
||||
oData.desktopNotifications(true);
|
||||
}
|
||||
else if (NotificationClass && Enums.DesktopNotifications.NotAllowed === iPermission)
|
||||
{
|
||||
NotificationClass.requestPermission(function () {
|
||||
oData.desktopNotifications.valueHasMutated();
|
||||
if (Enums.DesktopNotifications.Allowed === oData.desktopNotificationsPermisions())
|
||||
{
|
||||
if (oData.desktopNotifications())
|
||||
{
|
||||
oData.desktopNotifications.valueHasMutated();
|
||||
}
|
||||
else
|
||||
{
|
||||
oData.desktopNotifications(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (oData.desktopNotifications())
|
||||
{
|
||||
oData.desktopNotifications(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
oData.desktopNotifications.valueHasMutated();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
oData.desktopNotifications(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oData.desktopNotifications(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
oData.language = ko.observable('');
|
||||
oData.languages = ko.observableArray([]);
|
||||
|
||||
oData.mainLanguage = ko.computed({
|
||||
'read': oData.language,
|
||||
'write': function (sValue) {
|
||||
if (sValue !== oData.language())
|
||||
{
|
||||
if (-1 < Utils.inArray(sValue, oData.languages()))
|
||||
{
|
||||
oData.language(sValue);
|
||||
}
|
||||
else if (0 < oData.languages().length)
|
||||
{
|
||||
oData.language(oData.languages()[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oData.language.valueHasMutated();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
oData.theme = ko.observable('');
|
||||
oData.themes = ko.observableArray([]);
|
||||
oData.themeBackgroundName = ko.observable('');
|
||||
oData.themeBackgroundHash = ko.observable('');
|
||||
|
||||
oData.mainTheme = ko.computed({
|
||||
'read': oData.theme,
|
||||
'write': function (sValue) {
|
||||
if (sValue !== oData.theme())
|
||||
{
|
||||
var aThemes = oData.themes();
|
||||
if (-1 < Utils.inArray(sValue, aThemes))
|
||||
{
|
||||
oData.theme(sValue);
|
||||
}
|
||||
else if (0 < aThemes.length)
|
||||
{
|
||||
oData.theme(aThemes[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oData.theme.valueHasMutated();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
oData.capaAdditionalAccounts = ko.observable(false);
|
||||
oData.capaAdditionalIdentities = ko.observable(false);
|
||||
oData.capaGravatar = ko.observable(false);
|
||||
|
|
@ -1061,54 +666,6 @@
|
|||
|
||||
oData.weakPassword = ko.observable(false);
|
||||
|
||||
oData.messagesPerPage = ko.observable(Consts.Defaults.MessagesPerPage);//.extend({'throttle': 200});
|
||||
|
||||
oData.mainMessagesPerPage = oData.messagesPerPage;
|
||||
oData.mainMessagesPerPage = ko.computed({
|
||||
'read': oData.messagesPerPage,
|
||||
'write': function (iValue) {
|
||||
if (-1 < Utils.inArray(Utils.pInt(iValue), Consts.Defaults.MessagesPerPageArray))
|
||||
{
|
||||
if (iValue !== oData.messagesPerPage())
|
||||
{
|
||||
oData.messagesPerPage(iValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
oData.messagesPerPage.valueHasMutated();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
oData.facebookSupported = ko.observable(false);
|
||||
oData.facebookEnable = ko.observable(false);
|
||||
oData.facebookAppID = ko.observable('');
|
||||
oData.facebookAppSecret = ko.observable('');
|
||||
|
||||
oData.twitterEnable = ko.observable(false);
|
||||
oData.twitterConsumerKey = ko.observable('');
|
||||
oData.twitterConsumerSecret = ko.observable('');
|
||||
|
||||
oData.googleEnable = ko.observable(false);
|
||||
oData.googleEnable.auth = ko.observable(false);
|
||||
oData.googleEnable.drive = ko.observable(false);
|
||||
oData.googleEnable.preview = ko.observable(false);
|
||||
oData.googleClientID = ko.observable('');
|
||||
oData.googleClientSecret = ko.observable('');
|
||||
oData.googleApiKey = ko.observable('');
|
||||
|
||||
oData.googleEnable.requireClientSettings = ko.computed(function () {
|
||||
return oData.googleEnable() && (oData.googleEnable.auth() || oData.googleEnable.drive());
|
||||
});
|
||||
|
||||
oData.googleEnable.requireApiKey = ko.computed(function () {
|
||||
return oData.googleEnable() && oData.googleEnable.drive();
|
||||
});
|
||||
|
||||
oData.dropboxEnable = ko.observable(false);
|
||||
oData.dropboxApiKey = ko.observable('');
|
||||
|
||||
oData.contactsIsAllowed = ko.observable(false);
|
||||
};
|
||||
|
||||
|
|
@ -1153,13 +710,13 @@
|
|||
}
|
||||
else if (oMomentNow.format('L') === oMoment.format('L'))
|
||||
{
|
||||
sResult = Utils.i18n('MESSAGE_LIST/TODAY_AT', {
|
||||
sResult = require('Common/Translator').i18n('MESSAGE_LIST/TODAY_AT', {
|
||||
'TIME': oMoment.format('LT')
|
||||
});
|
||||
}
|
||||
else if (oMomentNow.clone().subtract('days', 1).format('L') === oMoment.format('L'))
|
||||
{
|
||||
sResult = Utils.i18n('MESSAGE_LIST/YESTERDAY_AT', {
|
||||
sResult = require('Common/Translator').i18n('MESSAGE_LIST/YESTERDAY_AT', {
|
||||
'TIME': oMoment.format('LT')
|
||||
});
|
||||
}
|
||||
|
|
@ -1224,7 +781,7 @@
|
|||
*/
|
||||
Utils.convertLangName = function (sLanguage, bEng)
|
||||
{
|
||||
return Utils.i18n('LANGS_NAMES' + (true === bEng ? '_EN' : '') + '/LANG_' +
|
||||
return require('Common/Translator').i18n('LANGS_NAMES' + (true === bEng ? '_EN' : '') + '/LANG_' +
|
||||
sLanguage.toUpperCase().replace(/[^a-zA-Z0-9]+/g, '_'), null, sLanguage);
|
||||
};
|
||||
|
||||
|
|
@ -1291,7 +848,7 @@
|
|||
$('#rl-content', oBody).html(oTemplate.html());
|
||||
$('html', oWin.document).addClass('external ' + $('html').attr('class'));
|
||||
|
||||
Utils.i18nToNode(oBody);
|
||||
require('Common/Translator').i18nToNode(oBody);
|
||||
|
||||
if (oViewModel && $('#rl-content', oBody)[0])
|
||||
{
|
||||
|
|
@ -1985,33 +1542,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} sLanguage
|
||||
* @param {Function=} fDone
|
||||
* @param {Function=} fFail
|
||||
*/
|
||||
Utils.reloadLanguage = function (sLanguage, fDone, fFail)
|
||||
{
|
||||
var iStart = Utils.microtime();
|
||||
|
||||
Globals.$html.addClass('rl-changing-language');
|
||||
|
||||
$.ajax({
|
||||
'url': require('Common/Links').langLink(sLanguage),
|
||||
'dataType': 'script',
|
||||
'cache': true
|
||||
})
|
||||
.fail(fFail || Utils.emptyFunction)
|
||||
.done(function () {
|
||||
_.delay(function () {
|
||||
Utils.i18nReload();
|
||||
(fDone || Utils.emptyFunction)();
|
||||
Globals.$html.removeClass('rl-changing-language');
|
||||
}, 500 < Utils.microtime() - iStart ? 1 : 500);
|
||||
})
|
||||
;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Object} oParams
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue