Fix not spam translate (Closes #168)

Small refactoring and fixes
This commit is contained in:
RainLoop Team 2014-05-16 19:57:50 +04:00
parent 07b0f20305
commit d3ee36bb97
68 changed files with 629 additions and 392 deletions

View file

@ -1,5 +1,5 @@
/*! RainLoop Webmail Admin Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (window, $, ko, crossroads, hasher, _) {
/*! RainLoop Webmail Admin Module (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (window, $, ko, crossroads, hasher, _) {
'use strict';
@ -77,14 +77,14 @@ var
$document = $(window.document),
NotificationClass = window.Notification && window.Notification.requestPermission ? window.Notification : null
;
;
/*jshint onevar: false*/
/**
* @type {?AdminApp}
*/
var RL = null;
/*jshint onevar: true*/
/**
* @type {?}
*/
@ -233,7 +233,7 @@ if (Globals.bAllowPdfPreview && navigator && navigator.mimeTypes)
return oType && 'application/pdf' === oType.type;
});
}
Consts.Defaults = {};
Consts.Values = {};
Consts.DataImages = {};
@ -351,7 +351,7 @@ Consts.DataImages.UserDotPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA
* @type {string}
*/
Consts.DataImages.TranspPic = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQIW2NkAAIAAAoAAggA9GkAAAAASUVORK5CYII=';
/**
* @enum {string}
*/
@ -383,7 +383,14 @@ Enums.StateType = {
* @enum {string}
*/
Enums.Capa = {
'Prem': 'PREM'
'Prem': 'PREM',
'TwoFactor': 'TWO_FACTOR',
'OpenPGP': 'OPEN_PGP',
'Prefetch': 'PREFETCH',
'Gravatar': 'GRAVATAR',
'Themes': 'THEMES',
'AdditionalAccounts': 'ADDITIONAL_ACCOUNTS',
'AdditionalIdentities': 'ADDITIONAL_IDENTITIES'
};
/**
@ -733,7 +740,7 @@ Enums.Notification = {
'UnknownNotification': 999,
'UnknownError': 999
};
Utils.trim = $.trim;
Utils.inArray = $.inArray;
Utils.isArray = _.isArray;
@ -1506,7 +1513,7 @@ Utils.initDataConstructorBySettings = function (oData)
Globals.sAnimationType = Enums.InterfaceAnimation.Full;
oData.allowThemes = ko.observable(true);
oData.capaThemes = ko.observable(false);
oData.allowCustomLogin = ko.observable(false);
oData.allowLanguagesOnSettings = ko.observable(true);
oData.allowLanguagesOnLogin = ko.observable(true);
@ -1674,9 +1681,9 @@ Utils.initDataConstructorBySettings = function (oData)
}
});
oData.allowAdditionalAccounts = ko.observable(false);
oData.allowIdentities = ko.observable(false);
oData.allowGravatar = ko.observable(false);
oData.capaAdditionalAccounts = ko.observable(false);
oData.capaAdditionalIdentities = ko.observable(false);
oData.capaGravatar = ko.observable(false);
oData.determineUserLanguage = ko.observable(false);
oData.messagesPerPage = ko.observable(Consts.Defaults.MessagesPerPage);//.extend({'throttle': 200});
@ -2483,7 +2490,7 @@ Utils.detectDropdownVisibility = _.debounce(function () {
return oItem.hasClass('open');
}));
}, 50);
// Base64 encode / decode
// http://www.webtoolkit.info/
@ -2646,7 +2653,7 @@ Base64 = {
}
};
/*jslint bitwise: false*/
/*jslint bitwise: false*/
ko.bindingHandlers.tooltip = {
'init': function (oElement, fValueAccessor) {
if (!Globals.bMobileDevice)
@ -3473,7 +3480,7 @@ ko.observable.fn.validateFunc = function (fFunc)
return this;
};
/**
* @constructor
*/
@ -3785,7 +3792,7 @@ LinkBuilder.prototype.socialFacebook = function ()
{
return this.sServer + 'SocialFacebook' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : '');
};
/**
* @type {Object}
*/
@ -3879,7 +3886,7 @@ Plugins.settingsGet = function (sPluginSection, sName)
};
/**
* @constructor
*/
@ -3953,7 +3960,7 @@ CookieDriver.prototype.get = function (sKey)
return mResult;
};
/**
* @constructor
*/
@ -4024,7 +4031,7 @@ LocalStorageDriver.prototype.get = function (sKey)
return mResult;
};
/**
* @constructor
*/
@ -4067,7 +4074,7 @@ LocalStorage.prototype.get = function (iKey)
{
return this.oDriver ? this.oDriver.get('p' + iKey) : null;
};
/**
* @constructor
*/
@ -4080,7 +4087,7 @@ KnoinAbstractBoot.prototype.bootstart = function ()
{
};
/**
* @param {string=} sPosition = ''
* @param {string=} sTemplate = ''
@ -4173,7 +4180,7 @@ KnoinAbstractViewModel.prototype.registerPopupKeyDown = function ()
return true;
});
};
/**
* @param {string} sScreenName
* @param {?=} aViewModels = []
@ -4249,7 +4256,7 @@ KnoinAbstractScreen.prototype.__start = function ()
this.oCross = oRoute;
}
};
/**
* @constructor
*/
@ -4649,7 +4656,7 @@ Knoin.prototype.bootstart = function ()
};
kn = new Knoin();
/**
* @param {string=} sEmail
* @param {string=} sName
@ -5013,7 +5020,7 @@ EmailModel.prototype.inputoTagLine = function ()
{
return 0 < this.name.length ? this.name + ' (' + this.email + ')' : this.email;
};
/**
* @constructor
*/
@ -5057,7 +5064,7 @@ ContactTagModel.prototype.toLine = function (bEncodeHtml)
return (Utils.isUnd(bEncodeHtml) ? false : !!bEncodeHtml) ?
Utils.encodeHtml(this.name()) : this.name();
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -5352,7 +5359,7 @@ PopupsDomainViewModel.prototype.clearForm = function ()
this.smtpAuth(true);
this.whiteList('');
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -5489,7 +5496,7 @@ PopupsPluginViewModel.prototype.onBuild = function ()
}
}, this));
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -5605,7 +5612,7 @@ PopupsActivateViewModel.prototype.validateSubscriptionKey = function ()
{
var sValue = this.key();
return '' === sValue || !!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(Utils.trim(sValue));
};
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -5665,7 +5672,7 @@ PopupsLanguagesViewModel.prototype.changeLanguage = function (sLang)
RL.data().mainLanguage(sLang);
this.cancelCommand();
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -5771,7 +5778,7 @@ PopupsAskViewModel.prototype.onBuild = function ()
}, this));
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -5858,7 +5865,7 @@ AdminLoginViewModel.prototype.onHide = function ()
{
this.loginFocus(false);
};
/**
* @param {?} oScreen
*
@ -5882,7 +5889,7 @@ AdminMenuViewModel.prototype.link = function (sRoute)
{
return '#/' + sRoute;
};
/**
* @constructor
* @extends KnoinAbstractViewModel
@ -5906,7 +5913,7 @@ AdminPaneViewModel.prototype.logoutClick = function ()
RL.remote().adminLogout(function () {
RL.loginAndLogoutReload();
});
};
};
/**
* @constructor
*/
@ -5920,11 +5927,11 @@ function AdminGeneral()
this.language = oData.language;
this.theme = oData.theme;
this.allowThemes = oData.allowThemes;
this.allowLanguagesOnSettings = oData.allowLanguagesOnSettings;
this.allowAdditionalAccounts = oData.allowAdditionalAccounts;
this.allowIdentities = oData.allowIdentities;
this.allowGravatar = oData.allowGravatar;
this.capaThemes = oData.capaThemes;
this.capaGravatar = oData.capaGravatar;
this.capaAdditionalAccounts = oData.capaAdditionalAccounts;
this.capaAdditionalIdentities = oData.capaAdditionalIdentities;
this.themesOptions = ko.computed(function () {
return _.map(oData.themes(), function (sTheme) {
@ -5969,27 +5976,27 @@ AdminGeneral.prototype.onBuild = function ()
});
});
self.allowAdditionalAccounts.subscribe(function (bValue) {
self.capaAdditionalAccounts.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'AllowAdditionalAccounts': bValue ? '1' : '0'
'CapaAdditionalAccounts': bValue ? '1' : '0'
});
});
self.allowIdentities.subscribe(function (bValue) {
self.capaAdditionalIdentities.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'AllowIdentities': bValue ? '1' : '0'
'CapaAdditionalIdentities': bValue ? '1' : '0'
});
});
self.allowGravatar.subscribe(function (bValue) {
self.capaGravatar.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'AllowGravatar': bValue ? '1' : '0'
'CapaGravatar': bValue ? '1' : '0'
});
});
self.allowThemes.subscribe(function (bValue) {
self.capaThemes.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'AllowThemes': bValue ? '1' : '0'
'CapaThemes': bValue ? '1' : '0'
});
});
@ -6006,7 +6013,7 @@ AdminGeneral.prototype.selectLanguage = function ()
{
kn.showScreenPopup(PopupsLanguagesViewModel);
};
/**
* @constructor
*/
@ -6058,7 +6065,7 @@ AdminLogin.prototype.onBuild = function ()
}, 50);
};
/**
* @constructor
*/
@ -6127,7 +6134,7 @@ AdminBranding.prototype.onBuild = function ()
}, 50);
};
/**
* @constructor
*/
@ -6347,7 +6354,7 @@ AdminContacts.prototype.onBuild = function ()
}, 50);
};
/**
* @constructor
*/
@ -6436,15 +6443,15 @@ AdminDomains.prototype.onDomainListChangeRequest = function ()
{
RL.reloadDomainList();
};
/**
* @constructor
*/
function AdminSecurity()
{
this.csrfProtection = ko.observable(!!RL.settingsGet('UseTokenProtection'));
this.openPGP = ko.observable(!!RL.settingsGet('OpenPGP'));
this.allowTwoFactorAuth = ko.observable(!!RL.settingsGet('AllowTwoFactorAuth'));
this.capaOpenPGP = ko.observable(RL.capa(Enums.Capa.OpenPGP));
this.capaTwoFactorAuth = ko.observable(RL.capa(Enums.Capa.TwoFactor));
this.adminLogin = ko.observable(RL.settingsGet('AdminLogin'));
this.adminPassword = ko.observable('');
@ -6521,15 +6528,15 @@ AdminSecurity.prototype.onBuild = function ()
});
});
this.openPGP.subscribe(function (bValue) {
this.capaOpenPGP.subscribe(function (bValue) {
RL.remote().saveAdminConfig(Utils.emptyFunction, {
'OpenPGP': bValue ? '1' : '0'
'CapaOpenPGP': bValue ? '1' : '0'
});
});
this.allowTwoFactorAuth.subscribe(function (bValue) {
this.capaTwoFactorAuth.subscribe(function (bValue) {
RL.remote().saveAdminConfig(Utils.emptyFunction, {
'AllowTwoFactorAuth': bValue ? '1' : '0'
'CapaTwoFactorAuth': bValue ? '1' : '0'
});
});
};
@ -6548,7 +6555,7 @@ AdminSecurity.prototype.phpInfoLink = function ()
{
return RL.link().phpInfo();
};
/**
* @constructor
*/
@ -6664,7 +6671,7 @@ AdminSocial.prototype.onBuild = function ()
}, 50);
};
/**
* @constructor
*/
@ -6761,7 +6768,7 @@ AdminPlugins.prototype.onPluginDisableRequest = function (sResult, oData)
RL.reloadPluginList();
};
/**
* @constructor
*/
@ -6859,7 +6866,7 @@ AdminPackages.prototype.installPackage = function (oPackage)
RL.remote().packageInstall(this.requestHelper(oPackage, true), oPackage);
}
};
/**
* @constructor
*/
@ -6910,7 +6917,22 @@ AdminLicensing.prototype.licenseExpiredMomentValue = function ()
{
var oDate = moment.unix(this.licenseExpired());
return oDate.format('LL') + ' (' + oDate.from(moment()) + ')';
};
};
/**
* @constructor
*/
function AdminAbout()
{
this.version = ko.observable(RL.settingsGet('Version'));
}
Utils.addSettingsViewModel(AdminAbout, 'AdminSettingsAbout', 'About', 'about');
//AdminAbout.prototype.onBuild = function ()
//{
//
//};
/**
* @constructor
*/
@ -6995,12 +7017,12 @@ AbstractData.prototype.populateDataOnStart = function()
this.mainLanguage(RL.settingsGet('Language'));
this.mainTheme(RL.settingsGet('Theme'));
this.allowAdditionalAccounts(!!RL.settingsGet('AllowAdditionalAccounts'));
this.allowIdentities(!!RL.settingsGet('AllowIdentities'));
this.allowGravatar(!!RL.settingsGet('AllowGravatar'));
this.capaAdditionalAccounts(RL.capa(Enums.Capa.AdditionalAccounts));
this.capaAdditionalIdentities(RL.capa(Enums.Capa.AdditionalIdentities));
this.capaGravatar(RL.capa(Enums.Capa.Gravatar));
this.determineUserLanguage(!!RL.settingsGet('DetermineUserLanguage'));
this.allowThemes(!!RL.settingsGet('AllowThemes'));
this.capaThemes(RL.capa(Enums.Capa.Themes));
this.allowCustomLogin(!!RL.settingsGet('AllowCustomLogin'));
this.allowLanguagesOnLogin(!!RL.settingsGet('AllowLanguagesOnLogin'));
this.allowLanguagesOnSettings(!!RL.settingsGet('AllowLanguagesOnSettings'));
@ -7040,7 +7062,7 @@ AbstractData.prototype.populateDataOnStart = function()
this.contactsIsAllowed(!!RL.settingsGet('ContactsIsAllowed'));
};
/**
* @constructor
* @extends AbstractData
@ -7082,7 +7104,7 @@ _.extend(AdminDataStorage.prototype, AbstractData.prototype);
AdminDataStorage.prototype.populateDataOnStart = function()
{
AbstractData.prototype.populateDataOnStart.call(this);
};
};
/**
* @constructor
*/
@ -7356,7 +7378,7 @@ AbstractAjaxRemoteStorage.prototype.jsVersion = function (fCallback, sVersion)
'Version': sVersion
});
};
/**
* @constructor
* @extends AbstractAjaxRemoteStorage
@ -7601,7 +7623,7 @@ AdminAjaxRemoteStorage.prototype.adminPing = function (fCallback)
{
this.defaultRequest(fCallback, 'AdminPing');
};
/**
* @constructor
*/
@ -7609,7 +7631,7 @@ function AbstractCacheStorage()
{
this.oEmailsPicsHashes = {};
this.oServices = {};
this.bAllowGravatar = !!RL.settingsGet('AllowGravatar');
this.bCapaGravatar = RL.capa(Enums.Capa.Gravatar);
}
/**
@ -7625,7 +7647,7 @@ AbstractCacheStorage.prototype.oServices = {};
/**
* @type {boolean}
*/
AbstractCacheStorage.prototype.bAllowGravatar = false;
AbstractCacheStorage.prototype.bCapaGravatar = false;
AbstractCacheStorage.prototype.clear = function ()
{
@ -7659,7 +7681,7 @@ AbstractCacheStorage.prototype.getUserPic = function (sEmail, fCallback)
}
if (this.bAllowGravatar && '' === sUrl)
if (this.bCapaGravatar && '' === sUrl)
{
fCallback('//secure.gravatar.com/avatar/' + Utils.md5(sEmailLower) + '.jpg?s=80&d=mm', sEmail);
}
@ -7684,7 +7706,7 @@ AbstractCacheStorage.prototype.setEmailsPicsHashesData = function (oData)
{
this.oEmailsPicsHashes = oData;
};
/**
* @constructor
* @extends AbstractCacheStorage
@ -7695,7 +7717,7 @@ function AdminCacheStorage()
}
_.extend(AdminCacheStorage.prototype, AbstractCacheStorage.prototype);
/**
* @param {Array} aViewModels
* @constructor
@ -7873,7 +7895,7 @@ AbstractSettings.prototype.routes = function ()
['', oRules]
];
};
/**
* @constructor
* @extends KnoinAbstractScreen
@ -7888,7 +7910,7 @@ _.extend(AdminLoginScreen.prototype, KnoinAbstractScreen.prototype);
AdminLoginScreen.prototype.onShow = function ()
{
RL.setTitle('');
};
};
/**
* @constructor
* @extends AbstractSettings
@ -7908,7 +7930,7 @@ AdminSettingsScreen.prototype.onShow = function ()
// AbstractSettings.prototype.onShow.call(this);
RL.setTitle('');
};
};
/**
* @constructor
* @extends KnoinAbstractBoot
@ -8266,7 +8288,7 @@ AbstractApp.prototype.bootstart = function ()
ssm.ready();
};
/**
* @constructor
* @extends AbstractApp
@ -8479,6 +8501,8 @@ AdminApp.prototype.bootstart = function ()
}
else
{
Utils.removeSettingsViewModel(AdminAbout);
if (!RL.capa(Enums.Capa.Prem))
{
Utils.removeSettingsViewModel(AdminBranding);
@ -8510,7 +8534,7 @@ AdminApp.prototype.bootstart = function ()
* @type {AdminApp}
*/
RL = new AdminApp();
$html.addClass(Globals.bMobileDevice ? 'mobile' : 'no-mobile');
$window.keydown(Utils.killCtrlAandS).keyup(Utils.killCtrlAandS);
@ -8561,9 +8585,9 @@ window['__RLBOOT'] = function (fCall) {
window['__RLBOOT'] = null;
});
};
if (window.SimplePace) {
window.SimplePace.add(10);
}
}
}(window, jQuery, ko, crossroads, hasher, _));