CommonJS (research/2)

This commit is contained in:
RainLoop Team 2014-08-21 19:08:34 +04:00
parent 56607de87c
commit 586abbb802
115 changed files with 16201 additions and 9943 deletions

View file

@ -1,76 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function AdminAbout()
{
var oData = RL.data();
this.version = ko.observable(RL.settingsGet('Version'));
this.access = ko.observable(!!RL.settingsGet('CoreAccess'));
this.errorDesc = ko.observable('');
this.coreReal = oData.coreReal;
this.coreUpdatable = oData.coreUpdatable;
this.coreAccess = oData.coreAccess;
this.coreChecking = oData.coreChecking;
this.coreUpdating = oData.coreUpdating;
this.coreRemoteVersion = oData.coreRemoteVersion;
this.coreRemoteRelease = oData.coreRemoteRelease;
this.coreVersionCompare = oData.coreVersionCompare;
this.statusType = ko.computed(function () {
var
sType = '',
iVersionCompare = this.coreVersionCompare(),
bChecking = this.coreChecking(),
bUpdating = this.coreUpdating(),
bReal = this.coreReal()
;
if (bChecking)
{
sType = 'checking';
}
else if (bUpdating)
{
sType = 'updating';
}
else if (bReal && 0 === iVersionCompare)
{
sType = 'up-to-date';
}
else if (bReal && -1 === iVersionCompare)
{
sType = 'available';
}
else if (!bReal)
{
sType = 'error';
this.errorDesc('Cannot access the repository at the moment.');
}
return sType;
}, this);
}
Utils.addSettingsViewModel(AdminAbout, 'AdminSettingsAbout', 'About', 'about');
AdminAbout.prototype.onBuild = function ()
{
if (this.access())
{
RL.reloadCoreData();
}
};
AdminAbout.prototype.updateCoreData = function ()
{
if (!this.coreUpdating())
{
RL.updateCoreData();
}
};

View file

@ -0,0 +1,87 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
ko = require('../External/ko.js'),
Data = require('../Storages/AdminDataStorage.js')
;
/**
* @constructor
*/
function AdminSettingsAbout()
{
this.version = ko.observable(RL.settingsGet('Version'));
this.access = ko.observable(!!RL.settingsGet('CoreAccess'));
this.errorDesc = ko.observable('');
this.coreReal = Data.coreReal;
this.coreUpdatable = Data.coreUpdatable;
this.coreAccess = Data.coreAccess;
this.coreChecking = Data.coreChecking;
this.coreUpdating = Data.coreUpdating;
this.coreRemoteVersion = Data.coreRemoteVersion;
this.coreRemoteRelease = Data.coreRemoteRelease;
this.coreVersionCompare = Data.coreVersionCompare;
this.statusType = ko.computed(function () {
var
sType = '',
iVersionCompare = this.coreVersionCompare(),
bChecking = this.coreChecking(),
bUpdating = this.coreUpdating(),
bReal = this.coreReal()
;
if (bChecking)
{
sType = 'checking';
}
else if (bUpdating)
{
sType = 'updating';
}
else if (bReal && 0 === iVersionCompare)
{
sType = 'up-to-date';
}
else if (bReal && -1 === iVersionCompare)
{
sType = 'available';
}
else if (!bReal)
{
sType = 'error';
this.errorDesc('Cannot access the repository at the moment.');
}
return sType;
}, this);
}
kn.addSettingsViewModel(AdminSettingsAbout, 'AdminSettingsAbout', 'About', 'about');
AdminSettingsAbout.prototype.onBuild = function ()
{
if (this.access())
{
RL.reloadCoreData();
}
};
AdminSettingsAbout.prototype.updateCoreData = function ()
{
if (!this.coreUpdating())
{
RL.updateCoreData();
}
};
module.exports = AdminSettingsAbout;
}(module));

View file

@ -0,0 +1,87 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
kn = require('../Knoin/Knoin.js'),
Remote = require('../Storages/AdminAjaxRemoteStorage.js')
;
/**
* @constructor
*/
function AdminSettingsBranding()
{
this.title = ko.observable(RL.settingsGet('Title'));
this.title.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.loadingDesc = ko.observable(RL.settingsGet('LoadingDescription'));
this.loadingDesc.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.loginLogo = ko.observable(RL.settingsGet('LoginLogo'));
this.loginLogo.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.loginDescription = ko.observable(RL.settingsGet('LoginDescription'));
this.loginDescription.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.loginCss = ko.observable(RL.settingsGet('LoginCss'));
this.loginCss.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
kn.addSettingsViewModel(AdminSettingsBranding, 'AdminSettingsBranding', 'Branding', 'branding');
AdminSettingsBranding.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.title.trigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.loadingDesc.trigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.loginLogo.trigger, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.loginDescription.trigger, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.loginCss.trigger, self)
;
self.title.subscribe(function (sValue) {
Remote.saveAdminConfig(f1, {
'Title': Utils.trim(sValue)
});
});
self.loadingDesc.subscribe(function (sValue) {
Remote.saveAdminConfig(f2, {
'LoadingDescription': Utils.trim(sValue)
});
});
self.loginLogo.subscribe(function (sValue) {
Remote.saveAdminConfig(f3, {
'LoginLogo': Utils.trim(sValue)
});
});
self.loginDescription.subscribe(function (sValue) {
Remote.saveAdminConfig(f4, {
'LoginDescription': Utils.trim(sValue)
});
});
self.loginCss.subscribe(function (sValue) {
Remote.saveAdminConfig(f5, {
'LoginCss': Utils.trim(sValue)
});
});
}, 50);
};
module.exports = AdminSettingsBranding;
}(module));

View file

@ -0,0 +1,235 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
Remote = require('../Storages/AdminAjaxRemoteStorage.js')
;
/**
* @constructor
*/
function AdminSettingsContacts()
{
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
this.enableContacts = ko.observable(!!RL.settingsGet('ContactsEnable'));
this.contactsSharing = ko.observable(!!RL.settingsGet('ContactsSharing'));
this.contactsSync = ko.observable(!!RL.settingsGet('ContactsSync'));
var
aTypes = ['sqlite', 'mysql', 'pgsql'],
aSupportedTypes = [],
getTypeName = function(sName) {
switch (sName)
{
case 'sqlite':
sName = 'SQLite';
break;
case 'mysql':
sName = 'MySQL';
break;
case 'pgsql':
sName = 'PostgreSQL';
break;
}
return sName;
}
;
if (!!RL.settingsGet('SQLiteIsSupported'))
{
aSupportedTypes.push('sqlite');
}
if (!!RL.settingsGet('MySqlIsSupported'))
{
aSupportedTypes.push('mysql');
}
if (!!RL.settingsGet('PostgreSqlIsSupported'))
{
aSupportedTypes.push('pgsql');
}
this.contactsSupported = 0 < aSupportedTypes.length;
this.contactsTypes = ko.observableArray([]);
this.contactsTypesOptions = this.contactsTypes.map(function (sValue) {
var bDisabled = -1 === Utils.inArray(sValue, aSupportedTypes);
return {
'id': sValue,
'name': getTypeName(sValue) + (bDisabled ? ' (not supported)' : ''),
'disabled': bDisabled
};
});
this.contactsTypes(aTypes);
this.contactsType = ko.observable('');
this.mainContactsType = ko.computed({
'owner': this,
'read': this.contactsType,
'write': function (sValue) {
if (sValue !== this.contactsType())
{
if (-1 < Utils.inArray(sValue, aSupportedTypes))
{
this.contactsType(sValue);
}
else if (0 < aSupportedTypes.length)
{
this.contactsType('');
}
}
else
{
this.contactsType.valueHasMutated();
}
}
});
this.contactsType.subscribe(function () {
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
}, this);
this.pdoDsn = ko.observable(RL.settingsGet('ContactsPdoDsn'));
this.pdoUser = ko.observable(RL.settingsGet('ContactsPdoUser'));
this.pdoPassword = ko.observable(RL.settingsGet('ContactsPdoPassword'));
this.pdoDsnTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.pdoUserTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.pdoPasswordTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.contactsTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.testing = ko.observable(false);
this.testContactsSuccess = ko.observable(false);
this.testContactsError = ko.observable(false);
this.testContactsErrorMessage = ko.observable('');
this.testContactsCommand = Utils.createCommand(this, function () {
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
this.testing(true);
Remote.testContacts(this.onTestContactsResponse, {
'ContactsPdoType': this.contactsType(),
'ContactsPdoDsn': this.pdoDsn(),
'ContactsPdoUser': this.pdoUser(),
'ContactsPdoPassword': this.pdoPassword()
});
}, function () {
return '' !== this.pdoDsn() && '' !== this.pdoUser();
});
this.contactsType(RL.settingsGet('ContactsPdoType'));
this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this);
}
kn.addSettingsViewModel(AdminSettingsContacts, 'AdminSettingsContacts', 'Contacts', 'contacts');
AdminSettingsContacts.prototype.onTestContactsResponse = function (sResult, oData)
{
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.Result)
{
this.testContactsSuccess(true);
}
else
{
this.testContactsError(true);
if (oData && oData.Result)
{
this.testContactsErrorMessage(oData.Result.Message || '');
}
else
{
this.testContactsErrorMessage('');
}
}
this.testing(false);
};
AdminSettingsContacts.prototype.onShow = function ()
{
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
};
AdminSettingsContacts.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.pdoDsnTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.contactsTypeTrigger, self)
;
self.enableContacts.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'ContactsEnable': bValue ? '1' : '0'
});
});
self.contactsSharing.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'ContactsSharing': bValue ? '1' : '0'
});
});
self.contactsSync.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'ContactsSync': bValue ? '1' : '0'
});
});
self.contactsType.subscribe(function (sValue) {
Remote.saveAdminConfig(f5, {
'ContactsPdoType': sValue
});
});
self.pdoDsn.subscribe(function (sValue) {
Remote.saveAdminConfig(f1, {
'ContactsPdoDsn': Utils.trim(sValue)
});
});
self.pdoUser.subscribe(function (sValue) {
Remote.saveAdminConfig(f3, {
'ContactsPdoUser': Utils.trim(sValue)
});
});
self.pdoPassword.subscribe(function (sValue) {
Remote.saveAdminConfig(f4, {
'ContactsPdoPassword': Utils.trim(sValue)
});
});
self.contactsType(RL.settingsGet('ContactsPdoType'));
}, 50);
};
module.exports = AdminSettingsContacts;
}(module));

View file

@ -0,0 +1,107 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
window = require('../External/window.js'),
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Data = require('../Storages/AdminDataStorage.js'),
Remote = require('../Storages/AdminAjaxRemoteStorage.js')
;
/**
* @constructor
*/
function AdminSettingsDomains()
{
this.domains = Data.domains;
this.domainsLoading = Data.domainsLoading;
this.iDomainForDeletionTimeout = 0;
this.visibility = ko.computed(function () {
return Data.domainsLoading() ? 'visible' : 'hidden';
}, this);
this.domainForDeletion = ko.observable(null).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
this.startDomainForDeletionTimeout();
}
}
]});
}
kn.addSettingsViewModel(AdminSettingsDomains, 'AdminSettingsDomains', 'Domains', 'domains');
AdminSettingsDomains.prototype.startDomainForDeletionTimeout = function ()
{
var self = this;
window.clearInterval(this.iDomainForDeletionTimeout);
this.iDomainForDeletionTimeout = window.setTimeout(function () {
self.domainForDeletion(null);
}, 1000 * 3);
};
AdminSettingsDomains.prototype.createDomain = function ()
{
kn.showScreenPopup(PopupsDomainViewModel);
};
AdminSettingsDomains.prototype.deleteDomain = function (oDomain)
{
this.domains.remove(oDomain);
Remote.domainDelete(_.bind(this.onDomainListChangeRequest, this), oDomain.name);
};
AdminSettingsDomains.prototype.disableDomain = function (oDomain)
{
oDomain.disabled(!oDomain.disabled());
Remote.domainDisable(_.bind(this.onDomainListChangeRequest, this), oDomain.name, oDomain.disabled());
};
AdminSettingsDomains.prototype.onBuild = function (oDom)
{
var self = this;
oDom
.on('click', '.b-admin-domains-list-table .e-item .e-action', function () {
var oDomainItem = ko.dataFor(this);
if (oDomainItem)
{
Remote.domain(_.bind(self.onDomainLoadRequest, self), oDomainItem.name);
}
})
;
RL.reloadDomainList();
};
AdminSettingsDomains.prototype.onDomainLoadRequest = function (sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
kn.showScreenPopup(PopupsDomainViewModel, [oData.Result]);
}
};
AdminSettingsDomains.prototype.onDomainListChangeRequest = function ()
{
RL.reloadDomainList();
};
module.exports = AdminSettingsDomains;
}(module));

View file

@ -0,0 +1,148 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
kn = require('../Knoin/Knoin.js'),
Data = require('../Storages/AdminDataStorage.js'),
Remote = require('../Storages/AdminAjaxRemoteStorage.js'),
PopupsLanguagesViewModel = require('../ViewModels/Popups/PopupsLanguagesViewModel.js')
;
/**
* @constructor
*/
function AdminSettingsGeneral()
{
this.mainLanguage = Data.mainLanguage;
this.mainTheme = Data.mainTheme;
this.language = Data.language;
this.theme = Data.theme;
this.allowLanguagesOnSettings = Data.allowLanguagesOnSettings;
this.capaThemes = Data.capaThemes;
this.capaGravatar = Data.capaGravatar;
this.capaAdditionalAccounts = Data.capaAdditionalAccounts;
this.capaAdditionalIdentities = Data.capaAdditionalIdentities;
this.mainAttachmentLimit = ko.observable(Utils.pInt(RL.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25});
this.uploadData = RL.settingsGet('PhpUploadSizes');
this.uploadDataDesc = this.uploadData && (this.uploadData['upload_max_filesize'] || this.uploadData['post_max_size']) ?
[
this.uploadData['upload_max_filesize'] ? 'upload_max_filesize = ' + this.uploadData['upload_max_filesize'] + '; ' : '',
this.uploadData['post_max_size'] ? 'post_max_size = ' + this.uploadData['post_max_size'] : ''
].join('')
: '';
this.themesOptions = ko.computed(function () {
return _.map(Data.themes(), function (sTheme) {
return {
'optValue': sTheme,
'optText': Utils.convertThemeName(sTheme)
};
});
});
this.mainLanguageFullName = ko.computed(function () {
return Utils.convertLangName(this.mainLanguage());
}, this);
this.weakPassword = !!RL.settingsGet('WeakPassword');
this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
kn.addSettingsViewModel(AdminSettingsGeneral, 'AdminSettingsGeneral', 'General', 'general', true);
AdminSettingsGeneral.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self)
;
self.mainAttachmentLimit.subscribe(function (sValue) {
Remote.saveAdminConfig(f1, {
'AttachmentLimit': Utils.pInt(sValue)
});
});
self.language.subscribe(function (sValue) {
Remote.saveAdminConfig(f2, {
'Language': Utils.trim(sValue)
});
});
self.theme.subscribe(function (sValue) {
Remote.saveAdminConfig(f3, {
'Theme': Utils.trim(sValue)
});
});
self.capaAdditionalAccounts.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'CapaAdditionalAccounts': bValue ? '1' : '0'
});
});
self.capaAdditionalIdentities.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'CapaAdditionalIdentities': bValue ? '1' : '0'
});
});
self.capaGravatar.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'CapaGravatar': bValue ? '1' : '0'
});
});
self.capaThemes.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'CapaThemes': bValue ? '1' : '0'
});
});
self.allowLanguagesOnSettings.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'AllowLanguagesOnSettings': bValue ? '1' : '0'
});
});
}, 50);
};
AdminSettingsGeneral.prototype.selectLanguage = function ()
{
kn.showScreenPopup(PopupsLanguagesViewModel);
};
/**
* @return {string}
*/
AdminSettingsGeneral.prototype.phpInfoLink = function ()
{
return LinkBuilder.phpInfo();
};
module.exports = AdminSettingsGeneral;
}(module));

View file

@ -0,0 +1,75 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
ko = require('../External/ko.js'),
moment = require('../External/moment.js'),
Data = require('../Storages/AdminDataStorage.js'),
kn = require('../Knoin/Knoin.js'),
PopupsActivateViewModel = require('../ViewModels/Popups/PopupsActivateViewModel.js')
;
/**
* @constructor
*/
function AdminSettingsLicensing()
{
this.licensing = Data.licensing;
this.licensingProcess = Data.licensingProcess;
this.licenseValid = Data.licenseValid;
this.licenseExpired = Data.licenseExpired;
this.licenseError = Data.licenseError;
this.licenseTrigger = Data.licenseTrigger;
this.adminDomain = ko.observable('');
this.subscriptionEnabled = ko.observable(!!RL.settingsGet('SubscriptionEnabled'));
this.licenseTrigger.subscribe(function () {
if (this.subscriptionEnabled())
{
RL.reloadLicensing(true);
}
}, this);
}
kn.addSettingsViewModel(AdminSettingsLicensing, 'AdminSettingsLicensing', 'Licensing', 'licensing');
AdminSettingsLicensing.prototype.onBuild = function ()
{
if (this.subscriptionEnabled())
{
RL.reloadLicensing(false);
}
};
AdminSettingsLicensing.prototype.onShow = function ()
{
this.adminDomain(RL.settingsGet('AdminDomain'));
};
AdminSettingsLicensing.prototype.showActivationForm = function ()
{
kn.showScreenPopup(PopupsActivateViewModel);
};
/**
* @returns {string}
*/
AdminSettingsLicensing.prototype.licenseExpiredMomentValue = function ()
{
var
iTime = this.licenseExpired(),
oDate = moment.unix(iTime)
;
return iTime && 1898625600 === iTime ? 'Never' : (oDate.format('LL') + ' (' + oDate.from(moment()) + ')');
};
module.exports = AdminSettingsLicensing;
}(module));

View file

@ -0,0 +1,69 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
Data = require('../Storages/AdminDataStorage.js'),
Remote = require('../Storages/AdminAjaxRemoteStorage.js')
;
/**
* @constructor
*/
function AdminSettingsLogin()
{
this.determineUserLanguage = Data.determineUserLanguage;
this.determineUserDomain = Data.determineUserDomain;
this.defaultDomain = ko.observable(RL.settingsGet('LoginDefaultDomain'));
this.allowLanguagesOnLogin = Data.allowLanguagesOnLogin;
this.defaultDomainTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
kn.addSettingsViewModel(AdminSettingsLogin, 'AdminSettingsLogin', 'Login', 'login');
AdminSettingsLogin.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var f1 = Utils.settingsSaveHelperSimpleFunction(self.defaultDomainTrigger, self);
self.determineUserLanguage.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'DetermineUserLanguage': bValue ? '1' : '0'
});
});
self.determineUserDomain.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'DetermineUserDomain': bValue ? '1' : '0'
});
});
self.allowLanguagesOnLogin.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'AllowLanguagesOnLogin': bValue ? '1' : '0'
});
});
self.defaultDomain.subscribe(function (sValue) {
Remote.saveAdminConfig(f1, {
'LoginDefaultDomain': Utils.trim(sValue)
});
});
}, 50);
};
module.exports = AdminSettingsLogin;
}(module));

View file

@ -0,0 +1,116 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
window = require('../External/window.js'),
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
Data = require('../Storages/AdminDataStorage.js'),
Remote = require('../Storages/AdminAjaxRemoteStorage.js')
;
/**
* @constructor
*/
function AdminSettingsPackages()
{
this.packagesError = ko.observable('');
this.packages = Data.packages;
this.packagesLoading = Data.packagesLoading;
this.packagesReal = Data.packagesReal;
this.packagesMainUpdatable = Data.packagesMainUpdatable;
this.packagesCurrent = this.packages.filter(function (oItem) {
return oItem && '' !== oItem['installed'] && !oItem['compare'];
});
this.packagesAvailableForUpdate = this.packages.filter(function (oItem) {
return oItem && '' !== oItem['installed'] && !!oItem['compare'];
});
this.packagesAvailableForInstallation = this.packages.filter(function (oItem) {
return oItem && '' === oItem['installed'];
});
this.visibility = ko.computed(function () {
return Data.packagesLoading() ? 'visible' : 'hidden';
}, this);
}
kn.addSettingsViewModel(AdminSettingsPackages, 'AdminSettingsPackages', 'Packages', 'packages');
AdminSettingsPackages.prototype.onShow = function ()
{
this.packagesError('');
};
AdminSettingsPackages.prototype.onBuild = function ()
{
RL.reloadPackagesList();
};
AdminSettingsPackages.prototype.requestHelper = function (oPackage, bInstall)
{
var self = this;
return function (sResult, oData) {
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{
if (oData && oData.ErrorCode)
{
self.packagesError(Utils.getNotification(oData.ErrorCode));
}
else
{
self.packagesError(Utils.getNotification(
bInstall ? Enums.Notification.CantInstallPackage : Enums.Notification.CantDeletePackage));
}
}
_.each(Data.packages(), function (oItem) {
if (oItem && oPackage && oItem['loading']() && oPackage['file'] === oItem['file'])
{
oPackage['loading'](false);
oItem['loading'](false);
}
});
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result['Reload'])
{
window.location.reload();
}
else
{
RL.reloadPackagesList();
}
};
};
AdminSettingsPackages.prototype.deletePackage = function (oPackage)
{
if (oPackage)
{
oPackage['loading'](true);
Remote.packageDelete(this.requestHelper(oPackage, false), oPackage);
}
};
AdminSettingsPackages.prototype.installPackage = function (oPackage)
{
if (oPackage)
{
oPackage['loading'](true);
Remote.packageInstall(this.requestHelper(oPackage, true), oPackage);
}
};
module.exports = AdminSettingsPackages;
}(module));

View file

@ -0,0 +1,117 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
Data = require('../Storages/AdminDataStorage.js'),
Remote = require('../Storages/AdminAjaxRemoteStorage.js'),
PopupsPluginViewModel = require('../ViewModels/Popups/PopupsPluginViewModel.js')
;
/**
* @constructor
*/
function AdminSettingsPlugins()
{
this.enabledPlugins = ko.observable(!!RL.settingsGet('EnabledPlugins'));
this.pluginsError = ko.observable('');
this.plugins = Data.plugins;
this.pluginsLoading = Data.pluginsLoading;
this.visibility = ko.computed(function () {
return Data.pluginsLoading() ? 'visible' : 'hidden';
}, this);
this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this);
this.onPluginDisableRequest = _.bind(this.onPluginDisableRequest, this);
}
kn.addSettingsViewModel(AdminSettingsPlugins, 'AdminSettingsPlugins', 'Plugins', 'plugins');
AdminSettingsPlugins.prototype.disablePlugin = function (oPlugin)
{
oPlugin.disabled(!oPlugin.disabled());
Remote.pluginDisable(this.onPluginDisableRequest, oPlugin.name, oPlugin.disabled());
};
AdminSettingsPlugins.prototype.configurePlugin = function (oPlugin)
{
Remote.plugin(this.onPluginLoadRequest, oPlugin.name);
};
AdminSettingsPlugins.prototype.onBuild = function (oDom)
{
var self = this;
oDom
.on('click', '.e-item .configure-plugin-action', function () {
var oPlugin = ko.dataFor(this);
if (oPlugin)
{
self.configurePlugin(oPlugin);
}
})
.on('click', '.e-item .disabled-plugin', function () {
var oPlugin = ko.dataFor(this);
if (oPlugin)
{
self.disablePlugin(oPlugin);
}
})
;
this.enabledPlugins.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'EnabledPlugins': bValue ? '1' : '0'
});
});
};
AdminSettingsPlugins.prototype.onShow = function ()
{
this.pluginsError('');
RL.reloadPluginList();
};
AdminSettingsPlugins.prototype.onPluginLoadRequest = function (sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
kn.showScreenPopup(PopupsPluginViewModel, [oData.Result]);
}
};
AdminSettingsPlugins.prototype.onPluginDisableRequest = function (sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData)
{
if (!oData.Result && oData.ErrorCode)
{
if (Enums.Notification.UnsupportedPluginPackage === oData.ErrorCode && oData.ErrorMessage && '' !== oData.ErrorMessage)
{
this.pluginsError(oData.ErrorMessage);
}
else
{
this.pluginsError(Utils.getNotification(oData.ErrorCode));
}
}
}
RL.reloadPluginList();
};
module.exports = AdminSettingsPlugins;
}(module));

View file

@ -0,0 +1,134 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
Data = require('../Storages/AdminDataStorage.js'),
Remote = require('../Storages/AdminAjaxRemoteStorage.js')
;
/**
* @constructor
*/
function AdminSettingsSecurity()
{
this.useLocalProxyForExternalImages = Data.useLocalProxyForExternalImages;
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('');
this.adminPasswordNew = ko.observable('');
this.adminPasswordNew2 = ko.observable('');
this.adminPasswordNewError = ko.observable(false);
this.adminPasswordUpdateError = ko.observable(false);
this.adminPasswordUpdateSuccess = ko.observable(false);
this.adminPassword.subscribe(function () {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
}, this);
this.adminPasswordNew.subscribe(function () {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false);
}, this);
this.adminPasswordNew2.subscribe(function () {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false);
}, this);
this.saveNewAdminPasswordCommand = Utils.createCommand(this, function () {
if (this.adminPasswordNew() !== this.adminPasswordNew2())
{
this.adminPasswordNewError(true);
return false;
}
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
Remote.saveNewAdminPassword(this.onNewAdminPasswordResponse, {
'Password': this.adminPassword(),
'NewPassword': this.adminPasswordNew()
});
}, function () {
return '' !== this.adminPassword() && '' !== this.adminPasswordNew() && '' !== this.adminPasswordNew2();
});
this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this);
}
kn.addSettingsViewModel(AdminSettingsSecurity, 'AdminSettingsSecurity', 'Security', 'security');
AdminSettingsSecurity.prototype.onNewAdminPasswordResponse = function (sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.adminPassword('');
this.adminPasswordNew('');
this.adminPasswordNew2('');
this.adminPasswordUpdateSuccess(true);
}
else
{
this.adminPasswordUpdateError(true);
}
};
AdminSettingsSecurity.prototype.onBuild = function ()
{
this.capaOpenPGP.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'CapaOpenPGP': bValue ? '1' : '0'
});
});
this.capaTwoFactorAuth.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'CapaTwoFactorAuth': bValue ? '1' : '0'
});
});
this.useLocalProxyForExternalImages.subscribe(function (bValue) {
Remote.saveAdminConfig(null, {
'UseLocalProxyForExternalImages': bValue ? '1' : '0'
});
});
};
AdminSettingsSecurity.prototype.onHide = function ()
{
this.adminPassword('');
this.adminPasswordNew('');
this.adminPasswordNew2('');
};
/**
* @return {string}
*/
AdminSettingsSecurity.prototype.phpInfoLink = function ()
{
return LinkBuilder.phpInfo();
};
module.exports = AdminSettingsSecurity;
}(module));

View file

@ -0,0 +1,153 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
Data = require('../Storages/AdminDataStorage.js'),
Remote = require('../Storages/AdminAjaxRemoteStorage.js')
;
/**
* @constructor
*/
function AdminSettingsSocial()
{
this.googleEnable = Data.googleEnable;
this.googleClientID = Data.googleClientID;
this.googleApiKey = Data.googleApiKey;
this.googleClientSecret = Data.googleClientSecret;
this.googleTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.googleTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.googleTrigger3 = ko.observable(Enums.SaveSettingsStep.Idle);
this.facebookSupported = Data.facebookSupported;
this.facebookEnable = Data.facebookEnable;
this.facebookAppID = Data.facebookAppID;
this.facebookAppSecret = Data.facebookAppSecret;
this.facebookTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.facebookTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.twitterEnable = Data.twitterEnable;
this.twitterConsumerKey = Data.twitterConsumerKey;
this.twitterConsumerSecret = Data.twitterConsumerSecret;
this.twitterTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.twitterTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.dropboxEnable = Data.dropboxEnable;
this.dropboxApiKey = Data.dropboxApiKey;
this.dropboxTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
}
kn.addSettingsViewModel(AdminSettingsSocial, 'AdminSettingsSocial', 'Social', 'social');
AdminSettingsSocial.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger1, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger2, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger1, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger2, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger1, self),
f6 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger2, self),
f7 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger3, self),
f8 = Utils.settingsSaveHelperSimpleFunction(self.dropboxTrigger1, self)
;
self.facebookEnable.subscribe(function (bValue) {
if (self.facebookSupported())
{
Remote.saveAdminConfig(Utils.emptyFunction, {
'FacebookEnable': bValue ? '1' : '0'
});
}
});
self.facebookAppID.subscribe(function (sValue) {
if (self.facebookSupported())
{
Remote.saveAdminConfig(f1, {
'FacebookAppID': Utils.trim(sValue)
});
}
});
self.facebookAppSecret.subscribe(function (sValue) {
if (self.facebookSupported())
{
Remote.saveAdminConfig(f2, {
'FacebookAppSecret': Utils.trim(sValue)
});
}
});
self.twitterEnable.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'TwitterEnable': bValue ? '1' : '0'
});
});
self.twitterConsumerKey.subscribe(function (sValue) {
Remote.saveAdminConfig(f3, {
'TwitterConsumerKey': Utils.trim(sValue)
});
});
self.twitterConsumerSecret.subscribe(function (sValue) {
Remote.saveAdminConfig(f4, {
'TwitterConsumerSecret': Utils.trim(sValue)
});
});
self.googleEnable.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'GoogleEnable': bValue ? '1' : '0'
});
});
self.googleClientID.subscribe(function (sValue) {
Remote.saveAdminConfig(f5, {
'GoogleClientID': Utils.trim(sValue)
});
});
self.googleClientSecret.subscribe(function (sValue) {
Remote.saveAdminConfig(f6, {
'GoogleClientSecret': Utils.trim(sValue)
});
});
self.googleApiKey.subscribe(function (sValue) {
Remote.saveAdminConfig(f7, {
'GoogleApiKey': Utils.trim(sValue)
});
});
self.dropboxEnable.subscribe(function (bValue) {
Remote.saveAdminConfig(Utils.emptyFunction, {
'DropboxEnable': bValue ? '1' : '0'
});
});
self.dropboxApiKey.subscribe(function (sValue) {
Remote.saveAdminConfig(f8, {
'DropboxApiKey': Utils.trim(sValue)
});
});
}, 50);
};
module.exports = AdminSettingsSocial;
}(module));

View file

@ -1,70 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function AdminBranding()
{
this.title = ko.observable(RL.settingsGet('Title'));
this.title.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.loadingDesc = ko.observable(RL.settingsGet('LoadingDescription'));
this.loadingDesc.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.loginLogo = ko.observable(RL.settingsGet('LoginLogo'));
this.loginLogo.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.loginDescription = ko.observable(RL.settingsGet('LoginDescription'));
this.loginDescription.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.loginCss = ko.observable(RL.settingsGet('LoginCss'));
this.loginCss.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
Utils.addSettingsViewModel(AdminBranding, 'AdminSettingsBranding', 'Branding', 'branding');
AdminBranding.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.title.trigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.loadingDesc.trigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.loginLogo.trigger, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.loginDescription.trigger, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.loginCss.trigger, self)
;
self.title.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f1, {
'Title': Utils.trim(sValue)
});
});
self.loadingDesc.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f2, {
'LoadingDescription': Utils.trim(sValue)
});
});
self.loginLogo.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f3, {
'LoginLogo': Utils.trim(sValue)
});
});
self.loginDescription.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f4, {
'LoginDescription': Utils.trim(sValue)
});
});
self.loginCss.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f5, {
'LoginCss': Utils.trim(sValue)
});
});
}, 50);
};

View file

@ -1,221 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function AdminContacts()
{
// var oData = RL.data();
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
this.enableContacts = ko.observable(!!RL.settingsGet('ContactsEnable'));
this.contactsSharing = ko.observable(!!RL.settingsGet('ContactsSharing'));
this.contactsSync = ko.observable(!!RL.settingsGet('ContactsSync'));
var
aTypes = ['sqlite', 'mysql', 'pgsql'],
aSupportedTypes = [],
getTypeName = function(sName) {
switch (sName)
{
case 'sqlite':
sName = 'SQLite';
break;
case 'mysql':
sName = 'MySQL';
break;
case 'pgsql':
sName = 'PostgreSQL';
break;
}
return sName;
}
;
if (!!RL.settingsGet('SQLiteIsSupported'))
{
aSupportedTypes.push('sqlite');
}
if (!!RL.settingsGet('MySqlIsSupported'))
{
aSupportedTypes.push('mysql');
}
if (!!RL.settingsGet('PostgreSqlIsSupported'))
{
aSupportedTypes.push('pgsql');
}
this.contactsSupported = 0 < aSupportedTypes.length;
this.contactsTypes = ko.observableArray([]);
this.contactsTypesOptions = this.contactsTypes.map(function (sValue) {
var bDisabled = -1 === Utils.inArray(sValue, aSupportedTypes);
return {
'id': sValue,
'name': getTypeName(sValue) + (bDisabled ? ' (not supported)' : ''),
'disabled': bDisabled
};
});
this.contactsTypes(aTypes);
this.contactsType = ko.observable('');
this.mainContactsType = ko.computed({
'owner': this,
'read': this.contactsType,
'write': function (sValue) {
if (sValue !== this.contactsType())
{
if (-1 < Utils.inArray(sValue, aSupportedTypes))
{
this.contactsType(sValue);
}
else if (0 < aSupportedTypes.length)
{
this.contactsType('');
}
}
else
{
this.contactsType.valueHasMutated();
}
}
});
this.contactsType.subscribe(function () {
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
}, this);
this.pdoDsn = ko.observable(RL.settingsGet('ContactsPdoDsn'));
this.pdoUser = ko.observable(RL.settingsGet('ContactsPdoUser'));
this.pdoPassword = ko.observable(RL.settingsGet('ContactsPdoPassword'));
this.pdoDsnTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.pdoUserTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.pdoPasswordTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.contactsTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.testing = ko.observable(false);
this.testContactsSuccess = ko.observable(false);
this.testContactsError = ko.observable(false);
this.testContactsErrorMessage = ko.observable('');
this.testContactsCommand = Utils.createCommand(this, function () {
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
this.testing(true);
RL.remote().testContacts(this.onTestContactsResponse, {
'ContactsPdoType': this.contactsType(),
'ContactsPdoDsn': this.pdoDsn(),
'ContactsPdoUser': this.pdoUser(),
'ContactsPdoPassword': this.pdoPassword()
});
}, function () {
return '' !== this.pdoDsn() && '' !== this.pdoUser();
});
this.contactsType(RL.settingsGet('ContactsPdoType'));
this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this);
}
Utils.addSettingsViewModel(AdminContacts, 'AdminSettingsContacts', 'Contacts', 'contacts');
AdminContacts.prototype.onTestContactsResponse = function (sResult, oData)
{
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.Result)
{
this.testContactsSuccess(true);
}
else
{
this.testContactsError(true);
if (oData && oData.Result)
{
this.testContactsErrorMessage(oData.Result.Message || '');
}
else
{
this.testContactsErrorMessage('');
}
}
this.testing(false);
};
AdminContacts.prototype.onShow = function ()
{
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
};
AdminContacts.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.pdoDsnTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.contactsTypeTrigger, self)
;
self.enableContacts.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'ContactsEnable': bValue ? '1' : '0'
});
});
self.contactsSharing.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'ContactsSharing': bValue ? '1' : '0'
});
});
self.contactsSync.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'ContactsSync': bValue ? '1' : '0'
});
});
self.contactsType.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f5, {
'ContactsPdoType': sValue
});
});
self.pdoDsn.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f1, {
'ContactsPdoDsn': Utils.trim(sValue)
});
});
self.pdoUser.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f3, {
'ContactsPdoUser': Utils.trim(sValue)
});
});
self.pdoPassword.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f4, {
'ContactsPdoPassword': Utils.trim(sValue)
});
});
self.contactsType(RL.settingsGet('ContactsPdoType'));
}, 50);
};

View file

@ -1,90 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function AdminDomains()
{
var oData = RL.data();
this.domains = oData.domains;
this.domainsLoading = oData.domainsLoading;
this.iDomainForDeletionTimeout = 0;
this.visibility = ko.computed(function () {
return oData.domainsLoading() ? 'visible' : 'hidden';
}, this);
this.domainForDeletion = ko.observable(null).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
this.startDomainForDeletionTimeout();
}
}
]});
}
Utils.addSettingsViewModel(AdminDomains, 'AdminSettingsDomains', 'Domains', 'domains');
AdminDomains.prototype.startDomainForDeletionTimeout = function ()
{
var self = this;
window.clearInterval(this.iDomainForDeletionTimeout);
this.iDomainForDeletionTimeout = window.setTimeout(function () {
self.domainForDeletion(null);
}, 1000 * 3);
};
AdminDomains.prototype.createDomain = function ()
{
kn.showScreenPopup(PopupsDomainViewModel);
};
AdminDomains.prototype.deleteDomain = function (oDomain)
{
this.domains.remove(oDomain);
RL.remote().domainDelete(_.bind(this.onDomainListChangeRequest, this), oDomain.name);
};
AdminDomains.prototype.disableDomain = function (oDomain)
{
oDomain.disabled(!oDomain.disabled());
RL.remote().domainDisable(_.bind(this.onDomainListChangeRequest, this), oDomain.name, oDomain.disabled());
};
AdminDomains.prototype.onBuild = function (oDom)
{
var self = this;
oDom
.on('click', '.b-admin-domains-list-table .e-item .e-action', function () {
var oDomainItem = ko.dataFor(this);
if (oDomainItem)
{
RL.remote().domain(_.bind(self.onDomainLoadRequest, self), oDomainItem.name);
}
})
;
RL.reloadDomainList();
};
AdminDomains.prototype.onDomainLoadRequest = function (sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
kn.showScreenPopup(PopupsDomainViewModel, [oData.Result]);
}
};
AdminDomains.prototype.onDomainListChangeRequest = function ()
{
RL.reloadDomainList();
};

View file

@ -1,127 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function AdminGeneral()
{
var oData = RL.data();
this.mainLanguage = oData.mainLanguage;
this.mainTheme = oData.mainTheme;
this.language = oData.language;
this.theme = oData.theme;
this.allowLanguagesOnSettings = oData.allowLanguagesOnSettings;
this.capaThemes = oData.capaThemes;
this.capaGravatar = oData.capaGravatar;
this.capaAdditionalAccounts = oData.capaAdditionalAccounts;
this.capaAdditionalIdentities = oData.capaAdditionalIdentities;
this.mainAttachmentLimit = ko.observable(Utils.pInt(RL.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25});
this.uploadData = RL.settingsGet('PhpUploadSizes');
this.uploadDataDesc = this.uploadData && (this.uploadData['upload_max_filesize'] || this.uploadData['post_max_size']) ?
[
this.uploadData['upload_max_filesize'] ? 'upload_max_filesize = ' + this.uploadData['upload_max_filesize'] + '; ' : '',
this.uploadData['post_max_size'] ? 'post_max_size = ' + this.uploadData['post_max_size'] : ''
].join('')
: '';
this.themesOptions = ko.computed(function () {
return _.map(oData.themes(), function (sTheme) {
return {
'optValue': sTheme,
'optText': Utils.convertThemeName(sTheme)
};
});
});
this.mainLanguageFullName = ko.computed(function () {
return Utils.convertLangName(this.mainLanguage());
}, this);
this.weakPassword = !!RL.settingsGet('WeakPassword');
this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
Utils.addSettingsViewModel(AdminGeneral, 'AdminSettingsGeneral', 'General', 'general', true);
AdminGeneral.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self)
;
self.mainAttachmentLimit.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f1, {
'AttachmentLimit': Utils.pInt(sValue)
});
});
self.language.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f2, {
'Language': Utils.trim(sValue)
});
});
self.theme.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f3, {
'Theme': Utils.trim(sValue)
});
});
self.capaAdditionalAccounts.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'CapaAdditionalAccounts': bValue ? '1' : '0'
});
});
self.capaAdditionalIdentities.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'CapaAdditionalIdentities': bValue ? '1' : '0'
});
});
self.capaGravatar.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'CapaGravatar': bValue ? '1' : '0'
});
});
self.capaThemes.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'CapaThemes': bValue ? '1' : '0'
});
});
self.allowLanguagesOnSettings.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'AllowLanguagesOnSettings': bValue ? '1' : '0'
});
});
}, 50);
};
AdminGeneral.prototype.selectLanguage = function ()
{
kn.showScreenPopup(PopupsLanguagesViewModel);
};
/**
* @return {string}
*/
AdminGeneral.prototype.phpInfoLink = function ()
{
return RL.link().phpInfo();
};

View file

@ -1,57 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function AdminLicensing()
{
this.licensing = RL.data().licensing;
this.licensingProcess = RL.data().licensingProcess;
this.licenseValid = RL.data().licenseValid;
this.licenseExpired = RL.data().licenseExpired;
this.licenseError = RL.data().licenseError;
this.licenseTrigger = RL.data().licenseTrigger;
this.adminDomain = ko.observable('');
this.subscriptionEnabled = ko.observable(!!RL.settingsGet('SubscriptionEnabled'));
this.licenseTrigger.subscribe(function () {
if (this.subscriptionEnabled())
{
RL.reloadLicensing(true);
}
}, this);
}
Utils.addSettingsViewModel(AdminLicensing, 'AdminSettingsLicensing', 'Licensing', 'licensing');
AdminLicensing.prototype.onBuild = function ()
{
if (this.subscriptionEnabled())
{
RL.reloadLicensing(false);
}
};
AdminLicensing.prototype.onShow = function ()
{
this.adminDomain(RL.settingsGet('AdminDomain'));
};
AdminLicensing.prototype.showActivationForm = function ()
{
kn.showScreenPopup(PopupsActivateViewModel);
};
/**
* @returns {string}
*/
AdminLicensing.prototype.licenseExpiredMomentValue = function ()
{
var
iTime = this.licenseExpired(),
oDate = moment.unix(iTime)
;
return iTime && 1898625600 === iTime ? 'Never' : (oDate.format('LL') + ' (' + oDate.from(moment()) + ')');
};

View file

@ -1,53 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function AdminLogin()
{
var oData = RL.data();
this.determineUserLanguage = oData.determineUserLanguage;
this.determineUserDomain = oData.determineUserDomain;
this.defaultDomain = ko.observable(RL.settingsGet('LoginDefaultDomain'));
this.allowLanguagesOnLogin = oData.allowLanguagesOnLogin;
this.defaultDomainTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
Utils.addSettingsViewModel(AdminLogin, 'AdminSettingsLogin', 'Login', 'login');
AdminLogin.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var f1 = Utils.settingsSaveHelperSimpleFunction(self.defaultDomainTrigger, self);
self.determineUserLanguage.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'DetermineUserLanguage': bValue ? '1' : '0'
});
});
self.determineUserDomain.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'DetermineUserDomain': bValue ? '1' : '0'
});
});
self.allowLanguagesOnLogin.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'AllowLanguagesOnLogin': bValue ? '1' : '0'
});
});
self.defaultDomain.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f1, {
'LoginDefaultDomain': Utils.trim(sValue)
});
});
}, 50);
};

View file

@ -1,99 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function AdminPackages()
{
var oData = RL.data();
this.packagesError = ko.observable('');
this.packages = oData.packages;
this.packagesLoading = oData.packagesLoading;
this.packagesReal = oData.packagesReal;
this.packagesMainUpdatable = oData.packagesMainUpdatable;
this.packagesCurrent = this.packages.filter(function (oItem) {
return oItem && '' !== oItem['installed'] && !oItem['compare'];
});
this.packagesAvailableForUpdate = this.packages.filter(function (oItem) {
return oItem && '' !== oItem['installed'] && !!oItem['compare'];
});
this.packagesAvailableForInstallation = this.packages.filter(function (oItem) {
return oItem && '' === oItem['installed'];
});
this.visibility = ko.computed(function () {
return oData.packagesLoading() ? 'visible' : 'hidden';
}, this);
}
Utils.addSettingsViewModel(AdminPackages, 'AdminSettingsPackages', 'Packages', 'packages');
AdminPackages.prototype.onShow = function ()
{
this.packagesError('');
};
AdminPackages.prototype.onBuild = function ()
{
RL.reloadPackagesList();
};
AdminPackages.prototype.requestHelper = function (oPackage, bInstall)
{
var self = this;
return function (sResult, oData) {
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{
if (oData && oData.ErrorCode)
{
self.packagesError(Utils.getNotification(oData.ErrorCode));
}
else
{
self.packagesError(Utils.getNotification(
bInstall ? Enums.Notification.CantInstallPackage : Enums.Notification.CantDeletePackage));
}
}
_.each(RL.data().packages(), function (oItem) {
if (oItem && oPackage && oItem['loading']() && oPackage['file'] === oItem['file'])
{
oPackage['loading'](false);
oItem['loading'](false);
}
});
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result['Reload'])
{
window.location.reload();
}
else
{
RL.reloadPackagesList();
}
};
};
AdminPackages.prototype.deletePackage = function (oPackage)
{
if (oPackage)
{
oPackage['loading'](true);
RL.remote().packageDelete(this.requestHelper(oPackage, false), oPackage);
}
};
AdminPackages.prototype.installPackage = function (oPackage)
{
if (oPackage)
{
oPackage['loading'](true);
RL.remote().packageInstall(this.requestHelper(oPackage, true), oPackage);
}
};

View file

@ -1,98 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function AdminPlugins()
{
var oData = RL.data();
this.enabledPlugins = ko.observable(!!RL.settingsGet('EnabledPlugins'));
this.pluginsError = ko.observable('');
this.plugins = oData.plugins;
this.pluginsLoading = oData.pluginsLoading;
this.visibility = ko.computed(function () {
return oData.pluginsLoading() ? 'visible' : 'hidden';
}, this);
this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this);
this.onPluginDisableRequest = _.bind(this.onPluginDisableRequest, this);
}
Utils.addSettingsViewModel(AdminPlugins, 'AdminSettingsPlugins', 'Plugins', 'plugins');
AdminPlugins.prototype.disablePlugin = function (oPlugin)
{
oPlugin.disabled(!oPlugin.disabled());
RL.remote().pluginDisable(this.onPluginDisableRequest, oPlugin.name, oPlugin.disabled());
};
AdminPlugins.prototype.configurePlugin = function (oPlugin)
{
RL.remote().plugin(this.onPluginLoadRequest, oPlugin.name);
};
AdminPlugins.prototype.onBuild = function (oDom)
{
var self = this;
oDom
.on('click', '.e-item .configure-plugin-action', function () {
var oPlugin = ko.dataFor(this);
if (oPlugin)
{
self.configurePlugin(oPlugin);
}
})
.on('click', '.e-item .disabled-plugin', function () {
var oPlugin = ko.dataFor(this);
if (oPlugin)
{
self.disablePlugin(oPlugin);
}
})
;
this.enabledPlugins.subscribe(function (bValue) {
RL.remote().saveAdminConfig(Utils.emptyFunction, {
'EnabledPlugins': bValue ? '1' : '0'
});
});
};
AdminPlugins.prototype.onShow = function ()
{
this.pluginsError('');
RL.reloadPluginList();
};
AdminPlugins.prototype.onPluginLoadRequest = function (sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
kn.showScreenPopup(PopupsPluginViewModel, [oData.Result]);
}
};
AdminPlugins.prototype.onPluginDisableRequest = function (sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData)
{
if (!oData.Result && oData.ErrorCode)
{
if (Enums.Notification.UnsupportedPluginPackage === oData.ErrorCode && oData.ErrorMessage && '' !== oData.ErrorMessage)
{
this.pluginsError(oData.ErrorMessage);
}
else
{
this.pluginsError(Utils.getNotification(oData.ErrorCode));
}
}
}
RL.reloadPluginList();
};

View file

@ -1,114 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function AdminSecurity()
{
this.useLocalProxyForExternalImages = RL.data().useLocalProxyForExternalImages;
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('');
this.adminPasswordNew = ko.observable('');
this.adminPasswordNew2 = ko.observable('');
this.adminPasswordNewError = ko.observable(false);
this.adminPasswordUpdateError = ko.observable(false);
this.adminPasswordUpdateSuccess = ko.observable(false);
this.adminPassword.subscribe(function () {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
}, this);
this.adminPasswordNew.subscribe(function () {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false);
}, this);
this.adminPasswordNew2.subscribe(function () {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false);
}, this);
this.saveNewAdminPasswordCommand = Utils.createCommand(this, function () {
if (this.adminPasswordNew() !== this.adminPasswordNew2())
{
this.adminPasswordNewError(true);
return false;
}
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
RL.remote().saveNewAdminPassword(this.onNewAdminPasswordResponse, {
'Password': this.adminPassword(),
'NewPassword': this.adminPasswordNew()
});
}, function () {
return '' !== this.adminPassword() && '' !== this.adminPasswordNew() && '' !== this.adminPasswordNew2();
});
this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this);
}
Utils.addSettingsViewModel(AdminSecurity, 'AdminSettingsSecurity', 'Security', 'security');
AdminSecurity.prototype.onNewAdminPasswordResponse = function (sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.adminPassword('');
this.adminPasswordNew('');
this.adminPasswordNew2('');
this.adminPasswordUpdateSuccess(true);
}
else
{
this.adminPasswordUpdateError(true);
}
};
AdminSecurity.prototype.onBuild = function ()
{
this.capaOpenPGP.subscribe(function (bValue) {
RL.remote().saveAdminConfig(Utils.emptyFunction, {
'CapaOpenPGP': bValue ? '1' : '0'
});
});
this.capaTwoFactorAuth.subscribe(function (bValue) {
RL.remote().saveAdminConfig(Utils.emptyFunction, {
'CapaTwoFactorAuth': bValue ? '1' : '0'
});
});
this.useLocalProxyForExternalImages.subscribe(function (bValue) {
RL.remote().saveAdminConfig(null, {
'UseLocalProxyForExternalImages': bValue ? '1' : '0'
});
});
};
AdminSecurity.prototype.onHide = function ()
{
this.adminPassword('');
this.adminPasswordNew('');
this.adminPasswordNew2('');
};
/**
* @return {string}
*/
AdminSecurity.prototype.phpInfoLink = function ()
{
return RL.link().phpInfo();
};

View file

@ -1,136 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function AdminSocial()
{
var oData = RL.data();
this.googleEnable = oData.googleEnable;
this.googleClientID = oData.googleClientID;
this.googleApiKey = oData.googleApiKey;
this.googleClientSecret = oData.googleClientSecret;
this.googleTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.googleTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.googleTrigger3 = ko.observable(Enums.SaveSettingsStep.Idle);
this.facebookSupported = oData.facebookSupported;
this.facebookEnable = oData.facebookEnable;
this.facebookAppID = oData.facebookAppID;
this.facebookAppSecret = oData.facebookAppSecret;
this.facebookTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.facebookTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.twitterEnable = oData.twitterEnable;
this.twitterConsumerKey = oData.twitterConsumerKey;
this.twitterConsumerSecret = oData.twitterConsumerSecret;
this.twitterTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.twitterTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.dropboxEnable = oData.dropboxEnable;
this.dropboxApiKey = oData.dropboxApiKey;
this.dropboxTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
}
Utils.addSettingsViewModel(AdminSocial, 'AdminSettingsSocial', 'Social', 'social');
AdminSocial.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger1, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger2, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger1, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger2, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger1, self),
f6 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger2, self),
f7 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger3, self),
f8 = Utils.settingsSaveHelperSimpleFunction(self.dropboxTrigger1, self)
;
self.facebookEnable.subscribe(function (bValue) {
if (self.facebookSupported())
{
RL.remote().saveAdminConfig(Utils.emptyFunction, {
'FacebookEnable': bValue ? '1' : '0'
});
}
});
self.facebookAppID.subscribe(function (sValue) {
if (self.facebookSupported())
{
RL.remote().saveAdminConfig(f1, {
'FacebookAppID': Utils.trim(sValue)
});
}
});
self.facebookAppSecret.subscribe(function (sValue) {
if (self.facebookSupported())
{
RL.remote().saveAdminConfig(f2, {
'FacebookAppSecret': Utils.trim(sValue)
});
}
});
self.twitterEnable.subscribe(function (bValue) {
RL.remote().saveAdminConfig(Utils.emptyFunction, {
'TwitterEnable': bValue ? '1' : '0'
});
});
self.twitterConsumerKey.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f3, {
'TwitterConsumerKey': Utils.trim(sValue)
});
});
self.twitterConsumerSecret.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f4, {
'TwitterConsumerSecret': Utils.trim(sValue)
});
});
self.googleEnable.subscribe(function (bValue) {
RL.remote().saveAdminConfig(Utils.emptyFunction, {
'GoogleEnable': bValue ? '1' : '0'
});
});
self.googleClientID.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f5, {
'GoogleClientID': Utils.trim(sValue)
});
});
self.googleClientSecret.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f6, {
'GoogleClientSecret': Utils.trim(sValue)
});
});
self.googleApiKey.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f7, {
'GoogleApiKey': Utils.trim(sValue)
});
});
self.dropboxEnable.subscribe(function (bValue) {
RL.remote().saveAdminConfig(Utils.emptyFunction, {
'DropboxEnable': bValue ? '1' : '0'
});
});
self.dropboxApiKey.subscribe(function (sValue) {
RL.remote().saveAdminConfig(f8, {
'DropboxApiKey': Utils.trim(sValue)
});
});
}, 50);
};

View file

@ -4,7 +4,8 @@
var var
kn = require('./Knoin/Knoin.js'), kn = require('./Knoin/Knoin.js'),
RL = require('./Boots/AdminApp.js') RL = require('./Boots/AdminApp.js'),
Remote = require('./Storages/AdminAjaxRemoteStorage.js')
; ;
kn.bootstart(RL); kn.bootstart(RL, Remote);

View file

@ -13,10 +13,16 @@
$window = require('../External/$window.js'), $window = require('../External/$window.js'),
$doc = require('../External/$doc.js'), $doc = require('../External/$doc.js'),
AppData = require('../External/AppData.js'), AppData = require('../External/AppData.js'),
Globals = require('../Common/Globals.js'), Globals = require('../Common/Globals.js'),
Utils = require('../Common/Utils.js'), Utils = require('../Common/Utils.js'),
KnoinAbstractBoot = require('../Knoin/KnoinAbstractBoot.js'), Plugins = require('../Common/Plugins.js'),
RL = require('./RL.js') LinkBuilder = require('../Common/LinkBuilder.js'),
Remote = require('../Remote.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractBoot = require('../Knoin/KnoinAbstractBoot.js')
; ;
/** /**
@ -49,8 +55,7 @@
'Script error.', 'Uncaught Error: Error calling method on NPObject.' 'Script error.', 'Uncaught Error: Error calling method on NPObject.'
])) ]))
{ {
// TODO cjs Remote().jsError(
RL.remote().jsError(
Utils.emptyFunction, Utils.emptyFunction,
oEvent.originalEvent.message, oEvent.originalEvent.message,
oEvent.originalEvent.filename, oEvent.originalEvent.filename,
@ -126,32 +131,6 @@
return true; return true;
}; };
/**
* @return {LinkBuilder}
*/
AbstractApp.prototype.link = function ()
{
if (null === this.oLink)
{
this.oLink = new LinkBuilder(); // TODO cjs
}
return this.oLink;
};
/**
* @return {LocalStorage}
*/
AbstractApp.prototype.local = function ()
{
if (null === this.oLocal)
{
this.oLocal = new LocalStorage(); // TODO cjs
}
return this.oLocal;
};
/** /**
* @param {string} sName * @param {string} sName
* @return {?} * @return {?}
@ -183,7 +162,7 @@
AbstractApp.prototype.setTitle = function (sTitle) AbstractApp.prototype.setTitle = function (sTitle)
{ {
sTitle = ((Utils.isNormal(sTitle) && 0 < sTitle.length) ? sTitle + ' - ' : '') + sTitle = ((Utils.isNormal(sTitle) && 0 < sTitle.length) ? sTitle + ' - ' : '') +
RL.settingsGet('Title') || ''; // TODO cjs this.settingsGet('Title') || '';
window.document.title = '_'; window.document.title = '_';
window.document.title = sTitle; window.document.title = sTitle;
@ -196,12 +175,10 @@
AbstractApp.prototype.loginAndLogoutReload = function (bLogout, bClose) AbstractApp.prototype.loginAndLogoutReload = function (bLogout, bClose)
{ {
var var
sCustomLogoutLink = Utils.pString(RL.settingsGet('CustomLogoutLink')), sCustomLogoutLink = Utils.pString(this.settingsGet('CustomLogoutLink')),
bInIframe = !!RL.settingsGet('InIframe') bInIframe = !!this.settingsGet('InIframe')
; ;
// TODO cjs
bLogout = Utils.isUnd(bLogout) ? false : !!bLogout; bLogout = Utils.isUnd(bLogout) ? false : !!bLogout;
bClose = Utils.isUnd(bClose) ? false : !!bClose; bClose = Utils.isUnd(bClose) ? false : !!bClose;
@ -226,7 +203,7 @@
else else
{ {
kn.routeOff(); kn.routeOff();
kn.setHash(RL.link().root(), true); kn.setHash(LinkBuilder.root(), true);
kn.routeOff(); kn.routeOff();
_.delay(function () { _.delay(function () {
@ -307,7 +284,10 @@
AbstractApp.prototype.bootstart = function () AbstractApp.prototype.bootstart = function ()
{ {
var ssm = require('../External/ssm.js'); var
self = this,
ssm = require('../External/ssm.js')
;
Utils.initOnStartOrLangChange(function () { Utils.initOnStartOrLangChange(function () {
Utils.initNotificationLanguage(); Utils.initNotificationLanguage();
@ -322,11 +302,11 @@
'maxWidth': 767, 'maxWidth': 767,
'onEnter': function() { 'onEnter': function() {
$html.addClass('ssm-state-mobile'); $html.addClass('ssm-state-mobile');
RL.pub('ssm.mobile-enter'); self.pub('ssm.mobile-enter');
}, },
'onLeave': function() { 'onLeave': function() {
$html.removeClass('ssm-state-mobile'); $html.removeClass('ssm-state-mobile');
RL.pub('ssm.mobile-leave'); self.pub('ssm.mobile-leave');
} }
}); });
@ -365,12 +345,12 @@
} }
}); });
RL.sub('ssm.mobile-enter', function () { // TODO cjs this.sub('ssm.mobile-enter', function () {
RL.data().leftPanelDisabled(true); RL.data().leftPanelDisabled(true); // TODO cjs
}); });
RL.sub('ssm.mobile-leave', function () { // TODO cjs this.sub('ssm.mobile-leave', function () {
RL.data().leftPanelDisabled(false); RL.data().leftPanelDisabled(false); // TODO cjs
}); });
RL.data().leftPanelDisabled.subscribe(function (bValue) { // TODO cjs RL.data().leftPanelDisabled.subscribe(function (bValue) { // TODO cjs

View file

@ -8,9 +8,16 @@
ko = require('../External/ko.js'), ko = require('../External/ko.js'),
_ = require('../External/underscore.js'), _ = require('../External/underscore.js'),
window = require('../External/window.js'), window = require('../External/window.js'),
Enums = require('../Common/Enums.js'), Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'), Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
kn = require('../Knoin/Knoin.js'), kn = require('../Knoin/Knoin.js'),
Data = require('../Storages/AdminDataStorage.js'),
Remote = require('../Storages/AdminAjaxRemoteStorage.js'),
AbstractApp = require('./AbstractApp.js') AbstractApp = require('./AbstractApp.js')
; ;
@ -59,25 +66,12 @@
return this.oRemote; return this.oRemote;
}; };
/**
* @return {AdminCacheStorage}
*/
AdminApp.prototype.cache = function ()
{
if (null === this.oCache)
{
this.oCache = new AdminCacheStorage(); // TODO cjs
}
return this.oCache;
};
AdminApp.prototype.reloadDomainList = function () AdminApp.prototype.reloadDomainList = function ()
{ {
// TODO cjs // TODO cjs
RL.data().domainsLoading(true); Data.domainsLoading(true);
RL.remote().domainList(function (sResult, oData) { Remote.domainList(function (sResult, oData) {
RL.data().domainsLoading(false); Data.domainsLoading(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
var aList = _.map(oData.Result, function (bEnabled, sName) { var aList = _.map(oData.Result, function (bEnabled, sName) {
@ -88,7 +82,7 @@
}; };
}, this); }, this);
RL.data().domains(aList); Data.domains(aList);
} }
}); });
}; };
@ -96,9 +90,9 @@
AdminApp.prototype.reloadPluginList = function () AdminApp.prototype.reloadPluginList = function ()
{ {
// TODO cjs // TODO cjs
RL.data().pluginsLoading(true); Data.pluginsLoading(true);
RL.remote().pluginList(function (sResult, oData) { Remote.pluginList(function (sResult, oData) {
RL.data().pluginsLoading(false); Data.pluginsLoading(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
var aList = _.map(oData.Result, function (oItem) { var aList = _.map(oData.Result, function (oItem) {
@ -109,7 +103,7 @@
}; };
}, this); }, this);
RL.data().plugins(aList); Data.plugins(aList);
} }
}); });
}; };
@ -117,24 +111,24 @@
AdminApp.prototype.reloadPackagesList = function () AdminApp.prototype.reloadPackagesList = function ()
{ {
// TODO cjs // TODO cjs
RL.data().packagesLoading(true); Data.packagesLoading(true);
RL.data().packagesReal(true); Data.packagesReal(true);
RL.remote().packagesList(function (sResult, oData) { Remote.packagesList(function (sResult, oData) {
RL.data().packagesLoading(false); Data.packagesLoading(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
RL.data().packagesReal(!!oData.Result.Real); Data.packagesReal(!!oData.Result.Real);
RL.data().packagesMainUpdatable(!!oData.Result.MainUpdatable); Data.packagesMainUpdatable(!!oData.Result.MainUpdatable);
var var
aList = [], aList = [],
aLoading = {} aLoading = {}
; ;
_.each(RL.data().packages(), function (oItem) { _.each(Data.packages(), function (oItem) {
if (oItem && oItem['loading']()) if (oItem && oItem['loading']())
{ {
aLoading[oItem['file']] = oItem; aLoading[oItem['file']] = oItem;
@ -153,36 +147,33 @@
})); }));
} }
RL.data().packages(aList); Data.packages(aList);
} }
else else
{ {
RL.data().packagesReal(false); Data.packagesReal(false);
} }
}); });
}; };
AdminApp.prototype.updateCoreData = function () AdminApp.prototype.updateCoreData = function ()
{ {
// TODO cjs Data.coreUpdating(true);
var oRainData = RL.data(); Remote.updateCoreData(function (sResult, oData) {
oRainData.coreUpdating(true); Data.coreUpdating(false);
RL.remote().updateCoreData(function (sResult, oData) { Data.coreRemoteVersion('');
Data.coreRemoteRelease('');
oRainData.coreUpdating(false); Data.coreVersionCompare(-2);
oRainData.coreRemoteVersion('');
oRainData.coreRemoteRelease('');
oRainData.coreVersionCompare(-2);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
oRainData.coreReal(true); Data.coreReal(true);
window.location.reload(); window.location.reload();
} }
else else
{ {
oRainData.coreReal(false); Data.coreReal(false);
} }
}); });
@ -190,30 +181,28 @@
AdminApp.prototype.reloadCoreData = function () AdminApp.prototype.reloadCoreData = function ()
{ {
var oRainData = RL.data(); Data.coreChecking(true);
Data.coreReal(true);
oRainData.coreChecking(true); Remote.coreData(function (sResult, oData) {
oRainData.coreReal(true);
RL.remote().coreData(function (sResult, oData) { Data.coreChecking(false);
oRainData.coreChecking(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
oRainData.coreReal(!!oData.Result.Real); Data.coreReal(!!oData.Result.Real);
oRainData.coreUpdatable(!!oData.Result.Updatable); Data.coreUpdatable(!!oData.Result.Updatable);
oRainData.coreAccess(!!oData.Result.Access); Data.coreAccess(!!oData.Result.Access);
oRainData.coreRemoteVersion(oData.Result.RemoteVersion || ''); Data.coreRemoteVersion(oData.Result.RemoteVersion || '');
oRainData.coreRemoteRelease(oData.Result.RemoteRelease || ''); Data.coreRemoteRelease(oData.Result.RemoteRelease || '');
oRainData.coreVersionCompare(Utils.pInt(oData.Result.VersionCompare)); Data.coreVersionCompare(Utils.pInt(oData.Result.VersionCompare));
} }
else else
{ {
oRainData.coreReal(false); Data.coreReal(false);
oRainData.coreRemoteVersion(''); Data.coreRemoteVersion('');
oRainData.coreRemoteRelease(''); Data.coreRemoteRelease('');
oRainData.coreVersionCompare(-2); Data.coreVersionCompare(-2);
} }
}); });
}; };
@ -227,18 +216,18 @@
bForce = Utils.isUnd(bForce) ? false : !!bForce; bForce = Utils.isUnd(bForce) ? false : !!bForce;
// TODO cjs // TODO cjs
RL.data().licensingProcess(true); Data.licensingProcess(true);
RL.data().licenseError(''); Data.licenseError('');
RL.remote().licensing(function (sResult, oData) { Remote.licensing(function (sResult, oData) {
RL.data().licensingProcess(false); Data.licensingProcess(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && Utils.isNormal(oData.Result['Expired'])) if (Enums.StorageResultType.Success === sResult && oData && oData.Result && Utils.isNormal(oData.Result['Expired']))
{ {
RL.data().licenseValid(true); Data.licenseValid(true);
RL.data().licenseExpired(Utils.pInt(oData.Result['Expired'])); Data.licenseExpired(Utils.pInt(oData.Result['Expired']));
RL.data().licenseError(''); Data.licenseError('');
RL.data().licensing(true); Data.licensing(true);
} }
else else
{ {
@ -247,19 +236,19 @@
Enums.Notification.LicensingExpired Enums.Notification.LicensingExpired
])) ]))
{ {
RL.data().licenseError(Utils.getNotification(Utils.pInt(oData.ErrorCode))); Data.licenseError(Utils.getNotification(Utils.pInt(oData.ErrorCode)));
RL.data().licensing(true); Data.licensing(true);
} }
else else
{ {
if (Enums.StorageResultType.Abort === sResult) if (Enums.StorageResultType.Abort === sResult)
{ {
RL.data().licenseError(Utils.getNotification(Enums.Notification.LicensingServerIsUnavailable)); Data.licenseError(Utils.getNotification(Enums.Notification.LicensingServerIsUnavailable));
RL.data().licensing(true); Data.licensing(true);
} }
else else
{ {
RL.data().licensing(false); Data.licensing(false);
} }
} }
} }
@ -270,14 +259,14 @@
{ {
AbstractApp.prototype.bootstart.call(this); AbstractApp.prototype.bootstart.call(this);
RL.data().populateDataOnStart(); Data.populateDataOnStart();
kn.hideLoading(); kn.hideLoading();
if (!RL.settingsGet('AllowAdminPanel')) if (!RL.settingsGet('AllowAdminPanel'))
{ {
kn.routeOff(); kn.routeOff();
kn.setHash(RL.link().root(), true); kn.setHash(LinkBuilder.root(), true);
kn.routeOff(); kn.routeOff();
_.defer(function () { _.defer(function () {
@ -286,11 +275,11 @@
} }
else else
{ {
// Utils.removeSettingsViewModel(AdminAbout); // kn.removeSettingsViewModel(AdminAbout);
if (!RL.capa(Enums.Capa.Prem)) if (!RL.capa(Enums.Capa.Prem))
{ {
Utils.removeSettingsViewModel(AdminBranding); kn.removeSettingsViewModel(AdminBranding);
} }
if (!!RL.settingsGet('Auth')) if (!!RL.settingsGet('Auth'))
@ -298,7 +287,7 @@
// TODO // TODO
// if (!RL.settingsGet('AllowPackages') && AdminPackages) // if (!RL.settingsGet('AllowPackages') && AdminPackages)
// { // {
// Utils.disableSettingsViewModel(AdminPackages); // kn.disableSettingsViewModel(AdminPackages);
// } // }
kn.startScreens([AdminSettingsScreen]); kn.startScreens([AdminSettingsScreen]);

View file

@ -8,12 +8,24 @@
window = require('../External/window.js'), window = require('../External/window.js'),
$ = require('../External/jquery.js'), $ = require('../External/jquery.js'),
_ = require('../External/underscore.js'), _ = require('../External/underscore.js'),
moment = require('../External/moment.js'),
Enums = require('../Common/Enums.js'), Enums = require('../Common/Enums.js'),
Globals = require('../Common/Globals.js'), Globals = require('../Common/Globals.js'),
Consts = require('../Common/Consts.js'), Consts = require('../Common/Consts.js'),
Plugins = require('../Common/Plugins.js'), Plugins = require('../Common/Plugins.js'),
Utils = require('../Common/Utils.js'), Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
kn = require('../Knoin/Knoin.js'), kn = require('../Knoin/Knoin.js'),
Data = require('../Storages/WebMailDataStorage.js'),
Cache = require('../Storages/WebMailCacheStorage.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
PopupsFolderSystemViewModel = require('../ViewModels/Popups/PopupsAskViewModel.js'),
PopupsAskViewModel = require('../ViewModels/Popups/PopupsAskViewModel.js'),
AbstractApp = require('./AbstractApp.js') AbstractApp = require('./AbstractApp.js')
; ;
@ -66,7 +78,7 @@
}, 60000 * 5); }, 60000 * 5);
$.wakeUp(function () { $.wakeUp(function () {
RL.remote().jsVersion(function (sResult, oData) { Remote.jsVersion(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData && !oData.Result) if (Enums.StorageResultType.Success === sResult && oData && !oData.Result)
{ {
if (window.parent && !!RL.settingsGet('InIframe')) if (window.parent && !!RL.settingsGet('InIframe'))
@ -114,27 +126,13 @@
return this.oRemote; return this.oRemote;
}; };
/**
* @return {WebMailCacheStorage}
*/
RainLoopApp.prototype.cache = function ()
{
if (null === this.oCache)
{
this.oCache = new WebMailCacheStorage();
}
return this.oCache;
};
RainLoopApp.prototype.reloadFlagsCurrentMessageListAndMessageFromCache = function () RainLoopApp.prototype.reloadFlagsCurrentMessageListAndMessageFromCache = function ()
{ {
var oCache = RL.cache(); _.each(Data.messageList(), function (oMessage) {
_.each(RL.data().messageList(), function (oMessage) { Cache.initMessageFlagsFromCache(oMessage);
oCache.initMessageFlagsFromCache(oMessage);
}); });
oCache.initMessageFlagsFromCache(RL.data().message()); Cache.initMessageFlagsFromCache(Data.message());
}; };
/** /**
@ -144,50 +142,49 @@
RainLoopApp.prototype.reloadMessageList = function (bDropPagePosition, bDropCurrenFolderCache) RainLoopApp.prototype.reloadMessageList = function (bDropPagePosition, bDropCurrenFolderCache)
{ {
var var
oRLData = RL.data(), iOffset = (Data.messageListPage() - 1) * Data.messagesPerPage()
iOffset = (oRLData.messageListPage() - 1) * oRLData.messagesPerPage()
; ;
if (Utils.isUnd(bDropCurrenFolderCache) ? false : !!bDropCurrenFolderCache) if (Utils.isUnd(bDropCurrenFolderCache) ? false : !!bDropCurrenFolderCache)
{ {
RL.cache().setFolderHash(oRLData.currentFolderFullNameRaw(), ''); Cache.setFolderHash(Data.currentFolderFullNameRaw(), '');
} }
if (Utils.isUnd(bDropPagePosition) ? false : !!bDropPagePosition) if (Utils.isUnd(bDropPagePosition) ? false : !!bDropPagePosition)
{ {
oRLData.messageListPage(1); Data.messageListPage(1);
iOffset = 0; iOffset = 0;
} }
oRLData.messageListLoading(true); Data.messageListLoading(true);
RL.remote().messageList(function (sResult, oData, bCached) { Remote.messageList(function (sResult, oData, bCached) {
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
oRLData.messageListError(''); Data.messageListError('');
oRLData.messageListLoading(false); Data.messageListLoading(false);
oRLData.setMessageList(oData, bCached); Data.setMessageList(oData, bCached);
} }
else if (Enums.StorageResultType.Unload === sResult) else if (Enums.StorageResultType.Unload === sResult)
{ {
oRLData.messageListError(''); Data.messageListError('');
oRLData.messageListLoading(false); Data.messageListLoading(false);
} }
else if (Enums.StorageResultType.Abort !== sResult) else if (Enums.StorageResultType.Abort !== sResult)
{ {
oRLData.messageList([]); Data.messageList([]);
oRLData.messageListLoading(false); Data.messageListLoading(false);
oRLData.messageListError(oData && oData.ErrorCode ? Data.messageListError(oData && oData.ErrorCode ?
Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_GET_MESSAGE_LIST') Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_GET_MESSAGE_LIST')
); );
} }
}, oRLData.currentFolderFullNameRaw(), iOffset, oRLData.messagesPerPage(), oRLData.messageListSearch()); }, Data.currentFolderFullNameRaw(), iOffset, Data.messagesPerPage(), Data.messageListSearch());
}; };
RainLoopApp.prototype.recacheInboxMessageList = function () RainLoopApp.prototype.recacheInboxMessageList = function ()
{ {
RL.remote().messageList(Utils.emptyFunction, 'INBOX', 0, RL.data().messagesPerPage(), '', true); Remote.messageList(Utils.emptyFunction, 'INBOX', 0, Data.messagesPerPage(), '', true);
}; };
RainLoopApp.prototype.reloadMessageListHelper = function (bEmptyList) RainLoopApp.prototype.reloadMessageListHelper = function (bEmptyList)
@ -201,15 +198,15 @@
*/ */
RainLoopApp.prototype.contactsSync = function (fResultFunc) RainLoopApp.prototype.contactsSync = function (fResultFunc)
{ {
var oContacts = RL.data().contacts; var oContacts = Data.contacts;
if (oContacts.importing() || oContacts.syncing() || !RL.data().enableContactsSync() || !RL.data().allowContactsSync()) if (oContacts.importing() || oContacts.syncing() || !Data.enableContactsSync() || !Data.allowContactsSync())
{ {
return false; return false;
} }
oContacts.syncing(true); oContacts.syncing(true);
RL.remote().contactsSync(function (sResult, oData) { Remote.contactsSync(function (sResult, oData) {
oContacts.syncing(false); oContacts.syncing(false);
@ -226,7 +223,7 @@
{ {
var var
self = this, self = this,
sSpamFolder = RL.data().spamFolder() sSpamFolder = Data.spamFolder()
; ;
_.each(this.oMoveCache, function (oItem) { _.each(this.oMoveCache, function (oItem) {
@ -236,7 +233,7 @@
bHam = !bSpam && sSpamFolder === oItem['From'] && 'INBOX' === oItem['To'] bHam = !bSpam && sSpamFolder === oItem['From'] && 'INBOX' === oItem['To']
; ;
RL.remote().messagesMove(self.moveOrDeleteResponseHelper, oItem['From'], oItem['To'], oItem['Uid'], Remote.messagesMove(self.moveOrDeleteResponseHelper, oItem['From'], oItem['To'], oItem['Uid'],
bSpam ? 'SPAM' : (bHam ? 'HAM' : '')); bSpam ? 'SPAM' : (bHam ? 'HAM' : ''));
}); });
@ -261,7 +258,7 @@
RainLoopApp.prototype.messagesCopyHelper = function (sFromFolderFullNameRaw, sToFolderFullNameRaw, aUidForCopy) RainLoopApp.prototype.messagesCopyHelper = function (sFromFolderFullNameRaw, sToFolderFullNameRaw, aUidForCopy)
{ {
RL.remote().messagesCopy( Remote.messagesCopy(
this.moveOrDeleteResponseHelper, this.moveOrDeleteResponseHelper,
sFromFolderFullNameRaw, sFromFolderFullNameRaw,
sToFolderFullNameRaw, sToFolderFullNameRaw,
@ -271,7 +268,7 @@
RainLoopApp.prototype.messagesDeleteHelper = function (sFromFolderFullNameRaw, aUidForRemove) RainLoopApp.prototype.messagesDeleteHelper = function (sFromFolderFullNameRaw, aUidForRemove)
{ {
RL.remote().messagesDelete( Remote.messagesDelete(
this.moveOrDeleteResponseHelper, this.moveOrDeleteResponseHelper,
sFromFolderFullNameRaw, sFromFolderFullNameRaw,
aUidForRemove aUidForRemove
@ -280,15 +277,15 @@
RainLoopApp.prototype.moveOrDeleteResponseHelper = function (sResult, oData) RainLoopApp.prototype.moveOrDeleteResponseHelper = function (sResult, oData)
{ {
if (Enums.StorageResultType.Success === sResult && RL.data().currentFolder()) if (Enums.StorageResultType.Success === sResult && Data.currentFolder())
{ {
if (oData && Utils.isArray(oData.Result) && 2 === oData.Result.length) if (oData && Utils.isArray(oData.Result) && 2 === oData.Result.length)
{ {
RL.cache().setFolderHash(oData.Result[0], oData.Result[1]); Cache.setFolderHash(oData.Result[0], oData.Result[1]);
} }
else else
{ {
RL.cache().setFolderHash(RL.data().currentFolderFullNameRaw(), ''); Cache.setFolderHash(Data.currentFolderFullNameRaw(), '');
if (oData && -1 < Utils.inArray(oData.ErrorCode, if (oData && -1 < Utils.inArray(oData.ErrorCode,
[Enums.Notification.CantMoveMessage, Enums.Notification.CantCopyMessage])) [Enums.Notification.CantMoveMessage, Enums.Notification.CantCopyMessage]))
@ -297,7 +294,7 @@
} }
} }
RL.reloadMessageListHelper(0 === RL.data().messageList().length); RL.reloadMessageListHelper(0 === Data.messageList().length);
RL.quotaDebounce(); RL.quotaDebounce();
} }
}; };
@ -309,7 +306,7 @@
RainLoopApp.prototype.deleteMessagesFromFolderWithoutCheck = function (sFromFolderFullNameRaw, aUidForRemove) RainLoopApp.prototype.deleteMessagesFromFolderWithoutCheck = function (sFromFolderFullNameRaw, aUidForRemove)
{ {
this.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove); this.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove);
RL.data().removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); Data.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove);
}; };
/** /**
@ -322,8 +319,6 @@
{ {
var var
self = this, self = this,
oData = RL.data(),
oCache = RL.cache(),
oMoveFolder = null, oMoveFolder = null,
nSetSystemFoldersNotification = null nSetSystemFoldersNotification = null
; ;
@ -331,18 +326,18 @@
switch (iDeleteType) switch (iDeleteType)
{ {
case Enums.FolderType.Spam: case Enums.FolderType.Spam:
oMoveFolder = oCache.getFolderFromCacheList(oData.spamFolder()); oMoveFolder = Cache.getFolderFromCacheList(Data.spamFolder());
nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Spam; nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Spam;
break; break;
case Enums.FolderType.NotSpam: case Enums.FolderType.NotSpam:
oMoveFolder = oCache.getFolderFromCacheList('INBOX'); oMoveFolder = Cache.getFolderFromCacheList('INBOX');
break; break;
case Enums.FolderType.Trash: case Enums.FolderType.Trash:
oMoveFolder = oCache.getFolderFromCacheList(oData.trashFolder()); oMoveFolder = Cache.getFolderFromCacheList(Data.trashFolder());
nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Trash; nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Trash;
break; break;
case Enums.FolderType.Archive: case Enums.FolderType.Archive:
oMoveFolder = oCache.getFolderFromCacheList(oData.archiveFolder()); oMoveFolder = Cache.getFolderFromCacheList(Data.archiveFolder());
nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Archive; nSetSystemFoldersNotification = Enums.SetSystemFoldersNotification.Archive;
break; break;
} }
@ -350,9 +345,9 @@
bUseFolder = Utils.isUnd(bUseFolder) ? true : !!bUseFolder; bUseFolder = Utils.isUnd(bUseFolder) ? true : !!bUseFolder;
if (bUseFolder) if (bUseFolder)
{ {
if ((Enums.FolderType.Spam === iDeleteType && Consts.Values.UnuseOptionValue === oData.spamFolder()) || if ((Enums.FolderType.Spam === iDeleteType && Consts.Values.UnuseOptionValue === Data.spamFolder()) ||
(Enums.FolderType.Trash === iDeleteType && Consts.Values.UnuseOptionValue === oData.trashFolder()) || (Enums.FolderType.Trash === iDeleteType && Consts.Values.UnuseOptionValue === Data.trashFolder()) ||
(Enums.FolderType.Archive === iDeleteType && Consts.Values.UnuseOptionValue === oData.archiveFolder())) (Enums.FolderType.Archive === iDeleteType && Consts.Values.UnuseOptionValue === Data.archiveFolder()))
{ {
bUseFolder = false; bUseFolder = false;
} }
@ -363,19 +358,19 @@
kn.showScreenPopup(PopupsFolderSystemViewModel, [nSetSystemFoldersNotification]); kn.showScreenPopup(PopupsFolderSystemViewModel, [nSetSystemFoldersNotification]);
} }
else if (!bUseFolder || (Enums.FolderType.Trash === iDeleteType && else if (!bUseFolder || (Enums.FolderType.Trash === iDeleteType &&
(sFromFolderFullNameRaw === oData.spamFolder() || sFromFolderFullNameRaw === oData.trashFolder()))) (sFromFolderFullNameRaw === Data.spamFolder() || sFromFolderFullNameRaw === Data.trashFolder())))
{ {
kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), function () { kn.showScreenPopup(PopupsAskViewModel, [Utils.i18n('POPUPS_ASK/DESC_WANT_DELETE_MESSAGES'), function () {
self.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove); self.messagesDeleteHelper(sFromFolderFullNameRaw, aUidForRemove);
oData.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove); Data.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove);
}]); }]);
} }
else if (oMoveFolder) else if (oMoveFolder)
{ {
this.messagesMoveHelper(sFromFolderFullNameRaw, oMoveFolder.fullNameRaw, aUidForRemove); this.messagesMoveHelper(sFromFolderFullNameRaw, oMoveFolder.fullNameRaw, aUidForRemove);
oData.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove, oMoveFolder.fullNameRaw); Data.removeMessagesFromList(sFromFolderFullNameRaw, aUidForRemove, oMoveFolder.fullNameRaw);
} }
}; };
@ -390,8 +385,8 @@
if (sFromFolderFullNameRaw !== sToFolderFullNameRaw && Utils.isArray(aUidForMove) && 0 < aUidForMove.length) if (sFromFolderFullNameRaw !== sToFolderFullNameRaw && Utils.isArray(aUidForMove) && 0 < aUidForMove.length)
{ {
var var
oFromFolder = RL.cache().getFolderFromCacheList(sFromFolderFullNameRaw), oFromFolder = Cache.getFolderFromCacheList(sFromFolderFullNameRaw),
oToFolder = RL.cache().getFolderFromCacheList(sToFolderFullNameRaw) oToFolder = Cache.getFolderFromCacheList(sToFolderFullNameRaw)
; ;
if (oFromFolder && oToFolder) if (oFromFolder && oToFolder)
@ -405,7 +400,7 @@
this.messagesMoveHelper(oFromFolder.fullNameRaw, oToFolder.fullNameRaw, aUidForMove); this.messagesMoveHelper(oFromFolder.fullNameRaw, oToFolder.fullNameRaw, aUidForMove);
} }
RL.data().removeMessagesFromList(oFromFolder.fullNameRaw, aUidForMove, oToFolder.fullNameRaw, bCopy); Data.removeMessagesFromList(oFromFolder.fullNameRaw, aUidForMove, oToFolder.fullNameRaw, bCopy);
return true; return true;
} }
} }
@ -421,7 +416,7 @@
this.data().foldersLoading(true); this.data().foldersLoading(true);
this.remote().folders(_.bind(function (sResult, oData) { this.remote().folders(_.bind(function (sResult, oData) {
RL.data().foldersLoading(false); Data.foldersLoading(false);
if (Enums.StorageResultType.Success === sResult) if (Enums.StorageResultType.Success === sResult)
{ {
this.data().setFolders(oData); this.data().setFolders(oData);
@ -442,12 +437,12 @@
RainLoopApp.prototype.reloadOpenPgpKeys = function () RainLoopApp.prototype.reloadOpenPgpKeys = function ()
{ {
if (RL.data().capaOpenPGP()) if (Data.capaOpenPGP())
{ {
var var
aKeys = [], aKeys = [],
oEmail = new EmailModel(), oEmail = new EmailModel(),
oOpenpgpKeyring = RL.data().openpgpKeyring, oOpenpgpKeyring = Data.openpgpKeyring,
oOpenpgpKeys = oOpenpgpKeyring ? oOpenpgpKeyring.getAllKeys() : [] oOpenpgpKeys = oOpenpgpKeyring ? oOpenpgpKeyring.getAllKeys() : []
; ;
@ -479,41 +474,39 @@
} }
}); });
RL.data().openpgpkeys(aKeys); Data.openpgpkeys(aKeys);
} }
}; };
RainLoopApp.prototype.accountsAndIdentities = function () RainLoopApp.prototype.accountsAndIdentities = function ()
{ {
var oRainLoopData = RL.data(); Data.accountsLoading(true);
Data.identitiesLoading(true);
oRainLoopData.accountsLoading(true); Remote.accountsAndIdentities(function (sResult, oData) {
oRainLoopData.identitiesLoading(true);
RL.remote().accountsAndIdentities(function (sResult, oData) { Data.accountsLoading(false);
Data.identitiesLoading(false);
oRainLoopData.accountsLoading(false);
oRainLoopData.identitiesLoading(false);
if (Enums.StorageResultType.Success === sResult && oData.Result) if (Enums.StorageResultType.Success === sResult && oData.Result)
{ {
var var
sParentEmail = RL.settingsGet('ParentEmail'), sParentEmail = RL.settingsGet('ParentEmail'),
sAccountEmail = oRainLoopData.accountEmail() sAccountEmail = Data.accountEmail()
; ;
sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail; sParentEmail = '' === sParentEmail ? sAccountEmail : sParentEmail;
if (Utils.isArray(oData.Result['Accounts'])) if (Utils.isArray(oData.Result['Accounts']))
{ {
oRainLoopData.accounts(_.map(oData.Result['Accounts'], function (sValue) { Data.accounts(_.map(oData.Result['Accounts'], function (sValue) {
return new AccountModel(sValue, sValue !== sParentEmail); return new AccountModel(sValue, sValue !== sParentEmail);
})); }));
} }
if (Utils.isArray(oData.Result['Identities'])) if (Utils.isArray(oData.Result['Identities']))
{ {
oRainLoopData.identities(_.map(oData.Result['Identities'], function (oIdentityData) { Data.identities(_.map(oData.Result['Identities'], function (oIdentityData) {
var var
sId = Utils.pString(oIdentityData['Id']), sId = Utils.pString(oIdentityData['Id']),
@ -539,8 +532,8 @@
Utils.isArray(oData.Result) && 1 < oData.Result.length && Utils.isArray(oData.Result) && 1 < oData.Result.length &&
Utils.isPosNumeric(oData.Result[0], true) && Utils.isPosNumeric(oData.Result[1], true)) Utils.isPosNumeric(oData.Result[0], true) && Utils.isPosNumeric(oData.Result[1], true))
{ {
RL.data().userQuota(Utils.pInt(oData.Result[1]) * 1024); Data.userQuota(Utils.pInt(oData.Result[1]) * 1024);
RL.data().userUsageSize(Utils.pInt(oData.Result[0]) * 1024); Data.userUsageSize(Utils.pInt(oData.Result[0]) * 1024);
} }
}); });
}; };
@ -560,8 +553,8 @@
{ {
var var
iUtc = moment().unix(), iUtc = moment().unix(),
sHash = RL.cache().getFolderHash(oData.Result.Folder), sHash = Cache.getFolderHash(oData.Result.Folder),
oFolder = RL.cache().getFolderFromCacheList(oData.Result.Folder), oFolder = Cache.getFolderFromCacheList(oData.Result.Folder),
bCheck = false, bCheck = false,
sUid = '', sUid = '',
aList = [], aList = [],
@ -575,7 +568,7 @@
if (oData.Result.Hash) if (oData.Result.Hash)
{ {
RL.cache().setFolderHash(oData.Result.Folder, oData.Result.Hash); Cache.setFolderHash(oData.Result.Folder, oData.Result.Hash);
} }
if (Utils.isNormal(oData.Result.MessageCount)) if (Utils.isNormal(oData.Result.MessageCount))
@ -595,7 +588,7 @@
if (bUnreadCountChange) if (bUnreadCountChange)
{ {
RL.cache().clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw); Cache.clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw);
} }
if (oData.Result.Flags) if (oData.Result.Flags)
@ -606,7 +599,7 @@
{ {
bCheck = true; bCheck = true;
oFlags = oData.Result.Flags[sUid]; oFlags = oData.Result.Flags[sUid];
RL.cache().storeMessageFlagsToCacheByFolderAndUid(oFolder.fullNameRaw, sUid.toString(), [ Cache.storeMessageFlagsToCacheByFolderAndUid(oFolder.fullNameRaw, sUid.toString(), [
!oFlags['IsSeen'], !!oFlags['IsFlagged'], !!oFlags['IsAnswered'], !!oFlags['IsForwarded'], !!oFlags['IsReadReceipt'] !oFlags['IsSeen'], !!oFlags['IsFlagged'], !!oFlags['IsAnswered'], !!oFlags['IsForwarded'], !!oFlags['IsReadReceipt']
]); ]);
} }
@ -618,11 +611,11 @@
} }
} }
RL.data().initUidNextAndNewMessages(oFolder.fullNameRaw, oData.Result.UidNext, oData.Result.NewMessages); Data.initUidNextAndNewMessages(oFolder.fullNameRaw, oData.Result.UidNext, oData.Result.NewMessages);
if (oData.Result.Hash !== sHash || '' === sHash) if (oData.Result.Hash !== sHash || '' === sHash)
{ {
if (oFolder.fullNameRaw === RL.data().currentFolderFullNameRaw()) if (oFolder.fullNameRaw === Data.currentFolderFullNameRaw())
{ {
RL.reloadMessageList(); RL.reloadMessageList();
} }
@ -633,9 +626,9 @@
} }
else if (bUnreadCountChange) else if (bUnreadCountChange)
{ {
if (oFolder.fullNameRaw === RL.data().currentFolderFullNameRaw()) if (oFolder.fullNameRaw === Data.currentFolderFullNameRaw())
{ {
aList = RL.data().messageList(); aList = Data.messageList();
if (Utils.isNonEmptyArray(aList)) if (Utils.isNonEmptyArray(aList))
{ {
RL.folderInformation(oFolder.fullNameRaw, aList); RL.folderInformation(oFolder.fullNameRaw, aList);
@ -658,7 +651,7 @@
var var
iUtc = moment().unix(), iUtc = moment().unix(),
aFolders = RL.data().getNextFolderNames(bBoot) aFolders = Data.getNextFolderNames(bBoot)
; ;
if (Utils.isNonEmptyArray(aFolders)) if (Utils.isNonEmptyArray(aFolders))
@ -672,8 +665,8 @@
var var
aList = [], aList = [],
sHash = RL.cache().getFolderHash(oItem.Folder), sHash = Cache.getFolderHash(oItem.Folder),
oFolder = RL.cache().getFolderFromCacheList(oItem.Folder), oFolder = Cache.getFolderFromCacheList(oItem.Folder),
bUnreadCountChange = false bUnreadCountChange = false
; ;
@ -683,7 +676,7 @@
if (oItem.Hash) if (oItem.Hash)
{ {
RL.cache().setFolderHash(oItem.Folder, oItem.Hash); Cache.setFolderHash(oItem.Folder, oItem.Hash);
} }
if (Utils.isNormal(oItem.MessageCount)) if (Utils.isNormal(oItem.MessageCount))
@ -703,21 +696,21 @@
if (bUnreadCountChange) if (bUnreadCountChange)
{ {
RL.cache().clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw); Cache.clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw);
} }
if (oItem.Hash !== sHash || '' === sHash) if (oItem.Hash !== sHash || '' === sHash)
{ {
if (oFolder.fullNameRaw === RL.data().currentFolderFullNameRaw()) if (oFolder.fullNameRaw === Data.currentFolderFullNameRaw())
{ {
RL.reloadMessageList(); RL.reloadMessageList();
} }
} }
else if (bUnreadCountChange) else if (bUnreadCountChange)
{ {
if (oFolder.fullNameRaw === RL.data().currentFolderFullNameRaw()) if (oFolder.fullNameRaw === Data.currentFolderFullNameRaw())
{ {
aList = RL.data().messageList(); aList = Data.messageList();
if (Utils.isNonEmptyArray(aList)) if (Utils.isNonEmptyArray(aList))
{ {
RL.folderInformation(oFolder.fullNameRaw, aList); RL.folderInformation(oFolder.fullNameRaw, aList);
@ -743,33 +736,33 @@
{ {
oMessage.unseen(false); oMessage.unseen(false);
var oFolder = RL.cache().getFolderFromCacheList(oMessage.folderFullNameRaw); var oFolder = Cache.getFolderFromCacheList(oMessage.folderFullNameRaw);
if (oFolder) if (oFolder)
{ {
oFolder.messageCountUnread(0 <= oFolder.messageCountUnread() - 1 ? oFolder.messageCountUnread(0 <= oFolder.messageCountUnread() - 1 ?
oFolder.messageCountUnread() - 1 : 0); oFolder.messageCountUnread() - 1 : 0);
} }
RL.cache().storeMessageFlagsToCache(oMessage); Cache.storeMessageFlagsToCache(oMessage);
RL.reloadFlagsCurrentMessageListAndMessageFromCache(); RL.reloadFlagsCurrentMessageListAndMessageFromCache();
} }
RL.remote().messageSetSeen(Utils.emptyFunction, oMessage.folderFullNameRaw, [oMessage.uid], true); Remote.messageSetSeen(Utils.emptyFunction, oMessage.folderFullNameRaw, [oMessage.uid], true);
}; };
RainLoopApp.prototype.googleConnect = function () RainLoopApp.prototype.googleConnect = function ()
{ {
window.open(RL.link().socialGoogle(), 'Google', 'left=200,top=100,width=650,height=600,menubar=no,status=no,resizable=yes,scrollbars=yes'); window.open(LinkBuilder.socialGoogle(), 'Google', 'left=200,top=100,width=650,height=600,menubar=no,status=no,resizable=yes,scrollbars=yes');
}; };
RainLoopApp.prototype.twitterConnect = function () RainLoopApp.prototype.twitterConnect = function ()
{ {
window.open(RL.link().socialTwitter(), 'Twitter', 'left=200,top=100,width=650,height=350,menubar=no,status=no,resizable=yes,scrollbars=yes'); window.open(LinkBuilder.socialTwitter(), 'Twitter', 'left=200,top=100,width=650,height=350,menubar=no,status=no,resizable=yes,scrollbars=yes');
}; };
RainLoopApp.prototype.facebookConnect = function () RainLoopApp.prototype.facebookConnect = function ()
{ {
window.open(RL.link().socialFacebook(), 'Facebook', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes'); window.open(LinkBuilder.socialFacebook(), 'Facebook', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
}; };
/** /**
@ -777,60 +770,58 @@
*/ */
RainLoopApp.prototype.socialUsers = function (bFireAllActions) RainLoopApp.prototype.socialUsers = function (bFireAllActions)
{ {
var oRainLoopData = RL.data();
if (bFireAllActions) if (bFireAllActions)
{ {
oRainLoopData.googleActions(true); Data.googleActions(true);
oRainLoopData.facebookActions(true); Data.facebookActions(true);
oRainLoopData.twitterActions(true); Data.twitterActions(true);
} }
RL.remote().socialUsers(function (sResult, oData) { Remote.socialUsers(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
oRainLoopData.googleUserName(oData.Result['Google'] || ''); Data.googleUserName(oData.Result['Google'] || '');
oRainLoopData.facebookUserName(oData.Result['Facebook'] || ''); Data.facebookUserName(oData.Result['Facebook'] || '');
oRainLoopData.twitterUserName(oData.Result['Twitter'] || ''); Data.twitterUserName(oData.Result['Twitter'] || '');
} }
else else
{ {
oRainLoopData.googleUserName(''); Data.googleUserName('');
oRainLoopData.facebookUserName(''); Data.facebookUserName('');
oRainLoopData.twitterUserName(''); Data.twitterUserName('');
} }
oRainLoopData.googleLoggined('' !== oRainLoopData.googleUserName()); Data.googleLoggined('' !== Data.googleUserName());
oRainLoopData.facebookLoggined('' !== oRainLoopData.facebookUserName()); Data.facebookLoggined('' !== Data.facebookUserName());
oRainLoopData.twitterLoggined('' !== oRainLoopData.twitterUserName()); Data.twitterLoggined('' !== Data.twitterUserName());
oRainLoopData.googleActions(false); Data.googleActions(false);
oRainLoopData.facebookActions(false); Data.facebookActions(false);
oRainLoopData.twitterActions(false); Data.twitterActions(false);
}); });
}; };
RainLoopApp.prototype.googleDisconnect = function () RainLoopApp.prototype.googleDisconnect = function ()
{ {
RL.data().googleActions(true); Data.googleActions(true);
RL.remote().googleDisconnect(function () { Remote.googleDisconnect(function () {
RL.socialUsers(); RL.socialUsers();
}); });
}; };
RainLoopApp.prototype.facebookDisconnect = function () RainLoopApp.prototype.facebookDisconnect = function ()
{ {
RL.data().facebookActions(true); Data.facebookActions(true);
RL.remote().facebookDisconnect(function () { Remote.facebookDisconnect(function () {
RL.socialUsers(); RL.socialUsers();
}); });
}; };
RainLoopApp.prototype.twitterDisconnect = function () RainLoopApp.prototype.twitterDisconnect = function ()
{ {
RL.data().twitterActions(true); Data.twitterActions(true);
RL.remote().twitterDisconnect(function () { Remote.twitterDisconnect(function () {
RL.socialUsers(); RL.socialUsers();
}); });
}; };
@ -974,7 +965,7 @@
aData = [] aData = []
; ;
RL.remote().suggestions(function (sResult, oData) { Remote.suggestions(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData && Utils.isArray(oData.Result)) if (Enums.StorageResultType.Success === sResult && oData && Utils.isArray(oData.Result))
{ {
aData = _.map(oData.Result, function (aItem) { aData = _.map(oData.Result, function (aItem) {
@ -997,7 +988,7 @@
*/ */
RainLoopApp.prototype.getContactTagsAutocomplete = function (sQuery, fCallback) RainLoopApp.prototype.getContactTagsAutocomplete = function (sQuery, fCallback)
{ {
fCallback(_.filter(RL.data().contactTags(), function (oContactTag) { fCallback(_.filter(Data.contactTags(), function (oContactTag) {
return oContactTag && oContactTag.filterHelper(sQuery); return oContactTag && oContactTag.filterHelper(sQuery);
})); }));
}; };
@ -1042,7 +1033,7 @@
RL.pub('rl.bootstart'); RL.pub('rl.bootstart');
AbstractApp.prototype.bootstart.call(this); AbstractApp.prototype.bootstart.call(this);
RL.data().populateDataOnStart(); Data.populateDataOnStart();
var var
sCustomLoginLink = '', sCustomLoginLink = '',
@ -1055,51 +1046,51 @@
if (!RL.settingsGet('ChangePasswordIsAllowed')) if (!RL.settingsGet('ChangePasswordIsAllowed'))
{ {
Utils.removeSettingsViewModel(SettingsChangePasswordScreen); kn.removeSettingsViewModel(SettingsChangePasswordScreen);
} }
if (!RL.settingsGet('ContactsIsAllowed')) if (!RL.settingsGet('ContactsIsAllowed'))
{ {
Utils.removeSettingsViewModel(SettingsContacts); kn.removeSettingsViewModel(SettingsContacts);
} }
if (!RL.capa(Enums.Capa.AdditionalAccounts)) if (!RL.capa(Enums.Capa.AdditionalAccounts))
{ {
Utils.removeSettingsViewModel(SettingsAccounts); kn.removeSettingsViewModel(SettingsAccounts);
} }
if (RL.capa(Enums.Capa.AdditionalIdentities)) if (RL.capa(Enums.Capa.AdditionalIdentities))
{ {
Utils.removeSettingsViewModel(SettingsIdentity); kn.removeSettingsViewModel(SettingsIdentity);
} }
else else
{ {
Utils.removeSettingsViewModel(SettingsIdentities); kn.removeSettingsViewModel(SettingsIdentities);
} }
if (!RL.capa(Enums.Capa.OpenPGP)) if (!RL.capa(Enums.Capa.OpenPGP))
{ {
Utils.removeSettingsViewModel(SettingsOpenPGP); kn.removeSettingsViewModel(SettingsOpenPGP);
} }
if (!RL.capa(Enums.Capa.TwoFactor)) if (!RL.capa(Enums.Capa.TwoFactor))
{ {
Utils.removeSettingsViewModel(SettingsSecurity); kn.removeSettingsViewModel(SettingsSecurity);
} }
if (!RL.capa(Enums.Capa.Themes)) if (!RL.capa(Enums.Capa.Themes))
{ {
Utils.removeSettingsViewModel(SettingsThemes); kn.removeSettingsViewModel(SettingsThemes);
} }
if (!RL.capa(Enums.Capa.Filters)) if (!RL.capa(Enums.Capa.Filters))
{ {
Utils.removeSettingsViewModel(SettingsFilters); kn.removeSettingsViewModel(SettingsFilters);
} }
if (!bGoogle && !bFacebook && !bTwitter) if (!bGoogle && !bFacebook && !bTwitter)
{ {
Utils.removeSettingsViewModel(SettingsSocialScreen); kn.removeSettingsViewModel(SettingsSocialScreen);
} }
Utils.initOnStartOrLangChange(function () { Utils.initOnStartOrLangChange(function () {
@ -1140,11 +1131,11 @@
{ {
if (window.$LAB && window.crypto && window.crypto.getRandomValues && RL.capa(Enums.Capa.OpenPGP)) if (window.$LAB && window.crypto && window.crypto.getRandomValues && RL.capa(Enums.Capa.OpenPGP))
{ {
window.$LAB.script(window.openpgp ? '' : RL.link().openPgpJs()).wait(function () { window.$LAB.script(window.openpgp ? '' : LinkBuilder.openPgpJs()).wait(function () {
if (window.openpgp) if (window.openpgp)
{ {
RL.data().openpgpKeyring = new window.openpgp.Keyring(); Data.openpgpKeyring = new window.openpgp.Keyring();
RL.data().capaOpenPGP(true); Data.capaOpenPGP(true);
RL.pub('openpgp.init'); RL.pub('openpgp.init');
@ -1154,7 +1145,7 @@
} }
else else
{ {
RL.data().capaOpenPGP(false); Data.capaOpenPGP(false);
} }
kn.startScreens([MailBoxScreen, SettingsScreen]); kn.startScreens([MailBoxScreen, SettingsScreen]);
@ -1169,7 +1160,7 @@
}); });
RL.sub('interval.2m', function () { RL.sub('interval.2m', function () {
var sF = RL.data().currentFolderFullNameRaw(); var sF = Data.currentFolderFullNameRaw();
if ('INBOX' !== sF) if ('INBOX' !== sF)
{ {
RL.folderInformation(sF); RL.folderInformation(sF);
@ -1263,7 +1254,7 @@
else else
{ {
kn.routeOff(); kn.routeOff();
kn.setHash(RL.link().root(), true); kn.setHash(LinkBuilder.root(), true);
kn.routeOff(); kn.routeOff();
_.defer(function () { _.defer(function () {
@ -1275,7 +1266,7 @@
if (bGoogle) if (bGoogle)
{ {
window['rl_' + sJsHash + '_google_service'] = function () { window['rl_' + sJsHash + '_google_service'] = function () {
RL.data().googleActions(true); Data.googleActions(true);
RL.socialUsers(); RL.socialUsers();
}; };
} }
@ -1283,7 +1274,7 @@
if (bFacebook) if (bFacebook)
{ {
window['rl_' + sJsHash + '_facebook_service'] = function () { window['rl_' + sJsHash + '_facebook_service'] = function () {
RL.data().facebookActions(true); Data.facebookActions(true);
RL.socialUsers(); RL.socialUsers();
}; };
} }
@ -1291,7 +1282,7 @@
if (bTwitter) if (bTwitter)
{ {
window['rl_' + sJsHash + '_twitter_service'] = function () { window['rl_' + sJsHash + '_twitter_service'] = function () {
RL.data().twitterActions(true); Data.twitterActions(true);
RL.socialUsers(); RL.socialUsers();
}; };
} }

View file

@ -323,6 +323,6 @@
return this.sServer + 'SocialFacebook' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : ''); return this.sServer + 'SocialFacebook' + ('' !== this.sSpecSuffix ? '/' + this.sSpecSuffix + '/' : '');
}; };
module.exports = LinkBuilder; module.exports = new LinkBuilder();
}(module)); }(module));

View file

@ -6,7 +6,9 @@
var var
Plugins = {}, Plugins = {},
Utils = require('./Utils.js') Utils = require('./Utils.js'),
Remote = require('../Remote.js'),
RL = require('../RL.js')
; ;
/** /**
@ -70,7 +72,7 @@
*/ */
Plugins.mainSettingsGet = function (sName) Plugins.mainSettingsGet = function (sName)
{ {
return RL ? RL.settingsGet(sName) : null; // TODO cjs return RL ? RL().settingsGet(sName) : null;
}; };
/** /**
@ -83,9 +85,9 @@
*/ */
Plugins.remoteRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions) Plugins.remoteRequest = function (fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions)
{ {
if (RL) // TODO cjs if (Remote)
{ {
RL.remote().defaultRequest(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions); // TODO cjs Remote().defaultRequest(fCallback, sAction, oParameters, iTimeout, sGetAdd, aAbortActions);
} }
}; };

View file

@ -6,13 +6,20 @@
var var
Utils = {}, Utils = {},
$ = require('../External/jquery.js'), $ = require('../External/jquery.js'),
_ = require('../External/underscore.js'), _ = require('../External/underscore.js'),
ko = require('../External/ko.js'), ko = require('../External/ko.js'),
key = require('../External/key.js'),
window = require('../External/window.js'), window = require('../External/window.js'),
$window = require('../External/$window.js'), $window = require('../External/$window.js'),
$doc = require('../External/$doc.js'), $doc = require('../External/$doc.js'),
NotificationClass = require('../External/NotificationClass.js'), NotificationClass = require('../External/NotificationClass.js'),
LocalStorage = require('../Storages/LocalStorage.js'),
kn = require('../Knoin/Knoin.js'),
Enums = require('./Enums.js'), Enums = require('./Enums.js'),
Globals = require('./Globals.js') Globals = require('./Globals.js')
; ;
@ -1240,7 +1247,7 @@
*/ */
Utils.isFolderExpanded = function (sFullNameHash) Utils.isFolderExpanded = function (sFullNameHash)
{ {
var aExpandedList = /** @type {Array|null} */ RL.local().get(Enums.ClientSideKeyName.ExpandedFolders); var aExpandedList = /** @type {Array|null} */ LocalStorage.get(Enums.ClientSideKeyName.ExpandedFolders);
return _.isArray(aExpandedList) && -1 !== _.indexOf(aExpandedList, sFullNameHash); return _.isArray(aExpandedList) && -1 !== _.indexOf(aExpandedList, sFullNameHash);
}; };
@ -1250,7 +1257,7 @@
*/ */
Utils.setExpandedFolder = function (sFullNameHash, bExpanded) Utils.setExpandedFolder = function (sFullNameHash, bExpanded)
{ {
var aExpandedList = /** @type {Array|null} */ RL.local().get(Enums.ClientSideKeyName.ExpandedFolders); var aExpandedList = /** @type {Array|null} */ LocalStorage.get(Enums.ClientSideKeyName.ExpandedFolders);
if (!_.isArray(aExpandedList)) if (!_.isArray(aExpandedList))
{ {
aExpandedList = []; aExpandedList = [];
@ -1266,7 +1273,7 @@
aExpandedList = _.without(aExpandedList, sFullNameHash); aExpandedList = _.without(aExpandedList, sFullNameHash);
} }
RL.local().set(Enums.ClientSideKeyName.ExpandedFolders, aExpandedList); LocalStorage.set(Enums.ClientSideKeyName.ExpandedFolders, aExpandedList);
}; };
Utils.initLayoutResizer = function (sLeft, sRight, sClientSideKeyName) Utils.initLayoutResizer = function (sLeft, sRight, sClientSideKeyName)
@ -1277,7 +1284,7 @@
oLeft = $(sLeft), oLeft = $(sLeft),
oRight = $(sRight), oRight = $(sRight),
mLeftWidth = RL.local().get(sClientSideKeyName) || null, mLeftWidth = LocalStorage.get(sClientSideKeyName) || null,
fSetWidth = function (iWidth) { fSetWidth = function (iWidth) {
if (iWidth) if (iWidth)
@ -1301,7 +1308,7 @@
else else
{ {
oLeft.resizable('enable'); oLeft.resizable('enable');
var iWidth = Utils.pInt(RL.local().get(sClientSideKeyName)) || iMinWidth; var iWidth = Utils.pInt(LocalStorage.get(sClientSideKeyName)) || iMinWidth;
fSetWidth(iWidth > iMinWidth ? iWidth : iMinWidth); fSetWidth(iWidth > iMinWidth ? iWidth : iMinWidth);
} }
}, },
@ -1309,7 +1316,7 @@
fResizeFunction = function (oEvent, oObject) { fResizeFunction = function (oEvent, oObject) {
if (oObject && oObject.size && oObject.size.width) if (oObject && oObject.size && oObject.size.width)
{ {
RL.local().set(sClientSideKeyName, oObject.size.width); LocalStorage.set(sClientSideKeyName, oObject.size.width);
oRight.css({ oRight.css({
'left': '' + oObject.size.width + 'px' 'left': '' + oObject.size.width + 'px'
@ -1401,61 +1408,6 @@
} }
}; };
/**
* @param {string} sName
* @param {Function} ViewModelClass
* @param {Function=} AbstractViewModel = KnoinAbstractViewModel
*/
Utils.extendAsViewModel = function (sName, ViewModelClass, AbstractViewModel)
{
if (ViewModelClass)
{
if (!AbstractViewModel)
{
AbstractViewModel = KnoinAbstractViewModel;
}
ViewModelClass.__name = sName;
Plugins.regViewModelHook(sName, ViewModelClass);
_.extend(ViewModelClass.prototype, AbstractViewModel.prototype);
}
};
/**
* @param {Function} SettingsViewModelClass
* @param {string} sLabelName
* @param {string} sTemplate
* @param {string} sRoute
* @param {boolean=} bDefault
*/
Utils.addSettingsViewModel = function (SettingsViewModelClass, sTemplate, sLabelName, sRoute, bDefault)
{
SettingsViewModelClass.__rlSettingsData = {
'Label': sLabelName,
'Template': sTemplate,
'Route': sRoute,
'IsDefault': !!bDefault
};
Globals.aViewModels['settings'].push(SettingsViewModelClass);
};
/**
* @param {Function} SettingsViewModelClass
*/
Utils.removeSettingsViewModel = function (SettingsViewModelClass)
{
Globals.aViewModels['settings-removed'].push(SettingsViewModelClass);
};
/**
* @param {Function} SettingsViewModelClass
*/
Utils.disableSettingsViewModel = function (SettingsViewModelClass)
{
Globals.aViewModels['settings-disabled'].push(SettingsViewModelClass);
};
Utils.convertThemeName = function (sTheme) Utils.convertThemeName = function (sTheme)
{ {
if ('@custom' === sTheme.substr(-7)) if ('@custom' === sTheme.substr(-7))
@ -1510,7 +1462,7 @@
while (sResult.length < iLen) while (sResult.length < iLen)
{ {
sResult += sLine.substr(Math.round(Math.random() * sLine.length), 1); sResult += sLine.substr(window.Math.round(window.Math.random() * sLine.length), 1);
} }
return sResult; return sResult;
@ -1574,7 +1526,7 @@
Utils.i18nToNode(oBody); Utils.i18nToNode(oBody);
Knoin.prototype.applyExternal(oViewModel, $('#rl-content', oBody)[0]); kn.applyExternal(oViewModel, $('#rl-content', oBody)[0]);
window[sFunc] = null; window[sFunc] = null;

5
dev/External/Jua.js vendored Normal file
View file

@ -0,0 +1,5 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
'use strict';
module.exports = Jua;

5
dev/External/ifvisible.js vendored Normal file
View file

@ -0,0 +1,5 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
'use strict';
module.exports = ifvisible;

9
dev/External/ko.js vendored
View file

@ -10,8 +10,11 @@
window = require('./window.js'), window = require('./window.js'),
$window = require('./$window.js'), $window = require('./$window.js'),
$doc = require('./$doc.js'), $doc = require('./$doc.js'),
Globals = require('../Common/Globals.js'), Globals = require('../Common/Globals.js'),
Utils = require('../Common/Utils.js') Utils = require('../Common/Utils.js'),
RL = require('../RL.js')
; ;
ko.bindingHandlers.tooltip = { ko.bindingHandlers.tooltip = {
@ -555,7 +558,7 @@
'focusCallback': fFocusCallback, 'focusCallback': fFocusCallback,
'inputDelimiters': [',', ';'], 'inputDelimiters': [',', ';'],
'autoCompleteSource': function (oData, fResponse) { 'autoCompleteSource': function (oData, fResponse) {
RL.getAutocomplete(oData.term, function (aData) { RL().getAutocomplete(oData.term, function (aData) {
fResponse(_.map(aData, function (oEmailItem) { fResponse(_.map(aData, function (oEmailItem) {
return oEmailItem.toLine(false); return oEmailItem.toLine(false);
})); }));
@ -630,7 +633,7 @@
'inputDelimiters': [',', ';'], 'inputDelimiters': [',', ';'],
'outputDelimiter': ',', 'outputDelimiter': ',',
'autoCompleteSource': function (oData, fResponse) { 'autoCompleteSource': function (oData, fResponse) {
RL.getContactTagsAutocomplete(oData.term, function (aData) { // TODO cjs RL().getContactTagsAutocomplete(oData.term, function (aData) {
fResponse(_.map(aData, function (oTagItem) { fResponse(_.map(aData, function (oTagItem) {
return oTagItem.toLine(false); return oTagItem.toLine(false);
})); }));

View file

@ -11,9 +11,11 @@
hasher = require('../External/hasher.js'), hasher = require('../External/hasher.js'),
crossroads = require('../External/crossroads.js'), crossroads = require('../External/crossroads.js'),
$html = require('../External/$html.js'), $html = require('../External/$html.js'),
Utils = require('../Common/Utils.js'),
Globals = require('../Common/Globals.js'), Globals = require('../Common/Globals.js'),
Enums = require('../Common/Enums.js') Enums = require('../Common/Enums.js'),
Plugins = require('../Common/Plugins.js'),
Utils = require('../Common/Utils.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
; ;
/** /**
@ -53,6 +55,11 @@
return this.oBoot; return this.oBoot;
}; };
Knoin.prototype.remote = function ()
{
return this.oRemote;
};
/** /**
* @param {Object} thisObject * @param {Object} thisObject
*/ */
@ -64,6 +71,61 @@
} }
}; };
/**
* @param {string} sName
* @param {Function} ViewModelClass
* @param {Function=} AbstractViewModel = KnoinAbstractViewModel
*/
Knoin.prototype.extendAsViewModel = function (sName, ViewModelClass, AbstractViewModel)
{
if (ViewModelClass)
{
if (!AbstractViewModel)
{
AbstractViewModel = KnoinAbstractViewModel;
}
ViewModelClass.__name = sName;
Plugins.regViewModelHook(sName, ViewModelClass);
_.extend(ViewModelClass.prototype, AbstractViewModel.prototype);
}
};
/**
* @param {Function} SettingsViewModelClass
* @param {string} sLabelName
* @param {string} sTemplate
* @param {string} sRoute
* @param {boolean=} bDefault
*/
Knoin.prototype.addSettingsViewModel = function (SettingsViewModelClass, sTemplate, sLabelName, sRoute, bDefault)
{
SettingsViewModelClass.__rlSettingsData = {
'Label': sLabelName,
'Template': sTemplate,
'Route': sRoute,
'IsDefault': !!bDefault
};
Globals.aViewModels['settings'].push(SettingsViewModelClass);
};
/**
* @param {Function} SettingsViewModelClass
*/
Knoin.prototype.removeSettingsViewModel = function (SettingsViewModelClass)
{
Globals.aViewModels['settings-removed'].push(SettingsViewModelClass);
};
/**
* @param {Function} SettingsViewModelClass
*/
Knoin.prototype.disableSettingsViewModel = function (SettingsViewModelClass)
{
Globals.aViewModels['settings-disabled'].push(SettingsViewModelClass);
};
Knoin.prototype.routeOff = function () Knoin.prototype.routeOff = function ()
{ {
hasher.changed.active = false; hasher.changed.active = false;
@ -420,9 +482,10 @@
/** /**
* @return {Knoin} * @return {Knoin}
*/ */
Knoin.prototype.bootstart = function (RL) Knoin.prototype.bootstart = function (RL, Remote)
{ {
this.oBoot = RL; this.oBoot = RL;
this.oRemote = Remote;
var var
window = require('../External/window.js'), window = require('../External/window.js'),
@ -449,7 +512,7 @@
window['rl']['settingsGet'] = Plugins.mainSettingsGet; window['rl']['settingsGet'] = Plugins.mainSettingsGet;
window['rl']['remoteRequest'] = Plugins.remoteRequest; window['rl']['remoteRequest'] = Plugins.remoteRequest;
window['rl']['pluginSettingsGet'] = Plugins.settingsGet; window['rl']['pluginSettingsGet'] = Plugins.settingsGet;
window['rl']['addSettingsViewModel'] = Utils.addSettingsViewModel; window['rl']['addSettingsViewModel'] = _.bind(this.addSettingsViewModel, this);
window['rl']['createCommand'] = Utils.createCommand; window['rl']['createCommand'] = Utils.createCommand;
window['rl']['EmailModel'] = EmailModel; window['rl']['EmailModel'] = EmailModel;

View file

@ -5,7 +5,8 @@
'use strict'; 'use strict';
var var
ko = require('../External/ko.js') ko = require('../External/ko.js'),
LinkBuilder = require('../Common/LinkBuilder.js')
; ;
/** /**
@ -27,7 +28,7 @@
*/ */
AccountModel.prototype.changeAccountLink = function () AccountModel.prototype.changeAccountLink = function ()
{ {
return RL.link().change(this.email); // TODO cjs return LinkBuilder.change(this.email);
}; };
module.exports = AccountModel; module.exports = AccountModel;

View file

@ -7,7 +7,8 @@
var var
window = require('../External/window.js'), window = require('../External/window.js'),
Globals = require('../Common/Globals.js'), Globals = require('../Common/Globals.js'),
Utils = require('../Common/Utils.js') Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js')
; ;
/** /**
@ -117,7 +118,7 @@
*/ */
AttachmentModel.prototype.linkDownload = function () AttachmentModel.prototype.linkDownload = function ()
{ {
return RL.link().attachmentDownload(this.download); // TODO cjs return LinkBuilder.attachmentDownload(this.download); // TODO cjs
}; };
/** /**
@ -125,7 +126,7 @@
*/ */
AttachmentModel.prototype.linkPreview = function () AttachmentModel.prototype.linkPreview = function ()
{ {
return RL.link().attachmentPreview(this.download); // TODO cjs return LinkBuilder.attachmentPreview(this.download); // TODO cjs
}; };
/** /**
@ -133,7 +134,7 @@
*/ */
AttachmentModel.prototype.linkPreviewAsPlain = function () AttachmentModel.prototype.linkPreviewAsPlain = function ()
{ {
return RL.link().attachmentPreviewAsPlain(this.download); return LinkBuilder.attachmentPreviewAsPlain(this.download);
}; };
/** /**

View file

@ -8,7 +8,8 @@
_ = require('../External/underscore.js'), _ = require('../External/underscore.js'),
ko = require('../External/ko.js'), ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'), Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js') Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js')
; ;
/** /**
@ -98,7 +99,7 @@
*/ */
ContactModel.prototype.srcAttr = function () ContactModel.prototype.srcAttr = function ()
{ {
return RL.link().emptyContactPic(); // TODO cjs return LinkBuilder.emptyContactPic();
}; };
/** /**

View file

@ -15,6 +15,7 @@
Enums = require('../Common/Enums.js'), Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'), Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
EmailModel = require('./EmailModel.js'), EmailModel = require('./EmailModel.js'),
AttachmentModel = require('./AttachmentModel.js') AttachmentModel = require('./AttachmentModel.js')
@ -730,7 +731,7 @@
*/ */
MessageModel.prototype.viewLink = function () MessageModel.prototype.viewLink = function ()
{ {
return RL.link().messageViewLink(this.requestHash);// TODO cjs return LinkBuilder.messageViewLink(this.requestHash);// TODO cjs
}; };
/** /**
@ -738,7 +739,7 @@
*/ */
MessageModel.prototype.downloadLink = function () MessageModel.prototype.downloadLink = function ()
{ {
return RL.link().messageDownloadLink(this.requestHash);// TODO cjs return LinkBuilder.messageDownloadLink(this.requestHash);// TODO cjs
}; };
/** /**

View file

@ -5,7 +5,7 @@
'use strict'; 'use strict';
var var
ko = require('./ko.js') ko = require('../Externalko.js')
; ;
/** /**

View file

@ -4,7 +4,8 @@
var var
kn = require('./Knoin/Knoin.js'), kn = require('./Knoin/Knoin.js'),
RL = require('./Boots/RainLoopApp.js') RL = require('./Boots/RainLoopApp.js'),
Remote = require('./Storages/WebMailAjaxRemoteStorage.js')
; ;
kn.bootstart(RL); kn.bootstart(RL, Remote);

7
dev/Remote.js Normal file
View file

@ -0,0 +1,7 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
'use strict';
module.exports = function () {
return require('./Knoin/Knoin.js').remote();
};

View file

@ -5,13 +5,16 @@
'use strict'; 'use strict';
var var
$ = require('./External/jquery.js'), $ = require('../External/jquery.js'),
_ = require('./External/underscore.js'), _ = require('../External/underscore.js'),
ko = require('./External/ko.js'), ko = require('../External/ko.js'),
Globals = require('./Common/Globals.js'),
Utils = require('./Common/Utils.js'), Globals = require('../Common/Globals.js'),
kn = require('./Knoin/Knoin.js'), Utils = require('../Common/Utils.js'),
KnoinAbstractScreen = require('./Knoin/KnoinAbstractScreen.js') LinkBuilder = require('../Common/LinkBuilder.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractScreen = require('../Knoin/KnoinAbstractScreen.js')
; ;
/** /**
@ -136,7 +139,7 @@
} }
else else
{ {
kn.setHash(RL.link().settings(), false, true); // TODO cjs kn.setHash(LinkBuilder.settings(), false, true); // TODO cjs
} }
}; };

View file

@ -5,9 +5,9 @@
'use strict'; 'use strict';
var var
_ = require('./External/underscore.js'), _ = require('../External/underscore.js'),
KnoinAbstractScreen = require('./Knoin/KnoinAbstractScreen.js'), KnoinAbstractScreen = require('../Knoin/KnoinAbstractScreen.js'),
AdminLoginViewModel = require('./ViewModels/AdminLoginViewModel.js') AdminLoginViewModel = require('../ViewModels/AdminLoginViewModel.js')
; ;
/** /**

View file

@ -5,10 +5,10 @@
'use strict'; 'use strict';
var var
_ = require('./External/underscore.js'), _ = require('../External/underscore.js'),
AbstractSettings = require('./Screens/AbstractSettings.js'), AbstractSettings = require('./AbstractSettings.js'),
AdminMenuViewModel = require('./ViewModels/AdminMenuViewModel.js'), AdminMenuViewModel = require('../ViewModels/AdminMenuViewModel.js'),
AdminPaneViewModel = require('./ViewModels/AdminPaneViewModel.js') AdminPaneViewModel = require('../ViewModels/AdminPaneViewModel.js')
; ;
/** /**

View file

@ -5,9 +5,9 @@
'use strict'; 'use strict';
var var
_ = require('./External/underscore.js'), _ = require('../External/underscore.js'),
KnoinAbstractScreen = require('./Knoin/KnoinAbstractScreen.js'), KnoinAbstractScreen = require('../Knoin/KnoinAbstractScreen.js'),
LoginViewModel = require('./ViewModels/LoginViewModel.js') LoginViewModel = require('../ViewModels/LoginViewModel.js')
; ;
/** /**

View file

@ -5,15 +5,21 @@
'use strict'; 'use strict';
var var
_ = require('./External/underscore.js'), _ = require('../External/underscore.js'),
$html = require('./External/$html.js'), $html = require('../External/$html.js'),
Enums = require('./Common/Enums.js'),
Utils = require('./Common/Utils.js'), Enums = require('../Common/Enums.js'),
KnoinAbstractScreen = require('./Knoin/KnoinAbstractScreen.js'), Utils = require('../Common/Utils.js'),
MailBoxSystemDropDownViewModel = require('./ViewModels/MailBoxSystemDropDownViewModel.js'),
MailBoxFolderListViewModel = require('./ViewModels/MailBoxFolderListViewModel.js'), KnoinAbstractScreen = require('../Knoin/KnoinAbstractScreen.js'),
MailBoxMessageListViewModel = require('./ViewModels/MailBoxMessageListViewModel.js'),
MailBoxMessageViewViewModel = require('./ViewModels/MailBoxMessageViewViewModel.js') Cache = require('../Storages/WebMailCacheStorage.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
MailBoxSystemDropDownViewModel = require('../ViewModels/MailBoxSystemDropDownViewModel.js'),
MailBoxFolderListViewModel = require('../ViewModels/MailBoxFolderListViewModel.js'),
MailBoxMessageListViewModel = require('../ViewModels/MailBoxMessageListViewModel.js'),
MailBoxMessageViewViewModel = require('../ViewModels/MailBoxMessageViewViewModel.js')
; ;
/** /**
@ -75,8 +81,8 @@
{ {
var var
oData = RL.data(),// TODO cjs oData = RL.data(),// TODO cjs
sFolderFullNameRaw = RL.cache().getFolderFullNameRaw(sFolderHash),// TODO cjs sFolderFullNameRaw = Cache.getFolderFullNameRaw(sFolderHash),
oFolder = RL.cache().getFolderFromCacheList(sFolderFullNameRaw)// TODO cjs oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw)
; ;
if (oFolder) if (oFolder)
@ -123,7 +129,7 @@
}, 5000); }, 5000);
_.delay(function () { _.delay(function () {
RL.remote().appDelayStart(Utils.emptyFunction);// TODO cjs Remote.appDelayStart(Utils.emptyFunction);
}, 35000); }, 35000);
$html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === oData.layout()); $html.toggleClass('rl-no-preview-pane', Enums.Layout.NoPreview === oData.layout());

View file

@ -5,13 +5,13 @@
'use strict'; 'use strict';
var var
_ = require('./External/underscore.js'), _ = require('../External/underscore.js'),
Enums = require('./Common/Enums.js'), Enums = require('../Common/Enums.js'),
Utils = require('./Common/Utils.js'), Utils = require('../Common/Utils.js'),
AbstractSettings = require('./Screens/AbstractSettings.js'), AbstractSettings = require('../AbstractSettings.js'),
SettingsSystemDropDownViewModel = require('./ViewModels/SettingsSystemDropDownViewModel.js'), SettingsSystemDropDownViewModel = require('../ViewModels/SettingsSystemDropDownViewModel.js'),
SettingsMenuViewModel = require('./ViewModels/SettingsMenuViewModel.js'), SettingsMenuViewModel = require('../ViewModels/SettingsMenuViewModel.js'),
SettingsPaneViewModel = require('./ViewModels/SettingsPaneViewModel.js') SettingsPaneViewModel = require('../ViewModels/SettingsPaneViewModel.js')
; ;
/** /**

View file

@ -1,82 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsAccounts()
{
var oData = RL.data();
this.accounts = oData.accounts;
this.processText = ko.computed(function () {
return oData.accountsLoading() ? Utils.i18n('SETTINGS_ACCOUNTS/LOADING_PROCESS') : '';
}, this);
this.visibility = ko.computed(function () {
return '' === this.processText() ? 'hidden' : 'visible';
}, this);
this.accountForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
}
}
]});
}
Utils.addSettingsViewModel(SettingsAccounts, 'SettingsAccounts', 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME', 'accounts');
SettingsAccounts.prototype.addNewAccount = function ()
{
kn.showScreenPopup(PopupsAddAccountViewModel);
};
/**
* @param {AccountModel} oAccountToRemove
*/
SettingsAccounts.prototype.deleteAccount = function (oAccountToRemove)
{
if (oAccountToRemove && oAccountToRemove.deleteAccess())
{
this.accountForDeletion(null);
var
fRemoveAccount = function (oAccount) {
return oAccountToRemove === oAccount;
}
;
if (oAccountToRemove)
{
this.accounts.remove(fRemoveAccount);
RL.remote().accountDelete(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData &&
oData.Result && oData.Reload)
{
kn.routeOff();
kn.setHash(RL.link().root(), true);
kn.routeOff();
_.defer(function () {
window.location.reload();
});
}
else
{
RL.accountsAndIdentities();
}
}, oAccountToRemove.email);
}
}
};

View file

@ -1,106 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsChangePasswordScreen()
{
this.changeProcess = ko.observable(false);
this.errorDescription = ko.observable('');
this.passwordMismatch = ko.observable(false);
this.passwordUpdateError = ko.observable(false);
this.passwordUpdateSuccess = ko.observable(false);
this.currentPassword = ko.observable('');
this.currentPassword.error = ko.observable(false);
this.newPassword = ko.observable('');
this.newPassword2 = ko.observable('');
this.currentPassword.subscribe(function () {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.currentPassword.error(false);
}, this);
this.newPassword.subscribe(function () {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.passwordMismatch(false);
}, this);
this.newPassword2.subscribe(function () {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.passwordMismatch(false);
}, this);
this.saveNewPasswordCommand = Utils.createCommand(this, function () {
if (this.newPassword() !== this.newPassword2())
{
this.passwordMismatch(true);
this.errorDescription(Utils.i18n('SETTINGS_CHANGE_PASSWORD/ERROR_PASSWORD_MISMATCH'));
}
else
{
this.changeProcess(true);
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.currentPassword.error(false);
this.passwordMismatch(false);
this.errorDescription('');
RL.remote().changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword());
}
}, function () {
return !this.changeProcess() && '' !== this.currentPassword() &&
'' !== this.newPassword() && '' !== this.newPassword2();
});
this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this);
}
Utils.addSettingsViewModel(SettingsChangePasswordScreen, 'SettingsChangePassword', 'SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME', 'change-password');
SettingsChangePasswordScreen.prototype.onHide = function ()
{
this.changeProcess(false);
this.currentPassword('');
this.newPassword('');
this.newPassword2('');
this.errorDescription('');
this.passwordMismatch(false);
this.currentPassword.error(false);
};
SettingsChangePasswordScreen.prototype.onChangePasswordResponse = function (sResult, oData)
{
this.changeProcess(false);
this.passwordMismatch(false);
this.errorDescription('');
this.currentPassword.error(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.currentPassword('');
this.newPassword('');
this.newPassword2('');
this.passwordUpdateSuccess(true);
this.currentPassword.error(false);
}
else
{
if (oData && Enums.Notification.CurrentPasswordIncorrect === oData.ErrorCode)
{
this.currentPassword.error(true);
}
this.passwordUpdateError(true);
this.errorDescription(oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) :
Utils.getNotification(Enums.Notification.CouldNotSaveNewPassword));
}
};

View file

@ -1,51 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsContacts()
{
var oData = RL.data();
this.contactsAutosave = oData.contactsAutosave;
this.allowContactsSync = oData.allowContactsSync;
this.enableContactsSync = oData.enableContactsSync;
this.contactsSyncUrl = oData.contactsSyncUrl;
this.contactsSyncUser = oData.contactsSyncUser;
this.contactsSyncPass = oData.contactsSyncPass;
this.saveTrigger = ko.computed(function () {
return [
this.enableContactsSync() ? '1' : '0',
this.contactsSyncUrl(),
this.contactsSyncUser(),
this.contactsSyncPass()
].join('|');
}, this).extend({'throttle': 500});
this.saveTrigger.subscribe(function () {
RL.remote().saveContactsSyncData(null,
this.enableContactsSync(),
this.contactsSyncUrl(),
this.contactsSyncUser(),
this.contactsSyncPass()
);
}, this);
}
Utils.addSettingsViewModel(SettingsContacts, 'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts');
SettingsContacts.prototype.onBuild = function ()
{
RL.data().contactsAutosave.subscribe(function (bValue) {
RL.remote().saveSettings(Utils.emptyFunction, {
'ContactsAutosave': bValue ? '1' : '0'
});
});
};
//SettingsContacts.prototype.onShow = function ()
//{
//
//};

View file

@ -1,32 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsFilters()
{
// var oData = RL.data();
this.filters = ko.observableArray([]);
this.filters.loading = ko.observable(false);
this.filters.subscribe(function () {
Utils.windowResize();
});
}
Utils.addSettingsViewModel(SettingsFilters, 'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters');
//SettingsFilters.prototype.onBuild = function ()
//{
//};
SettingsFilters.prototype.deleteFilter = function (oFilter)
{
this.filters.remove(oFilter);
};
SettingsFilters.prototype.addFilter = function ()
{
kn.showScreenPopup(PopupsFilterViewModel, [new FilterModel()]);
};

View file

@ -1,196 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsFolders()
{
var oData = RL.data();
this.foldersListError = oData.foldersListError;
this.folderList = oData.folderList;
this.processText = ko.computed(function () {
var
oData = RL.data(),
bLoading = oData.foldersLoading(),
bCreating = oData.foldersCreating(),
bDeleting = oData.foldersDeleting(),
bRenaming = oData.foldersRenaming()
;
if (bCreating)
{
return Utils.i18n('SETTINGS_FOLDERS/CREATING_PROCESS');
}
else if (bDeleting)
{
return Utils.i18n('SETTINGS_FOLDERS/DELETING_PROCESS');
}
else if (bRenaming)
{
return Utils.i18n('SETTINGS_FOLDERS/RENAMING_PROCESS');
}
else if (bLoading)
{
return Utils.i18n('SETTINGS_FOLDERS/LOADING_PROCESS');
}
return '';
}, this);
this.visibility = ko.computed(function () {
return '' === this.processText() ? 'hidden' : 'visible';
}, this);
this.folderForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
}
}
]});
this.folderForEdit = ko.observable(null).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.edited(false);
}
}, function (oNext) {
if (oNext && oNext.canBeEdited())
{
oNext.edited(true);
}
}
]});
this.useImapSubscribe = !!RL.settingsGet('UseImapSubscribe');
}
Utils.addSettingsViewModel(SettingsFolders, 'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders');
SettingsFolders.prototype.folderEditOnEnter = function (oFolder)
{
var sEditName = oFolder ? Utils.trim(oFolder.nameForEdit()) : '';
if ('' !== sEditName && oFolder.name() !== sEditName)
{
RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, '');
RL.data().foldersRenaming(true);
RL.remote().folderRename(function (sResult, oData) {
RL.data().foldersRenaming(false);
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{
RL.data().foldersListError(
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER'));
}
RL.folders();
}, oFolder.fullNameRaw, sEditName);
RL.cache().removeFolderFromCacheList(oFolder.fullNameRaw);
oFolder.name(sEditName);
}
oFolder.edited(false);
};
SettingsFolders.prototype.folderEditOnEsc = function (oFolder)
{
if (oFolder)
{
oFolder.edited(false);
}
};
SettingsFolders.prototype.onShow = function ()
{
RL.data().foldersListError('');
};
SettingsFolders.prototype.createFolder = function ()
{
kn.showScreenPopup(PopupsFolderCreateViewModel);
};
SettingsFolders.prototype.systemFolder = function ()
{
kn.showScreenPopup(PopupsFolderSystemViewModel);
};
SettingsFolders.prototype.deleteFolder = function (oFolderToRemove)
{
if (oFolderToRemove && oFolderToRemove.canBeDeleted() && oFolderToRemove.deleteAccess() &&
0 === oFolderToRemove.privateMessageCountAll())
{
this.folderForDeletion(null);
var
fRemoveFolder = function (oFolder) {
if (oFolderToRemove === oFolder)
{
return true;
}
oFolder.subFolders.remove(fRemoveFolder);
return false;
}
;
if (oFolderToRemove)
{
RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, '');
RL.data().folderList.remove(fRemoveFolder);
RL.data().foldersDeleting(true);
RL.remote().folderDelete(function (sResult, oData) {
RL.data().foldersDeleting(false);
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{
RL.data().foldersListError(
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER'));
}
RL.folders();
}, oFolderToRemove.fullNameRaw);
RL.cache().removeFolderFromCacheList(oFolderToRemove.fullNameRaw);
}
}
else if (0 < oFolderToRemove.privateMessageCountAll())
{
RL.data().foldersListError(Utils.getNotification(Enums.Notification.CantDeleteNonEmptyFolder));
}
};
SettingsFolders.prototype.subscribeFolder = function (oFolder)
{
RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, '');
RL.remote().folderSetSubscribe(Utils.emptyFunction, oFolder.fullNameRaw, true);
oFolder.subScribed(true);
};
SettingsFolders.prototype.unSubscribeFolder = function (oFolder)
{
RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, '');
RL.remote().folderSetSubscribe(Utils.emptyFunction, oFolder.fullNameRaw, false);
oFolder.subScribed(false);
};

View file

@ -1,161 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsGeneral()
{
var oData = RL.data();
this.mainLanguage = oData.mainLanguage;
this.mainMessagesPerPage = oData.mainMessagesPerPage;
this.mainMessagesPerPageArray = Consts.Defaults.MessagesPerPageArray;
this.editorDefaultType = oData.editorDefaultType;
this.showImages = oData.showImages;
this.interfaceAnimation = oData.interfaceAnimation;
this.useDesktopNotifications = oData.useDesktopNotifications;
this.threading = oData.threading;
this.useThreads = oData.useThreads;
this.replySameFolder = oData.replySameFolder;
this.layout = oData.layout;
this.usePreviewPane = oData.usePreviewPane;
this.useCheckboxesInList = oData.useCheckboxesInList;
this.allowLanguagesOnSettings = oData.allowLanguagesOnSettings;
this.isDesktopNotificationsSupported = ko.computed(function () {
return Enums.DesktopNotifications.NotSupported !== oData.desktopNotificationsPermisions();
});
this.isDesktopNotificationsDenied = ko.computed(function () {
return Enums.DesktopNotifications.NotSupported === oData.desktopNotificationsPermisions() ||
Enums.DesktopNotifications.Denied === oData.desktopNotificationsPermisions();
});
this.mainLanguageFullName = ko.computed(function () {
return Utils.convertLangName(this.mainLanguage());
}, this);
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
this.mppTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.isAnimationSupported = Globals.bAnimationSupported;
}
Utils.addSettingsViewModel(SettingsGeneral, 'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true);
SettingsGeneral.prototype.toggleLayout = function ()
{
this.layout(Enums.Layout.NoPreview === this.layout() ? Enums.Layout.SidePreview : Enums.Layout.NoPreview);
};
SettingsGeneral.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
oData = RL.data(),
f1 = Utils.settingsSaveHelperSimpleFunction(self.mppTrigger, self)
;
oData.language.subscribe(function (sValue) {
self.languageTrigger(Enums.SaveSettingsStep.Animate);
$.ajax({
'url': RL.link().langLink(sValue),
'dataType': 'script',
'cache': true
}).done(function() {
Utils.i18nReload();
self.languageTrigger(Enums.SaveSettingsStep.TrueResult);
}).fail(function() {
self.languageTrigger(Enums.SaveSettingsStep.FalseResult);
}).always(function() {
_.delay(function () {
self.languageTrigger(Enums.SaveSettingsStep.Idle);
}, 1000);
});
RL.remote().saveSettings(Utils.emptyFunction, {
'Language': sValue
});
});
oData.editorDefaultType.subscribe(function (sValue) {
RL.remote().saveSettings(Utils.emptyFunction, {
'EditorDefaultType': sValue
});
});
oData.messagesPerPage.subscribe(function (iValue) {
RL.remote().saveSettings(f1, {
'MPP': iValue
});
});
oData.showImages.subscribe(function (bValue) {
RL.remote().saveSettings(Utils.emptyFunction, {
'ShowImages': bValue ? '1' : '0'
});
});
oData.interfaceAnimation.subscribe(function (sValue) {
RL.remote().saveSettings(Utils.emptyFunction, {
'InterfaceAnimation': sValue
});
});
oData.useDesktopNotifications.subscribe(function (bValue) {
Utils.timeOutAction('SaveDesktopNotifications', function () {
RL.remote().saveSettings(Utils.emptyFunction, {
'DesktopNotifications': bValue ? '1' : '0'
});
}, 3000);
});
oData.replySameFolder.subscribe(function (bValue) {
Utils.timeOutAction('SaveReplySameFolder', function () {
RL.remote().saveSettings(Utils.emptyFunction, {
'ReplySameFolder': bValue ? '1' : '0'
});
}, 3000);
});
oData.useThreads.subscribe(function (bValue) {
oData.messageList([]);
RL.remote().saveSettings(Utils.emptyFunction, {
'UseThreads': bValue ? '1' : '0'
});
});
oData.layout.subscribe(function (nValue) {
oData.messageList([]);
RL.remote().saveSettings(Utils.emptyFunction, {
'Layout': nValue
});
});
oData.useCheckboxesInList.subscribe(function (bValue) {
RL.remote().saveSettings(Utils.emptyFunction, {
'UseCheckboxesInList': bValue ? '1' : '0'
});
});
}, 50);
};
SettingsGeneral.prototype.onShow = function ()
{
RL.data().desktopNotifications.valueHasMutated();
};
SettingsGeneral.prototype.selectLanguage = function ()
{
kn.showScreenPopup(PopupsLanguagesViewModel);
};

View file

@ -1,219 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsIdentities()
{
var oData = RL.data();
this.editor = null;
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
this.accountEmail = oData.accountEmail;
this.displayName = oData.displayName;
this.signature = oData.signature;
this.signatureToAll = oData.signatureToAll;
this.replyTo = oData.replyTo;
this.signatureDom = ko.observable(null);
this.defaultIdentityIDTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.displayNameTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.replyTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.identities = oData.identities;
this.defaultIdentityID = oData.defaultIdentityID;
this.identitiesOptions = ko.computed(function () {
var
aList = this.identities(),
aResult = []
;
if (0 < aList.length)
{
aResult.push({
'id': this.accountEmail.peek(),
'name': this.formattedAccountIdentity(),
'seporator': false
});
aResult.push({
'id': '---',
'name': '---',
'seporator': true,
'disabled': true
});
_.each(aList, function (oItem) {
aResult.push({
'id': oItem.id,
'name': oItem.formattedNameForEmail(),
'seporator': false
});
});
}
return aResult;
}, this);
this.processText = ko.computed(function () {
return oData.identitiesLoading() ? Utils.i18n('SETTINGS_IDENTITIES/LOADING_PROCESS') : '';
}, this);
this.visibility = ko.computed(function () {
return '' === this.processText() ? 'hidden' : 'visible';
}, this);
this.identityForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
}
}
]});
}
Utils.addSettingsViewModel(SettingsIdentities, 'SettingsIdentities', 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', 'identities');
/**
*
* @return {string}
*/
SettingsIdentities.prototype.formattedAccountIdentity = function ()
{
var
sDisplayName = this.displayName.peek(),
sEmail = this.accountEmail.peek()
;
return '' === sDisplayName ? sEmail : '"' + Utils.quoteName(sDisplayName) + '" <' + sEmail + '>';
};
SettingsIdentities.prototype.addNewIdentity = function ()
{
kn.showScreenPopup(PopupsIdentityViewModel);
};
SettingsIdentities.prototype.editIdentity = function (oIdentity)
{
kn.showScreenPopup(PopupsIdentityViewModel, [oIdentity]);
};
/**
* @param {IdentityModel} oIdentityToRemove
*/
SettingsIdentities.prototype.deleteIdentity = function (oIdentityToRemove)
{
if (oIdentityToRemove && oIdentityToRemove.deleteAccess())
{
this.identityForDeletion(null);
var
fRemoveFolder = function (oIdentity) {
return oIdentityToRemove === oIdentity;
}
;
if (oIdentityToRemove)
{
this.identities.remove(fRemoveFolder);
RL.remote().identityDelete(function () {
RL.accountsAndIdentities();
}, oIdentityToRemove.id);
}
}
};
SettingsIdentities.prototype.onFocus = function ()
{
if (!this.editor && this.signatureDom())
{
var
self = this,
sSignature = RL.data().signature()
;
this.editor = new NewHtmlEditorWrapper(self.signatureDom(), function () {
RL.data().signature(
(self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData()
);
}, function () {
if (':HTML:' === sSignature.substr(0, 6))
{
self.editor.setHtml(sSignature.substr(6), false);
}
else
{
self.editor.setPlain(sSignature, false);
}
});
}
};
SettingsIdentities.prototype.onBuild = function (oDom)
{
var self = this;
oDom
.on('click', '.identity-item .e-action', function () {
var oIdentityItem = ko.dataFor(this);
if (oIdentityItem)
{
self.editIdentity(oIdentityItem);
}
})
;
_.delay(function () {
var
oData = RL.data(),
f1 = Utils.settingsSaveHelperSimpleFunction(self.displayNameTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.defaultIdentityIDTrigger, self)
;
oData.defaultIdentityID.subscribe(function (sValue) {
RL.remote().saveSettings(f4, {
'DefaultIdentityID': sValue
});
});
oData.displayName.subscribe(function (sValue) {
RL.remote().saveSettings(f1, {
'DisplayName': sValue
});
});
oData.replyTo.subscribe(function (sValue) {
RL.remote().saveSettings(f2, {
'ReplyTo': sValue
});
});
oData.signature.subscribe(function (sValue) {
RL.remote().saveSettings(f3, {
'Signature': sValue
});
});
oData.signatureToAll.subscribe(function (bValue) {
RL.remote().saveSettings(null, {
'SignatureToAll': bValue ? '1' : '0'
});
});
}, 50);
};

View file

@ -1,89 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsIdentity()
{
var oData = RL.data();
this.editor = null;
this.displayName = oData.displayName;
this.signature = oData.signature;
this.signatureToAll = oData.signatureToAll;
this.replyTo = oData.replyTo;
this.signatureDom = ko.observable(null);
this.displayNameTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.replyTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
Utils.addSettingsViewModel(SettingsIdentity, 'SettingsIdentity', 'SETTINGS_LABELS/LABEL_IDENTITY_NAME', 'identity');
SettingsIdentity.prototype.onFocus = function ()
{
if (!this.editor && this.signatureDom())
{
var
self = this,
sSignature = RL.data().signature()
;
this.editor = new NewHtmlEditorWrapper(self.signatureDom(), function () {
RL.data().signature(
(self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData()
);
}, function () {
if (':HTML:' === sSignature.substr(0, 6))
{
self.editor.setHtml(sSignature.substr(6), false);
}
else
{
self.editor.setPlain(sSignature, false);
}
});
}
};
SettingsIdentity.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
oData = RL.data(),
f1 = Utils.settingsSaveHelperSimpleFunction(self.displayNameTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self)
;
oData.displayName.subscribe(function (sValue) {
RL.remote().saveSettings(f1, {
'DisplayName': sValue
});
});
oData.replyTo.subscribe(function (sValue) {
RL.remote().saveSettings(f2, {
'ReplyTo': sValue
});
});
oData.signature.subscribe(function (sValue) {
RL.remote().saveSettings(f3, {
'Signature': sValue
});
});
oData.signatureToAll.subscribe(function (bValue) {
RL.remote().saveSettings(null, {
'SignatureToAll': bValue ? '1' : '0'
});
});
}, 50);
};

View file

@ -1,70 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsOpenPGP()
{
this.openpgpkeys = RL.data().openpgpkeys;
this.openpgpkeysPublic = RL.data().openpgpkeysPublic;
this.openpgpkeysPrivate = RL.data().openpgpkeysPrivate;
this.openPgpKeyForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
}
}
]});
}
Utils.addSettingsViewModel(SettingsOpenPGP, 'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp');
SettingsOpenPGP.prototype.addOpenPgpKey = function ()
{
kn.showScreenPopup(PopupsAddOpenPgpKeyViewModel);
};
SettingsOpenPGP.prototype.generateOpenPgpKey = function ()
{
kn.showScreenPopup(PopupsGenerateNewOpenPgpKeyViewModel);
};
SettingsOpenPGP.prototype.viewOpenPgpKey = function (oOpenPgpKey)
{
if (oOpenPgpKey)
{
kn.showScreenPopup(PopupsViewOpenPgpKeyViewModel, [oOpenPgpKey]);
}
};
/**
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove
*/
SettingsOpenPGP.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove)
{
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
{
this.openPgpKeyForDeletion(null);
if (oOpenPgpKeyToRemove && RL.data().openpgpKeyring)
{
this.openpgpkeys.remove(function (oOpenPgpKey) {
return oOpenPgpKeyToRemove === oOpenPgpKey;
});
RL.data().openpgpKeyring[oOpenPgpKeyToRemove.isPrivate ? 'privateKeys' : 'publicKeys']
.removeForId(oOpenPgpKeyToRemove.guid);
RL.data().openpgpKeyring.store();
RL.reloadOpenPgpKeys();
}
}
};

View file

@ -1,151 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsSecurity()
{
this.processing = ko.observable(false);
this.clearing = ko.observable(false);
this.secreting = ko.observable(false);
this.viewUser = ko.observable('');
this.viewEnable = ko.observable(false);
this.viewEnable.subs = true;
this.twoFactorStatus = ko.observable(false);
this.viewSecret = ko.observable('');
this.viewBackupCodes = ko.observable('');
this.viewUrl = ko.observable('');
this.bFirst = true;
this.viewTwoFactorStatus = ko.computed(function () {
Globals.langChangeTrigger();
return Utils.i18n(
this.twoFactorStatus() ?
'SETTINGS_SECURITY/TWO_FACTOR_SECRET_CONFIGURED_DESC' :
'SETTINGS_SECURITY/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC'
);
}, this);
this.onResult = _.bind(this.onResult, this);
this.onSecretResult = _.bind(this.onSecretResult, this);
}
Utils.addSettingsViewModel(SettingsSecurity, 'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security');
SettingsSecurity.prototype.showSecret = function ()
{
this.secreting(true);
RL.remote().showTwoFactorSecret(this.onSecretResult);
};
SettingsSecurity.prototype.hideSecret = function ()
{
this.viewSecret('');
this.viewBackupCodes('');
this.viewUrl('');
};
SettingsSecurity.prototype.createTwoFactor = function ()
{
this.processing(true);
RL.remote().createTwoFactor(this.onResult);
};
SettingsSecurity.prototype.enableTwoFactor = function ()
{
this.processing(true);
RL.remote().enableTwoFactor(this.onResult, this.viewEnable());
};
SettingsSecurity.prototype.testTwoFactor = function ()
{
kn.showScreenPopup(PopupsTwoFactorTestViewModel);
};
SettingsSecurity.prototype.clearTwoFactor = function ()
{
this.viewSecret('');
this.viewBackupCodes('');
this.viewUrl('');
this.clearing(true);
RL.remote().clearTwoFactor(this.onResult);
};
SettingsSecurity.prototype.onShow = function ()
{
this.viewSecret('');
this.viewBackupCodes('');
this.viewUrl('');
};
SettingsSecurity.prototype.onResult = function (sResult, oData)
{
this.processing(false);
this.clearing(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.viewUser(Utils.pString(oData.Result.User));
this.viewEnable(!!oData.Result.Enable);
this.twoFactorStatus(!!oData.Result.IsSet);
this.viewSecret(Utils.pString(oData.Result.Secret));
this.viewBackupCodes(Utils.pString(oData.Result.BackupCodes).replace(/[\s]+/g, ' '));
this.viewUrl(Utils.pString(oData.Result.Url));
}
else
{
this.viewUser('');
this.viewEnable(false);
this.twoFactorStatus(false);
this.viewSecret('');
this.viewBackupCodes('');
this.viewUrl('');
}
if (this.bFirst)
{
this.bFirst = false;
var self = this;
this.viewEnable.subscribe(function (bValue) {
if (this.viewEnable.subs)
{
RL.remote().enableTwoFactor(function (sResult, oData) {
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{
self.viewEnable.subs = false;
self.viewEnable(false);
self.viewEnable.subs = true;
}
}, bValue);
}
}, this);
}
};
SettingsSecurity.prototype.onSecretResult = function (sResult, oData)
{
this.secreting(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.viewSecret(Utils.pString(oData.Result.Secret));
this.viewUrl(Utils.pString(oData.Result.Url));
}
else
{
this.viewSecret('');
this.viewUrl('');
}
};
SettingsSecurity.prototype.onBuild = function ()
{
this.processing(true);
RL.remote().getTwoFactor(this.onResult);
};

View file

@ -0,0 +1,105 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
window = require('../External/window.js'),
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'),
PopupsAddAccountViewModel = require('../ViewModels/Popups/PopupsAddAccountViewModel.js')
;
/**
* @constructor
*/
function SettingsAccounts()
{
var oData = RL.data();
this.accounts = oData.accounts;
this.processText = ko.computed(function () {
return oData.accountsLoading() ? Utils.i18n('SETTINGS_ACCOUNTS/LOADING_PROCESS') : '';
}, this);
this.visibility = ko.computed(function () {
return '' === this.processText() ? 'hidden' : 'visible';
}, this);
this.accountForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
}
}
]});
}
kn.addSettingsViewModel(SettingsAccounts, 'SettingsAccounts', 'SETTINGS_LABELS/LABEL_ACCOUNTS_NAME', 'accounts');
SettingsAccounts.prototype.addNewAccount = function ()
{
kn.showScreenPopup(PopupsAddAccountViewModel);
};
/**
* @param {AccountModel} oAccountToRemove
*/
SettingsAccounts.prototype.deleteAccount = function (oAccountToRemove)
{
if (oAccountToRemove && oAccountToRemove.deleteAccess())
{
this.accountForDeletion(null);
var
fRemoveAccount = function (oAccount) {
return oAccountToRemove === oAccount;
}
;
if (oAccountToRemove)
{
this.accounts.remove(fRemoveAccount);
Remote.accountDelete(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData &&
oData.Result && oData.Reload)
{
kn.routeOff();
kn.setHash(LinkBuilder.root(), true);
kn.routeOff();
_.defer(function () {
window.location.reload();
});
}
else
{
RL.accountsAndIdentities();
}
}, oAccountToRemove.email);
}
}
};
module.exports = SettingsAccounts;
}(module));

View file

@ -0,0 +1,124 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js')
;
/**
* @constructor
*/
function SettingsChangePassword()
{
this.changeProcess = ko.observable(false);
this.errorDescription = ko.observable('');
this.passwordMismatch = ko.observable(false);
this.passwordUpdateError = ko.observable(false);
this.passwordUpdateSuccess = ko.observable(false);
this.currentPassword = ko.observable('');
this.currentPassword.error = ko.observable(false);
this.newPassword = ko.observable('');
this.newPassword2 = ko.observable('');
this.currentPassword.subscribe(function () {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.currentPassword.error(false);
}, this);
this.newPassword.subscribe(function () {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.passwordMismatch(false);
}, this);
this.newPassword2.subscribe(function () {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.passwordMismatch(false);
}, this);
this.saveNewPasswordCommand = Utils.createCommand(this, function () {
if (this.newPassword() !== this.newPassword2())
{
this.passwordMismatch(true);
this.errorDescription(Utils.i18n('SETTINGS_CHANGE_PASSWORD/ERROR_PASSWORD_MISMATCH'));
}
else
{
this.changeProcess(true);
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.currentPassword.error(false);
this.passwordMismatch(false);
this.errorDescription('');
Remote.changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword());
}
}, function () {
return !this.changeProcess() && '' !== this.currentPassword() &&
'' !== this.newPassword() && '' !== this.newPassword2();
});
this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this);
}
kn.addSettingsViewModel(SettingsChangePassword, 'SettingsChangePassword', 'SETTINGS_LABELS/LABEL_CHANGE_PASSWORD_NAME', 'change-password');
SettingsChangePassword.prototype.onHide = function ()
{
this.changeProcess(false);
this.currentPassword('');
this.newPassword('');
this.newPassword2('');
this.errorDescription('');
this.passwordMismatch(false);
this.currentPassword.error(false);
};
SettingsChangePassword.prototype.onChangePasswordResponse = function (sResult, oData)
{
this.changeProcess(false);
this.passwordMismatch(false);
this.errorDescription('');
this.currentPassword.error(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.currentPassword('');
this.newPassword('');
this.newPassword2('');
this.passwordUpdateSuccess(true);
this.currentPassword.error(false);
}
else
{
if (oData && Enums.Notification.CurrentPasswordIncorrect === oData.ErrorCode)
{
this.currentPassword.error(true);
}
this.passwordUpdateError(true);
this.errorDescription(oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) :
Utils.getNotification(Enums.Notification.CouldNotSaveNewPassword));
}
};
module.exports = SettingsChangePassword;
}(module));

View file

@ -0,0 +1,62 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
ko = require('../External/ko.js'),
Utils = require('../Common/Utils.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js')
;
/**
* @constructor
*/
function SettingsContacts()
{
var oData = RL.data();
this.contactsAutosave = oData.contactsAutosave;
this.allowContactsSync = oData.allowContactsSync;
this.enableContactsSync = oData.enableContactsSync;
this.contactsSyncUrl = oData.contactsSyncUrl;
this.contactsSyncUser = oData.contactsSyncUser;
this.contactsSyncPass = oData.contactsSyncPass;
this.saveTrigger = ko.computed(function () {
return [
this.enableContactsSync() ? '1' : '0',
this.contactsSyncUrl(),
this.contactsSyncUser(),
this.contactsSyncPass()
].join('|');
}, this).extend({'throttle': 500});
this.saveTrigger.subscribe(function () {
Remote.saveContactsSyncData(null,
this.enableContactsSync(),
this.contactsSyncUrl(),
this.contactsSyncUser(),
this.contactsSyncPass()
);
}, this);
}
kn.addSettingsViewModel(SettingsContacts, 'SettingsContacts', 'SETTINGS_LABELS/LABEL_CONTACTS_NAME', 'contacts');
SettingsContacts.prototype.onBuild = function ()
{
RL.data().contactsAutosave.subscribe(function (bValue) {
Remote.saveSettings(Utils.emptyFunction, {
'ContactsAutosave': bValue ? '1' : '0'
});
});
};
module.exports = SettingsContacts;
}(module));

View file

@ -0,0 +1,40 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
ko = require('../External/ko.js'),
Utils = require('../Common/Utils.js'),
PopupsFilterViewModel = require('../ViewModels/Popups/PopupsFilterViewModel.js')
;
/**
* @constructor
*/
function SettingsFilters()
{
this.filters = ko.observableArray([]);
this.filters.loading = ko.observable(false);
this.filters.subscribe(function () {
Utils.windowResize();
});
}
kn.addSettingsViewModel(SettingsFilters, 'SettingsFilters', 'SETTINGS_LABELS/LABEL_FILTERS_NAME', 'filters');
SettingsFilters.prototype.deleteFilter = function (oFilter)
{
this.filters.remove(oFilter);
};
SettingsFilters.prototype.addFilter = function ()
{
kn.showScreenPopup(PopupsFilterViewModel, [new FilterModel()]);
};
module.exports = SettingsFilters;
}(module));

View file

@ -0,0 +1,217 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
LocalStorage = require('../Storages/LocalStorage.js'),
Cache = require('../Storages/WebMailCacheStorage.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
PopupsFolderCreateViewModel = require('../ViewModels/Popups/PopupsFolderCreateViewModel.js'),
PopupsFolderSystemViewModel = require('../ViewModels/Popups/PopupsFolderSystemViewModel.js')
;
/**
* @constructor
*/
function SettingsFolders()
{
var oData = RL.data();
this.foldersListError = oData.foldersListError;
this.folderList = oData.folderList;
this.processText = ko.computed(function () {
var
oData = RL.data(),
bLoading = oData.foldersLoading(),
bCreating = oData.foldersCreating(),
bDeleting = oData.foldersDeleting(),
bRenaming = oData.foldersRenaming()
;
if (bCreating)
{
return Utils.i18n('SETTINGS_FOLDERS/CREATING_PROCESS');
}
else if (bDeleting)
{
return Utils.i18n('SETTINGS_FOLDERS/DELETING_PROCESS');
}
else if (bRenaming)
{
return Utils.i18n('SETTINGS_FOLDERS/RENAMING_PROCESS');
}
else if (bLoading)
{
return Utils.i18n('SETTINGS_FOLDERS/LOADING_PROCESS');
}
return '';
}, this);
this.visibility = ko.computed(function () {
return '' === this.processText() ? 'hidden' : 'visible';
}, this);
this.folderForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
}
}
]});
this.folderForEdit = ko.observable(null).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.edited(false);
}
}, function (oNext) {
if (oNext && oNext.canBeEdited())
{
oNext.edited(true);
}
}
]});
this.useImapSubscribe = !!RL.settingsGet('UseImapSubscribe');
}
kn.addSettingsViewModel(SettingsFolders, 'SettingsFolders', 'SETTINGS_LABELS/LABEL_FOLDERS_NAME', 'folders');
SettingsFolders.prototype.folderEditOnEnter = function (oFolder)
{
var sEditName = oFolder ? Utils.trim(oFolder.nameForEdit()) : '';
if ('' !== sEditName && oFolder.name() !== sEditName)
{
LocalStorage.set(Enums.ClientSideKeyName.FoldersLashHash, '');
RL.data().foldersRenaming(true);
Remote.folderRename(function (sResult, oData) {
RL.data().foldersRenaming(false);
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{
RL.data().foldersListError(
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER'));
}
RL.folders();
}, oFolder.fullNameRaw, sEditName);
Cache.removeFolderFromCacheList(oFolder.fullNameRaw);
oFolder.name(sEditName);
}
oFolder.edited(false);
};
SettingsFolders.prototype.folderEditOnEsc = function (oFolder)
{
if (oFolder)
{
oFolder.edited(false);
}
};
SettingsFolders.prototype.onShow = function ()
{
RL.data().foldersListError('');
};
SettingsFolders.prototype.createFolder = function ()
{
kn.showScreenPopup(PopupsFolderCreateViewModel);
};
SettingsFolders.prototype.systemFolder = function ()
{
kn.showScreenPopup(PopupsFolderSystemViewModel);
};
SettingsFolders.prototype.deleteFolder = function (oFolderToRemove)
{
if (oFolderToRemove && oFolderToRemove.canBeDeleted() && oFolderToRemove.deleteAccess() &&
0 === oFolderToRemove.privateMessageCountAll())
{
this.folderForDeletion(null);
var
fRemoveFolder = function (oFolder) {
if (oFolderToRemove === oFolder)
{
return true;
}
oFolder.subFolders.remove(fRemoveFolder);
return false;
}
;
if (oFolderToRemove)
{
LocalStorage.set(Enums.ClientSideKeyName.FoldersLashHash, '');
RL.data().folderList.remove(fRemoveFolder);
RL.data().foldersDeleting(true);
Remote.folderDelete(function (sResult, oData) {
RL.data().foldersDeleting(false);
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{
RL.data().foldersListError(
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER'));
}
RL.folders();
}, oFolderToRemove.fullNameRaw);
Cache.removeFolderFromCacheList(oFolderToRemove.fullNameRaw);
}
}
else if (0 < oFolderToRemove.privateMessageCountAll())
{
RL.data().foldersListError(Utils.getNotification(Enums.Notification.CantDeleteNonEmptyFolder));
}
};
SettingsFolders.prototype.subscribeFolder = function (oFolder)
{
LocalStorage.set(Enums.ClientSideKeyName.FoldersLashHash, '');
Remote.folderSetSubscribe(Utils.emptyFunction, oFolder.fullNameRaw, true);
oFolder.subScribed(true);
};
SettingsFolders.prototype.unSubscribeFolder = function (oFolder)
{
LocalStorage.set(Enums.ClientSideKeyName.FoldersLashHash, '');
Remote.folderSetSubscribe(Utils.emptyFunction, oFolder.fullNameRaw, false);
oFolder.subScribed(false);
};
module.exports = SettingsFolders;
}(module));

View file

@ -0,0 +1,184 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Consts = require('../Common/Consts.js'),
Globals = require('../Common/Globals.js'),
Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'),
PopupsLanguagesViewModel = require('../ViewModels/Popups/PopupsLanguagesViewModel.js')
;
/**
* @constructor
*/
function SettingsGeneral()
{
var oData = RL.data();
this.mainLanguage = oData.mainLanguage;
this.mainMessagesPerPage = oData.mainMessagesPerPage;
this.mainMessagesPerPageArray = Consts.Defaults.MessagesPerPageArray;
this.editorDefaultType = oData.editorDefaultType;
this.showImages = oData.showImages;
this.interfaceAnimation = oData.interfaceAnimation;
this.useDesktopNotifications = oData.useDesktopNotifications;
this.threading = oData.threading;
this.useThreads = oData.useThreads;
this.replySameFolder = oData.replySameFolder;
this.layout = oData.layout;
this.usePreviewPane = oData.usePreviewPane;
this.useCheckboxesInList = oData.useCheckboxesInList;
this.allowLanguagesOnSettings = oData.allowLanguagesOnSettings;
this.isDesktopNotificationsSupported = ko.computed(function () {
return Enums.DesktopNotifications.NotSupported !== oData.desktopNotificationsPermisions();
});
this.isDesktopNotificationsDenied = ko.computed(function () {
return Enums.DesktopNotifications.NotSupported === oData.desktopNotificationsPermisions() ||
Enums.DesktopNotifications.Denied === oData.desktopNotificationsPermisions();
});
this.mainLanguageFullName = ko.computed(function () {
return Utils.convertLangName(this.mainLanguage());
}, this);
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
this.mppTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.isAnimationSupported = Globals.bAnimationSupported;
}
kn.addSettingsViewModel(SettingsGeneral, 'SettingsGeneral', 'SETTINGS_LABELS/LABEL_GENERAL_NAME', 'general', true);
SettingsGeneral.prototype.toggleLayout = function ()
{
this.layout(Enums.Layout.NoPreview === this.layout() ? Enums.Layout.SidePreview : Enums.Layout.NoPreview);
};
SettingsGeneral.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
oData = RL.data(),
f1 = Utils.settingsSaveHelperSimpleFunction(self.mppTrigger, self)
;
oData.language.subscribe(function (sValue) {
self.languageTrigger(Enums.SaveSettingsStep.Animate);
$.ajax({
'url': LinkBuilder.langLink(sValue),
'dataType': 'script',
'cache': true
}).done(function() {
Utils.i18nReload();
self.languageTrigger(Enums.SaveSettingsStep.TrueResult);
}).fail(function() {
self.languageTrigger(Enums.SaveSettingsStep.FalseResult);
}).always(function() {
_.delay(function () {
self.languageTrigger(Enums.SaveSettingsStep.Idle);
}, 1000);
});
Remote.saveSettings(Utils.emptyFunction, {
'Language': sValue
});
});
oData.editorDefaultType.subscribe(function (sValue) {
Remote.saveSettings(Utils.emptyFunction, {
'EditorDefaultType': sValue
});
});
oData.messagesPerPage.subscribe(function (iValue) {
Remote.saveSettings(f1, {
'MPP': iValue
});
});
oData.showImages.subscribe(function (bValue) {
Remote.saveSettings(Utils.emptyFunction, {
'ShowImages': bValue ? '1' : '0'
});
});
oData.interfaceAnimation.subscribe(function (sValue) {
Remote.saveSettings(Utils.emptyFunction, {
'InterfaceAnimation': sValue
});
});
oData.useDesktopNotifications.subscribe(function (bValue) {
Utils.timeOutAction('SaveDesktopNotifications', function () {
Remote.saveSettings(Utils.emptyFunction, {
'DesktopNotifications': bValue ? '1' : '0'
});
}, 3000);
});
oData.replySameFolder.subscribe(function (bValue) {
Utils.timeOutAction('SaveReplySameFolder', function () {
Remote.saveSettings(Utils.emptyFunction, {
'ReplySameFolder': bValue ? '1' : '0'
});
}, 3000);
});
oData.useThreads.subscribe(function (bValue) {
oData.messageList([]);
Remote.saveSettings(Utils.emptyFunction, {
'UseThreads': bValue ? '1' : '0'
});
});
oData.layout.subscribe(function (nValue) {
oData.messageList([]);
Remote.saveSettings(Utils.emptyFunction, {
'Layout': nValue
});
});
oData.useCheckboxesInList.subscribe(function (bValue) {
Remote.saveSettings(Utils.emptyFunction, {
'UseCheckboxesInList': bValue ? '1' : '0'
});
});
}, 50);
};
SettingsGeneral.prototype.onShow = function ()
{
RL.data().desktopNotifications.valueHasMutated();
};
SettingsGeneral.prototype.selectLanguage = function ()
{
kn.showScreenPopup(PopupsLanguagesViewModel);
};
module.exports = SettingsGeneral;
}(module));

View file

@ -0,0 +1,239 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'),
PopupsIdentityViewModel = require('../ViewModels/Popups/PopupsIdentityViewModel.js')
;
/**
* @constructor
*/
function SettingsIdentities()
{
var oData = RL.data();
this.editor = null;
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
this.accountEmail = oData.accountEmail;
this.displayName = oData.displayName;
this.signature = oData.signature;
this.signatureToAll = oData.signatureToAll;
this.replyTo = oData.replyTo;
this.signatureDom = ko.observable(null);
this.defaultIdentityIDTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.displayNameTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.replyTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.identities = oData.identities;
this.defaultIdentityID = oData.defaultIdentityID;
this.identitiesOptions = ko.computed(function () {
var
aList = this.identities(),
aResult = []
;
if (0 < aList.length)
{
aResult.push({
'id': this.accountEmail.peek(),
'name': this.formattedAccountIdentity(),
'seporator': false
});
aResult.push({
'id': '---',
'name': '---',
'seporator': true,
'disabled': true
});
_.each(aList, function (oItem) {
aResult.push({
'id': oItem.id,
'name': oItem.formattedNameForEmail(),
'seporator': false
});
});
}
return aResult;
}, this);
this.processText = ko.computed(function () {
return oData.identitiesLoading() ? Utils.i18n('SETTINGS_IDENTITIES/LOADING_PROCESS') : '';
}, this);
this.visibility = ko.computed(function () {
return '' === this.processText() ? 'hidden' : 'visible';
}, this);
this.identityForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
}
}
]});
}
kn.addSettingsViewModel(SettingsIdentities, 'SettingsIdentities', 'SETTINGS_LABELS/LABEL_IDENTITIES_NAME', 'identities');
/**
*
* @return {string}
*/
SettingsIdentities.prototype.formattedAccountIdentity = function ()
{
var
sDisplayName = this.displayName.peek(),
sEmail = this.accountEmail.peek()
;
return '' === sDisplayName ? sEmail : '"' + Utils.quoteName(sDisplayName) + '" <' + sEmail + '>';
};
SettingsIdentities.prototype.addNewIdentity = function ()
{
kn.showScreenPopup(PopupsIdentityViewModel);
};
SettingsIdentities.prototype.editIdentity = function (oIdentity)
{
kn.showScreenPopup(PopupsIdentityViewModel, [oIdentity]);
};
/**
* @param {IdentityModel} oIdentityToRemove
*/
SettingsIdentities.prototype.deleteIdentity = function (oIdentityToRemove)
{
if (oIdentityToRemove && oIdentityToRemove.deleteAccess())
{
this.identityForDeletion(null);
var
fRemoveFolder = function (oIdentity) {
return oIdentityToRemove === oIdentity;
}
;
if (oIdentityToRemove)
{
this.identities.remove(fRemoveFolder);
Remote.identityDelete(function () {
RL.accountsAndIdentities();
}, oIdentityToRemove.id);
}
}
};
SettingsIdentities.prototype.onFocus = function ()
{
if (!this.editor && this.signatureDom())
{
var
self = this,
sSignature = RL.data().signature()
;
this.editor = new NewHtmlEditorWrapper(self.signatureDom(), function () {
RL.data().signature(
(self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData()
);
}, function () {
if (':HTML:' === sSignature.substr(0, 6))
{
self.editor.setHtml(sSignature.substr(6), false);
}
else
{
self.editor.setPlain(sSignature, false);
}
});
}
};
SettingsIdentities.prototype.onBuild = function (oDom)
{
var self = this;
oDom
.on('click', '.identity-item .e-action', function () {
var oIdentityItem = ko.dataFor(this);
if (oIdentityItem)
{
self.editIdentity(oIdentityItem);
}
})
;
_.delay(function () {
var
oData = RL.data(),
f1 = Utils.settingsSaveHelperSimpleFunction(self.displayNameTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.defaultIdentityIDTrigger, self)
;
oData.defaultIdentityID.subscribe(function (sValue) {
Remote.saveSettings(f4, {
'DefaultIdentityID': sValue
});
});
oData.displayName.subscribe(function (sValue) {
Remote.saveSettings(f1, {
'DisplayName': sValue
});
});
oData.replyTo.subscribe(function (sValue) {
Remote.saveSettings(f2, {
'ReplyTo': sValue
});
});
oData.signature.subscribe(function (sValue) {
Remote.saveSettings(f3, {
'Signature': sValue
});
});
oData.signatureToAll.subscribe(function (bValue) {
Remote.saveSettings(null, {
'SignatureToAll': bValue ? '1' : '0'
});
});
}, 50);
};
module.exports = SettingsIdentities;
}(module));

View file

@ -0,0 +1,106 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js')
;
/**
* @constructor
*/
function SettingsIdentity()
{
var oData = RL.data();
this.editor = null;
this.displayName = oData.displayName;
this.signature = oData.signature;
this.signatureToAll = oData.signatureToAll;
this.replyTo = oData.replyTo;
this.signatureDom = ko.observable(null);
this.displayNameTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.replyTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.signatureTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
}
kn.addSettingsViewModel(SettingsIdentity, 'SettingsIdentity', 'SETTINGS_LABELS/LABEL_IDENTITY_NAME', 'identity');
SettingsIdentity.prototype.onFocus = function ()
{
if (!this.editor && this.signatureDom())
{
var
self = this,
sSignature = RL.data().signature()
;
this.editor = new NewHtmlEditorWrapper(self.signatureDom(), function () {
RL.data().signature(
(self.editor.isHtml() ? ':HTML:' : '') + self.editor.getData()
);
}, function () {
if (':HTML:' === sSignature.substr(0, 6))
{
self.editor.setHtml(sSignature.substr(6), false);
}
else
{
self.editor.setPlain(sSignature, false);
}
});
}
};
SettingsIdentity.prototype.onBuild = function ()
{
var self = this;
_.delay(function () {
var
oData = RL.data(),
f1 = Utils.settingsSaveHelperSimpleFunction(self.displayNameTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.replyTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.signatureTrigger, self)
;
oData.displayName.subscribe(function (sValue) {
Remote.saveSettings(f1, {
'DisplayName': sValue
});
});
oData.replyTo.subscribe(function (sValue) {
Remote.saveSettings(f2, {
'ReplyTo': sValue
});
});
oData.signature.subscribe(function (sValue) {
Remote.saveSettings(f3, {
'Signature': sValue
});
});
oData.signatureToAll.subscribe(function (bValue) {
Remote.saveSettings(null, {
'SignatureToAll': bValue ? '1' : '0'
});
});
}, 50);
};
module.exports = SettingsIdentity;
}(module));

View file

@ -0,0 +1,87 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
ko = require('../External/ko.js'),
Utils = require('../Common/Utils.js'),
PopupsAddOpenPgpKeyViewModel = require('../ViewModels/Popups/PopupsAddOpenPgpKeyViewModel.js'),
PopupsGenerateNewOpenPgpKeyViewModel = require('../ViewModels/Popups/PopupsGenerateNewOpenPgpKeyViewModel.js'),
PopupsViewOpenPgpKeyViewModel = require('../ViewModels/Popups/PopupsViewOpenPgpKeyViewModel.js')
;
/**
* @constructor
*/
function SettingsOpenPGP()
{
this.openpgpkeys = RL.data().openpgpkeys;
this.openpgpkeysPublic = RL.data().openpgpkeysPublic;
this.openpgpkeysPrivate = RL.data().openpgpkeysPrivate;
this.openPgpKeyForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend({'toggleSubscribe': [this,
function (oPrev) {
if (oPrev)
{
oPrev.deleteAccess(false);
}
}, function (oNext) {
if (oNext)
{
oNext.deleteAccess(true);
}
}
]});
}
kn.addSettingsViewModel(SettingsOpenPGP, 'SettingsOpenPGP', 'SETTINGS_LABELS/LABEL_OPEN_PGP_NAME', 'openpgp');
SettingsOpenPGP.prototype.addOpenPgpKey = function ()
{
kn.showScreenPopup(PopupsAddOpenPgpKeyViewModel);
};
SettingsOpenPGP.prototype.generateOpenPgpKey = function ()
{
kn.showScreenPopup(PopupsGenerateNewOpenPgpKeyViewModel);
};
SettingsOpenPGP.prototype.viewOpenPgpKey = function (oOpenPgpKey)
{
if (oOpenPgpKey)
{
kn.showScreenPopup(PopupsViewOpenPgpKeyViewModel, [oOpenPgpKey]);
}
};
/**
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove
*/
SettingsOpenPGP.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove)
{
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
{
this.openPgpKeyForDeletion(null);
if (oOpenPgpKeyToRemove && RL.data().openpgpKeyring)
{
this.openpgpkeys.remove(function (oOpenPgpKey) {
return oOpenPgpKeyToRemove === oOpenPgpKey;
});
RL.data().openpgpKeyring[oOpenPgpKeyToRemove.isPrivate ? 'privateKeys' : 'publicKeys']
.removeForId(oOpenPgpKeyToRemove.guid);
RL.data().openpgpKeyring.store();
RL.reloadOpenPgpKeys();
}
}
};
module.exports = SettingsOpenPGP;
}(module));

View file

@ -0,0 +1,172 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
ko = require('../External/ko.js'),
Enums = require('../Common/Utils.js'),
Globals = require('../Common/Globals.js'),
Utils = require('../Common/Utils.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'),
PopupsTwoFactorTestViewModel = require('../ViewModels/Popups/PopupsTwoFactorTestViewModel.js')
;
/**
* @constructor
*/
function SettingsSecurity()
{
this.processing = ko.observable(false);
this.clearing = ko.observable(false);
this.secreting = ko.observable(false);
this.viewUser = ko.observable('');
this.viewEnable = ko.observable(false);
this.viewEnable.subs = true;
this.twoFactorStatus = ko.observable(false);
this.viewSecret = ko.observable('');
this.viewBackupCodes = ko.observable('');
this.viewUrl = ko.observable('');
this.bFirst = true;
this.viewTwoFactorStatus = ko.computed(function () {
Globals.langChangeTrigger();
return Utils.i18n(
this.twoFactorStatus() ?
'SETTINGS_SECURITY/TWO_FACTOR_SECRET_CONFIGURED_DESC' :
'SETTINGS_SECURITY/TWO_FACTOR_SECRET_NOT_CONFIGURED_DESC'
);
}, this);
this.onResult = _.bind(this.onResult, this);
this.onSecretResult = _.bind(this.onSecretResult, this);
}
kn.addSettingsViewModel(SettingsSecurity, 'SettingsSecurity', 'SETTINGS_LABELS/LABEL_SECURITY_NAME', 'security');
SettingsSecurity.prototype.showSecret = function ()
{
this.secreting(true);
Remote.showTwoFactorSecret(this.onSecretResult);
};
SettingsSecurity.prototype.hideSecret = function ()
{
this.viewSecret('');
this.viewBackupCodes('');
this.viewUrl('');
};
SettingsSecurity.prototype.createTwoFactor = function ()
{
this.processing(true);
Remote.createTwoFactor(this.onResult);
};
SettingsSecurity.prototype.enableTwoFactor = function ()
{
this.processing(true);
Remote.enableTwoFactor(this.onResult, this.viewEnable());
};
SettingsSecurity.prototype.testTwoFactor = function ()
{
kn.showScreenPopup(PopupsTwoFactorTestViewModel);
};
SettingsSecurity.prototype.clearTwoFactor = function ()
{
this.viewSecret('');
this.viewBackupCodes('');
this.viewUrl('');
this.clearing(true);
Remote.clearTwoFactor(this.onResult);
};
SettingsSecurity.prototype.onShow = function ()
{
this.viewSecret('');
this.viewBackupCodes('');
this.viewUrl('');
};
SettingsSecurity.prototype.onResult = function (sResult, oData)
{
this.processing(false);
this.clearing(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.viewUser(Utils.pString(oData.Result.User));
this.viewEnable(!!oData.Result.Enable);
this.twoFactorStatus(!!oData.Result.IsSet);
this.viewSecret(Utils.pString(oData.Result.Secret));
this.viewBackupCodes(Utils.pString(oData.Result.BackupCodes).replace(/[\s]+/g, ' '));
this.viewUrl(Utils.pString(oData.Result.Url));
}
else
{
this.viewUser('');
this.viewEnable(false);
this.twoFactorStatus(false);
this.viewSecret('');
this.viewBackupCodes('');
this.viewUrl('');
}
if (this.bFirst)
{
this.bFirst = false;
var self = this;
this.viewEnable.subscribe(function (bValue) {
if (this.viewEnable.subs)
{
Remote.enableTwoFactor(function (sResult, oData) {
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
{
self.viewEnable.subs = false;
self.viewEnable(false);
self.viewEnable.subs = true;
}
}, bValue);
}
}, this);
}
};
SettingsSecurity.prototype.onSecretResult = function (sResult, oData)
{
this.secreting(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
this.viewSecret(Utils.pString(oData.Result.Secret));
this.viewUrl(Utils.pString(oData.Result.Url));
}
else
{
this.viewSecret('');
this.viewUrl('');
}
};
SettingsSecurity.prototype.onBuild = function ()
{
this.processing(true);
Remote.getTwoFactor(this.onResult);
};
module.exports = SettingsSecurity;
}(module));

View file

@ -0,0 +1,80 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
Utils = require('../Common/Utils.js')
;
/**
* @constructor
*/
function SettingsSocial()
{
var oData = RL.data();
this.googleEnable = oData.googleEnable;
this.googleActions = oData.googleActions;
this.googleLoggined = oData.googleLoggined;
this.googleUserName = oData.googleUserName;
this.facebookEnable = oData.facebookEnable;
this.facebookActions = oData.facebookActions;
this.facebookLoggined = oData.facebookLoggined;
this.facebookUserName = oData.facebookUserName;
this.twitterEnable = oData.twitterEnable;
this.twitterActions = oData.twitterActions;
this.twitterLoggined = oData.twitterLoggined;
this.twitterUserName = oData.twitterUserName;
this.connectGoogle = Utils.createCommand(this, function () {
if (!this.googleLoggined())
{
RL.googleConnect();
}
}, function () {
return !this.googleLoggined() && !this.googleActions();
});
this.disconnectGoogle = Utils.createCommand(this, function () {
RL.googleDisconnect();
});
this.connectFacebook = Utils.createCommand(this, function () {
if (!this.facebookLoggined())
{
RL.facebookConnect();
}
}, function () {
return !this.facebookLoggined() && !this.facebookActions();
});
this.disconnectFacebook = Utils.createCommand(this, function () {
RL.facebookDisconnect();
});
this.connectTwitter = Utils.createCommand(this, function () {
if (!this.twitterLoggined())
{
RL.twitterConnect();
}
}, function () {
return !this.twitterLoggined() && !this.twitterActions();
});
this.disconnectTwitter = Utils.createCommand(this, function () {
RL.twitterDisconnect();
});
}
kn.addSettingsViewModel(SettingsSocial, 'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social');
module.exports = SettingsSocial;
}(module));

View file

@ -0,0 +1,136 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
window = require('../External/window.js'),
$ = require('../External/jquery.js'),
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js')
;
/**
* @constructor
*/
function SettingsThemes()
{
var
self = this,
oData = RL.data()
;
this.mainTheme = oData.mainTheme;
this.themesObjects = ko.observableArray([]);
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
this.oLastAjax = null;
this.iTimer = 0;
RL.data().theme.subscribe(function (sValue) {
_.each(this.themesObjects(), function (oTheme) {
oTheme.selected(sValue === oTheme.name);
});
var
oThemeLink = $('#rlThemeLink'),
oThemeStyle = $('#rlThemeStyle'),
sUrl = oThemeLink.attr('href')
;
if (!sUrl)
{
sUrl = oThemeStyle.attr('data-href');
}
if (sUrl)
{
sUrl = sUrl.toString().replace(/\/-\/[^\/]+\/\-\//, '/-/' + sValue + '/-/');
sUrl = sUrl.toString().replace(/\/Css\/[^\/]+\/User\//, '/Css/0/User/');
if ('Json/' !== sUrl.substring(sUrl.length - 5, sUrl.length))
{
sUrl += 'Json/';
}
window.clearTimeout(self.iTimer);
self.themeTrigger(Enums.SaveSettingsStep.Animate);
if (this.oLastAjax && this.oLastAjax.abort)
{
this.oLastAjax.abort();
}
this.oLastAjax = $.ajax({
'url': sUrl,
'dataType': 'json'
}).done(function(aData) {
if (aData && Utils.isArray(aData) && 2 === aData.length)
{
if (oThemeLink && oThemeLink[0] && (!oThemeStyle || !oThemeStyle[0]))
{
oThemeStyle = $('<style id="rlThemeStyle"></style>');
oThemeLink.after(oThemeStyle);
oThemeLink.remove();
}
if (oThemeStyle && oThemeStyle[0])
{
oThemeStyle.attr('data-href', sUrl).attr('data-theme', aData[0]);
if (oThemeStyle && oThemeStyle[0] && oThemeStyle[0].styleSheet && !Utils.isUnd(oThemeStyle[0].styleSheet.cssText))
{
oThemeStyle[0].styleSheet.cssText = aData[1];
}
else
{
oThemeStyle.text(aData[1]);
}
}
self.themeTrigger(Enums.SaveSettingsStep.TrueResult);
}
}).always(function() {
self.iTimer = window.setTimeout(function () {
self.themeTrigger(Enums.SaveSettingsStep.Idle);
}, 1000);
self.oLastAjax = null;
});
}
Remote.saveSettings(null, {
'Theme': sValue
});
}, this);
}
kn.addSettingsViewModel(SettingsThemes, 'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes');
SettingsThemes.prototype.onBuild = function ()
{
var sCurrentTheme = RL.data().theme();
this.themesObjects(_.map(RL.data().themes(), function (sTheme) {
return {
'name': sTheme,
'nameDisplay': Utils.convertThemeName(sTheme),
'selected': ko.observable(sTheme === sCurrentTheme),
'themePreviewSrc': LinkBuilder.themePreviewLink(sTheme)
};
}));
};
module.exports = SettingsThemes;
}(module));

View file

@ -1,68 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsSocialScreen()
{
var oData = RL.data();
this.googleEnable = oData.googleEnable;
this.googleActions = oData.googleActions;
this.googleLoggined = oData.googleLoggined;
this.googleUserName = oData.googleUserName;
this.facebookEnable = oData.facebookEnable;
this.facebookActions = oData.facebookActions;
this.facebookLoggined = oData.facebookLoggined;
this.facebookUserName = oData.facebookUserName;
this.twitterEnable = oData.twitterEnable;
this.twitterActions = oData.twitterActions;
this.twitterLoggined = oData.twitterLoggined;
this.twitterUserName = oData.twitterUserName;
this.connectGoogle = Utils.createCommand(this, function () {
if (!this.googleLoggined())
{
RL.googleConnect();
}
}, function () {
return !this.googleLoggined() && !this.googleActions();
});
this.disconnectGoogle = Utils.createCommand(this, function () {
RL.googleDisconnect();
});
this.connectFacebook = Utils.createCommand(this, function () {
if (!this.facebookLoggined())
{
RL.facebookConnect();
}
}, function () {
return !this.facebookLoggined() && !this.facebookActions();
});
this.disconnectFacebook = Utils.createCommand(this, function () {
RL.facebookDisconnect();
});
this.connectTwitter = Utils.createCommand(this, function () {
if (!this.twitterLoggined())
{
RL.twitterConnect();
}
}, function () {
return !this.twitterLoggined() && !this.twitterActions();
});
this.disconnectTwitter = Utils.createCommand(this, function () {
RL.twitterDisconnect();
});
}
Utils.addSettingsViewModel(SettingsSocialScreen, 'SettingsSocial', 'SETTINGS_LABELS/LABEL_SOCIAL_NAME', 'social');

View file

@ -1,115 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/**
* @constructor
*/
function SettingsThemes()
{
var
self = this,
oData = RL.data()
;
this.mainTheme = oData.mainTheme;
this.themesObjects = ko.observableArray([]);
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
this.oLastAjax = null;
this.iTimer = 0;
RL.data().theme.subscribe(function (sValue) {
_.each(this.themesObjects(), function (oTheme) {
oTheme.selected(sValue === oTheme.name);
});
var
oThemeLink = $('#rlThemeLink'),
oThemeStyle = $('#rlThemeStyle'),
sUrl = oThemeLink.attr('href')
;
if (!sUrl)
{
sUrl = oThemeStyle.attr('data-href');
}
if (sUrl)
{
sUrl = sUrl.toString().replace(/\/-\/[^\/]+\/\-\//, '/-/' + sValue + '/-/');
sUrl = sUrl.toString().replace(/\/Css\/[^\/]+\/User\//, '/Css/0/User/');
if ('Json/' !== sUrl.substring(sUrl.length - 5, sUrl.length))
{
sUrl += 'Json/';
}
window.clearTimeout(self.iTimer);
self.themeTrigger(Enums.SaveSettingsStep.Animate);
if (this.oLastAjax && this.oLastAjax.abort)
{
this.oLastAjax.abort();
}
this.oLastAjax = $.ajax({
'url': sUrl,
'dataType': 'json'
}).done(function(aData) {
if (aData && Utils.isArray(aData) && 2 === aData.length)
{
if (oThemeLink && oThemeLink[0] && (!oThemeStyle || !oThemeStyle[0]))
{
oThemeStyle = $('<style id="rlThemeStyle"></style>');
oThemeLink.after(oThemeStyle);
oThemeLink.remove();
}
if (oThemeStyle && oThemeStyle[0])
{
oThemeStyle.attr('data-href', sUrl).attr('data-theme', aData[0]);
if (oThemeStyle && oThemeStyle[0] && oThemeStyle[0].styleSheet && !Utils.isUnd(oThemeStyle[0].styleSheet.cssText))
{
oThemeStyle[0].styleSheet.cssText = aData[1];
}
else
{
oThemeStyle.text(aData[1]);
}
}
self.themeTrigger(Enums.SaveSettingsStep.TrueResult);
}
}).always(function() {
self.iTimer = window.setTimeout(function () {
self.themeTrigger(Enums.SaveSettingsStep.Idle);
}, 1000);
self.oLastAjax = null;
});
}
RL.remote().saveSettings(null, {
'Theme': sValue
});
}, this);
}
Utils.addSettingsViewModel(SettingsThemes, 'SettingsThemes', 'SETTINGS_LABELS/LABEL_THEMES_NAME', 'themes');
SettingsThemes.prototype.onBuild = function ()
{
var sCurrentTheme = RL.data().theme();
this.themesObjects(_.map(RL.data().themes(), function (sTheme) {
return {
'name': sTheme,
'nameDisplay': Utils.convertThemeName(sTheme),
'selected': ko.observable(sTheme === sCurrentTheme),
'themePreviewSrc': RL.link().themePreviewLink(sTheme)
};
}));
};

View file

@ -5,13 +5,17 @@
'use strict'; 'use strict';
var var
window = require('./External/window.js'), window = require('../External/window.js'),
$ = require('./External/jquery.js'), $ = require('../External/jquery.js'),
Consts = require('./Common/Consts.js'),
Enums = require('./Common/Enums.js'), Consts = require('../Common/Consts.js'),
Globals = require('./Common/Globals.js'), Enums = require('../Common/Enums.js'),
Utils = require('./Common/Utils.js'), Globals = require('../Common/Globals.js'),
Plugins = require('./Common/Plugins.js') Utils = require('../Common/Utils.js'),
Plugins = require('../Common/Plugins.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
RL = require('../RL.js')
; ;
/** /**
@ -59,7 +63,7 @@
if (Consts.Values.TokenErrorLimit < Globals.iTokenErrorCount) if (Consts.Values.TokenErrorLimit < Globals.iTokenErrorCount)
{ {
RL.loginAndLogoutReload(true); // TODO cjs RL().loginAndLogoutReload(true);
} }
if (oData.Logout || Consts.Values.AjaxErrorLimit < Globals.iAjaxErrorCount) if (oData.Logout || Consts.Values.AjaxErrorLimit < Globals.iAjaxErrorCount)
@ -69,7 +73,7 @@
window.__rlah_clear(); window.__rlah_clear();
} }
RL.loginAndLogoutReload(true); // TODO cjs RL().loginAndLogoutReload(true);
} }
} }
else if (Enums.StorageResultType.Success === sType && oData && oData.Result) else if (Enums.StorageResultType.Success === sType && oData && oData.Result)
@ -164,7 +168,7 @@
oDefAjax = $.ajax({ oDefAjax = $.ajax({
'type': bPost ? 'POST' : 'GET', 'type': bPost ? 'POST' : 'GET',
'url': RL.link().ajax(sGetAdd), // TODO cjs 'url': LinkBuilder.ajax(sGetAdd),
'async': true, 'async': true,
'dataType': 'json', 'dataType': 'json',
'data': bPost ? oParameters : {}, 'data': bPost ? oParameters : {},

View file

@ -1,48 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
Enums = require('./Common/Enums.js'),
Utils = require('./Common/Utils.js'),
RL = require('./RL.js')
;
/**
* @constructor
*/
function AbstractCacheStorage()
{
this.bCapaGravatar = RL().capa(Enums.Capa.Gravatar);
}
/**
* @type {Object}
*/
AbstractCacheStorage.prototype.oServices = {};
/**
* @type {boolean}
*/
AbstractCacheStorage.prototype.bCapaGravatar = false;
AbstractCacheStorage.prototype.clear = function ()
{
this.bCapaGravatar = !!this.bCapaGravatar; // TODO
};
/**
* @param {string} sEmail
* @return {string}
*/
AbstractCacheStorage.prototype.getUserPic = function (sEmail, fCallback)
{
sEmail = Utils.trim(sEmail);
fCallback(this.bCapaGravatar && '' !== sEmail ? RL().link().avatarLink(sEmail) : '', sEmail);
};
module.exports = AbstractCacheStorage;
}(module));

View file

@ -5,11 +5,11 @@
'use strict'; 'use strict';
var var
ko = require('./External/ko.js'), ko = require('../External/ko.js'),
key = require('./External/key.js'), key = require('../External/key.js'),
Enums = require('./Common/Enums.js'), Enums = require('../Common/Enums.js'),
Globals = require('./Common/Globals.js'), Globals = require('../Common/Globals.js'),
Utils = require('./Common/Utils.js') Utils = require('../Common/Utils.js')
; ;
/** /**

View file

@ -5,8 +5,8 @@
'use strict'; 'use strict';
var var
_ = require('./External/underscore.js'), _ = require('../External/underscore.js'),
AbstractAjaxRemoteStorage = require('./Storages/AbstractAjaxRemoteStorage.js') AbstractAjaxRemoteStorage = require('./AbstractAjaxRemoteStorage.js')
; ;
/** /**
@ -270,6 +270,6 @@
this.defaultRequest(fCallback, 'AdminPing'); this.defaultRequest(fCallback, 'AdminPing');
}; };
module.exports = AdminAjaxRemoteStorage; module.exports = new AdminAjaxRemoteStorage();
}(module)); }(module));

View file

@ -1,25 +0,0 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
(function (module) {
'use strict';
var
_ = require('./External/underscore.js'),
AbstractCacheStorage = require('./Storages/AbstractCacheStorage.js')
;
/**
* @constructor
* @extends AbstractCacheStorage
*/
function AdminCacheStorage()
{
AbstractCacheStorage.call(this);
}
_.extend(AdminCacheStorage.prototype, AbstractCacheStorage.prototype);
module.exports = AdminCacheStorage;
}(module));

View file

@ -5,9 +5,10 @@
'use strict'; 'use strict';
var var
_ = require('./External/underscore.js'), _ = require('../External/underscore.js'),
ko = require('./External/ko.js'), ko = require('../External/ko.js'),
AbstractData = require('./Storages/AbstractData.js')
AbstractData = require('./AbstractData.js')
; ;
/** /**
@ -62,6 +63,6 @@
AbstractData.prototype.populateDataOnStart.call(this); AbstractData.prototype.populateDataOnStart.call(this);
}; };
module.exports = AdminDataStorage; module.exports = new AdminDataStorage();
}(module)); }(module));

View file

@ -5,9 +5,9 @@
'use strict'; 'use strict';
var var
_ = require('./External/underscore.js'), _ = require('../External/underscore.js'),
CookieDriver = require('./Storages/LocalStorages/CookieDriver.js'), CookieDriver = require('./LocalStorages/CookieDriver.js'),
LocalStorageDriver = require('./Storages/LocalStorages/LocalStorageDriver.js') LocalStorageDriver = require('./LocalStorages/LocalStorageDriver.js')
; ;
/** /**
@ -49,6 +49,6 @@
return this.oDriver ? this.oDriver.get('p' + iKey) : null; return this.oDriver ? this.oDriver.get('p' + iKey) : null;
}; };
module.exports = LocalStorage; module.exports = new LocalStorage();
}(module)); }(module));

View file

@ -5,10 +5,10 @@
'use strict'; 'use strict';
var var
$ = require('./External/jquery.js'), $ = require('../../External/jquery.js'),
JSON = require('./External/JSON.js'), JSON = require('../../External/JSON.js'),
Consts = require('./Common/Consts.js'), Consts = require('../../Common/Consts.js'),
Utils = require('./Common/Utils.js') Utils = require('../../Common/Utils.js')
; ;
/** /**

View file

@ -5,10 +5,10 @@
'use strict'; 'use strict';
var var
window = require('./External/window.js'), window = require('../../External/window.js'),
JSON = require('./External/JSON.js'), JSON = require('../../External/JSON.js'),
Consts = require('./Common/Consts.js'), Consts = require('../../Common/Consts.js'),
Utils = require('./Common/Utils.js') Utils = require('../../Common/Utils.js')
; ;
/** /**

View file

@ -1,23 +1,37 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
_ = require('../External/underscore.js'),
Utils = require('../Common/Utils.js'),
Cache = require('../Storages/WebMailCacheStorage.js'),
AbstractAjaxRemoteStorage = require('./AbstractAjaxRemoteStorage.js')
;
/**
* @constructor * @constructor
* @extends AbstractAjaxRemoteStorage * @extends AbstractAjaxRemoteStorage
*/ */
function WebMailAjaxRemoteStorage() function WebMailAjaxRemoteStorage()
{ {
AbstractAjaxRemoteStorage.call(this); AbstractAjaxRemoteStorage.call(this);
this.oRequests = {}; this.oRequests = {};
} }
_.extend(WebMailAjaxRemoteStorage.prototype, AbstractAjaxRemoteStorage.prototype); _.extend(WebMailAjaxRemoteStorage.prototype, AbstractAjaxRemoteStorage.prototype);
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.folders = function (fCallback) WebMailAjaxRemoteStorage.prototype.folders = function (fCallback)
{ {
this.defaultRequest(fCallback, 'Folders', { this.defaultRequest(fCallback, 'Folders', {
'SentFolder': RL.settingsGet('SentFolder'), 'SentFolder': RL.settingsGet('SentFolder'),
'DraftFolder': RL.settingsGet('DraftFolder'), 'DraftFolder': RL.settingsGet('DraftFolder'),
@ -25,9 +39,9 @@ WebMailAjaxRemoteStorage.prototype.folders = function (fCallback)
'TrashFolder': RL.settingsGet('TrashFolder'), 'TrashFolder': RL.settingsGet('TrashFolder'),
'ArchiveFolder': RL.settingsGet('ArchiveFolder') 'ArchiveFolder': RL.settingsGet('ArchiveFolder')
}, null, '', ['Folders']); }, null, '', ['Folders']);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sEmail * @param {string} sEmail
* @param {string} sLogin * @param {string} sLogin
@ -37,8 +51,8 @@ WebMailAjaxRemoteStorage.prototype.folders = function (fCallback)
* @param {string=} sAdditionalCode * @param {string=} sAdditionalCode
* @param {boolean=} bAdditionalCodeSignMe * @param {boolean=} bAdditionalCodeSignMe
*/ */
WebMailAjaxRemoteStorage.prototype.login = function (fCallback, sEmail, sLogin, sPassword, bSignMe, sLanguage, sAdditionalCode, bAdditionalCodeSignMe) WebMailAjaxRemoteStorage.prototype.login = function (fCallback, sEmail, sLogin, sPassword, bSignMe, sLanguage, sAdditionalCode, bAdditionalCodeSignMe)
{ {
this.defaultRequest(fCallback, 'Login', { this.defaultRequest(fCallback, 'Login', {
'Email': sEmail, 'Email': sEmail,
'Login': sLogin, 'Login': sLogin,
@ -48,122 +62,122 @@ WebMailAjaxRemoteStorage.prototype.login = function (fCallback, sEmail, sLogin,
'AdditionalCodeSignMe': bAdditionalCodeSignMe ? '1' : '0', 'AdditionalCodeSignMe': bAdditionalCodeSignMe ? '1' : '0',
'SignMe': bSignMe ? '1' : '0' 'SignMe': bSignMe ? '1' : '0'
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.getTwoFactor = function (fCallback) WebMailAjaxRemoteStorage.prototype.getTwoFactor = function (fCallback)
{ {
this.defaultRequest(fCallback, 'GetTwoFactorInfo'); this.defaultRequest(fCallback, 'GetTwoFactorInfo');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.createTwoFactor = function (fCallback) WebMailAjaxRemoteStorage.prototype.createTwoFactor = function (fCallback)
{ {
this.defaultRequest(fCallback, 'CreateTwoFactorSecret'); this.defaultRequest(fCallback, 'CreateTwoFactorSecret');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.clearTwoFactor = function (fCallback) WebMailAjaxRemoteStorage.prototype.clearTwoFactor = function (fCallback)
{ {
this.defaultRequest(fCallback, 'ClearTwoFactorInfo'); this.defaultRequest(fCallback, 'ClearTwoFactorInfo');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.showTwoFactorSecret = function (fCallback) WebMailAjaxRemoteStorage.prototype.showTwoFactorSecret = function (fCallback)
{ {
this.defaultRequest(fCallback, 'ShowTwoFactorSecret'); this.defaultRequest(fCallback, 'ShowTwoFactorSecret');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sCode * @param {string} sCode
*/ */
WebMailAjaxRemoteStorage.prototype.testTwoFactor = function (fCallback, sCode) WebMailAjaxRemoteStorage.prototype.testTwoFactor = function (fCallback, sCode)
{ {
this.defaultRequest(fCallback, 'TestTwoFactorInfo', { this.defaultRequest(fCallback, 'TestTwoFactorInfo', {
'Code': sCode 'Code': sCode
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {boolean} bEnable * @param {boolean} bEnable
*/ */
WebMailAjaxRemoteStorage.prototype.enableTwoFactor = function (fCallback, bEnable) WebMailAjaxRemoteStorage.prototype.enableTwoFactor = function (fCallback, bEnable)
{ {
this.defaultRequest(fCallback, 'EnableTwoFactor', { this.defaultRequest(fCallback, 'EnableTwoFactor', {
'Enable': bEnable ? '1' : '0' 'Enable': bEnable ? '1' : '0'
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.clearTwoFactorInfo = function (fCallback) WebMailAjaxRemoteStorage.prototype.clearTwoFactorInfo = function (fCallback)
{ {
this.defaultRequest(fCallback, 'ClearTwoFactorInfo'); this.defaultRequest(fCallback, 'ClearTwoFactorInfo');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.contactsSync = function (fCallback) WebMailAjaxRemoteStorage.prototype.contactsSync = function (fCallback)
{ {
this.defaultRequest(fCallback, 'ContactsSync', null, Consts.Defaults.ContactsSyncAjaxTimeout); this.defaultRequest(fCallback, 'ContactsSync', null, Consts.Defaults.ContactsSyncAjaxTimeout);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {boolean} bEnable * @param {boolean} bEnable
* @param {string} sUrl * @param {string} sUrl
* @param {string} sUser * @param {string} sUser
* @param {string} sPassword * @param {string} sPassword
*/ */
WebMailAjaxRemoteStorage.prototype.saveContactsSyncData = function (fCallback, bEnable, sUrl, sUser, sPassword) WebMailAjaxRemoteStorage.prototype.saveContactsSyncData = function (fCallback, bEnable, sUrl, sUser, sPassword)
{ {
this.defaultRequest(fCallback, 'SaveContactsSyncData', { this.defaultRequest(fCallback, 'SaveContactsSyncData', {
'Enable': bEnable ? '1' : '0', 'Enable': bEnable ? '1' : '0',
'Url': sUrl, 'Url': sUrl,
'User': sUser, 'User': sUser,
'Password': sPassword 'Password': sPassword
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sEmail * @param {string} sEmail
* @param {string} sLogin * @param {string} sLogin
* @param {string} sPassword * @param {string} sPassword
*/ */
WebMailAjaxRemoteStorage.prototype.accountAdd = function (fCallback, sEmail, sLogin, sPassword) WebMailAjaxRemoteStorage.prototype.accountAdd = function (fCallback, sEmail, sLogin, sPassword)
{ {
this.defaultRequest(fCallback, 'AccountAdd', { this.defaultRequest(fCallback, 'AccountAdd', {
'Email': sEmail, 'Email': sEmail,
'Login': sLogin, 'Login': sLogin,
'Password': sPassword 'Password': sPassword
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sEmailToDelete * @param {string} sEmailToDelete
*/ */
WebMailAjaxRemoteStorage.prototype.accountDelete = function (fCallback, sEmailToDelete) WebMailAjaxRemoteStorage.prototype.accountDelete = function (fCallback, sEmailToDelete)
{ {
this.defaultRequest(fCallback, 'AccountDelete', { this.defaultRequest(fCallback, 'AccountDelete', {
'EmailToDelete': sEmailToDelete 'EmailToDelete': sEmailToDelete
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sId * @param {string} sId
* @param {string} sEmail * @param {string} sEmail
@ -171,8 +185,8 @@ WebMailAjaxRemoteStorage.prototype.accountDelete = function (fCallback, sEmailTo
* @param {string} sReplyTo * @param {string} sReplyTo
* @param {string} sBcc * @param {string} sBcc
*/ */
WebMailAjaxRemoteStorage.prototype.identityUpdate = function (fCallback, sId, sEmail, sName, sReplyTo, sBcc) WebMailAjaxRemoteStorage.prototype.identityUpdate = function (fCallback, sId, sEmail, sName, sReplyTo, sBcc)
{ {
this.defaultRequest(fCallback, 'IdentityUpdate', { this.defaultRequest(fCallback, 'IdentityUpdate', {
'Id': sId, 'Id': sId,
'Email': sEmail, 'Email': sEmail,
@ -180,28 +194,28 @@ WebMailAjaxRemoteStorage.prototype.identityUpdate = function (fCallback, sId, sE
'ReplyTo': sReplyTo, 'ReplyTo': sReplyTo,
'Bcc': sBcc 'Bcc': sBcc
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sIdToDelete * @param {string} sIdToDelete
*/ */
WebMailAjaxRemoteStorage.prototype.identityDelete = function (fCallback, sIdToDelete) WebMailAjaxRemoteStorage.prototype.identityDelete = function (fCallback, sIdToDelete)
{ {
this.defaultRequest(fCallback, 'IdentityDelete', { this.defaultRequest(fCallback, 'IdentityDelete', {
'IdToDelete': sIdToDelete 'IdToDelete': sIdToDelete
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.accountsAndIdentities = function (fCallback) WebMailAjaxRemoteStorage.prototype.accountsAndIdentities = function (fCallback)
{ {
this.defaultRequest(fCallback, 'AccountsAndIdentities'); this.defaultRequest(fCallback, 'AccountsAndIdentities');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {number=} iOffset = 0 * @param {number=} iOffset = 0
@ -209,13 +223,13 @@ WebMailAjaxRemoteStorage.prototype.accountsAndIdentities = function (fCallback)
* @param {string=} sSearch = '' * @param {string=} sSearch = ''
* @param {boolean=} bSilent = false * @param {boolean=} bSilent = false
*/ */
WebMailAjaxRemoteStorage.prototype.messageList = function (fCallback, sFolderFullNameRaw, iOffset, iLimit, sSearch, bSilent) WebMailAjaxRemoteStorage.prototype.messageList = function (fCallback, sFolderFullNameRaw, iOffset, iLimit, sSearch, bSilent)
{ {
sFolderFullNameRaw = Utils.pString(sFolderFullNameRaw); sFolderFullNameRaw = Utils.pString(sFolderFullNameRaw);
var var
oData = RL.data(), oData = RL.data(),
sFolderHash = RL.cache().getFolderHash(sFolderFullNameRaw) sFolderHash = Cache.getFolderHash(sFolderFullNameRaw)
; ;
bSilent = Utils.isUnd(bSilent) ? false : !!bSilent; bSilent = Utils.isUnd(bSilent) ? false : !!bSilent;
@ -234,7 +248,7 @@ WebMailAjaxRemoteStorage.prototype.messageList = function (fCallback, sFolderFul
sSearch, sSearch,
oData.projectHash(), oData.projectHash(),
sFolderHash, sFolderHash,
'INBOX' === sFolderFullNameRaw ? RL.cache().getFolderUidNext(sFolderFullNameRaw) : '', 'INBOX' === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '',
oData.threading() && oData.useThreads() ? '1' : '0', oData.threading() && oData.useThreads() ? '1' : '0',
oData.threading() && sFolderFullNameRaw === oData.messageListThreadFolder() ? oData.messageListThreadUids().join(',') : '' oData.threading() && sFolderFullNameRaw === oData.messageListThreadFolder() ? oData.messageListThreadUids().join(',') : ''
].join(String.fromCharCode(0))), bSilent ? [] : ['MessageList']); ].join(String.fromCharCode(0))), bSilent ? [] : ['MessageList']);
@ -246,36 +260,36 @@ WebMailAjaxRemoteStorage.prototype.messageList = function (fCallback, sFolderFul
'Offset': iOffset, 'Offset': iOffset,
'Limit': iLimit, 'Limit': iLimit,
'Search': sSearch, 'Search': sSearch,
'UidNext': 'INBOX' === sFolderFullNameRaw ? RL.cache().getFolderUidNext(sFolderFullNameRaw) : '', 'UidNext': 'INBOX' === sFolderFullNameRaw ? Cache.getFolderUidNext(sFolderFullNameRaw) : '',
'UseThreads': RL.data().threading() && RL.data().useThreads() ? '1' : '0', 'UseThreads': RL.data().threading() && RL.data().useThreads() ? '1' : '0',
'ExpandedThreadUid': oData.threading() && sFolderFullNameRaw === oData.messageListThreadFolder() ? oData.messageListThreadUids().join(',') : '' 'ExpandedThreadUid': oData.threading() && sFolderFullNameRaw === oData.messageListThreadFolder() ? oData.messageListThreadUids().join(',') : ''
}, '' === sSearch ? Consts.Defaults.DefaultAjaxTimeout : Consts.Defaults.SearchAjaxTimeout, '', bSilent ? [] : ['MessageList']); }, '' === sSearch ? Consts.Defaults.DefaultAjaxTimeout : Consts.Defaults.SearchAjaxTimeout, '', bSilent ? [] : ['MessageList']);
} }
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {Array} aDownloads * @param {Array} aDownloads
*/ */
WebMailAjaxRemoteStorage.prototype.messageUploadAttachments = function (fCallback, aDownloads) WebMailAjaxRemoteStorage.prototype.messageUploadAttachments = function (fCallback, aDownloads)
{ {
this.defaultRequest(fCallback, 'MessageUploadAttachments', { this.defaultRequest(fCallback, 'MessageUploadAttachments', {
'Attachments': aDownloads 'Attachments': aDownloads
}, 999000); }, 999000);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {number} iUid * @param {number} iUid
* @return {boolean} * @return {boolean}
*/ */
WebMailAjaxRemoteStorage.prototype.message = function (fCallback, sFolderFullNameRaw, iUid) WebMailAjaxRemoteStorage.prototype.message = function (fCallback, sFolderFullNameRaw, iUid)
{ {
sFolderFullNameRaw = Utils.pString(sFolderFullNameRaw); sFolderFullNameRaw = Utils.pString(sFolderFullNameRaw);
iUid = Utils.pInt(iUid); iUid = Utils.pInt(iUid);
if (RL.cache().getFolderFromCacheList(sFolderFullNameRaw) && 0 < iUid) if (Cache.getFolderFromCacheList(sFolderFullNameRaw) && 0 < iUid)
{ {
this.defaultRequest(fCallback, 'Message', {}, null, this.defaultRequest(fCallback, 'Message', {}, null,
'Message/' + Base64.urlsafe_encode([ 'Message/' + Base64.urlsafe_encode([
@ -289,42 +303,41 @@ WebMailAjaxRemoteStorage.prototype.message = function (fCallback, sFolderFullNam
} }
return false; return false;
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {Array} aExternals * @param {Array} aExternals
*/ */
WebMailAjaxRemoteStorage.prototype.composeUploadExternals = function (fCallback, aExternals) WebMailAjaxRemoteStorage.prototype.composeUploadExternals = function (fCallback, aExternals)
{ {
this.defaultRequest(fCallback, 'ComposeUploadExternals', { this.defaultRequest(fCallback, 'ComposeUploadExternals', {
'Externals': aExternals 'Externals': aExternals
}, 999000); }, 999000);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sUrl * @param {string} sUrl
* @param {string} sAccessToken * @param {string} sAccessToken
*/ */
WebMailAjaxRemoteStorage.prototype.composeUploadDrive = function (fCallback, sUrl, sAccessToken) WebMailAjaxRemoteStorage.prototype.composeUploadDrive = function (fCallback, sUrl, sAccessToken)
{ {
this.defaultRequest(fCallback, 'ComposeUploadDrive', { this.defaultRequest(fCallback, 'ComposeUploadDrive', {
'AccessToken': sAccessToken, 'AccessToken': sAccessToken,
'Url': sUrl 'Url': sUrl
}, 999000); }, 999000);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sFolder * @param {string} sFolder
* @param {Array=} aList = [] * @param {Array=} aList = []
*/ */
WebMailAjaxRemoteStorage.prototype.folderInformation = function (fCallback, sFolder, aList) WebMailAjaxRemoteStorage.prototype.folderInformation = function (fCallback, sFolder, aList)
{ {
var var
bRequest = true, bRequest = true,
oCache = RL.cache(),
aUids = [] aUids = []
; ;
@ -332,7 +345,7 @@ WebMailAjaxRemoteStorage.prototype.folderInformation = function (fCallback, sFol
{ {
bRequest = false; bRequest = false;
_.each(aList, function (oMessageListItem) { _.each(aList, function (oMessageListItem) {
if (!oCache.getMessageFlagsFromCache(oMessageListItem.folderFullNameRaw, oMessageListItem.uid)) if (!Cache.getMessageFlagsFromCache(oMessageListItem.folderFullNameRaw, oMessageListItem.uid))
{ {
aUids.push(oMessageListItem.uid); aUids.push(oMessageListItem.uid);
} }
@ -340,7 +353,7 @@ WebMailAjaxRemoteStorage.prototype.folderInformation = function (fCallback, sFol
if (0 < oMessageListItem.threads().length) if (0 < oMessageListItem.threads().length)
{ {
_.each(oMessageListItem.threads(), function (sUid) { _.each(oMessageListItem.threads(), function (sUid) {
if (!oCache.getMessageFlagsFromCache(oMessageListItem.folderFullNameRaw, sUid)) if (!Cache.getMessageFlagsFromCache(oMessageListItem.folderFullNameRaw, sUid))
{ {
aUids.push(sUid); aUids.push(sUid);
} }
@ -359,78 +372,78 @@ WebMailAjaxRemoteStorage.prototype.folderInformation = function (fCallback, sFol
this.defaultRequest(fCallback, 'FolderInformation', { this.defaultRequest(fCallback, 'FolderInformation', {
'Folder': sFolder, 'Folder': sFolder,
'FlagsUids': Utils.isArray(aUids) ? aUids.join(',') : '', 'FlagsUids': Utils.isArray(aUids) ? aUids.join(',') : '',
'UidNext': 'INBOX' === sFolder ? RL.cache().getFolderUidNext(sFolder) : '' 'UidNext': 'INBOX' === sFolder ? Cache.getFolderUidNext(sFolder) : ''
}); });
} }
else if (RL.data().useThreads()) else if (RL.data().useThreads())
{ {
RL.reloadFlagsCurrentMessageListAndMessageFromCache(); RL.reloadFlagsCurrentMessageListAndMessageFromCache();
} }
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {Array} aFolders * @param {Array} aFolders
*/ */
WebMailAjaxRemoteStorage.prototype.folderInformationMultiply = function (fCallback, aFolders) WebMailAjaxRemoteStorage.prototype.folderInformationMultiply = function (fCallback, aFolders)
{ {
this.defaultRequest(fCallback, 'FolderInformationMultiply', { this.defaultRequest(fCallback, 'FolderInformationMultiply', {
'Folders': aFolders 'Folders': aFolders
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.logout = function (fCallback) WebMailAjaxRemoteStorage.prototype.logout = function (fCallback)
{ {
this.defaultRequest(fCallback, 'Logout'); this.defaultRequest(fCallback, 'Logout');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {Array} aUids * @param {Array} aUids
* @param {boolean} bSetFlagged * @param {boolean} bSetFlagged
*/ */
WebMailAjaxRemoteStorage.prototype.messageSetFlagged = function (fCallback, sFolderFullNameRaw, aUids, bSetFlagged) WebMailAjaxRemoteStorage.prototype.messageSetFlagged = function (fCallback, sFolderFullNameRaw, aUids, bSetFlagged)
{ {
this.defaultRequest(fCallback, 'MessageSetFlagged', { this.defaultRequest(fCallback, 'MessageSetFlagged', {
'Folder': sFolderFullNameRaw, 'Folder': sFolderFullNameRaw,
'Uids': aUids.join(','), 'Uids': aUids.join(','),
'SetAction': bSetFlagged ? '1' : '0' 'SetAction': bSetFlagged ? '1' : '0'
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {Array} aUids * @param {Array} aUids
* @param {boolean} bSetSeen * @param {boolean} bSetSeen
*/ */
WebMailAjaxRemoteStorage.prototype.messageSetSeen = function (fCallback, sFolderFullNameRaw, aUids, bSetSeen) WebMailAjaxRemoteStorage.prototype.messageSetSeen = function (fCallback, sFolderFullNameRaw, aUids, bSetSeen)
{ {
this.defaultRequest(fCallback, 'MessageSetSeen', { this.defaultRequest(fCallback, 'MessageSetSeen', {
'Folder': sFolderFullNameRaw, 'Folder': sFolderFullNameRaw,
'Uids': aUids.join(','), 'Uids': aUids.join(','),
'SetAction': bSetSeen ? '1' : '0' 'SetAction': bSetSeen ? '1' : '0'
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {boolean} bSetSeen * @param {boolean} bSetSeen
*/ */
WebMailAjaxRemoteStorage.prototype.messageSetSeenToAll = function (fCallback, sFolderFullNameRaw, bSetSeen) WebMailAjaxRemoteStorage.prototype.messageSetSeenToAll = function (fCallback, sFolderFullNameRaw, bSetSeen)
{ {
this.defaultRequest(fCallback, 'MessageSetSeenToAll', { this.defaultRequest(fCallback, 'MessageSetSeenToAll', {
'Folder': sFolderFullNameRaw, 'Folder': sFolderFullNameRaw,
'SetAction': bSetSeen ? '1' : '0' 'SetAction': bSetSeen ? '1' : '0'
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sMessageFolder * @param {string} sMessageFolder
* @param {string} sMessageUid * @param {string} sMessageUid
@ -447,9 +460,9 @@ WebMailAjaxRemoteStorage.prototype.messageSetSeenToAll = function (fCallback, sF
* @param {string} sInReplyTo * @param {string} sInReplyTo
* @param {string} sReferences * @param {string} sReferences
*/ */
WebMailAjaxRemoteStorage.prototype.saveMessage = function (fCallback, sMessageFolder, sMessageUid, sDraftFolder, WebMailAjaxRemoteStorage.prototype.saveMessage = function (fCallback, sMessageFolder, sMessageUid, sDraftFolder,
sFrom, sTo, sCc, sBcc, sSubject, bTextIsHtml, sText, aAttachments, aDraftInfo, sInReplyTo, sReferences) sFrom, sTo, sCc, sBcc, sSubject, bTextIsHtml, sText, aAttachments, aDraftInfo, sInReplyTo, sReferences)
{ {
this.defaultRequest(fCallback, 'SaveMessage', { this.defaultRequest(fCallback, 'SaveMessage', {
'MessageFolder': sMessageFolder, 'MessageFolder': sMessageFolder,
'MessageUid': sMessageUid, 'MessageUid': sMessageUid,
@ -466,10 +479,10 @@ WebMailAjaxRemoteStorage.prototype.saveMessage = function (fCallback, sMessageFo
'References': sReferences, 'References': sReferences,
'Attachments': aAttachments 'Attachments': aAttachments
}, Consts.Defaults.SaveMessageAjaxTimeout); }, Consts.Defaults.SaveMessageAjaxTimeout);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sMessageFolder * @param {string} sMessageFolder
* @param {string} sMessageUid * @param {string} sMessageUid
@ -477,8 +490,8 @@ WebMailAjaxRemoteStorage.prototype.saveMessage = function (fCallback, sMessageFo
* @param {string} sSubject * @param {string} sSubject
* @param {string} sText * @param {string} sText
*/ */
WebMailAjaxRemoteStorage.prototype.sendReadReceiptMessage = function (fCallback, sMessageFolder, sMessageUid, sReadReceipt, sSubject, sText) WebMailAjaxRemoteStorage.prototype.sendReadReceiptMessage = function (fCallback, sMessageFolder, sMessageUid, sReadReceipt, sSubject, sText)
{ {
this.defaultRequest(fCallback, 'SendReadReceiptMessage', { this.defaultRequest(fCallback, 'SendReadReceiptMessage', {
'MessageFolder': sMessageFolder, 'MessageFolder': sMessageFolder,
'MessageUid': sMessageUid, 'MessageUid': sMessageUid,
@ -486,9 +499,9 @@ WebMailAjaxRemoteStorage.prototype.sendReadReceiptMessage = function (fCallback,
'Subject': sSubject, 'Subject': sSubject,
'Text': sText 'Text': sText
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sMessageFolder * @param {string} sMessageFolder
* @param {string} sMessageUid * @param {string} sMessageUid
@ -506,9 +519,9 @@ WebMailAjaxRemoteStorage.prototype.sendReadReceiptMessage = function (fCallback,
* @param {string} sReferences * @param {string} sReferences
* @param {boolean} bRequestReadReceipt * @param {boolean} bRequestReadReceipt
*/ */
WebMailAjaxRemoteStorage.prototype.sendMessage = function (fCallback, sMessageFolder, sMessageUid, sSentFolder, WebMailAjaxRemoteStorage.prototype.sendMessage = function (fCallback, sMessageFolder, sMessageUid, sSentFolder,
sFrom, sTo, sCc, sBcc, sSubject, bTextIsHtml, sText, aAttachments, aDraftInfo, sInReplyTo, sReferences, bRequestReadReceipt) sFrom, sTo, sCc, sBcc, sSubject, bTextIsHtml, sText, aAttachments, aDraftInfo, sInReplyTo, sReferences, bRequestReadReceipt)
{ {
this.defaultRequest(fCallback, 'SendMessage', { this.defaultRequest(fCallback, 'SendMessage', {
'MessageFolder': sMessageFolder, 'MessageFolder': sMessageFolder,
'MessageUid': sMessageUid, 'MessageUid': sMessageUid,
@ -526,266 +539,269 @@ WebMailAjaxRemoteStorage.prototype.sendMessage = function (fCallback, sMessageFo
'ReadReceiptRequest': bRequestReadReceipt ? '1' : '0', 'ReadReceiptRequest': bRequestReadReceipt ? '1' : '0',
'Attachments': aAttachments 'Attachments': aAttachments
}, Consts.Defaults.SendMessageAjaxTimeout); }, Consts.Defaults.SendMessageAjaxTimeout);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {Object} oData * @param {Object} oData
*/ */
WebMailAjaxRemoteStorage.prototype.saveSystemFolders = function (fCallback, oData) WebMailAjaxRemoteStorage.prototype.saveSystemFolders = function (fCallback, oData)
{ {
this.defaultRequest(fCallback, 'SystemFoldersUpdate', oData); this.defaultRequest(fCallback, 'SystemFoldersUpdate', oData);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {Object} oData * @param {Object} oData
*/ */
WebMailAjaxRemoteStorage.prototype.saveSettings = function (fCallback, oData) WebMailAjaxRemoteStorage.prototype.saveSettings = function (fCallback, oData)
{ {
this.defaultRequest(fCallback, 'SettingsUpdate', oData); this.defaultRequest(fCallback, 'SettingsUpdate', oData);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sPrevPassword * @param {string} sPrevPassword
* @param {string} sNewPassword * @param {string} sNewPassword
*/ */
WebMailAjaxRemoteStorage.prototype.changePassword = function (fCallback, sPrevPassword, sNewPassword) WebMailAjaxRemoteStorage.prototype.changePassword = function (fCallback, sPrevPassword, sNewPassword)
{ {
this.defaultRequest(fCallback, 'ChangePassword', { this.defaultRequest(fCallback, 'ChangePassword', {
'PrevPassword': sPrevPassword, 'PrevPassword': sPrevPassword,
'NewPassword': sNewPassword 'NewPassword': sNewPassword
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sNewFolderName * @param {string} sNewFolderName
* @param {string} sParentName * @param {string} sParentName
*/ */
WebMailAjaxRemoteStorage.prototype.folderCreate = function (fCallback, sNewFolderName, sParentName) WebMailAjaxRemoteStorage.prototype.folderCreate = function (fCallback, sNewFolderName, sParentName)
{ {
this.defaultRequest(fCallback, 'FolderCreate', { this.defaultRequest(fCallback, 'FolderCreate', {
'Folder': sNewFolderName, 'Folder': sNewFolderName,
'Parent': sParentName 'Parent': sParentName
}, null, '', ['Folders']); }, null, '', ['Folders']);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
*/ */
WebMailAjaxRemoteStorage.prototype.folderDelete = function (fCallback, sFolderFullNameRaw) WebMailAjaxRemoteStorage.prototype.folderDelete = function (fCallback, sFolderFullNameRaw)
{ {
this.defaultRequest(fCallback, 'FolderDelete', { this.defaultRequest(fCallback, 'FolderDelete', {
'Folder': sFolderFullNameRaw 'Folder': sFolderFullNameRaw
}, null, '', ['Folders']); }, null, '', ['Folders']);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sPrevFolderFullNameRaw * @param {string} sPrevFolderFullNameRaw
* @param {string} sNewFolderName * @param {string} sNewFolderName
*/ */
WebMailAjaxRemoteStorage.prototype.folderRename = function (fCallback, sPrevFolderFullNameRaw, sNewFolderName) WebMailAjaxRemoteStorage.prototype.folderRename = function (fCallback, sPrevFolderFullNameRaw, sNewFolderName)
{ {
this.defaultRequest(fCallback, 'FolderRename', { this.defaultRequest(fCallback, 'FolderRename', {
'Folder': sPrevFolderFullNameRaw, 'Folder': sPrevFolderFullNameRaw,
'NewFolderName': sNewFolderName 'NewFolderName': sNewFolderName
}, null, '', ['Folders']); }, null, '', ['Folders']);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
*/ */
WebMailAjaxRemoteStorage.prototype.folderClear = function (fCallback, sFolderFullNameRaw) WebMailAjaxRemoteStorage.prototype.folderClear = function (fCallback, sFolderFullNameRaw)
{ {
this.defaultRequest(fCallback, 'FolderClear', { this.defaultRequest(fCallback, 'FolderClear', {
'Folder': sFolderFullNameRaw 'Folder': sFolderFullNameRaw
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {boolean} bSubscribe * @param {boolean} bSubscribe
*/ */
WebMailAjaxRemoteStorage.prototype.folderSetSubscribe = function (fCallback, sFolderFullNameRaw, bSubscribe) WebMailAjaxRemoteStorage.prototype.folderSetSubscribe = function (fCallback, sFolderFullNameRaw, bSubscribe)
{ {
this.defaultRequest(fCallback, 'FolderSubscribe', { this.defaultRequest(fCallback, 'FolderSubscribe', {
'Folder': sFolderFullNameRaw, 'Folder': sFolderFullNameRaw,
'Subscribe': bSubscribe ? '1' : '0' 'Subscribe': bSubscribe ? '1' : '0'
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sFolder * @param {string} sFolder
* @param {string} sToFolder * @param {string} sToFolder
* @param {Array} aUids * @param {Array} aUids
* @param {string=} sLearning * @param {string=} sLearning
*/ */
WebMailAjaxRemoteStorage.prototype.messagesMove = function (fCallback, sFolder, sToFolder, aUids, sLearning) WebMailAjaxRemoteStorage.prototype.messagesMove = function (fCallback, sFolder, sToFolder, aUids, sLearning)
{ {
this.defaultRequest(fCallback, 'MessageMove', { this.defaultRequest(fCallback, 'MessageMove', {
'FromFolder': sFolder, 'FromFolder': sFolder,
'ToFolder': sToFolder, 'ToFolder': sToFolder,
'Uids': aUids.join(','), 'Uids': aUids.join(','),
'Learning': sLearning || '' 'Learning': sLearning || ''
}, null, '', ['MessageList']); }, null, '', ['MessageList']);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sFolder * @param {string} sFolder
* @param {string} sToFolder * @param {string} sToFolder
* @param {Array} aUids * @param {Array} aUids
*/ */
WebMailAjaxRemoteStorage.prototype.messagesCopy = function (fCallback, sFolder, sToFolder, aUids) WebMailAjaxRemoteStorage.prototype.messagesCopy = function (fCallback, sFolder, sToFolder, aUids)
{ {
this.defaultRequest(fCallback, 'MessageCopy', { this.defaultRequest(fCallback, 'MessageCopy', {
'FromFolder': sFolder, 'FromFolder': sFolder,
'ToFolder': sToFolder, 'ToFolder': sToFolder,
'Uids': aUids.join(',') 'Uids': aUids.join(',')
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sFolder * @param {string} sFolder
* @param {Array} aUids * @param {Array} aUids
*/ */
WebMailAjaxRemoteStorage.prototype.messagesDelete = function (fCallback, sFolder, aUids) WebMailAjaxRemoteStorage.prototype.messagesDelete = function (fCallback, sFolder, aUids)
{ {
this.defaultRequest(fCallback, 'MessageDelete', { this.defaultRequest(fCallback, 'MessageDelete', {
'Folder': sFolder, 'Folder': sFolder,
'Uids': aUids.join(',') 'Uids': aUids.join(',')
}, null, '', ['MessageList']); }, null, '', ['MessageList']);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.appDelayStart = function (fCallback) WebMailAjaxRemoteStorage.prototype.appDelayStart = function (fCallback)
{ {
this.defaultRequest(fCallback, 'AppDelayStart'); this.defaultRequest(fCallback, 'AppDelayStart');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.quota = function (fCallback) WebMailAjaxRemoteStorage.prototype.quota = function (fCallback)
{ {
this.defaultRequest(fCallback, 'Quota'); this.defaultRequest(fCallback, 'Quota');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {number} iOffset * @param {number} iOffset
* @param {number} iLimit * @param {number} iLimit
* @param {string} sSearch * @param {string} sSearch
*/ */
WebMailAjaxRemoteStorage.prototype.contacts = function (fCallback, iOffset, iLimit, sSearch) WebMailAjaxRemoteStorage.prototype.contacts = function (fCallback, iOffset, iLimit, sSearch)
{ {
this.defaultRequest(fCallback, 'Contacts', { this.defaultRequest(fCallback, 'Contacts', {
'Offset': iOffset, 'Offset': iOffset,
'Limit': iLimit, 'Limit': iLimit,
'Search': sSearch 'Search': sSearch
}, null, '', ['Contacts']); }, null, '', ['Contacts']);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, sTags, aProperties) WebMailAjaxRemoteStorage.prototype.contactSave = function (fCallback, sRequestUid, sUid, sTags, aProperties)
{ {
this.defaultRequest(fCallback, 'ContactSave', { this.defaultRequest(fCallback, 'ContactSave', {
'RequestUid': sRequestUid, 'RequestUid': sRequestUid,
'Uid': Utils.trim(sUid), 'Uid': Utils.trim(sUid),
'Tags': Utils.trim(sTags), 'Tags': Utils.trim(sTags),
'Properties': aProperties 'Properties': aProperties
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {Array} aUids * @param {Array} aUids
*/ */
WebMailAjaxRemoteStorage.prototype.contactsDelete = function (fCallback, aUids) WebMailAjaxRemoteStorage.prototype.contactsDelete = function (fCallback, aUids)
{ {
this.defaultRequest(fCallback, 'ContactsDelete', { this.defaultRequest(fCallback, 'ContactsDelete', {
'Uids': aUids.join(',') 'Uids': aUids.join(',')
}); });
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
* @param {string} sQuery * @param {string} sQuery
* @param {number} iPage * @param {number} iPage
*/ */
WebMailAjaxRemoteStorage.prototype.suggestions = function (fCallback, sQuery, iPage) WebMailAjaxRemoteStorage.prototype.suggestions = function (fCallback, sQuery, iPage)
{ {
this.defaultRequest(fCallback, 'Suggestions', { this.defaultRequest(fCallback, 'Suggestions', {
'Query': sQuery, 'Query': sQuery,
'Page': iPage 'Page': iPage
}, null, '', ['Suggestions']); }, null, '', ['Suggestions']);
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.facebookUser = function (fCallback) WebMailAjaxRemoteStorage.prototype.facebookUser = function (fCallback)
{ {
this.defaultRequest(fCallback, 'SocialFacebookUserInformation'); this.defaultRequest(fCallback, 'SocialFacebookUserInformation');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.facebookDisconnect = function (fCallback) WebMailAjaxRemoteStorage.prototype.facebookDisconnect = function (fCallback)
{ {
this.defaultRequest(fCallback, 'SocialFacebookDisconnect'); this.defaultRequest(fCallback, 'SocialFacebookDisconnect');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.twitterUser = function (fCallback) WebMailAjaxRemoteStorage.prototype.twitterUser = function (fCallback)
{ {
this.defaultRequest(fCallback, 'SocialTwitterUserInformation'); this.defaultRequest(fCallback, 'SocialTwitterUserInformation');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.twitterDisconnect = function (fCallback) WebMailAjaxRemoteStorage.prototype.twitterDisconnect = function (fCallback)
{ {
this.defaultRequest(fCallback, 'SocialTwitterDisconnect'); this.defaultRequest(fCallback, 'SocialTwitterDisconnect');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.googleUser = function (fCallback) WebMailAjaxRemoteStorage.prototype.googleUser = function (fCallback)
{ {
this.defaultRequest(fCallback, 'SocialGoogleUserInformation'); this.defaultRequest(fCallback, 'SocialGoogleUserInformation');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.googleDisconnect = function (fCallback) WebMailAjaxRemoteStorage.prototype.googleDisconnect = function (fCallback)
{ {
this.defaultRequest(fCallback, 'SocialGoogleDisconnect'); this.defaultRequest(fCallback, 'SocialGoogleDisconnect');
}; };
/** /**
* @param {?Function} fCallback * @param {?Function} fCallback
*/ */
WebMailAjaxRemoteStorage.prototype.socialUsers = function (fCallback) WebMailAjaxRemoteStorage.prototype.socialUsers = function (fCallback)
{ {
this.defaultRequest(fCallback, 'SocialUsers'); this.defaultRequest(fCallback, 'SocialUsers');
}; };
module.exports = new WebMailAjaxRemoteStorage();
}(module));

View file

@ -1,13 +1,24 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
* @constructor
* @extends AbstractCacheStorage
*/
function WebMailCacheStorage()
{
AbstractCacheStorage.call(this);
'use strict';
var
_ = require('../External/underscore.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
RL = require('../RL.js')
;
/**
* @constructor
*/
function WebMailCacheStorage()
{
this.oFoldersCache = {}; this.oFoldersCache = {};
this.oFoldersNamesCache = {}; this.oFoldersNamesCache = {};
this.oFolderHashCache = {}; this.oFolderHashCache = {};
@ -16,59 +27,62 @@ function WebMailCacheStorage()
this.oMessageFlagsCache = {}; this.oMessageFlagsCache = {};
this.oNewMessage = {}; this.oNewMessage = {};
this.oRequestedMessage = {}; this.oRequestedMessage = {};
}
_.extend(WebMailCacheStorage.prototype, AbstractCacheStorage.prototype); this.bCapaGravatar = RL().capa(Enums.Capa.Gravatar);
}
/** /**
* @type {boolean}
*/
WebMailCacheStorage.prototype.bCapaGravatar = false;
/**
* @type {Object} * @type {Object}
*/ */
WebMailCacheStorage.prototype.oFoldersCache = {}; WebMailCacheStorage.prototype.oFoldersCache = {};
/** /**
* @type {Object} * @type {Object}
*/ */
WebMailCacheStorage.prototype.oFoldersNamesCache = {}; WebMailCacheStorage.prototype.oFoldersNamesCache = {};
/** /**
* @type {Object} * @type {Object}
*/ */
WebMailCacheStorage.prototype.oFolderHashCache = {}; WebMailCacheStorage.prototype.oFolderHashCache = {};
/** /**
* @type {Object} * @type {Object}
*/ */
WebMailCacheStorage.prototype.oFolderUidNextCache = {}; WebMailCacheStorage.prototype.oFolderUidNextCache = {};
/** /**
* @type {Object} * @type {Object}
*/ */
WebMailCacheStorage.prototype.oMessageListHashCache = {}; WebMailCacheStorage.prototype.oMessageListHashCache = {};
/** /**
* @type {Object} * @type {Object}
*/ */
WebMailCacheStorage.prototype.oMessageFlagsCache = {}; WebMailCacheStorage.prototype.oMessageFlagsCache = {};
/** /**
* @type {Object} * @type {Object}
*/ */
WebMailCacheStorage.prototype.oBodies = {}; WebMailCacheStorage.prototype.oBodies = {};
/** /**
* @type {Object} * @type {Object}
*/ */
WebMailCacheStorage.prototype.oNewMessage = {}; WebMailCacheStorage.prototype.oNewMessage = {};
/** /**
* @type {Object} * @type {Object}
*/ */
WebMailCacheStorage.prototype.oRequestedMessage = {}; WebMailCacheStorage.prototype.oRequestedMessage = {};
WebMailCacheStorage.prototype.clear = function ()
{
AbstractCacheStorage.prototype.clear.call(this);
WebMailCacheStorage.prototype.clear = function ()
{
this.oFoldersCache = {}; this.oFoldersCache = {};
this.oFoldersNamesCache = {}; this.oFoldersNamesCache = {};
this.oFolderHashCache = {}; this.oFolderHashCache = {};
@ -76,52 +90,64 @@ WebMailCacheStorage.prototype.clear = function ()
this.oMessageListHashCache = {}; this.oMessageListHashCache = {};
this.oMessageFlagsCache = {}; this.oMessageFlagsCache = {};
this.oBodies = {}; this.oBodies = {};
}; };
/**
/**
* @param {string} sEmail
* @param {Function} fCallback
* @return {string}
*/
WebMailCacheStorage.prototype.getUserPic = function (sEmail, fCallback)
{
sEmail = Utils.trim(sEmail);
fCallback(this.bCapaGravatar && '' !== sEmail ? LinkBuilder.avatarLink(sEmail) : '', sEmail);
};
/**
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {string} sUid * @param {string} sUid
* @return {string} * @return {string}
*/ */
WebMailCacheStorage.prototype.getMessageKey = function (sFolderFullNameRaw, sUid) WebMailCacheStorage.prototype.getMessageKey = function (sFolderFullNameRaw, sUid)
{ {
return sFolderFullNameRaw + '#' + sUid; return sFolderFullNameRaw + '#' + sUid;
}; };
/** /**
* @param {string} sFolder * @param {string} sFolder
* @param {string} sUid * @param {string} sUid
*/ */
WebMailCacheStorage.prototype.addRequestedMessage = function (sFolder, sUid) WebMailCacheStorage.prototype.addRequestedMessage = function (sFolder, sUid)
{ {
this.oRequestedMessage[this.getMessageKey(sFolder, sUid)] = true; this.oRequestedMessage[this.getMessageKey(sFolder, sUid)] = true;
}; };
/** /**
* @param {string} sFolder * @param {string} sFolder
* @param {string} sUid * @param {string} sUid
* @return {boolean} * @return {boolean}
*/ */
WebMailCacheStorage.prototype.hasRequestedMessage = function (sFolder, sUid) WebMailCacheStorage.prototype.hasRequestedMessage = function (sFolder, sUid)
{ {
return true === this.oRequestedMessage[this.getMessageKey(sFolder, sUid)]; return true === this.oRequestedMessage[this.getMessageKey(sFolder, sUid)];
}; };
/** /**
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {string} sUid * @param {string} sUid
*/ */
WebMailCacheStorage.prototype.addNewMessageCache = function (sFolderFullNameRaw, sUid) WebMailCacheStorage.prototype.addNewMessageCache = function (sFolderFullNameRaw, sUid)
{ {
this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)] = true; this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)] = true;
}; };
/** /**
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {string} sUid * @param {string} sUid
*/ */
WebMailCacheStorage.prototype.hasNewMessageAndRemoveFromCache = function (sFolderFullNameRaw, sUid) WebMailCacheStorage.prototype.hasNewMessageAndRemoveFromCache = function (sFolderFullNameRaw, sUid)
{ {
if (this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)]) if (this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)])
{ {
this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)] = null; this.oNewMessage[this.getMessageKey(sFolderFullNameRaw, sUid)] = null;
@ -129,132 +155,132 @@ WebMailCacheStorage.prototype.hasNewMessageAndRemoveFromCache = function (sFolde
} }
return false; return false;
}; };
WebMailCacheStorage.prototype.clearNewMessageCache = function () WebMailCacheStorage.prototype.clearNewMessageCache = function ()
{ {
this.oNewMessage = {}; this.oNewMessage = {};
}; };
/** /**
* @param {string} sFolderHash * @param {string} sFolderHash
* @return {string} * @return {string}
*/ */
WebMailCacheStorage.prototype.getFolderFullNameRaw = function (sFolderHash) WebMailCacheStorage.prototype.getFolderFullNameRaw = function (sFolderHash)
{ {
return '' !== sFolderHash && this.oFoldersNamesCache[sFolderHash] ? this.oFoldersNamesCache[sFolderHash] : ''; return '' !== sFolderHash && this.oFoldersNamesCache[sFolderHash] ? this.oFoldersNamesCache[sFolderHash] : '';
}; };
/** /**
* @param {string} sFolderHash * @param {string} sFolderHash
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
*/ */
WebMailCacheStorage.prototype.setFolderFullNameRaw = function (sFolderHash, sFolderFullNameRaw) WebMailCacheStorage.prototype.setFolderFullNameRaw = function (sFolderHash, sFolderFullNameRaw)
{ {
this.oFoldersNamesCache[sFolderHash] = sFolderFullNameRaw; this.oFoldersNamesCache[sFolderHash] = sFolderFullNameRaw;
}; };
/** /**
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @return {string} * @return {string}
*/ */
WebMailCacheStorage.prototype.getFolderHash = function (sFolderFullNameRaw) WebMailCacheStorage.prototype.getFolderHash = function (sFolderFullNameRaw)
{ {
return '' !== sFolderFullNameRaw && this.oFolderHashCache[sFolderFullNameRaw] ? this.oFolderHashCache[sFolderFullNameRaw] : ''; return '' !== sFolderFullNameRaw && this.oFolderHashCache[sFolderFullNameRaw] ? this.oFolderHashCache[sFolderFullNameRaw] : '';
}; };
/** /**
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {string} sFolderHash * @param {string} sFolderHash
*/ */
WebMailCacheStorage.prototype.setFolderHash = function (sFolderFullNameRaw, sFolderHash) WebMailCacheStorage.prototype.setFolderHash = function (sFolderFullNameRaw, sFolderHash)
{ {
this.oFolderHashCache[sFolderFullNameRaw] = sFolderHash; this.oFolderHashCache[sFolderFullNameRaw] = sFolderHash;
}; };
/** /**
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @return {string} * @return {string}
*/ */
WebMailCacheStorage.prototype.getFolderUidNext = function (sFolderFullNameRaw) WebMailCacheStorage.prototype.getFolderUidNext = function (sFolderFullNameRaw)
{ {
return '' !== sFolderFullNameRaw && this.oFolderUidNextCache[sFolderFullNameRaw] ? this.oFolderUidNextCache[sFolderFullNameRaw] : ''; return '' !== sFolderFullNameRaw && this.oFolderUidNextCache[sFolderFullNameRaw] ? this.oFolderUidNextCache[sFolderFullNameRaw] : '';
}; };
/** /**
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {string} sUidNext * @param {string} sUidNext
*/ */
WebMailCacheStorage.prototype.setFolderUidNext = function (sFolderFullNameRaw, sUidNext) WebMailCacheStorage.prototype.setFolderUidNext = function (sFolderFullNameRaw, sUidNext)
{ {
this.oFolderUidNextCache[sFolderFullNameRaw] = sUidNext; this.oFolderUidNextCache[sFolderFullNameRaw] = sUidNext;
}; };
/** /**
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @return {?FolderModel} * @return {?FolderModel}
*/ */
WebMailCacheStorage.prototype.getFolderFromCacheList = function (sFolderFullNameRaw) WebMailCacheStorage.prototype.getFolderFromCacheList = function (sFolderFullNameRaw)
{ {
return '' !== sFolderFullNameRaw && this.oFoldersCache[sFolderFullNameRaw] ? this.oFoldersCache[sFolderFullNameRaw] : null; return '' !== sFolderFullNameRaw && this.oFoldersCache[sFolderFullNameRaw] ? this.oFoldersCache[sFolderFullNameRaw] : null;
}; };
/** /**
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {?FolderModel} oFolder * @param {?FolderModel} oFolder
*/ */
WebMailCacheStorage.prototype.setFolderToCacheList = function (sFolderFullNameRaw, oFolder) WebMailCacheStorage.prototype.setFolderToCacheList = function (sFolderFullNameRaw, oFolder)
{ {
this.oFoldersCache[sFolderFullNameRaw] = oFolder; this.oFoldersCache[sFolderFullNameRaw] = oFolder;
}; };
/** /**
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
*/ */
WebMailCacheStorage.prototype.removeFolderFromCacheList = function (sFolderFullNameRaw) WebMailCacheStorage.prototype.removeFolderFromCacheList = function (sFolderFullNameRaw)
{ {
this.setFolderToCacheList(sFolderFullNameRaw, null); this.setFolderToCacheList(sFolderFullNameRaw, null);
}; };
/** /**
* @param {string} sFolderFullName * @param {string} sFolderFullName
* @param {string} sUid * @param {string} sUid
* @return {?Array} * @return {?Array}
*/ */
WebMailCacheStorage.prototype.getMessageFlagsFromCache = function (sFolderFullName, sUid) WebMailCacheStorage.prototype.getMessageFlagsFromCache = function (sFolderFullName, sUid)
{ {
return this.oMessageFlagsCache[sFolderFullName] && this.oMessageFlagsCache[sFolderFullName][sUid] ? return this.oMessageFlagsCache[sFolderFullName] && this.oMessageFlagsCache[sFolderFullName][sUid] ?
this.oMessageFlagsCache[sFolderFullName][sUid] : null; this.oMessageFlagsCache[sFolderFullName][sUid] : null;
}; };
/** /**
* @param {string} sFolderFullName * @param {string} sFolderFullName
* @param {string} sUid * @param {string} sUid
* @param {Array} aFlagsCache * @param {Array} aFlagsCache
*/ */
WebMailCacheStorage.prototype.setMessageFlagsToCache = function (sFolderFullName, sUid, aFlagsCache) WebMailCacheStorage.prototype.setMessageFlagsToCache = function (sFolderFullName, sUid, aFlagsCache)
{ {
if (!this.oMessageFlagsCache[sFolderFullName]) if (!this.oMessageFlagsCache[sFolderFullName])
{ {
this.oMessageFlagsCache[sFolderFullName] = {}; this.oMessageFlagsCache[sFolderFullName] = {};
} }
this.oMessageFlagsCache[sFolderFullName][sUid] = aFlagsCache; this.oMessageFlagsCache[sFolderFullName][sUid] = aFlagsCache;
}; };
/** /**
* @param {string} sFolderFullName * @param {string} sFolderFullName
*/ */
WebMailCacheStorage.prototype.clearMessageFlagsFromCacheByFolder = function (sFolderFullName) WebMailCacheStorage.prototype.clearMessageFlagsFromCacheByFolder = function (sFolderFullName)
{ {
this.oMessageFlagsCache[sFolderFullName] = {}; this.oMessageFlagsCache[sFolderFullName] = {};
}; };
/** /**
* @param {(MessageModel|null)} oMessage * @param {(MessageModel|null)} oMessage
*/ */
WebMailCacheStorage.prototype.initMessageFlagsFromCache = function (oMessage) WebMailCacheStorage.prototype.initMessageFlagsFromCache = function (oMessage)
{ {
if (oMessage) if (oMessage)
{ {
var var
@ -289,13 +315,13 @@ WebMailCacheStorage.prototype.initMessageFlagsFromCache = function (oMessage)
oMessage.hasFlaggedSubMessage(mFlaggedSubUid && 0 < Utils.pInt(mFlaggedSubUid)); oMessage.hasFlaggedSubMessage(mFlaggedSubUid && 0 < Utils.pInt(mFlaggedSubUid));
} }
} }
}; };
/** /**
* @param {(MessageModel|null)} oMessage * @param {(MessageModel|null)} oMessage
*/ */
WebMailCacheStorage.prototype.storeMessageFlagsToCache = function (oMessage) WebMailCacheStorage.prototype.storeMessageFlagsToCache = function (oMessage)
{ {
if (oMessage) if (oMessage)
{ {
this.setMessageFlagsToCache( this.setMessageFlagsToCache(
@ -304,16 +330,20 @@ WebMailCacheStorage.prototype.storeMessageFlagsToCache = function (oMessage)
[oMessage.unseen(), oMessage.flagged(), oMessage.answered(), oMessage.forwarded(), oMessage.isReadReceipt()] [oMessage.unseen(), oMessage.flagged(), oMessage.answered(), oMessage.forwarded(), oMessage.isReadReceipt()]
); );
} }
}; };
/** /**
* @param {string} sFolder * @param {string} sFolder
* @param {string} sUid * @param {string} sUid
* @param {Array} aFlags * @param {Array} aFlags
*/ */
WebMailCacheStorage.prototype.storeMessageFlagsToCacheByFolderAndUid = function (sFolder, sUid, aFlags) WebMailCacheStorage.prototype.storeMessageFlagsToCacheByFolderAndUid = function (sFolder, sUid, aFlags)
{ {
if (Utils.isArray(aFlags) && 0 < aFlags.length) if (Utils.isArray(aFlags) && 0 < aFlags.length)
{ {
this.setMessageFlagsToCache(sFolder, sUid, aFlags); this.setMessageFlagsToCache(sFolder, sUid, aFlags);
} }
}; };
module.exports = new WebMailCacheStorage();
}(module));

View file

@ -5,19 +5,29 @@
'use strict'; 'use strict';
var var
window = require('./External/window.js'), window = require('../External/window.js'),
$ = require('./External/jquery.js'), $ = require('../External/jquery.js'),
_ = require('./External/underscore.js'), _ = require('../External/underscore.js'),
ko = require('./External/ko.js'), ko = require('../External/ko.js'),
moment = require('./External/moment.js'), moment = require('../External/moment.js'),
$div = require('./External/$div.js'), $div = require('../External/$div.js'),
NotificationClass = require('./External/NotificationClass.js'), NotificationClass = require('../External/NotificationClass.js'),
Consts = require('./Common/Consts.js'),
Enums = require('./Common/Enums.js'), Consts = require('../Common/Consts.js'),
Globals = require('./Common/Globals.js'), Enums = require('../Common/Enums.js'),
Utils = require('./Common/Utils.js'), Globals = require('../Common/Globals.js'),
kn = require('./Knoin/Knoin.js'), Utils = require('../Common/Utils.js'),
AbstractData = require('./Storages/AbstractData.js') LinkBuilder = require('../Common/LinkBuilder.js'),
Cache = require('../Storages/WebMailCacheStorage.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'),
MessageModel = require('../Models/MessageModel.js'),
LocalStorage = require('./LocalStorage.js'),
AbstractData = require('./AbstractData.js')
; ;
/** /**
@ -31,7 +41,7 @@
var var
fRemoveSystemFolderType = function (observable) { fRemoveSystemFolderType = function (observable) {
return function () { return function () {
var oFolder = RL.cache().getFolderFromCacheList(observable()); // TODO cjs var oFolder = Cache.getFolderFromCacheList(observable()); // TODO cjs
if (oFolder) if (oFolder)
{ {
oFolder.type(Enums.FolderType.User); oFolder.type(Enums.FolderType.User);
@ -40,7 +50,7 @@
}, },
fSetSystemFolderType = function (iType) { fSetSystemFolderType = function (iType) {
return function (sValue) { return function (sValue) {
var oFolder = RL.cache().getFolderFromCacheList(sValue); // TODO cjs var oFolder = Cache.getFolderFromCacheList(sValue); // TODO cjs
if (oFolder) if (oFolder)
{ {
oFolder.type(iType); oFolder.type(iType);
@ -219,7 +229,7 @@
this.folderListSystem = ko.computed(function () { this.folderListSystem = ko.computed(function () {
return _.compact(_.map(this.folderListSystemNames(), function (sName) { return _.compact(_.map(this.folderListSystemNames(), function (sName) {
return RL.cache().getFolderFromCacheList(sName); // TODO cjs return Cache.getFolderFromCacheList(sName); // TODO cjs
})); }));
}, this); }, this);
@ -263,7 +273,7 @@
this.mainMessageListSearch = ko.computed({ this.mainMessageListSearch = ko.computed({
'read': this.messageListSearch, 'read': this.messageListSearch,
'write': function (sValue) { 'write': function (sValue) {
kn.setHash(RL.link().mailBox( // TODO cjs kn.setHash(LinkBuilder.mailBox( // TODO cjs
this.currentFolderFullNameHash(), 1, Utils.trim(sValue.toString()) this.currentFolderFullNameHash(), 1, Utils.trim(sValue.toString())
)); ));
}, },
@ -513,7 +523,7 @@
this.signatureToAll(!!RL.settingsGet('SignatureToAll')); this.signatureToAll(!!RL.settingsGet('SignatureToAll'));
this.enableTwoFactor(!!RL.settingsGet('EnableTwoFactor')); this.enableTwoFactor(!!RL.settingsGet('EnableTwoFactor'));
this.lastFoldersHash = RL.local().get(Enums.ClientSideKeyName.FoldersLashHash) || ''; this.lastFoldersHash = LocalStorage.get(Enums.ClientSideKeyName.FoldersLashHash) || '';
this.remoteSuggestions = !!RL.settingsGet('RemoteSuggestions'); this.remoteSuggestions = !!RL.settingsGet('RemoteSuggestions');
@ -528,7 +538,6 @@
if (Utils.isArray(aNewMessages) && 0 < aNewMessages.length) if (Utils.isArray(aNewMessages) && 0 < aNewMessages.length)
{ {
var var
oCache = RL.cache(),// TODO cjs
iIndex = 0, iIndex = 0,
iLen = aNewMessages.length, iLen = aNewMessages.length,
fNotificationHelper = function (sImageSrc, sTitle, sText) fNotificationHelper = function (sImageSrc, sTitle, sText)
@ -566,13 +575,13 @@
; ;
_.each(aNewMessages, function (oItem) { _.each(aNewMessages, function (oItem) {
oCache.addNewMessageCache(sFolder, oItem.Uid); Cache.addNewMessageCache(sFolder, oItem.Uid);
}); });
if (3 < iLen) if (3 < iLen)
{ {
fNotificationHelper( fNotificationHelper(
RL.link().notificationMailIcon(),// TODO cjs LinkBuilder.notificationMailIcon(),
RL.data().accountEmail(), RL.data().accountEmail(),
Utils.i18n('MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION', { Utils.i18n('MESSAGE_LIST/NEW_MESSAGE_NOTIFICATION', {
'COUNT': iLen 'COUNT': iLen
@ -584,15 +593,15 @@
for (; iIndex < iLen; iIndex++) for (; iIndex < iLen; iIndex++)
{ {
fNotificationHelper( fNotificationHelper(
RL.link().notificationMailIcon(),// TODO cjs LinkBuilder.notificationMailIcon(),
MessageModel.emailsToLine(MessageModel.initEmailsFromJson(aNewMessages[iIndex].From), false),// TODO cjs MessageModel.emailsToLine(MessageModel.initEmailsFromJson(aNewMessages[iIndex].From), false),
aNewMessages[iIndex].Subject aNewMessages[iIndex].Subject
); );
} }
} }
} }
RL.cache().setFolderUidNext(sFolder, sUidNext);// TODO cjs Cache.setFolderUidNext(sFolder, sUidNext);
} }
}; };
@ -620,14 +629,14 @@
{ {
sFolderFullNameRaw = oFolder.FullNameRaw; sFolderFullNameRaw = oFolder.FullNameRaw;
oCacheFolder = RL.cache().getFolderFromCacheList(sFolderFullNameRaw);// TODO cjs oCacheFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);// TODO cjs
if (!oCacheFolder) if (!oCacheFolder)
{ {
oCacheFolder = FolderModel.newInstanceFromJson(oFolder);// TODO cjs oCacheFolder = FolderModel.newInstanceFromJson(oFolder);// TODO cjs
if (oCacheFolder) if (oCacheFolder)
{ {
RL.cache().setFolderToCacheList(sFolderFullNameRaw, oCacheFolder);// TODO cjs Cache.setFolderToCacheList(sFolderFullNameRaw, oCacheFolder);// TODO cjs
RL.cache().setFolderFullNameRaw(oCacheFolder.fullNameHash, sFolderFullNameRaw);// TODO cjs Cache.setFolderFullNameRaw(oCacheFolder.fullNameHash, sFolderFullNameRaw);// TODO cjs
} }
} }
@ -639,7 +648,7 @@
{ {
if (oFolder.Extended.Hash) if (oFolder.Extended.Hash)
{ {
RL.cache().setFolderHash(oCacheFolder.fullNameRaw, oFolder.Extended.Hash);// TODO cjs Cache.setFolderHash(oCacheFolder.fullNameRaw, oFolder.Extended.Hash);// TODO cjs
} }
if (Utils.isNormal(oFolder.Extended.MessageCount)) if (Utils.isNormal(oFolder.Extended.MessageCount))
@ -680,7 +689,7 @@
oRLData = RL.data(),// TODO cjs oRLData = RL.data(),// TODO cjs
fNormalizeFolder = function (sFolderFullNameRaw) { fNormalizeFolder = function (sFolderFullNameRaw) {
return ('' === sFolderFullNameRaw || Consts.Values.UnuseOptionValue === sFolderFullNameRaw || return ('' === sFolderFullNameRaw || Consts.Values.UnuseOptionValue === sFolderFullNameRaw ||
null !== RL.cache().getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : '';// TODO cjs null !== Cache.getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : '';// TODO cjs
} }
; ;
@ -722,8 +731,7 @@
if (bUpdate) if (bUpdate)
{ {
// TODO cjs Remote.saveSystemFolders(Utils.emptyFunction, {
RL.remote().saveSystemFolders(Utils.emptyFunction, {
'SentFolder': oRLData.sentFolder(), 'SentFolder': oRLData.sentFolder(),
'DraftFolder': oRLData.draftFolder(), 'DraftFolder': oRLData.draftFolder(),
'SpamFolder': oRLData.spamFolder(), 'SpamFolder': oRLData.spamFolder(),
@ -733,8 +741,7 @@
}); });
} }
// TODO cjs LocalStorage.set(Enums.ClientSideKeyName.FoldersLashHash, oData.Result.FoldersHash);
RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, oData.Result.FoldersHash);
} }
}; };
@ -795,7 +802,7 @@
}); });
_.find(aTimeouts, function (aItem) { _.find(aTimeouts, function (aItem) {
var oFolder = RL.cache().getFolderFromCacheList(aItem[1]);// TODO cjs var oFolder = Cache.getFolderFromCacheList(aItem[1]);// TODO cjs
if (oFolder) if (oFolder)
{ {
oFolder.interval = iUtc; oFolder.interval = iUtc;
@ -827,10 +834,9 @@
var var
iUnseenCount = 0, iUnseenCount = 0,
oData = RL.data(),// TODO cjs oData = RL.data(),// TODO cjs
oCache = RL.cache(),// TODO cjs
aMessageList = oData.messageList(), aMessageList = oData.messageList(),
oFromFolder = RL.cache().getFolderFromCacheList(sFromFolderFullNameRaw), oFromFolder = Cache.getFolderFromCacheList(sFromFolderFullNameRaw),
oToFolder = '' === sToFolderFullNameRaw ? null : oCache.getFolderFromCacheList(sToFolderFullNameRaw || ''), oToFolder = '' === sToFolderFullNameRaw ? null : Cache.getFolderFromCacheList(sToFolderFullNameRaw || ''),
sCurrentFolderFullNameRaw = oData.currentFolderFullNameRaw(), sCurrentFolderFullNameRaw = oData.currentFolderFullNameRaw(),
oCurrentMessage = oData.message(), oCurrentMessage = oData.message(),
aMessages = sCurrentFolderFullNameRaw === sFromFolderFullNameRaw ? _.filter(aMessageList, function (oMessage) { aMessages = sCurrentFolderFullNameRaw === sFromFolderFullNameRaw ? _.filter(aMessageList, function (oMessage) {
@ -900,12 +906,12 @@
if ('' !== sFromFolderFullNameRaw) if ('' !== sFromFolderFullNameRaw)
{ {
oCache.setFolderHash(sFromFolderFullNameRaw, ''); Cache.setFolderHash(sFromFolderFullNameRaw, '');
} }
if ('' !== sToFolderFullNameRaw) if ('' !== sToFolderFullNameRaw)
{ {
oCache.setFolderHash(sToFolderFullNameRaw, ''); Cache.setFolderHash(sToFolderFullNameRaw, '');
} }
}; };
@ -931,7 +937,7 @@
this.messageError(''); this.messageError('');
oMessage.initUpdateByMessageJson(oData.Result); oMessage.initUpdateByMessageJson(oData.Result);
RL.cache().addRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid);// TODO cjs Cache.addRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid);// TODO cjs
if (!bCached) if (!bCached)
{ {
@ -1052,7 +1058,7 @@
} }
} }
RL.cache().initMessageFlagsFromCache(oMessage); Cache.initMessageFlagsFromCache(oMessage);
if (oMessage.unseen()) if (oMessage.unseen())
{ {
RL.setMessageSeen(oMessage); RL.setMessageSeen(oMessage);
@ -1080,7 +1086,6 @@
{ {
var var
oRainLoopData = RL.data(), oRainLoopData = RL.data(),
oCache = RL.cache(),
mLastCollapsedThreadUids = null, mLastCollapsedThreadUids = null,
iIndex = 0, iIndex = 0,
iLen = 0, iLen = 0,
@ -1104,14 +1109,14 @@
mLastCollapsedThreadUids = oData.Result.LastCollapsedThreadUids; mLastCollapsedThreadUids = oData.Result.LastCollapsedThreadUids;
} }
oFolder = RL.cache().getFolderFromCacheList( oFolder = Cache.getFolderFromCacheList(
Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : ''); Utils.isNormal(oData.Result.Folder) ? oData.Result.Folder : '');
if (oFolder && !bCached) if (oFolder && !bCached)
{ {
oFolder.interval = iUtc; oFolder.interval = iUtc;
RL.cache().setFolderHash(oData.Result.Folder, oData.Result.FolderHash); Cache.setFolderHash(oData.Result.Folder, oData.Result.FolderHash);
if (Utils.isNormal(oData.Result.MessageCount)) if (Utils.isNormal(oData.Result.MessageCount))
{ {
@ -1133,7 +1138,7 @@
if (bUnreadCountChange && oFolder) if (bUnreadCountChange && oFolder)
{ {
RL.cache().clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw); Cache.clearMessageFlagsFromCacheByFolder(oFolder.fullNameRaw);
} }
for (iIndex = 0, iLen = oData.Result['@Collection'].length; iIndex < iLen; iIndex++) for (iIndex = 0, iLen = oData.Result['@Collection'].length; iIndex < iLen; iIndex++)
@ -1149,7 +1154,7 @@
if (oMessage) if (oMessage)
{ {
if (oCache.hasNewMessageAndRemoveFromCache(oMessage.folderFullNameRaw, oMessage.uid) && 5 >= iNewCount) if (Cache.hasNewMessageAndRemoveFromCache(oMessage.folderFullNameRaw, oMessage.uid) && 5 >= iNewCount)
{ {
iNewCount++; iNewCount++;
oMessage.newForAnimation(true); oMessage.newForAnimation(true);
@ -1159,11 +1164,11 @@
if (bCached) if (bCached)
{ {
RL.cache().initMessageFlagsFromCache(oMessage); Cache.initMessageFlagsFromCache(oMessage);
} }
else else
{ {
RL.cache().storeMessageFlagsToCache(oMessage); Cache.storeMessageFlagsToCache(oMessage);
} }
oMessage.lastInCollapsedThread(mLastCollapsedThreadUids && -1 < Utils.inArray(Utils.pInt(oMessage.uid), mLastCollapsedThreadUids) ? true : false); oMessage.lastInCollapsedThread(mLastCollapsedThreadUids && -1 < Utils.inArray(Utils.pInt(oMessage.uid), mLastCollapsedThreadUids) ? true : false);
@ -1188,7 +1193,7 @@
oRainLoopData.staticMessageList = aList; oRainLoopData.staticMessageList = aList;
} }
oCache.clearNewMessageCache(); Cache.clearNewMessageCache();
if (oFolder && (bCached || bUnreadCountChange || RL.data().useThreads())) if (oFolder && (bCached || bUnreadCountChange || RL.data().useThreads()))
{ {
@ -1282,6 +1287,6 @@
return this.findPrivateKeyByEmail(this.accountEmail(), sPassword); return this.findPrivateKeyByEmail(this.accountEmail(), sPassword);
}; };
module.exports = WebMailDataStorage; module.exports = new WebMailDataStorage();
}(module)); }(module));

View file

@ -1,11 +1,31 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
window = require('../External/window.js'),
key = require('../External/key.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function AbstractSystemDropDownViewModel() function AbstractSystemDropDownViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Right', 'SystemDropDown'); KnoinAbstractViewModel.call(this, 'Right', 'SystemDropDown');
var oData = RL.data(); var oData = RL.data();
@ -23,12 +43,12 @@ function AbstractSystemDropDownViewModel()
}, this); }, this);
this.accountClick = _.bind(this.accountClick, this); this.accountClick = _.bind(this.accountClick, this);
} }
_.extend(AbstractSystemDropDownViewModel.prototype, KnoinAbstractViewModel.prototype); _.extend(AbstractSystemDropDownViewModel.prototype, KnoinAbstractViewModel.prototype);
AbstractSystemDropDownViewModel.prototype.accountClick = function (oAccount, oEvent) AbstractSystemDropDownViewModel.prototype.accountClick = function (oAccount, oEvent)
{ {
if (oAccount && oEvent && !Utils.isUnd(oEvent.which) && 1 === oEvent.which) if (oAccount && oEvent && !Utils.isUnd(oEvent.which) && 1 === oEvent.which)
{ {
var self = this; var self = this;
@ -39,34 +59,34 @@ AbstractSystemDropDownViewModel.prototype.accountClick = function (oAccount, oEv
} }
return true; return true;
}; };
AbstractSystemDropDownViewModel.prototype.emailTitle = function () AbstractSystemDropDownViewModel.prototype.emailTitle = function ()
{ {
return RL.data().accountEmail(); return RL.data().accountEmail();
}; };
AbstractSystemDropDownViewModel.prototype.settingsClick = function () AbstractSystemDropDownViewModel.prototype.settingsClick = function ()
{ {
kn.setHash(RL.link().settings()); kn.setHash(LinkBuilder.settings());
}; };
AbstractSystemDropDownViewModel.prototype.settingsHelp = function () AbstractSystemDropDownViewModel.prototype.settingsHelp = function ()
{ {
kn.showScreenPopup(PopupsKeyboardShortcutsHelpViewModel); kn.showScreenPopup(PopupsKeyboardShortcutsHelpViewModel);
}; };
AbstractSystemDropDownViewModel.prototype.addAccountClick = function () AbstractSystemDropDownViewModel.prototype.addAccountClick = function ()
{ {
if (this.capaAdditionalAccounts) if (this.capaAdditionalAccounts)
{ {
kn.showScreenPopup(PopupsAddAccountViewModel); kn.showScreenPopup(PopupsAddAccountViewModel);
} }
}; };
AbstractSystemDropDownViewModel.prototype.logoutClick = function () AbstractSystemDropDownViewModel.prototype.logoutClick = function ()
{ {
RL.remote().logout(function () { Remote.logout(function () {
if (window.__rlah_clear) if (window.__rlah_clear)
{ {
window.__rlah_clear(); window.__rlah_clear();
@ -74,10 +94,10 @@ AbstractSystemDropDownViewModel.prototype.logoutClick = function ()
RL.loginAndLogoutReload(true, RL.settingsGet('ParentEmail') && 0 < RL.settingsGet('ParentEmail').length); RL.loginAndLogoutReload(true, RL.settingsGet('ParentEmail') && 0 < RL.settingsGet('ParentEmail').length);
}); });
}; };
AbstractSystemDropDownViewModel.prototype.onBuild = function () AbstractSystemDropDownViewModel.prototype.onBuild = function ()
{ {
var self = this; var self = this;
key('`', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () { key('`', [Enums.KeyState.MessageList, Enums.KeyState.MessageView, Enums.KeyState.Settings], function () {
if (self.viewModelVisibility()) if (self.viewModelVisibility())
@ -94,4 +114,8 @@ AbstractSystemDropDownViewModel.prototype.onBuild = function ()
return false; return false;
} }
}); });
}; };
module.exports = new AbstractSystemDropDownViewModel();
}(module));

View file

@ -1,11 +1,28 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'),
Remote = require('../Storages/AdminAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function AdminLoginViewModel() function AdminLoginViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Center', 'AdminLogin'); KnoinAbstractViewModel.call(this, 'Center', 'AdminLogin');
this.login = ko.observable(''); this.login = ko.observable('');
@ -41,7 +58,7 @@ function AdminLoginViewModel()
this.submitRequest(true); this.submitRequest(true);
RL.remote().adminLogin(_.bind(function (sResult, oData) { Remote.adminLogin(_.bind(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action) if (Enums.StorageResultType.Success === sResult && oData && 'AdminLogin' === oData.Action)
{ {
@ -69,32 +86,36 @@ function AdminLoginViewModel()
return !this.submitRequest(); return !this.submitRequest();
}); });
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('AdminLoginViewModel', AdminLoginViewModel); kn.extendAsViewModel('AdminLoginViewModel', AdminLoginViewModel);
AdminLoginViewModel.prototype.onShow = function () AdminLoginViewModel.prototype.onShow = function ()
{ {
kn.routeOff(); kn.routeOff();
_.delay(_.bind(function () { _.delay(_.bind(function () {
this.loginFocus(true); this.loginFocus(true);
}, this), 100); }, this), 100);
}; };
AdminLoginViewModel.prototype.onHide = function () AdminLoginViewModel.prototype.onHide = function ()
{ {
this.loginFocus(false); this.loginFocus(false);
}; };
AdminLoginViewModel.prototype.onBuild = function () AdminLoginViewModel.prototype.onBuild = function ()
{ {
Utils.triggerAutocompleteInputChange(true); Utils.triggerAutocompleteInputChange(true);
}; };
AdminLoginViewModel.prototype.submitForm = function () AdminLoginViewModel.prototype.submitForm = function ()
{ {
this.submitCommand(); this.submitCommand();
}; };
module.exports = new AdminLoginViewModel();
}(module));

View file

@ -1,25 +1,38 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
kn = require('../External/kn.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
/**
* @param {?} oScreen * @param {?} oScreen
* *
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function AdminMenuViewModel(oScreen) function AdminMenuViewModel(oScreen)
{ {
KnoinAbstractViewModel.call(this, 'Left', 'AdminMenu'); KnoinAbstractViewModel.call(this, 'Left', 'AdminMenu');
this.leftPanelDisabled = RL.data().leftPanelDisabled; this.leftPanelDisabled = RL.data().leftPanelDisabled;
this.menu = oScreen.menu; this.menu = oScreen.menu;
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('AdminMenuViewModel', AdminMenuViewModel); kn.extendAsViewModel('AdminMenuViewModel', AdminMenuViewModel);
AdminMenuViewModel.prototype.link = function (sRoute) AdminMenuViewModel.prototype.link = function (sRoute)
{ {
return '#/' + sRoute; return '#/' + sRoute;
}; };
module.exports = new AdminMenuViewModel();
}(module));

View file

@ -1,11 +1,24 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
ko = require('../External/ko.js'),
Remote = require('../Storages/AdminAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function AdminPaneViewModel() function AdminPaneViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Right', 'AdminPane'); KnoinAbstractViewModel.call(this, 'Right', 'AdminPane');
this.adminDomain = ko.observable(RL.settingsGet('AdminDomain')); this.adminDomain = ko.observable(RL.settingsGet('AdminDomain'));
@ -13,14 +26,18 @@ function AdminPaneViewModel()
this.adminManLoadingVisibility = RL.data().adminManLoadingVisibility; this.adminManLoadingVisibility = RL.data().adminManLoadingVisibility;
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('AdminPaneViewModel', AdminPaneViewModel); kn.extendAsViewModel('AdminPaneViewModel', AdminPaneViewModel);
AdminPaneViewModel.prototype.logoutClick = function () AdminPaneViewModel.prototype.logoutClick = function ()
{ {
RL.remote().adminLogout(function () { Remote.adminLogout(function () {
RL.loginAndLogoutReload(); RL.loginAndLogoutReload();
}); });
}; };
module.exports = new AdminPaneViewModel();
}(module));

View file

@ -1,11 +1,31 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
window = require('../External/window.js'),
$ = require('../External/jquery.js'),
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
Utils = require('../Common/Utils.js'),
Enums = require('../Common/Enums.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function LoginViewModel() function LoginViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Center', 'Login'); KnoinAbstractViewModel.call(this, 'Center', 'Login');
var oData = RL.data(); var oData = RL.data();
@ -95,7 +115,7 @@ function LoginViewModel()
fLoginRequest = _.bind(function (sPassword) { fLoginRequest = _.bind(function (sPassword) {
RL.remote().login(_.bind(function (sResult, oData) { Remote.login(_.bind(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action) if (Enums.StorageResultType.Success === sResult && oData && 'Login' === oData.Action)
{ {
@ -146,7 +166,7 @@ function LoginViewModel()
if (!!RL.settingsGet('UseRsaEncryption') && Utils.rsaEncode.supported) if (!!RL.settingsGet('UseRsaEncryption') && Utils.rsaEncode.supported)
{ {
RL.remote().getPublicKey(_.bind(function (sResult, oData) { Remote.getPublicKey(_.bind(function (sResult, oData) {
var bRequest = false; var bRequest = false;
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && if (Enums.StorageResultType.Success === sResult && oData && oData.Result &&
@ -183,7 +203,7 @@ function LoginViewModel()
this.facebookCommand = Utils.createCommand(this, function () { this.facebookCommand = Utils.createCommand(this, function () {
window.open(RL.link().socialFacebook(), 'Facebook', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes'); window.open(LinkBuilder.socialFacebook(), 'Facebook', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true; return true;
}, function () { }, function () {
@ -194,7 +214,7 @@ function LoginViewModel()
this.googleCommand = Utils.createCommand(this, function () { this.googleCommand = Utils.createCommand(this, function () {
window.open(RL.link().socialGoogle(), 'Google', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes'); window.open(LinkBuilder.socialGoogle(), 'Google', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true; return true;
}, function () { }, function () {
@ -205,7 +225,7 @@ function LoginViewModel()
this.twitterCommand = Utils.createCommand(this, function () { this.twitterCommand = Utils.createCommand(this, function () {
window.open(RL.link().socialTwitter(), 'Twitter', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes'); window.open(LinkBuilder.socialTwitter(), 'Twitter', 'left=200,top=100,width=650,height=335,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true; return true;
}, function () { }, function () {
@ -223,13 +243,13 @@ function LoginViewModel()
return bF || bG || bT; return bF || bG || bT;
}, this); }, this);
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('LoginViewModel', LoginViewModel); kn.extendAsViewModel('LoginViewModel', LoginViewModel);
LoginViewModel.prototype.onShow = function () LoginViewModel.prototype.onShow = function ()
{ {
kn.routeOff(); kn.routeOff();
_.delay(_.bind(function () { _.delay(_.bind(function () {
@ -248,16 +268,16 @@ LoginViewModel.prototype.onShow = function ()
} }
}, this), 100); }, this), 100);
}; };
LoginViewModel.prototype.onHide = function () LoginViewModel.prototype.onHide = function ()
{ {
this.submitFocus(false); this.submitFocus(false);
this.emailFocus(false); this.emailFocus(false);
}; };
LoginViewModel.prototype.onBuild = function () LoginViewModel.prototype.onBuild = function ()
{ {
var var
self = this, self = this,
sJsHash = RL.settingsGet('JsHash'), sJsHash = RL.settingsGet('JsHash'),
@ -315,7 +335,7 @@ LoginViewModel.prototype.onBuild = function ()
RL.data().language.subscribe(function (sValue) { RL.data().language.subscribe(function (sValue) {
self.langRequest(true); self.langRequest(true);
$.ajax({ $.ajax({
'url': RL.link().langLink(sValue), 'url': LinkBuilder.langLink(sValue),
'dataType': 'script', 'dataType': 'script',
'cache': true 'cache': true
}).done(function() { }).done(function() {
@ -329,16 +349,18 @@ LoginViewModel.prototype.onBuild = function ()
}, 50); }, 50);
Utils.triggerAutocompleteInputChange(true); Utils.triggerAutocompleteInputChange(true);
};
}; LoginViewModel.prototype.submitForm = function ()
{
LoginViewModel.prototype.submitForm = function ()
{
this.submitCommand(); this.submitCommand();
}; };
LoginViewModel.prototype.selectLanguage = function () LoginViewModel.prototype.selectLanguage = function ()
{ {
kn.showScreenPopup(PopupsLanguagesViewModel); kn.showScreenPopup(PopupsLanguagesViewModel);
}; };
module.exports = new LoginViewModel();
}(module));

View file

@ -1,11 +1,32 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
window = require('../External/window.js'),
$ = require('../External/jquery.js'),
ko = require('../External/ko.js'),
key = require('../External/key.js'),
$html = require('../External/$html.js'),
Utils = require('../Common/Utils.js'),
Enums = require('../Common/Enums.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
Cache = require('../Storages/WebMailCacheStorage.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function MailBoxFolderListViewModel() function MailBoxFolderListViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Left', 'MailFolderList'); KnoinAbstractViewModel.call(this, 'Left', 'MailFolderList');
var oData = RL.data(); var oData = RL.data();
@ -24,13 +45,13 @@ function MailBoxFolderListViewModel()
this.allowContacts = !!RL.settingsGet('ContactsIsAllowed'); this.allowContacts = !!RL.settingsGet('ContactsIsAllowed');
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('MailBoxFolderListViewModel', MailBoxFolderListViewModel); kn.extendAsViewModel('MailBoxFolderListViewModel', MailBoxFolderListViewModel);
MailBoxFolderListViewModel.prototype.onBuild = function (oDom) MailBoxFolderListViewModel.prototype.onBuild = function (oDom)
{ {
this.oContentVisible = $('.b-content', oDom); this.oContentVisible = $('.b-content', oDom);
this.oContentScrollable = $('.content', this.oContentVisible); this.oContentScrollable = $('.content', this.oContentVisible);
@ -72,10 +93,10 @@ MailBoxFolderListViewModel.prototype.onBuild = function (oDom)
if (oFolder.fullNameRaw === oData.currentFolderFullNameRaw()) if (oFolder.fullNameRaw === oData.currentFolderFullNameRaw())
{ {
RL.cache().setFolderHash(oFolder.fullNameRaw, ''); Cache.setFolderHash(oFolder.fullNameRaw, '');
} }
kn.setHash(RL.link().mailBox(oFolder.fullNameHash)); kn.setHash(LinkBuilder.mailBox(oFolder.fullNameHash));
} }
}) })
; ;
@ -151,10 +172,10 @@ MailBoxFolderListViewModel.prototype.onBuild = function (oDom)
$('.b-folders .e-item .e-link.selected', oDom).addClass('focused'); $('.b-folders .e-item .e-link.selected', oDom).addClass('focused');
} }
}); });
}; };
MailBoxFolderListViewModel.prototype.messagesDropOver = function (oFolder) MailBoxFolderListViewModel.prototype.messagesDropOver = function (oFolder)
{ {
window.clearTimeout(this.iDropOverTimer); window.clearTimeout(this.iDropOverTimer);
if (oFolder && oFolder.collapsed()) if (oFolder && oFolder.collapsed())
{ {
@ -164,15 +185,15 @@ MailBoxFolderListViewModel.prototype.messagesDropOver = function (oFolder)
Utils.windowResize(); Utils.windowResize();
}, 500); }, 500);
} }
}; };
MailBoxFolderListViewModel.prototype.messagesDropOut = function () MailBoxFolderListViewModel.prototype.messagesDropOut = function ()
{ {
window.clearTimeout(this.iDropOverTimer); window.clearTimeout(this.iDropOverTimer);
}; };
MailBoxFolderListViewModel.prototype.scrollToFocused = function () MailBoxFolderListViewModel.prototype.scrollToFocused = function ()
{ {
if (!this.oContentVisible || !this.oContentScrollable) if (!this.oContentVisible || !this.oContentScrollable)
{ {
return false; return false;
@ -201,15 +222,15 @@ MailBoxFolderListViewModel.prototype.scrollToFocused = function ()
} }
return false; return false;
}; };
/** /**
* *
* @param {FolderModel} oToFolder * @param {FolderModel} oToFolder
* @param {{helper:jQuery}} oUi * @param {{helper:jQuery}} oUi
*/ */
MailBoxFolderListViewModel.prototype.messagesDrop = function (oToFolder, oUi) MailBoxFolderListViewModel.prototype.messagesDrop = function (oToFolder, oUi)
{ {
if (oToFolder && oUi && oUi.helper) if (oToFolder && oUi && oUi.helper)
{ {
var var
@ -223,27 +244,31 @@ MailBoxFolderListViewModel.prototype.messagesDrop = function (oToFolder, oUi)
RL.moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy); RL.moveMessagesToFolder(sFromFolderFullNameRaw, aUids, oToFolder.fullNameRaw, bCopy);
} }
} }
}; };
MailBoxFolderListViewModel.prototype.composeClick = function () MailBoxFolderListViewModel.prototype.composeClick = function ()
{ {
kn.showScreenPopup(PopupsComposeViewModel); kn.showScreenPopup(PopupsComposeViewModel);
}; };
MailBoxFolderListViewModel.prototype.createFolder = function () MailBoxFolderListViewModel.prototype.createFolder = function ()
{ {
kn.showScreenPopup(PopupsFolderCreateViewModel); kn.showScreenPopup(PopupsFolderCreateViewModel);
}; };
MailBoxFolderListViewModel.prototype.configureFolders = function () MailBoxFolderListViewModel.prototype.configureFolders = function ()
{ {
kn.setHash(RL.link().settings('folders')); kn.setHash(LinkBuilder.settings('folders'));
}; };
MailBoxFolderListViewModel.prototype.contactsClick = function () MailBoxFolderListViewModel.prototype.contactsClick = function ()
{ {
if (this.allowContacts) if (this.allowContacts)
{ {
kn.showScreenPopup(PopupsContactsViewModel); kn.showScreenPopup(PopupsContactsViewModel);
} }
}; };
module.exports = new MailBoxFolderListViewModel();
}(module));

View file

@ -1,11 +1,38 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
$ = require('../External/jquery.js'),
_ = require('../External/underscore.js'),
ko = require('../External/ko.js'),
key = require('../External/key.js'),
ifvisible = require('../External/ifvisible.js'),
Jua = require('../External/Jua.js'),
Utils = require('../Common/Utils.js'),
Enums = require('../Common/Enums.js'),
Consts = require('../Common/Consts.js'),
Globals = require('../Common/Globals.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
Cache = require('../Storages/WebMailCacheStorage.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js'),
PopupsComposeViewModel = require('./Popups/PopupsComposeViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function MailBoxMessageListViewModel() function MailBoxMessageListViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Right', 'MailMessageList'); KnoinAbstractViewModel.call(this, 'Right', 'MailMessageList');
this.sLastUid = null; this.sLastUid = null;
@ -202,7 +229,7 @@ function MailBoxMessageListViewModel()
if (Enums.Layout.NoPreview === oData.layout()) if (Enums.Layout.NoPreview === oData.layout())
{ {
kn.setHash(RL.link().messagePreview(), true); kn.setHash(LinkBuilder.messagePreview(), true);
oData.message.focused(true); oData.message.focused(true);
} }
} }
@ -235,43 +262,43 @@ function MailBoxMessageListViewModel()
}, this) }, this)
; ;
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('MailBoxMessageListViewModel', MailBoxMessageListViewModel); kn.extendAsViewModel('MailBoxMessageListViewModel', MailBoxMessageListViewModel);
/** /**
* @type {string} * @type {string}
*/ */
MailBoxMessageListViewModel.prototype.emptySubjectValue = ''; MailBoxMessageListViewModel.prototype.emptySubjectValue = '';
MailBoxMessageListViewModel.prototype.searchEnterAction = function () MailBoxMessageListViewModel.prototype.searchEnterAction = function ()
{ {
this.mainMessageListSearch(this.sLastSearchValue); this.mainMessageListSearch(this.sLastSearchValue);
this.inputMessageListSearchFocus(false); this.inputMessageListSearchFocus(false);
}; };
/** /**
* @returns {string} * @returns {string}
*/ */
MailBoxMessageListViewModel.prototype.printableMessageCountForDeletion = function () MailBoxMessageListViewModel.prototype.printableMessageCountForDeletion = function ()
{ {
var iCnt = this.messageListCheckedOrSelectedUidsWithSubMails().length; var iCnt = this.messageListCheckedOrSelectedUidsWithSubMails().length;
return 1 < iCnt ? ' (' + (100 > iCnt ? iCnt : '99+') + ')' : ''; return 1 < iCnt ? ' (' + (100 > iCnt ? iCnt : '99+') + ')' : '';
}; };
MailBoxMessageListViewModel.prototype.cancelSearch = function () MailBoxMessageListViewModel.prototype.cancelSearch = function ()
{ {
this.mainMessageListSearch(''); this.mainMessageListSearch('');
this.inputMessageListSearchFocus(false); this.inputMessageListSearchFocus(false);
}; };
/** /**
* @param {string} sToFolderFullNameRaw * @param {string} sToFolderFullNameRaw
* @return {boolean} * @return {boolean}
*/ */
MailBoxMessageListViewModel.prototype.moveSelectedMessagesToFolder = function (sToFolderFullNameRaw, bCopy) MailBoxMessageListViewModel.prototype.moveSelectedMessagesToFolder = function (sToFolderFullNameRaw, bCopy)
{ {
if (this.canBeMoved()) if (this.canBeMoved())
{ {
RL.moveMessagesToFolder( RL.moveMessagesToFolder(
@ -280,10 +307,10 @@ MailBoxMessageListViewModel.prototype.moveSelectedMessagesToFolder = function (s
} }
return false; return false;
}; };
MailBoxMessageListViewModel.prototype.dragAndDronHelper = function (oMessageListItem) MailBoxMessageListViewModel.prototype.dragAndDronHelper = function (oMessageListItem)
{ {
if (oMessageListItem) if (oMessageListItem)
{ {
oMessageListItem.checked(true); oMessageListItem.checked(true);
@ -306,15 +333,15 @@ MailBoxMessageListViewModel.prototype.dragAndDronHelper = function (oMessageList
}); });
return oEl; return oEl;
}; };
/** /**
* @param {string} sResult * @param {string} sResult
* @param {AjaxJsonDefaultResponse} oData * @param {AjaxJsonDefaultResponse} oData
* @param {boolean} bCached * @param {boolean} bCached
*/ */
MailBoxMessageListViewModel.prototype.onMessageResponse = function (sResult, oData, bCached) MailBoxMessageListViewModel.prototype.onMessageResponse = function (sResult, oData, bCached)
{ {
var oRainLoopData = RL.data(); var oRainLoopData = RL.data();
oRainLoopData.hideMessageBodies(); oRainLoopData.hideMessageBodies();
@ -336,13 +363,13 @@ MailBoxMessageListViewModel.prototype.onMessageResponse = function (sResult, oDa
Utils.getNotification(oData.ErrorCode) : Utils.getNotification(oData.ErrorCode) :
Utils.getNotification(Enums.Notification.UnknownError))); Utils.getNotification(Enums.Notification.UnknownError)));
} }
}; };
MailBoxMessageListViewModel.prototype.populateMessageBody = function (oMessage) MailBoxMessageListViewModel.prototype.populateMessageBody = function (oMessage)
{ {
if (oMessage) if (oMessage)
{ {
if (RL.remote().message(this.onMessageResponse, oMessage.folderFullNameRaw, oMessage.uid)) if (Remote.message(this.onMessageResponse, oMessage.folderFullNameRaw, oMessage.uid))
{ {
RL.data().messageLoading(true); RL.data().messageLoading(true);
} }
@ -351,19 +378,18 @@ MailBoxMessageListViewModel.prototype.populateMessageBody = function (oMessage)
Utils.log('Error: Unknown message request: ' + oMessage.folderFullNameRaw + ' ~ ' + oMessage.uid + ' [e-101]'); Utils.log('Error: Unknown message request: ' + oMessage.folderFullNameRaw + ' ~ ' + oMessage.uid + ' [e-101]');
} }
} }
}; };
/** /**
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {number} iSetAction * @param {number} iSetAction
* @param {Array=} aMessages = null * @param {Array=} aMessages = null
*/ */
MailBoxMessageListViewModel.prototype.setAction = function (sFolderFullNameRaw, iSetAction, aMessages) MailBoxMessageListViewModel.prototype.setAction = function (sFolderFullNameRaw, iSetAction, aMessages)
{ {
var var
aUids = [], aUids = [],
oFolder = null, oFolder = null,
oCache = RL.cache(),
iAlreadyUnread = 0 iAlreadyUnread = 0
; ;
@ -387,16 +413,16 @@ MailBoxMessageListViewModel.prototype.setAction = function (sFolderFullNameRaw,
} }
oMessage.unseen(false); oMessage.unseen(false);
oCache.storeMessageFlagsToCache(oMessage); Cache.storeMessageFlagsToCache(oMessage);
}); });
oFolder = oCache.getFolderFromCacheList(sFolderFullNameRaw); oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
if (oFolder) if (oFolder)
{ {
oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread); oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread);
} }
RL.remote().messageSetSeen(Utils.emptyFunction, sFolderFullNameRaw, aUids, true); Remote.messageSetSeen(Utils.emptyFunction, sFolderFullNameRaw, aUids, true);
break; break;
case Enums.MessageSetAction.UnsetSeen: case Enums.MessageSetAction.UnsetSeen:
_.each(aMessages, function (oMessage) { _.each(aMessages, function (oMessage) {
@ -406,57 +432,56 @@ MailBoxMessageListViewModel.prototype.setAction = function (sFolderFullNameRaw,
} }
oMessage.unseen(true); oMessage.unseen(true);
oCache.storeMessageFlagsToCache(oMessage); Cache.storeMessageFlagsToCache(oMessage);
}); });
oFolder = oCache.getFolderFromCacheList(sFolderFullNameRaw); oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
if (oFolder) if (oFolder)
{ {
oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread + aUids.length); oFolder.messageCountUnread(oFolder.messageCountUnread() - iAlreadyUnread + aUids.length);
} }
RL.remote().messageSetSeen(Utils.emptyFunction, sFolderFullNameRaw, aUids, false); Remote.messageSetSeen(Utils.emptyFunction, sFolderFullNameRaw, aUids, false);
break; break;
case Enums.MessageSetAction.SetFlag: case Enums.MessageSetAction.SetFlag:
_.each(aMessages, function (oMessage) { _.each(aMessages, function (oMessage) {
oMessage.flagged(true); oMessage.flagged(true);
oCache.storeMessageFlagsToCache(oMessage); Cache.storeMessageFlagsToCache(oMessage);
}); });
RL.remote().messageSetFlagged(Utils.emptyFunction, sFolderFullNameRaw, aUids, true); Remote.messageSetFlagged(Utils.emptyFunction, sFolderFullNameRaw, aUids, true);
break; break;
case Enums.MessageSetAction.UnsetFlag: case Enums.MessageSetAction.UnsetFlag:
_.each(aMessages, function (oMessage) { _.each(aMessages, function (oMessage) {
oMessage.flagged(false); oMessage.flagged(false);
oCache.storeMessageFlagsToCache(oMessage); Cache.storeMessageFlagsToCache(oMessage);
}); });
RL.remote().messageSetFlagged(Utils.emptyFunction, sFolderFullNameRaw, aUids, false); Remote.messageSetFlagged(Utils.emptyFunction, sFolderFullNameRaw, aUids, false);
break; break;
} }
RL.reloadFlagsCurrentMessageListAndMessageFromCache(); RL.reloadFlagsCurrentMessageListAndMessageFromCache();
} }
}; };
/** /**
* @param {string} sFolderFullNameRaw * @param {string} sFolderFullNameRaw
* @param {number} iSetAction * @param {number} iSetAction
*/ */
MailBoxMessageListViewModel.prototype.setActionForAll = function (sFolderFullNameRaw, iSetAction) MailBoxMessageListViewModel.prototype.setActionForAll = function (sFolderFullNameRaw, iSetAction)
{ {
var var
oFolder = null, oFolder = null,
aMessages = RL.data().messageList(), aMessages = RL.data().messageList()
oCache = RL.cache()
; ;
if ('' !== sFolderFullNameRaw) if ('' !== sFolderFullNameRaw)
{ {
oFolder = oCache.getFolderFromCacheList(sFolderFullNameRaw); oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
if (oFolder) if (oFolder)
{ {
switch (iSetAction) { switch (iSetAction) {
case Enums.MessageSetAction.SetSeen: case Enums.MessageSetAction.SetSeen:
oFolder = oCache.getFolderFromCacheList(sFolderFullNameRaw); oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
if (oFolder) if (oFolder)
{ {
_.each(aMessages, function (oMessage) { _.each(aMessages, function (oMessage) {
@ -464,13 +489,13 @@ MailBoxMessageListViewModel.prototype.setActionForAll = function (sFolderFullNam
}); });
oFolder.messageCountUnread(0); oFolder.messageCountUnread(0);
oCache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw); Cache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw);
} }
RL.remote().messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, true); Remote.messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, true);
break; break;
case Enums.MessageSetAction.UnsetSeen: case Enums.MessageSetAction.UnsetSeen:
oFolder = oCache.getFolderFromCacheList(sFolderFullNameRaw); oFolder = Cache.getFolderFromCacheList(sFolderFullNameRaw);
if (oFolder) if (oFolder)
{ {
_.each(aMessages, function (oMessage) { _.each(aMessages, function (oMessage) {
@ -478,44 +503,44 @@ MailBoxMessageListViewModel.prototype.setActionForAll = function (sFolderFullNam
}); });
oFolder.messageCountUnread(oFolder.messageCountAll()); oFolder.messageCountUnread(oFolder.messageCountAll());
oCache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw); Cache.clearMessageFlagsFromCacheByFolder(sFolderFullNameRaw);
} }
RL.remote().messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, false); Remote.messageSetSeenToAll(Utils.emptyFunction, sFolderFullNameRaw, false);
break; break;
} }
RL.reloadFlagsCurrentMessageListAndMessageFromCache(); RL.reloadFlagsCurrentMessageListAndMessageFromCache();
} }
} }
}; };
MailBoxMessageListViewModel.prototype.listSetSeen = function () MailBoxMessageListViewModel.prototype.listSetSeen = function ()
{ {
this.setAction(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen, RL.data().messageListCheckedOrSelected()); this.setAction(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen, RL.data().messageListCheckedOrSelected());
}; };
MailBoxMessageListViewModel.prototype.listSetAllSeen = function () MailBoxMessageListViewModel.prototype.listSetAllSeen = function ()
{ {
this.setActionForAll(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen); this.setActionForAll(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.SetSeen);
}; };
MailBoxMessageListViewModel.prototype.listUnsetSeen = function () MailBoxMessageListViewModel.prototype.listUnsetSeen = function ()
{ {
this.setAction(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetSeen, RL.data().messageListCheckedOrSelected()); this.setAction(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetSeen, RL.data().messageListCheckedOrSelected());
}; };
MailBoxMessageListViewModel.prototype.listSetFlags = function () MailBoxMessageListViewModel.prototype.listSetFlags = function ()
{ {
this.setAction(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.SetFlag, RL.data().messageListCheckedOrSelected()); this.setAction(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.SetFlag, RL.data().messageListCheckedOrSelected());
}; };
MailBoxMessageListViewModel.prototype.listUnsetFlags = function () MailBoxMessageListViewModel.prototype.listUnsetFlags = function ()
{ {
this.setAction(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetFlag, RL.data().messageListCheckedOrSelected()); this.setAction(RL.data().currentFolderFullNameRaw(), Enums.MessageSetAction.UnsetFlag, RL.data().messageListCheckedOrSelected());
}; };
MailBoxMessageListViewModel.prototype.flagMessages = function (oCurrentMessage) MailBoxMessageListViewModel.prototype.flagMessages = function (oCurrentMessage)
{ {
var var
aChecked = this.messageListCheckedOrSelected(), aChecked = this.messageListCheckedOrSelected(),
aCheckedUids = [] aCheckedUids = []
@ -541,10 +566,10 @@ MailBoxMessageListViewModel.prototype.flagMessages = function (oCurrentMessage)
Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, [oCurrentMessage]); Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, [oCurrentMessage]);
} }
} }
}; };
MailBoxMessageListViewModel.prototype.flagMessagesFast = function (bFlag) MailBoxMessageListViewModel.prototype.flagMessagesFast = function (bFlag)
{ {
var var
aChecked = this.messageListCheckedOrSelected(), aChecked = this.messageListCheckedOrSelected(),
aFlagged = [] aFlagged = []
@ -567,10 +592,10 @@ MailBoxMessageListViewModel.prototype.flagMessagesFast = function (bFlag)
!bFlag ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked); !bFlag ? Enums.MessageSetAction.UnsetFlag : Enums.MessageSetAction.SetFlag, aChecked);
} }
} }
}; };
MailBoxMessageListViewModel.prototype.seenMessagesFast = function (bSeen) MailBoxMessageListViewModel.prototype.seenMessagesFast = function (bSeen)
{ {
var var
aChecked = this.messageListCheckedOrSelected(), aChecked = this.messageListCheckedOrSelected(),
aUnseen = [] aUnseen = []
@ -593,10 +618,10 @@ MailBoxMessageListViewModel.prototype.seenMessagesFast = function (bSeen)
bSeen ? Enums.MessageSetAction.SetSeen : Enums.MessageSetAction.UnsetSeen, aChecked); bSeen ? Enums.MessageSetAction.SetSeen : Enums.MessageSetAction.UnsetSeen, aChecked);
} }
} }
}; };
MailBoxMessageListViewModel.prototype.onBuild = function (oDom) MailBoxMessageListViewModel.prototype.onBuild = function (oDom)
{ {
var var
self = this, self = this,
oData = RL.data() oData = RL.data()
@ -649,7 +674,7 @@ MailBoxMessageListViewModel.prototype.onBuild = function (oDom)
var oPage = ko.dataFor(this); var oPage = ko.dataFor(this);
if (oPage) if (oPage)
{ {
kn.setHash(RL.link().mailBox( kn.setHash(LinkBuilder.mailBox(
oData.currentFolderFullNameHash(), oData.currentFolderFullNameHash(),
oPage.value, oPage.value,
oData.messageListSearch() oData.messageListSearch()
@ -675,10 +700,10 @@ MailBoxMessageListViewModel.prototype.onBuild = function (oDom)
self.prefetchNextTick(); self.prefetchNextTick();
}); });
} }
}; };
MailBoxMessageListViewModel.prototype.initShortcuts = function () MailBoxMessageListViewModel.prototype.initShortcuts = function ()
{ {
var self = this; var self = this;
// disable print // disable print
@ -797,18 +822,17 @@ MailBoxMessageListViewModel.prototype.initShortcuts = function ()
key('ctrl+right, command+right', Enums.KeyState.MessageView, function () { key('ctrl+right, command+right', Enums.KeyState.MessageView, function () {
return false; return false;
}); });
}; };
MailBoxMessageListViewModel.prototype.prefetchNextTick = function () MailBoxMessageListViewModel.prototype.prefetchNextTick = function ()
{ {
if (!this.bPrefetch && !ifvisible.now() && this.viewModelVisibility()) if (!this.bPrefetch && !ifvisible.now() && this.viewModelVisibility())
{ {
var var
self = this, self = this,
oCache = RL.cache(),
oMessage = _.find(this.messageList(), function (oMessage) { oMessage = _.find(this.messageList(), function (oMessage) {
return oMessage && return oMessage &&
!oCache.hasRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid); !Cache.hasRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid);
}) })
; ;
@ -816,9 +840,9 @@ MailBoxMessageListViewModel.prototype.prefetchNextTick = function ()
{ {
this.bPrefetch = true; this.bPrefetch = true;
RL.cache().addRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid); Cache.addRequestedMessage(oMessage.folderFullNameRaw, oMessage.uid);
RL.remote().message(function (sResult, oData) { Remote.message(function (sResult, oData) {
var bNext = !!(Enums.StorageResultType.Success === sResult && oData && oData.Result); var bNext = !!(Enums.StorageResultType.Success === sResult && oData && oData.Result);
@ -833,36 +857,36 @@ MailBoxMessageListViewModel.prototype.prefetchNextTick = function ()
}, oMessage.folderFullNameRaw, oMessage.uid); }, oMessage.folderFullNameRaw, oMessage.uid);
} }
} }
}; };
MailBoxMessageListViewModel.prototype.composeClick = function () MailBoxMessageListViewModel.prototype.composeClick = function ()
{ {
kn.showScreenPopup(PopupsComposeViewModel); kn.showScreenPopup(PopupsComposeViewModel);
}; };
MailBoxMessageListViewModel.prototype.advancedSearchClick = function () MailBoxMessageListViewModel.prototype.advancedSearchClick = function ()
{ {
kn.showScreenPopup(PopupsAdvancedSearchViewModel); kn.showScreenPopup(PopupsAdvancedSearchViewModel);
}; };
MailBoxMessageListViewModel.prototype.quotaTooltip = function () MailBoxMessageListViewModel.prototype.quotaTooltip = function ()
{ {
return Utils.i18n('MESSAGE_LIST/QUOTA_SIZE', { return Utils.i18n('MESSAGE_LIST/QUOTA_SIZE', {
'SIZE': Utils.friendlySize(this.userUsageSize()), 'SIZE': Utils.friendlySize(this.userUsageSize()),
'PROC': this.userUsageProc(), 'PROC': this.userUsageProc(),
'LIMIT': Utils.friendlySize(this.userQuota()) 'LIMIT': Utils.friendlySize(this.userQuota())
}); });
}; };
MailBoxMessageListViewModel.prototype.initUploaderForAppend = function () MailBoxMessageListViewModel.prototype.initUploaderForAppend = function ()
{ {
if (!RL.settingsGet('AllowAppendMessage') || !this.dragOverArea()) if (!RL.settingsGet('AllowAppendMessage') || !this.dragOverArea())
{ {
return false; return false;
} }
var oJua = new Jua({ var oJua = new Jua({
'action': RL.link().append(), 'action': LinkBuilder.append(),
'name': 'AppendFile', 'name': 'AppendFile',
'queueSize': 1, 'queueSize': 1,
'multipleSizeLimit': 1, 'multipleSizeLimit': 1,
@ -904,4 +928,8 @@ MailBoxMessageListViewModel.prototype.initUploaderForAppend = function ()
; ;
return !!oJua; return !!oJua;
}; };
module.exports = new MailBoxMessageListViewModel();
}(module));

View file

@ -8,9 +8,14 @@
ko = require('../External/ko.js'), ko = require('../External/ko.js'),
key = require('../External/key.js'), key = require('../External/key.js'),
$html = require('../External/$html.js'), $html = require('../External/$html.js'),
Consts = require('../Common/Consts.js'), Consts = require('../Common/Consts.js'),
Enums = require('../Common/Enums.js'), Enums = require('../Common/Enums.js'),
Utils = require('../Common/Utils.js'), Utils = require('../Common/Utils.js'),
Cache = require('../Storages/WebMailCacheStorage.js'),
Remote = require('../Storages/WebMailAjaxRemoteStorage.js'),
kn = require('../Knoin/Knoin.js'), kn = require('../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js') KnoinAbstractViewModel = require('../Knoin/KnoinAbstractViewModel.js')
; ;
@ -188,7 +193,7 @@
this.viewDownloadLink(oMessage.downloadLink()); this.viewDownloadLink(oMessage.downloadLink());
sLastEmail = oMessage.fromAsSingleEmail(); sLastEmail = oMessage.fromAsSingleEmail();
RL.cache().getUserPic(sLastEmail, function (sPic, $sEmail) { Cache.getUserPic(sLastEmail, function (sPic, $sEmail) {
if (sPic !== self.viewUserPic() && sLastEmail === $sEmail) if (sPic !== self.viewUserPic() && sLastEmail === $sEmail)
{ {
self.viewUserPicVisible(false); self.viewUserPicVisible(false);
@ -240,7 +245,7 @@
kn.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('MailBoxMessageViewViewModel', MailBoxMessageViewViewModel); kn.extendAsViewModel('MailBoxMessageViewViewModel', MailBoxMessageViewViewModel);
MailBoxMessageViewViewModel.prototype.isPgpActionVisible = function () MailBoxMessageViewViewModel.prototype.isPgpActionVisible = function ()
{ {
@ -695,14 +700,14 @@
{ {
if (oMessage && '' !== oMessage.readReceipt()) if (oMessage && '' !== oMessage.readReceipt())
{ {
RL.remote().sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid, Remote.sendReadReceiptMessage(Utils.emptyFunction, oMessage.folderFullNameRaw, oMessage.uid,
oMessage.readReceipt(), oMessage.readReceipt(),
Utils.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}), Utils.i18n('READ_RECEIPT/SUBJECT', {'SUBJECT': oMessage.subject()}),
Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': RL.data().accountEmail()})); Utils.i18n('READ_RECEIPT/BODY', {'READ-RECEIPT': RL.data().accountEmail()}));
oMessage.isReadReceipt(true); oMessage.isReadReceipt(true);
RL.cache().storeMessageFlagsToCache(oMessage); Cache.storeMessageFlagsToCache(oMessage);
RL.reloadFlagsCurrentMessageListAndMessageFromCache(); RL.reloadFlagsCurrentMessageListAndMessageFromCache();
} }
}; };

View file

@ -20,7 +20,7 @@
kn.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('MailBoxSystemDropDownViewModel', MailBoxSystemDropDownViewModel, AbstractSystemDropDownViewModel); kn.extendAsViewModel('MailBoxSystemDropDownViewModel', MailBoxSystemDropDownViewModel, AbstractSystemDropDownViewModel);
module.exports = MailBoxSystemDropDownViewModel; module.exports = MailBoxSystemDropDownViewModel;

View file

@ -1,11 +1,27 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
ko = require('../../External/ko.js'),
Enums = require('../../Common/Enums.js'),
Utils = require('../../Common/Utils.js'),
Data = require('../../Storages/AdminDataStorage.js'),
Remote = require('../../Storages/AdminAjaxRemoteStorage.js'),
kn = require('../../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function PopupsActivateViewModel() function PopupsActivateViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsActivate'); KnoinAbstractViewModel.call(this, 'Popups', 'PopupsActivate');
var self = this; var self = this;
@ -15,7 +31,7 @@ function PopupsActivateViewModel()
this.key.focus = ko.observable(false); this.key.focus = ko.observable(false);
this.activationSuccessed = ko.observable(false); this.activationSuccessed = ko.observable(false);
this.licenseTrigger = RL.data().licenseTrigger; this.licenseTrigger = Data.licenseTrigger;
this.activateProcess = ko.observable(false); this.activateProcess = ko.observable(false);
this.activateText = ko.observable(''); this.activateText = ko.observable('');
@ -38,7 +54,7 @@ function PopupsActivateViewModel()
this.activateProcess(true); this.activateProcess(true);
if (this.validateSubscriptionKey()) if (this.validateSubscriptionKey())
{ {
RL.remote().licensingActivate(function (sResult, oData) { Remote.licensingActivate(function (sResult, oData) {
self.activateProcess(false); self.activateProcess(false);
if (Enums.StorageResultType.Success === sResult && oData.Result) if (Enums.StorageResultType.Success === sResult && oData.Result)
@ -83,13 +99,13 @@ function PopupsActivateViewModel()
return !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed(); return !this.activateProcess() && '' !== this.domain() && '' !== this.key() && !this.activationSuccessed();
}); });
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('PopupsActivateViewModel', PopupsActivateViewModel); kn.extendAsViewModel('PopupsActivateViewModel', PopupsActivateViewModel);
PopupsActivateViewModel.prototype.onShow = function () PopupsActivateViewModel.prototype.onShow = function ()
{ {
this.domain(RL.settingsGet('AdminDomain')); this.domain(RL.settingsGet('AdminDomain'));
if (!this.activateProcess()) if (!this.activateProcess())
{ {
@ -98,21 +114,25 @@ PopupsActivateViewModel.prototype.onShow = function ()
this.activateText.isError(false); this.activateText.isError(false);
this.activationSuccessed(false); this.activationSuccessed(false);
} }
}; };
PopupsActivateViewModel.prototype.onFocus = function () PopupsActivateViewModel.prototype.onFocus = function ()
{ {
if (!this.activateProcess()) if (!this.activateProcess())
{ {
this.key.focus(true); this.key.focus(true);
} }
}; };
/** /**
* @returns {boolean} * @returns {boolean}
*/ */
PopupsActivateViewModel.prototype.validateSubscriptionKey = function () PopupsActivateViewModel.prototype.validateSubscriptionKey = function ()
{ {
var sValue = this.key(); var sValue = this.key();
return '' === sValue || !!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(Utils.trim(sValue)); return '' === sValue || !!/^RL[\d]+-[A-Z0-9\-]+Z$/.test(Utils.trim(sValue));
}; };
module.exports = new PopupsActivateViewModel();
}(module));

View file

@ -1,11 +1,27 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
ko = require('../../External/ko.js'),
Enums = require('../../Common/Enums.js'),
Utils = require('../../Common/Utils.js'),
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
kn = require('../../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function PopupsAddAccountViewModel() function PopupsAddAccountViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddAccount'); KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddAccount');
this.email = ko.observable(''); this.email = ko.observable('');
@ -39,7 +55,7 @@ function PopupsAddAccountViewModel()
this.submitRequest(true); this.submitRequest(true);
RL.remote().accountAdd(_.bind(function (sResult, oData) { Remote.accountAdd(_.bind(function (sResult, oData) {
this.submitRequest(false); this.submitRequest(false);
if (Enums.StorageResultType.Success === sResult && oData && 'AccountAdd' === oData.Action) if (Enums.StorageResultType.Success === sResult && oData && 'AccountAdd' === oData.Action)
@ -67,13 +83,13 @@ function PopupsAddAccountViewModel()
return !this.submitRequest(); return !this.submitRequest();
}); });
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('PopupsAddAccountViewModel', PopupsAddAccountViewModel); kn.extendAsViewModel('PopupsAddAccountViewModel', PopupsAddAccountViewModel);
PopupsAddAccountViewModel.prototype.clearPopup = function () PopupsAddAccountViewModel.prototype.clearPopup = function ()
{ {
this.email(''); this.email('');
this.password(''); this.password('');
@ -82,14 +98,18 @@ PopupsAddAccountViewModel.prototype.clearPopup = function ()
this.submitRequest(false); this.submitRequest(false);
this.submitError(''); this.submitError('');
}; };
PopupsAddAccountViewModel.prototype.onShow = function () PopupsAddAccountViewModel.prototype.onShow = function ()
{ {
this.clearPopup(); this.clearPopup();
}; };
PopupsAddAccountViewModel.prototype.onFocus = function () PopupsAddAccountViewModel.prototype.onFocus = function ()
{ {
this.emailFocus(true); this.emailFocus(true);
}; };
module.exports = new PopupsAddAccountViewModel();
}(module));

View file

@ -1,11 +1,26 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
ko = require('../../External/ko.js'),
Utils = require('../../Common/Utils.js'),
Data = require('../../Storages/WebMailDataStorage.js'),
kn = require('../../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function PopupsAddOpenPgpKeyViewModel() function PopupsAddOpenPgpKeyViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddOpenPgpKey'); KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAddOpenPgpKey');
this.key = ko.observable(''); this.key = ko.observable('');
@ -23,7 +38,7 @@ function PopupsAddOpenPgpKeyViewModel()
aMatch = null, aMatch = null,
sKey = Utils.trim(this.key()), sKey = Utils.trim(this.key()),
oReg = /[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi, oReg = /[\-]{3,6}BEGIN[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}[\s\S]+?[\-]{3,6}END[\s]PGP[\s](PRIVATE|PUBLIC)[\s]KEY[\s]BLOCK[\-]{3,6}/gi,
oOpenpgpKeyring = RL.data().openpgpKeyring oOpenpgpKeyring = Data.openpgpKeyring
; ;
sKey = sKey.replace(/[\r\n]([a-zA-Z0-9]{2,}:[^\r\n]+)[\r\n]+([a-zA-Z0-9\/\\+=]{10,})/g, '\n$1!-!N!-!$2') sKey = sKey.replace(/[\r\n]([a-zA-Z0-9]{2,}:[^\r\n]+)[\r\n]+([a-zA-Z0-9\/\\+=]{10,})/g, '\n$1!-!N!-!$2')
@ -68,23 +83,27 @@ function PopupsAddOpenPgpKeyViewModel()
return true; return true;
}); });
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('PopupsAddOpenPgpKeyViewModel', PopupsAddOpenPgpKeyViewModel); kn.extendAsViewModel('PopupsAddOpenPgpKeyViewModel', PopupsAddOpenPgpKeyViewModel);
PopupsAddOpenPgpKeyViewModel.prototype.clearPopup = function () PopupsAddOpenPgpKeyViewModel.prototype.clearPopup = function ()
{ {
this.key(''); this.key('');
this.key.error(false); this.key.error(false);
}; };
PopupsAddOpenPgpKeyViewModel.prototype.onShow = function () PopupsAddOpenPgpKeyViewModel.prototype.onShow = function ()
{ {
this.clearPopup(); this.clearPopup();
}; };
PopupsAddOpenPgpKeyViewModel.prototype.onFocus = function () PopupsAddOpenPgpKeyViewModel.prototype.onFocus = function ()
{ {
this.key.focus(true); this.key.focus(true);
}; };
module.exports = new PopupsAddOpenPgpKeyViewModel();
}(module));

View file

@ -1,11 +1,27 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
ko = require('../../External/ko.js'),
moment = require('../../External/moment.js'),
Utils = require('../../Common/Utils.js'),
Data = require('../../Storages/WebMailDataStorage.js'),
kn = require('../../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function PopupsAdvancedSearchViewModel() function PopupsAdvancedSearchViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAdvancedSearch'); KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAdvancedSearch');
this.fromFocus = ko.observable(false); this.fromFocus = ko.observable(false);
@ -25,29 +41,29 @@ function PopupsAdvancedSearchViewModel()
var sSearch = this.buildSearchString(); var sSearch = this.buildSearchString();
if ('' !== sSearch) if ('' !== sSearch)
{ {
RL.data().mainMessageListSearch(sSearch); Data.mainMessageListSearch(sSearch);
} }
this.cancelCommand(); this.cancelCommand();
}); });
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('PopupsAdvancedSearchViewModel', PopupsAdvancedSearchViewModel); kn.extendAsViewModel('PopupsAdvancedSearchViewModel', PopupsAdvancedSearchViewModel);
PopupsAdvancedSearchViewModel.prototype.buildSearchStringValue = function (sValue) PopupsAdvancedSearchViewModel.prototype.buildSearchStringValue = function (sValue)
{ {
if (-1 < sValue.indexOf(' ')) if (-1 < sValue.indexOf(' '))
{ {
sValue = '"' + sValue + '"'; sValue = '"' + sValue + '"';
} }
return sValue; return sValue;
}; };
PopupsAdvancedSearchViewModel.prototype.buildSearchString = function () PopupsAdvancedSearchViewModel.prototype.buildSearchString = function ()
{ {
var var
aResult = [], aResult = [],
sFrom = Utils.trim(this.from()), sFrom = Utils.trim(this.from()),
@ -109,10 +125,10 @@ PopupsAdvancedSearchViewModel.prototype.buildSearchString = function ()
} }
return Utils.trim(aResult.join(' ')); return Utils.trim(aResult.join(' '));
}; };
PopupsAdvancedSearchViewModel.prototype.clearPopup = function () PopupsAdvancedSearchViewModel.prototype.clearPopup = function ()
{ {
this.from(''); this.from('');
this.to(''); this.to('');
this.subject(''); this.subject('');
@ -124,14 +140,18 @@ PopupsAdvancedSearchViewModel.prototype.clearPopup = function ()
this.unseen(false); this.unseen(false);
this.fromFocus(true); this.fromFocus(true);
}; };
PopupsAdvancedSearchViewModel.prototype.onShow = function () PopupsAdvancedSearchViewModel.prototype.onShow = function ()
{ {
this.clearPopup(); this.clearPopup();
}; };
PopupsAdvancedSearchViewModel.prototype.onFocus = function () PopupsAdvancedSearchViewModel.prototype.onFocus = function ()
{ {
this.fromFocus(true); this.fromFocus(true);
}; };
module.exports = new PopupsAdvancedSearchViewModel();
}(module));

View file

@ -1,11 +1,24 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
ko = require('../../External/ko.js'),
key = require('../../External/key.js'),
Enums = require('../../Common/Enums.js'),
Utils = require('../../Common/Utils.js'),
kn = require('../../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function PopupsAskViewModel() function PopupsAskViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAsk'); KnoinAbstractViewModel.call(this, 'Popups', 'PopupsAsk');
this.askDesc = ko.observable(''); this.askDesc = ko.observable('');
@ -21,13 +34,13 @@ function PopupsAskViewModel()
this.bDisabeCloseOnEsc = true; this.bDisabeCloseOnEsc = true;
this.sDefaultKeyScope = Enums.KeyState.PopupAsk; this.sDefaultKeyScope = Enums.KeyState.PopupAsk;
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('PopupsAskViewModel', PopupsAskViewModel); kn.extendAsViewModel('PopupsAskViewModel', PopupsAskViewModel);
PopupsAskViewModel.prototype.clearPopup = function () PopupsAskViewModel.prototype.clearPopup = function ()
{ {
this.askDesc(''); this.askDesc('');
this.yesButton(Utils.i18n('POPUPS_ASK/BUTTON_YES')); this.yesButton(Utils.i18n('POPUPS_ASK/BUTTON_YES'));
this.noButton(Utils.i18n('POPUPS_ASK/BUTTON_NO')); this.noButton(Utils.i18n('POPUPS_ASK/BUTTON_NO'));
@ -37,37 +50,37 @@ PopupsAskViewModel.prototype.clearPopup = function ()
this.fYesAction = null; this.fYesAction = null;
this.fNoAction = null; this.fNoAction = null;
}; };
PopupsAskViewModel.prototype.yesClick = function () PopupsAskViewModel.prototype.yesClick = function ()
{ {
this.cancelCommand(); this.cancelCommand();
if (Utils.isFunc(this.fYesAction)) if (Utils.isFunc(this.fYesAction))
{ {
this.fYesAction.call(null); this.fYesAction.call(null);
} }
}; };
PopupsAskViewModel.prototype.noClick = function () PopupsAskViewModel.prototype.noClick = function ()
{ {
this.cancelCommand(); this.cancelCommand();
if (Utils.isFunc(this.fNoAction)) if (Utils.isFunc(this.fNoAction))
{ {
this.fNoAction.call(null); this.fNoAction.call(null);
} }
}; };
/** /**
* @param {string} sAskDesc * @param {string} sAskDesc
* @param {Function=} fYesFunc * @param {Function=} fYesFunc
* @param {Function=} fNoFunc * @param {Function=} fNoFunc
* @param {string=} sYesButton * @param {string=} sYesButton
* @param {string=} sNoButton * @param {string=} sNoButton
*/ */
PopupsAskViewModel.prototype.onShow = function (sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton) PopupsAskViewModel.prototype.onShow = function (sAskDesc, fYesFunc, fNoFunc, sYesButton, sNoButton)
{ {
this.clearPopup(); this.clearPopup();
this.fYesAction = fYesFunc || null; this.fYesAction = fYesFunc || null;
@ -83,15 +96,15 @@ PopupsAskViewModel.prototype.onShow = function (sAskDesc, fYesFunc, fNoFunc, sYe
{ {
this.yesButton(sNoButton); this.yesButton(sNoButton);
} }
}; };
PopupsAskViewModel.prototype.onFocus = function () PopupsAskViewModel.prototype.onFocus = function ()
{ {
this.yesFocus(true); this.yesFocus(true);
}; };
PopupsAskViewModel.prototype.onBuild = function () PopupsAskViewModel.prototype.onBuild = function ()
{ {
key('tab, shift+tab, right, left', Enums.KeyState.PopupAsk, _.bind(function () { key('tab, shift+tab, right, left', Enums.KeyState.PopupAsk, _.bind(function () {
if (this.yesFocus()) if (this.yesFocus())
{ {
@ -108,5 +121,8 @@ PopupsAskViewModel.prototype.onBuild = function ()
this.noClick(); this.noClick();
return false; return false;
}, this)); }, this));
}; };
module.exports = new PopupsAskViewModel();
}(module));

View file

@ -1,11 +1,29 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
window = require('../../External/window.js'),
ko = require('../../External/ko.js'),
key = require('../../External/key.js'),
Utils = require('../../Common/Utils.js'),
Enums = require('../../Common/Enums.js'),
Data = require('../../Storages/WebMailDataStorage.js'),
kn = require('../../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function PopupsComposeOpenPgpViewModel() function PopupsComposeOpenPgpViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsComposeOpenPgp'); KnoinAbstractViewModel.call(this, 'Popups', 'PopupsComposeOpenPgp');
this.notification = ko.observable(''); this.notification = ko.observable('');
@ -31,7 +49,6 @@ function PopupsComposeOpenPgpViewModel()
var var
self = this, self = this,
bResult = true, bResult = true,
oData = RL.data(),
oPrivateKey = null, oPrivateKey = null,
aPublicKeys = [] aPublicKeys = []
; ;
@ -46,7 +63,7 @@ function PopupsComposeOpenPgpViewModel()
if (bResult && this.sign()) if (bResult && this.sign())
{ {
oPrivateKey = oData.findPrivateKeyByEmail(this.from(), this.password()); oPrivateKey = Data.findPrivateKeyByEmail(this.from(), this.password());
if (!oPrivateKey) if (!oPrivateKey)
{ {
this.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', { this.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PRIVATE_KEY_FOUND_FOR', {
@ -67,7 +84,7 @@ function PopupsComposeOpenPgpViewModel()
{ {
aPublicKeys = []; aPublicKeys = [];
_.each(this.to(), function (sEmail) { _.each(this.to(), function (sEmail) {
var aKeys = oData.findPublicKeysByEmail(sEmail); var aKeys = Data.findPublicKeysByEmail(sEmail);
if (0 === aKeys.length && bResult) if (0 === aKeys.length && bResult)
{ {
self.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', { self.notification(Utils.i18n('PGP_NOTIFICATIONS/NO_PUBLIC_KEYS_FOUND_FOR', {
@ -136,13 +153,13 @@ function PopupsComposeOpenPgpViewModel()
this.sDefaultKeyScope = Enums.KeyState.PopupComposeOpenPGP; this.sDefaultKeyScope = Enums.KeyState.PopupComposeOpenPGP;
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('PopupsComposeOpenPgpViewModel', PopupsComposeOpenPgpViewModel); kn.extendAsViewModel('PopupsComposeOpenPgpViewModel', PopupsComposeOpenPgpViewModel);
PopupsComposeOpenPgpViewModel.prototype.clearPopup = function () PopupsComposeOpenPgpViewModel.prototype.clearPopup = function ()
{ {
this.notification(''); this.notification('');
this.password(''); this.password('');
@ -156,10 +173,10 @@ PopupsComposeOpenPgpViewModel.prototype.clearPopup = function ()
this.submitRequest(false); this.submitRequest(false);
this.resultCallback = null; this.resultCallback = null;
}; };
PopupsComposeOpenPgpViewModel.prototype.onBuild = function () PopupsComposeOpenPgpViewModel.prototype.onBuild = function ()
{ {
key('tab,shift+tab', Enums.KeyState.PopupComposeOpenPGP, _.bind(function () { key('tab,shift+tab', Enums.KeyState.PopupComposeOpenPGP, _.bind(function () {
switch (true) switch (true)
@ -175,15 +192,15 @@ PopupsComposeOpenPgpViewModel.prototype.onBuild = function ()
return false; return false;
}, this)); }, this));
}; };
PopupsComposeOpenPgpViewModel.prototype.onHide = function () PopupsComposeOpenPgpViewModel.prototype.onHide = function ()
{ {
this.clearPopup(); this.clearPopup();
}; };
PopupsComposeOpenPgpViewModel.prototype.onFocus = function () PopupsComposeOpenPgpViewModel.prototype.onFocus = function ()
{ {
if (this.sign()) if (this.sign())
{ {
this.password.focus(true); this.password.focus(true);
@ -192,10 +209,10 @@ PopupsComposeOpenPgpViewModel.prototype.onFocus = function ()
{ {
this.buttonFocus(true); this.buttonFocus(true);
} }
}; };
PopupsComposeOpenPgpViewModel.prototype.onShow = function (fCallback, sText, sFromEmail, sTo, sCc, sBcc) PopupsComposeOpenPgpViewModel.prototype.onShow = function (fCallback, sText, sFromEmail, sTo, sCc, sBcc)
{ {
this.clearPopup(); this.clearPopup();
var var
@ -238,4 +255,8 @@ PopupsComposeOpenPgpViewModel.prototype.onShow = function (fCallback, sText, sFr
this.from(sResultFromEmail); this.from(sResultFromEmail);
this.to(aRec); this.to(aRec);
this.text(sText); this.text(sText);
}; };
module.exports = new PopupsComposeOpenPgpViewModel();
}(module));

View file

@ -1,11 +1,34 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
$ = require('../../External/jquery.js'),
_ = require('../../External/underscore.js'),
ko = require('../../External/ko.js'),
moment = require('../../External/moment.js'),
Enums = require('../../Common/Enums.js'),
Consts = require('../../Common/Consts.js'),
Utils = require('../../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
Data = require('../../Storages/WebMailDataStorage.js'),
Cache = require('../../Storages/WebMailCacheStorage.js'),
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
kn = require('../../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function PopupsComposeViewModel() function PopupsComposeViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsCompose'); KnoinAbstractViewModel.call(this, 'Popups', 'PopupsCompose');
this.oEditor = null; this.oEditor = null;
@ -19,7 +42,6 @@ function PopupsComposeViewModel()
var var
self = this, self = this,
oRainLoopData = RL.data(),
fCcAndBccCheckHelper = function (aValue) { fCcAndBccCheckHelper = function (aValue) {
if (false === self.showCcAndBcc() && 0 < aValue.length) if (false === self.showCcAndBcc() && 0 < aValue.length)
{ {
@ -28,7 +50,7 @@ function PopupsComposeViewModel()
} }
; ;
this.capaOpenPGP = oRainLoopData.capaOpenPGP; this.capaOpenPGP = Data.capaOpenPGP;
this.resizer = ko.observable(false).extend({'throttle': 50}); this.resizer = ko.observable(false).extend({'throttle': 50});
@ -91,8 +113,8 @@ function PopupsComposeViewModel()
this.composeEditorArea = ko.observable(null); this.composeEditorArea = ko.observable(null);
this.identities = RL.data().identities; this.identities = Data.identities;
this.defaultIdentityID = RL.data().defaultIdentityID; this.defaultIdentityID = Data.defaultIdentityID;
this.currentIdentityID = ko.observable(''); this.currentIdentityID = ko.observable('');
this.currentIdentityString = ko.observable(''); this.currentIdentityString = ko.observable('');
@ -101,11 +123,11 @@ function PopupsComposeViewModel()
this.identitiesOptions = ko.computed(function () { this.identitiesOptions = ko.computed(function () {
var aList = [{ var aList = [{
'optValue': oRainLoopData.accountEmail(), 'optValue': Data.accountEmail(),
'optText': this.formattedFrom(false) 'optText': this.formattedFrom(false)
}]; }];
_.each(oRainLoopData.identities(), function (oItem) { _.each(Data.identities(), function (oItem) {
aList.push({ aList.push({
'optValue': oItem.id, 'optValue': oItem.id,
'optText': oItem.formattedNameForCompose() 'optText': oItem.formattedNameForCompose()
@ -126,7 +148,7 @@ function PopupsComposeViewModel()
sID = this.currentIdentityID() sID = this.currentIdentityID()
; ;
if (this.bCapaAdditionalIdentities && sID && sID !== RL.data().accountEmail()) if (this.bCapaAdditionalIdentities && sID && sID !== Data.accountEmail())
{ {
oItem = _.find(aList, function (oItem) { oItem = _.find(aList, function (oItem) {
return oItem && sID === oItem['id']; return oItem && sID === oItem['id'];
@ -194,7 +216,7 @@ function PopupsComposeViewModel()
this.sendCommand = Utils.createCommand(this, function () { this.sendCommand = Utils.createCommand(this, function () {
var var
sTo = Utils.trim(this.to()), sTo = Utils.trim(this.to()),
sSentFolder = RL.data().sentFolder(), sSentFolder = Data.sentFolder(),
aFlagsCache = [] aFlagsCache = []
; ;
@ -208,7 +230,7 @@ function PopupsComposeViewModel()
} }
else else
{ {
if (RL.data().replySameFolder()) if (Data.replySameFolder())
{ {
if (Utils.isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length && Utils.isNormal(this.aDraftInfo[2]) && 0 < this.aDraftInfo[2].length) if (Utils.isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length && Utils.isNormal(this.aDraftInfo[2]) && 0 < this.aDraftInfo[2].length)
{ {
@ -227,7 +249,7 @@ function PopupsComposeViewModel()
if (Utils.isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length) if (Utils.isArray(this.aDraftInfo) && 3 === this.aDraftInfo.length)
{ {
aFlagsCache = RL.cache().getMessageFlagsFromCache(this.aDraftInfo[2], this.aDraftInfo[1]); aFlagsCache = Cache.getMessageFlagsFromCache(this.aDraftInfo[2], this.aDraftInfo[1]);
if (aFlagsCache) if (aFlagsCache)
{ {
if ('forward' === this.aDraftInfo[0]) if ('forward' === this.aDraftInfo[0])
@ -239,18 +261,18 @@ function PopupsComposeViewModel()
aFlagsCache[2] = true; aFlagsCache[2] = true;
} }
RL.cache().setMessageFlagsToCache(this.aDraftInfo[2], this.aDraftInfo[1], aFlagsCache); Cache.setMessageFlagsToCache(this.aDraftInfo[2], this.aDraftInfo[1], aFlagsCache);
RL.reloadFlagsCurrentMessageListAndMessageFromCache(); RL.reloadFlagsCurrentMessageListAndMessageFromCache();
RL.cache().setFolderHash(this.aDraftInfo[2], ''); Cache.setFolderHash(this.aDraftInfo[2], '');
} }
} }
sSentFolder = Consts.Values.UnuseOptionValue === sSentFolder ? '' : sSentFolder; sSentFolder = Consts.Values.UnuseOptionValue === sSentFolder ? '' : sSentFolder;
RL.cache().setFolderHash(this.draftFolder(), ''); Cache.setFolderHash(this.draftFolder(), '');
RL.cache().setFolderHash(sSentFolder, ''); Cache.setFolderHash(sSentFolder, '');
RL.remote().sendMessage( Remote.sendMessage(
this.sendMessageResponse, this.sendMessageResponse,
this.draftFolder(), this.draftFolder(),
this.draftUid(), this.draftUid(),
@ -274,7 +296,7 @@ function PopupsComposeViewModel()
this.saveCommand = Utils.createCommand(this, function () { this.saveCommand = Utils.createCommand(this, function () {
if (RL.data().draftFolderNotEnabled()) if (Data.draftFolderNotEnabled())
{ {
kn.showScreenPopup(PopupsFolderSystemViewModel, [Enums.SetSystemFoldersNotification.Draft]); kn.showScreenPopup(PopupsFolderSystemViewModel, [Enums.SetSystemFoldersNotification.Draft]);
} }
@ -285,13 +307,13 @@ function PopupsComposeViewModel()
this.bSkipNext = true; this.bSkipNext = true;
RL.cache().setFolderHash(RL.data().draftFolder(), ''); Cache.setFolderHash(Data.draftFolder(), '');
RL.remote().saveMessage( Remote.saveMessage(
this.saveMessageResponse, this.saveMessageResponse,
this.draftFolder(), this.draftFolder(),
this.draftUid(), this.draftUid(),
RL.data().draftFolder(), Data.draftFolder(),
this.currentIdentityResultEmail(), this.currentIdentityResultEmail(),
this.to(), this.to(),
this.cc(), this.cc(),
@ -309,7 +331,7 @@ function PopupsComposeViewModel()
}, this.canBeSendedOrSaved); }, this.canBeSendedOrSaved);
RL.sub('interval.1m', function () { RL.sub('interval.1m', function () {
if (this.modalVisibility() && !RL.data().draftFolderNotEnabled() && !this.isEmptyForm(false) && if (this.modalVisibility() && !Data.draftFolderNotEnabled() && !this.isEmptyForm(false) &&
!this.bSkipNext && !this.saving() && !this.sending() && !this.savedError()) !this.bSkipNext && !this.saving() && !this.sending() && !this.savedError())
{ {
this.bSkipNext = false; this.bSkipNext = false;
@ -368,13 +390,13 @@ function PopupsComposeViewModel()
this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200); this.tryToClosePopup = _.debounce(_.bind(this.tryToClosePopup, this), 200);
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('PopupsComposeViewModel', PopupsComposeViewModel); kn.extendAsViewModel('PopupsComposeViewModel', PopupsComposeViewModel);
PopupsComposeViewModel.prototype.openOpenPgpPopup = function () PopupsComposeViewModel.prototype.openOpenPgpPopup = function ()
{ {
if (this.capaOpenPGP() && this.oEditor && !this.oEditor.isHtml()) if (this.capaOpenPGP() && this.oEditor && !this.oEditor.isHtml())
{ {
var self = this; var self = this;
@ -391,15 +413,15 @@ PopupsComposeViewModel.prototype.openOpenPgpPopup = function ()
this.bcc() this.bcc()
]); ]);
} }
}; };
PopupsComposeViewModel.prototype.reloadDraftFolder = function () PopupsComposeViewModel.prototype.reloadDraftFolder = function ()
{ {
var sDraftFolder = RL.data().draftFolder(); var sDraftFolder = Data.draftFolder();
if ('' !== sDraftFolder) if ('' !== sDraftFolder)
{ {
RL.cache().setFolderHash(sDraftFolder, ''); Cache.setFolderHash(sDraftFolder, '');
if (RL.data().currentFolderFullNameRaw() === sDraftFolder) if (Data.currentFolderFullNameRaw() === sDraftFolder)
{ {
RL.reloadMessageList(true); RL.reloadMessageList(true);
} }
@ -408,10 +430,10 @@ PopupsComposeViewModel.prototype.reloadDraftFolder = function ()
RL.folderInformation(sDraftFolder); RL.folderInformation(sDraftFolder);
} }
} }
}; };
PopupsComposeViewModel.prototype.findIdentityIdByMessage = function (sComposeType, oMessage) PopupsComposeViewModel.prototype.findIdentityIdByMessage = function (sComposeType, oMessage)
{ {
var var
oIDs = {}, oIDs = {},
sResult = '', sResult = '',
@ -433,7 +455,7 @@ PopupsComposeViewModel.prototype.findIdentityIdByMessage = function (sComposeTyp
}); });
} }
oIDs[RL.data().accountEmail()] = RL.data().accountEmail(); oIDs[Data.accountEmail()] = Data.accountEmail();
if (oMessage) if (oMessage)
{ {
@ -460,30 +482,30 @@ PopupsComposeViewModel.prototype.findIdentityIdByMessage = function (sComposeTyp
if ('' === sResult) if ('' === sResult)
{ {
sResult = RL.data().accountEmail(); sResult = Data.accountEmail();
} }
return sResult; return sResult;
}; };
PopupsComposeViewModel.prototype.selectIdentity = function (oIdentity) PopupsComposeViewModel.prototype.selectIdentity = function (oIdentity)
{ {
if (oIdentity) if (oIdentity)
{ {
this.currentIdentityID(oIdentity.optValue); this.currentIdentityID(oIdentity.optValue);
} }
}; };
/** /**
* *
* @param {boolean=} bHeaderResult = false * @param {boolean=} bHeaderResult = false
* @returns {string} * @returns {string}
*/ */
PopupsComposeViewModel.prototype.formattedFrom = function (bHeaderResult) PopupsComposeViewModel.prototype.formattedFrom = function (bHeaderResult)
{ {
var var
sDisplayName = RL.data().displayName(), sDisplayName = Data.displayName(),
sEmail = RL.data().accountEmail() sEmail = Data.accountEmail()
; ;
return '' === sDisplayName ? sEmail : return '' === sDisplayName ? sEmail :
@ -491,10 +513,10 @@ PopupsComposeViewModel.prototype.formattedFrom = function (bHeaderResult)
'"' + Utils.quoteName(sDisplayName) + '" <' + sEmail + '>' : '"' + Utils.quoteName(sDisplayName) + '" <' + sEmail + '>' :
sDisplayName + ' (' + sEmail + ')') sDisplayName + ' (' + sEmail + ')')
; ;
}; };
PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData) PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
{ {
var var
bResult = false, bResult = false,
sMessage = '' sMessage = ''
@ -529,10 +551,10 @@ PopupsComposeViewModel.prototype.sendMessageResponse = function (sResult, oData)
} }
this.reloadDraftFolder(); this.reloadDraftFolder();
}; };
PopupsComposeViewModel.prototype.saveMessageResponse = function (sResult, oData) PopupsComposeViewModel.prototype.saveMessageResponse = function (sResult, oData)
{ {
var var
bResult = false, bResult = false,
oMessage = null oMessage = null
@ -546,10 +568,10 @@ PopupsComposeViewModel.prototype.saveMessageResponse = function (sResult, oData)
{ {
if (this.bFromDraft) if (this.bFromDraft)
{ {
oMessage = RL.data().message(); oMessage = Data.message();
if (oMessage && this.draftFolder() === oMessage.folderFullNameRaw && this.draftUid() === oMessage.uid) if (oMessage && this.draftFolder() === oMessage.folderFullNameRaw && this.draftUid() === oMessage.uid)
{ {
RL.data().message(null); Data.message(null);
} }
} }
@ -558,7 +580,7 @@ PopupsComposeViewModel.prototype.saveMessageResponse = function (sResult, oData)
if (this.modalVisibility()) if (this.modalVisibility())
{ {
this.savedTime(Math.round((new window.Date()).getTime() / 1000)); this.savedTime(window.Math.round((new window.Date()).getTime() / 1000));
this.savedOrSendingText( this.savedOrSendingText(
0 < this.savedTime() ? Utils.i18n('COMPOSE/SAVED_TIME', { 0 < this.savedTime() ? Utils.i18n('COMPOSE/SAVED_TIME', {
@ -570,7 +592,7 @@ PopupsComposeViewModel.prototype.saveMessageResponse = function (sResult, oData)
if (this.bFromDraft) if (this.bFromDraft)
{ {
RL.cache().setFolderHash(this.draftFolder(), ''); Cache.setFolderHash(this.draftFolder(), '');
} }
} }
} }
@ -583,23 +605,23 @@ PopupsComposeViewModel.prototype.saveMessageResponse = function (sResult, oData)
} }
this.reloadDraftFolder(); this.reloadDraftFolder();
}; };
PopupsComposeViewModel.prototype.onHide = function () PopupsComposeViewModel.prototype.onHide = function ()
{ {
this.reset(); this.reset();
kn.routeOn(); kn.routeOn();
}; };
/** /**
* @param {string} sSignature * @param {string} sSignature
* @param {string=} sFrom * @param {string=} sFrom
* @param {string=} sData * @param {string=} sData
* @param {string=} sComposeType * @param {string=} sComposeType
* @return {string} * @return {string}
*/ */
PopupsComposeViewModel.prototype.convertSignature = function (sSignature, sFrom, sData, sComposeType) PopupsComposeViewModel.prototype.convertSignature = function (sSignature, sFrom, sData, sComposeType)
{ {
var bHtml = false, bData = false; var bHtml = false, bData = false;
if ('' !== sSignature) if ('' !== sSignature)
{ {
@ -651,10 +673,10 @@ PopupsComposeViewModel.prototype.convertSignature = function (sSignature, sFrom,
} }
return sSignature; return sSignature;
}; };
PopupsComposeViewModel.prototype.editor = function (fOnInit) PopupsComposeViewModel.prototype.editor = function (fOnInit)
{ {
if (fOnInit) if (fOnInit)
{ {
var self = this; var self = this;
@ -673,17 +695,17 @@ PopupsComposeViewModel.prototype.editor = function (fOnInit)
fOnInit(this.oEditor); fOnInit(this.oEditor);
} }
} }
}; };
/** /**
* @param {string=} sType = Enums.ComposeType.Empty * @param {string=} sType = Enums.ComposeType.Empty
* @param {?MessageModel|Array=} oMessageOrArray = null * @param {?MessageModel|Array=} oMessageOrArray = null
* @param {Array=} aToEmails = null * @param {Array=} aToEmails = null
* @param {string=} sCustomSubject = null * @param {string=} sCustomSubject = null
* @param {string=} sCustomPlainText = null * @param {string=} sCustomPlainText = null
*/ */
PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToEmails, sCustomSubject, sCustomPlainText) PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToEmails, sCustomSubject, sCustomPlainText)
{ {
kn.routeOff(); kn.routeOff();
var var
@ -699,9 +721,9 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
sReplyTitle = '', sReplyTitle = '',
aResplyAllParts = [], aResplyAllParts = [],
oExcludeEmail = {}, oExcludeEmail = {},
mEmail = RL.data().accountEmail(), mEmail = Data.accountEmail(),
sSignature = RL.data().signature(), sSignature = Data.signature(),
bSignatureToAll = RL.data().signatureToAll(), bSignatureToAll = Data.signatureToAll(),
aDownloads = [], aDownloads = [],
aDraftInfo = null, aDraftInfo = null,
oMessage = null, oMessage = null,
@ -887,7 +909,7 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
this.editor(function (oEditor) { this.editor(function (oEditor) {
oEditor.setHtml(sText, false); oEditor.setHtml(sText, false);
if (Enums.EditorDefaultType.Html !== RL.data().editorDefaultType()) if (Enums.EditorDefaultType.Html !== Data.editorDefaultType())
{ {
oEditor.modeToggle(false); oEditor.modeToggle(false);
} }
@ -903,7 +925,7 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
aDownloads = this.getAttachmentsDownloadsForUpload(); aDownloads = this.getAttachmentsDownloadsForUpload();
if (Utils.isNonEmptyArray(aDownloads)) if (Utils.isNonEmptyArray(aDownloads))
{ {
RL.remote().messageUploadAttachments(function (sResult, oData) { Remote.messageUploadAttachments(function (sResult, oData) {
if (Enums.StorageResultType.Success === sResult && oData && oData.Result) if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{ {
@ -936,10 +958,10 @@ PopupsComposeViewModel.prototype.onShow = function (sType, oMessageOrArray, aToE
} }
this.triggerForResize(); this.triggerForResize();
}; };
PopupsComposeViewModel.prototype.onFocus = function () PopupsComposeViewModel.prototype.onFocus = function ()
{ {
if ('' === this.to()) if ('' === this.to())
{ {
this.to.focusTrigger(!this.to.focusTrigger()); this.to.focusTrigger(!this.to.focusTrigger());
@ -950,18 +972,18 @@ PopupsComposeViewModel.prototype.onFocus = function ()
} }
this.triggerForResize(); this.triggerForResize();
}; };
PopupsComposeViewModel.prototype.editorResize = function () PopupsComposeViewModel.prototype.editorResize = function ()
{ {
if (this.oEditor) if (this.oEditor)
{ {
this.oEditor.resize(); this.oEditor.resize();
} }
}; };
PopupsComposeViewModel.prototype.tryToClosePopup = function () PopupsComposeViewModel.prototype.tryToClosePopup = function ()
{ {
var self = this; var self = this;
if (!kn.isPopupVisible(PopupsAskViewModel)) if (!kn.isPopupVisible(PopupsAskViewModel))
{ {
@ -972,10 +994,10 @@ PopupsComposeViewModel.prototype.tryToClosePopup = function ()
} }
}]); }]);
} }
}; };
PopupsComposeViewModel.prototype.onBuild = function () PopupsComposeViewModel.prototype.onBuild = function ()
{ {
this.initUploader(); this.initUploader();
var var
@ -1029,10 +1051,10 @@ PopupsComposeViewModel.prototype.onBuild = function ()
} }
}); });
} }
}; };
PopupsComposeViewModel.prototype.driveCallback = function (sAccessToken, oData) PopupsComposeViewModel.prototype.driveCallback = function (sAccessToken, oData)
{ {
if (oData && window.XMLHttpRequest && window.google && if (oData && window.XMLHttpRequest && window.google &&
oData[window.google.picker.Response.ACTION] === window.google.picker.Action.PICKED && oData[window.google.picker.Response.ACTION] === window.google.picker.Action.PICKED &&
oData[window.google.picker.Response.DOCUMENTS] && oData[window.google.picker.Response.DOCUMENTS][0] && oData[window.google.picker.Response.DOCUMENTS] && oData[window.google.picker.Response.DOCUMENTS][0] &&
@ -1097,10 +1119,10 @@ PopupsComposeViewModel.prototype.driveCallback = function (sAccessToken, oData)
oRequest.send(); oRequest.send();
} }
}; };
PopupsComposeViewModel.prototype.driveCreatePiker = function (oOauthToken) PopupsComposeViewModel.prototype.driveCreatePiker = function (oOauthToken)
{ {
if (window.gapi && oOauthToken && oOauthToken.access_token) if (window.gapi && oOauthToken && oOauthToken.access_token)
{ {
var self = this; var self = this;
@ -1125,10 +1147,10 @@ PopupsComposeViewModel.prototype.driveCreatePiker = function (oOauthToken)
} }
}}); }});
} }
}; };
PopupsComposeViewModel.prototype.driveOpenPopup = function () PopupsComposeViewModel.prototype.driveOpenPopup = function ()
{ {
if (window.gapi) if (window.gapi)
{ {
var self = this; var self = this;
@ -1176,14 +1198,14 @@ PopupsComposeViewModel.prototype.driveOpenPopup = function ()
} }
}}); }});
} }
}; };
/** /**
* @param {string} sId * @param {string} sId
* @return {?Object} * @return {?Object}
*/ */
PopupsComposeViewModel.prototype.getAttachmentById = function (sId) PopupsComposeViewModel.prototype.getAttachmentById = function (sId)
{ {
var var
aAttachments = this.attachments(), aAttachments = this.attachments(),
iIndex = 0, iIndex = 0,
@ -1199,17 +1221,17 @@ PopupsComposeViewModel.prototype.getAttachmentById = function (sId)
} }
return null; return null;
}; };
PopupsComposeViewModel.prototype.initUploader = function () PopupsComposeViewModel.prototype.initUploader = function ()
{ {
if (this.composeUploaderButton()) if (this.composeUploaderButton())
{ {
var var
oUploadCache = {}, oUploadCache = {},
iAttachmentSizeLimit = Utils.pInt(RL.settingsGet('AttachmentLimit')), iAttachmentSizeLimit = Utils.pInt(RL.settingsGet('AttachmentLimit')),
oJua = new Jua({ oJua = new Jua({
'action': RL.link().upload(), 'action': LinkBuilder.upload(),
'name': 'uploader', 'name': 'uploader',
'queueSize': 2, 'queueSize': 2,
'multipleSizeLimit': 50, 'multipleSizeLimit': 50,
@ -1222,9 +1244,9 @@ PopupsComposeViewModel.prototype.initUploader = function ()
if (oJua) if (oJua)
{ {
oJua oJua
// .on('onLimitReached', function (iLimit) { // .on('onLimitReached', function (iLimit) {
// alert(iLimit); // alert(iLimit);
// }) // })
.on('onDragEnter', _.bind(function () { .on('onDragEnter', _.bind(function () {
this.dragAndDropOver(true); this.dragAndDropOver(true);
}, this)) }, this))
@ -1384,13 +1406,13 @@ PopupsComposeViewModel.prototype.initUploader = function ()
; ;
} }
} }
}; };
/** /**
* @return {Object} * @return {Object}
*/ */
PopupsComposeViewModel.prototype.prepearAttachmentsForSendOrSave = function () PopupsComposeViewModel.prototype.prepearAttachmentsForSendOrSave = function ()
{ {
var oResult = {}; var oResult = {};
_.each(this.attachmentsInReady(), function (oItem) { _.each(this.attachmentsInReady(), function (oItem) {
if (oItem && '' !== oItem.tempName() && oItem.enabled()) if (oItem && '' !== oItem.tempName() && oItem.enabled())
@ -1405,13 +1427,13 @@ PopupsComposeViewModel.prototype.prepearAttachmentsForSendOrSave = function ()
}); });
return oResult; return oResult;
}; };
/** /**
* @param {MessageModel} oMessage * @param {MessageModel} oMessage
*/ */
PopupsComposeViewModel.prototype.addMessageAsAttachment = function (oMessage) PopupsComposeViewModel.prototype.addMessageAsAttachment = function (oMessage)
{ {
if (oMessage) if (oMessage)
{ {
var var
@ -1438,14 +1460,14 @@ PopupsComposeViewModel.prototype.addMessageAsAttachment = function (oMessage)
this.attachments.push(oAttachment); this.attachments.push(oAttachment);
} }
}; };
/** /**
* @param {Object} oDropboxFile * @param {Object} oDropboxFile
* @return {boolean} * @return {boolean}
*/ */
PopupsComposeViewModel.prototype.addDropboxAttachment = function (oDropboxFile) PopupsComposeViewModel.prototype.addDropboxAttachment = function (oDropboxFile)
{ {
var var
self = this, self = this,
oAttachment = null, oAttachment = null,
@ -1477,7 +1499,7 @@ PopupsComposeViewModel.prototype.addDropboxAttachment = function (oDropboxFile)
return false; return false;
} }
RL.remote().composeUploadExternals(function (sResult, oData) { Remote.composeUploadExternals(function (sResult, oData) {
var bResult = false; var bResult = false;
oAttachment.uploading(false); oAttachment.uploading(false);
@ -1499,15 +1521,15 @@ PopupsComposeViewModel.prototype.addDropboxAttachment = function (oDropboxFile)
}, [oDropboxFile['link']]); }, [oDropboxFile['link']]);
return true; return true;
}; };
/** /**
* @param {Object} oDriveFile * @param {Object} oDriveFile
* @param {string} sAccessToken * @param {string} sAccessToken
* @return {boolean} * @return {boolean}
*/ */
PopupsComposeViewModel.prototype.addDriveAttachment = function (oDriveFile, sAccessToken) PopupsComposeViewModel.prototype.addDriveAttachment = function (oDriveFile, sAccessToken)
{ {
var var
self = this, self = this,
fCancelFunc = function (sId) { fCancelFunc = function (sId) {
@ -1539,7 +1561,7 @@ PopupsComposeViewModel.prototype.addDriveAttachment = function (oDriveFile, sAcc
return false; return false;
} }
RL.remote().composeUploadDrive(function (sResult, oData) { Remote.composeUploadDrive(function (sResult, oData) {
var bResult = false; var bResult = false;
oAttachment.uploading(false); oAttachment.uploading(false);
@ -1562,14 +1584,14 @@ PopupsComposeViewModel.prototype.addDriveAttachment = function (oDriveFile, sAcc
}, oDriveFile['downloadUrl'], sAccessToken); }, oDriveFile['downloadUrl'], sAccessToken);
return true; return true;
}; };
/** /**
* @param {MessageModel} oMessage * @param {MessageModel} oMessage
* @param {string} sType * @param {string} sType
*/ */
PopupsComposeViewModel.prototype.prepearMessageAttachments = function (oMessage, sType) PopupsComposeViewModel.prototype.prepearMessageAttachments = function (oMessage, sType)
{ {
if (oMessage) if (oMessage)
{ {
var var
@ -1629,17 +1651,17 @@ PopupsComposeViewModel.prototype.prepearMessageAttachments = function (oMessage,
} }
} }
} }
}; };
PopupsComposeViewModel.prototype.removeLinkedAttachments = function () PopupsComposeViewModel.prototype.removeLinkedAttachments = function ()
{ {
this.attachments.remove(function (oItem) { this.attachments.remove(function (oItem) {
return oItem && oItem.isLinked; return oItem && oItem.isLinked;
}); });
}; };
PopupsComposeViewModel.prototype.setMessageAttachmentFailedDowbloadText = function () PopupsComposeViewModel.prototype.setMessageAttachmentFailedDowbloadText = function ()
{ {
_.each(this.attachments(), function(oAttachment) { _.each(this.attachments(), function(oAttachment) {
if (oAttachment && oAttachment.fromMessage) if (oAttachment && oAttachment.fromMessage)
{ {
@ -1650,14 +1672,14 @@ PopupsComposeViewModel.prototype.setMessageAttachmentFailedDowbloadText = functi
; ;
} }
}, this); }, this);
}; };
/** /**
* @param {boolean=} bIncludeAttachmentInProgress = true * @param {boolean=} bIncludeAttachmentInProgress = true
* @return {boolean} * @return {boolean}
*/ */
PopupsComposeViewModel.prototype.isEmptyForm = function (bIncludeAttachmentInProgress) PopupsComposeViewModel.prototype.isEmptyForm = function (bIncludeAttachmentInProgress)
{ {
bIncludeAttachmentInProgress = Utils.isUnd(bIncludeAttachmentInProgress) ? true : !!bIncludeAttachmentInProgress; bIncludeAttachmentInProgress = Utils.isUnd(bIncludeAttachmentInProgress) ? true : !!bIncludeAttachmentInProgress;
var bAttach = bIncludeAttachmentInProgress ? var bAttach = bIncludeAttachmentInProgress ?
0 === this.attachments().length : 0 === this.attachmentsInReady().length; 0 === this.attachments().length : 0 === this.attachmentsInReady().length;
@ -1669,10 +1691,10 @@ PopupsComposeViewModel.prototype.isEmptyForm = function (bIncludeAttachmentInPro
bAttach && bAttach &&
(!this.oEditor || '' === this.oEditor.getData()) (!this.oEditor || '' === this.oEditor.getData())
; ;
}; };
PopupsComposeViewModel.prototype.reset = function () PopupsComposeViewModel.prototype.reset = function ()
{ {
this.to(''); this.to('');
this.cc(''); this.cc('');
this.bcc(''); this.bcc('');
@ -1709,23 +1731,26 @@ PopupsComposeViewModel.prototype.reset = function ()
{ {
this.oEditor.clear(false); this.oEditor.clear(false);
} }
}; };
/** /**
* @return {Array} * @return {Array}
*/ */
PopupsComposeViewModel.prototype.getAttachmentsDownloadsForUpload = function () PopupsComposeViewModel.prototype.getAttachmentsDownloadsForUpload = function ()
{ {
return _.map(_.filter(this.attachments(), function (oItem) { return _.map(_.filter(this.attachments(), function (oItem) {
return oItem && '' === oItem.tempName(); return oItem && '' === oItem.tempName();
}), function (oItem) { }), function (oItem) {
return oItem.id; return oItem.id;
}); });
}; };
PopupsComposeViewModel.prototype.triggerForResize = function () PopupsComposeViewModel.prototype.triggerForResize = function ()
{ {
this.resizer(!this.resizer()); this.resizer(!this.resizer());
this.editorResizeThrottle(); this.editorResizeThrottle();
}; };
module.exports = new PopupsComposeViewModel();
}(module));

View file

@ -1,11 +1,35 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
window = require('../../External/window.js'),
$ = require('../../External/jquery.js'),
_ = require('../../External/underscore.js'),
ko = require('../../External/ko.js'),
key = require('../../External/key.js'),
Enums = require('../../Common/Enums.js'),
Consts = require('../../Common/Consts.js'),
Globals = require('../../Common/Globals.js'),
Utils = require('../../Common/Utils.js'),
LinkBuilder = require('../Common/LinkBuilder.js'),
Data = require('../../Storages/WebMailDataStorage.js'),
Remote = require('../../Storages/WebMailAjaxRemoteStorage.js'),
kn = require('../../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function PopupsContactsViewModel() function PopupsContactsViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsContacts'); KnoinAbstractViewModel.call(this, 'Popups', 'PopupsContacts');
var var
@ -17,14 +41,14 @@ function PopupsContactsViewModel()
} }
; ;
this.allowContactsSync = RL.data().allowContactsSync; this.allowContactsSync = Data.allowContactsSync;
this.enableContactsSync = RL.data().enableContactsSync; this.enableContactsSync = Data.enableContactsSync;
this.allowExport = !Globals.bMobileDevice; this.allowExport = !Globals.bMobileDevice;
this.search = ko.observable(''); this.search = ko.observable('');
this.contactsCount = ko.observable(0); this.contactsCount = ko.observable(0);
this.contacts = RL.data().contacts; this.contacts = Data.contacts;
this.contactTags = RL.data().contactTags; this.contactTags = Data.contactTags;
this.currentContact = ko.observable(null); this.currentContact = ko.observable(null);
@ -32,7 +56,7 @@ function PopupsContactsViewModel()
this.contactsPage = ko.observable(1); this.contactsPage = ko.observable(1);
this.contactsPageCount = ko.computed(function () { this.contactsPageCount = ko.computed(function () {
var iPage = Math.ceil(this.contactsCount() / Consts.Defaults.ContactsPerPage); var iPage = window.Math.ceil(this.contactsCount() / Consts.Defaults.ContactsPerPage);
return 0 >= iPage ? 1 : iPage; return 0 >= iPage ? 1 : iPage;
}, this); }, this);
@ -157,7 +181,7 @@ function PopupsContactsViewModel()
this.viewSaving = ko.observable(false); this.viewSaving = ko.observable(false);
this.useCheckboxesInList = RL.data().useCheckboxesInList; this.useCheckboxesInList = Data.useCheckboxesInList;
this.search.subscribe(function () { this.search.subscribe(function () {
this.reloadContactList(); this.reloadContactList();
@ -277,7 +301,7 @@ function PopupsContactsViewModel()
} }
}); });
RL.remote().contactSave(function (sResult, oData) { Remote.contactSave(function (sResult, oData) {
var bRes = false; var bRes = false;
self.viewSaving(false); self.viewSaving(false);
@ -345,7 +369,7 @@ function PopupsContactsViewModel()
}).join(''); }).join('');
}); });
// this.saveCommandDebounce = _.debounce(_.bind(this.saveCommand, this), 1000); // this.saveCommandDebounce = _.debounce(_.bind(this.saveCommand, this), 1000);
this.viewHash.subscribe(function () { this.viewHash.subscribe(function () {
if (this.watchHash() && !this.viewReadOnly() && !this.watchDirty()) if (this.watchHash() && !this.viewReadOnly() && !this.watchDirty())
@ -356,13 +380,13 @@ function PopupsContactsViewModel()
this.sDefaultKeyScope = Enums.KeyState.ContactList; this.sDefaultKeyScope = Enums.KeyState.ContactList;
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('PopupsContactsViewModel', PopupsContactsViewModel); kn.extendAsViewModel('PopupsContactsViewModel', PopupsContactsViewModel);
PopupsContactsViewModel.prototype.getPropertyPlceholder = function (sType) PopupsContactsViewModel.prototype.getPropertyPlceholder = function (sType)
{ {
var sResult = ''; var sResult = '';
switch (sType) switch (sType)
{ {
@ -378,15 +402,15 @@ PopupsContactsViewModel.prototype.getPropertyPlceholder = function (sType)
} }
return sResult; return sResult;
}; };
PopupsContactsViewModel.prototype.addNewProperty = function (sType, sTypeStr) PopupsContactsViewModel.prototype.addNewProperty = function (sType, sTypeStr)
{ {
this.viewProperties.push(new ContactPropertyModel(sType, sTypeStr || '', '', true, this.getPropertyPlceholder(sType))); this.viewProperties.push(new ContactPropertyModel(sType, sTypeStr || '', '', true, this.getPropertyPlceholder(sType)));
}; };
PopupsContactsViewModel.prototype.addNewOrFocusProperty = function (sType, sTypeStr) PopupsContactsViewModel.prototype.addNewOrFocusProperty = function (sType, sTypeStr)
{ {
var oItem = _.find(this.viewProperties(), function (oItem) { var oItem = _.find(this.viewProperties(), function (oItem) {
return sType === oItem.type(); return sType === oItem.type();
}); });
@ -399,65 +423,65 @@ PopupsContactsViewModel.prototype.addNewOrFocusProperty = function (sType, sType
{ {
this.addNewProperty(sType, sTypeStr); this.addNewProperty(sType, sTypeStr);
} }
}; };
PopupsContactsViewModel.prototype.addNewTag = function () PopupsContactsViewModel.prototype.addNewTag = function ()
{ {
this.viewTags.visibility(true); this.viewTags.visibility(true);
this.viewTags.focusTrigger(true); this.viewTags.focusTrigger(true);
}; };
PopupsContactsViewModel.prototype.addNewEmail = function () PopupsContactsViewModel.prototype.addNewEmail = function ()
{ {
this.addNewProperty(Enums.ContactPropertyType.Email, 'Home'); this.addNewProperty(Enums.ContactPropertyType.Email, 'Home');
}; };
PopupsContactsViewModel.prototype.addNewPhone = function () PopupsContactsViewModel.prototype.addNewPhone = function ()
{ {
this.addNewProperty(Enums.ContactPropertyType.Phone, 'Mobile'); this.addNewProperty(Enums.ContactPropertyType.Phone, 'Mobile');
}; };
PopupsContactsViewModel.prototype.addNewWeb = function () PopupsContactsViewModel.prototype.addNewWeb = function ()
{ {
this.addNewProperty(Enums.ContactPropertyType.Web); this.addNewProperty(Enums.ContactPropertyType.Web);
}; };
PopupsContactsViewModel.prototype.addNewNickname = function () PopupsContactsViewModel.prototype.addNewNickname = function ()
{ {
this.addNewOrFocusProperty(Enums.ContactPropertyType.Nick); this.addNewOrFocusProperty(Enums.ContactPropertyType.Nick);
}; };
PopupsContactsViewModel.prototype.addNewNotes = function () PopupsContactsViewModel.prototype.addNewNotes = function ()
{ {
this.addNewOrFocusProperty(Enums.ContactPropertyType.Note); this.addNewOrFocusProperty(Enums.ContactPropertyType.Note);
}; };
PopupsContactsViewModel.prototype.addNewBirthday = function () PopupsContactsViewModel.prototype.addNewBirthday = function ()
{ {
this.addNewOrFocusProperty(Enums.ContactPropertyType.Birthday); this.addNewOrFocusProperty(Enums.ContactPropertyType.Birthday);
}; };
//PopupsContactsViewModel.prototype.addNewAddress = function () //PopupsContactsViewModel.prototype.addNewAddress = function ()
//{ //{
//}; //};
PopupsContactsViewModel.prototype.exportVcf = function () PopupsContactsViewModel.prototype.exportVcf = function ()
{ {
RL.download(RL.link().exportContactsVcf()); RL.download(LinkBuilder.exportContactsVcf());
}; };
PopupsContactsViewModel.prototype.exportCsv = function () PopupsContactsViewModel.prototype.exportCsv = function ()
{ {
RL.download(RL.link().exportContactsCsv()); RL.download(LinkBuilder.exportContactsCsv());
}; };
PopupsContactsViewModel.prototype.initUploader = function () PopupsContactsViewModel.prototype.initUploader = function ()
{ {
if (this.importUploaderButton()) if (this.importUploaderButton())
{ {
var var
oJua = new Jua({ oJua = new Jua({
'action': RL.link().uploadContacts(), 'action': LinkBuilder.uploadContacts(),
'name': 'uploader', 'name': 'uploader',
'queueSize': 1, 'queueSize': 1,
'multipleSizeLimit': 1, 'multipleSizeLimit': 1,
@ -489,10 +513,10 @@ PopupsContactsViewModel.prototype.initUploader = function ()
; ;
} }
} }
}; };
PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = function () PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = function ()
{ {
var var
self = this, self = this,
oKoContacts = this.contacts, oKoContacts = this.contacts,
@ -528,27 +552,27 @@ PopupsContactsViewModel.prototype.removeCheckedOrSelectedContactsFromList = func
}, 500); }, 500);
} }
}; };
PopupsContactsViewModel.prototype.deleteSelectedContacts = function () PopupsContactsViewModel.prototype.deleteSelectedContacts = function ()
{ {
if (0 < this.contactsCheckedOrSelected().length) if (0 < this.contactsCheckedOrSelected().length)
{ {
RL.remote().contactsDelete( Remote.contactsDelete(
_.bind(this.deleteResponse, this), _.bind(this.deleteResponse, this),
this.contactsCheckedOrSelectedUids() this.contactsCheckedOrSelectedUids()
); );
this.removeCheckedOrSelectedContactsFromList(); this.removeCheckedOrSelectedContactsFromList();
} }
}; };
/** /**
* @param {string} sResult * @param {string} sResult
* @param {AjaxJsonDefaultResponse} oData * @param {AjaxJsonDefaultResponse} oData
*/ */
PopupsContactsViewModel.prototype.deleteResponse = function (sResult, oData) PopupsContactsViewModel.prototype.deleteResponse = function (sResult, oData)
{ {
if (500 < (Enums.StorageResultType.Success === sResult && oData && oData.Time ? Utils.pInt(oData.Time) : 0)) if (500 < (Enums.StorageResultType.Success === sResult && oData && oData.Time ? Utils.pInt(oData.Time) : 0))
{ {
this.reloadContactList(this.bDropPageAfterDelete); this.reloadContactList(this.bDropPageAfterDelete);
@ -561,18 +585,18 @@ PopupsContactsViewModel.prototype.deleteResponse = function (sResult, oData)
}; };
}(this)), 500); }(this)), 500);
} }
}; };
PopupsContactsViewModel.prototype.removeProperty = function (oProp) PopupsContactsViewModel.prototype.removeProperty = function (oProp)
{ {
this.viewProperties.remove(oProp); this.viewProperties.remove(oProp);
}; };
/** /**
* @param {?ContactModel} oContact * @param {?ContactModel} oContact
*/ */
PopupsContactsViewModel.prototype.populateViewContact = function (oContact) PopupsContactsViewModel.prototype.populateViewContact = function (oContact)
{ {
var var
sId = '', sId = '',
sLastName = '', sLastName = '',
@ -630,13 +654,13 @@ PopupsContactsViewModel.prototype.populateViewContact = function (oContact)
this.watchDirty(false); this.watchDirty(false);
this.watchHash(true); this.watchHash(true);
}; };
/** /**
* @param {boolean=} bDropPagePosition = false * @param {boolean=} bDropPagePosition = false
*/ */
PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePosition) PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePosition)
{ {
var var
self = this, self = this,
iOffset = (this.contactsPage() - 1) * Consts.Defaults.ContactsPerPage iOffset = (this.contactsPage() - 1) * Consts.Defaults.ContactsPerPage
@ -651,7 +675,7 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio
} }
this.contacts.loading(true); this.contacts.loading(true);
RL.remote().contacts(function (sResult, oData) { Remote.contacts(function (sResult, oData) {
var var
iCount = 0, iCount = 0,
aList = [], aList = [],
@ -693,10 +717,10 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio
self.viewClearSearch('' !== self.search()); self.viewClearSearch('' !== self.search());
}, iOffset, Consts.Defaults.ContactsPerPage, this.search()); }, iOffset, Consts.Defaults.ContactsPerPage, this.search());
}; };
PopupsContactsViewModel.prototype.onBuild = function (oDom) PopupsContactsViewModel.prototype.onBuild = function (oDom)
{ {
this.oContentVisible = $('.b-list-content', oDom); this.oContentVisible = $('.b-list-content', oDom);
this.oContentScrollable = $('.content', this.oContentVisible); this.oContentScrollable = $('.content', this.oContentVisible);
@ -721,23 +745,24 @@ PopupsContactsViewModel.prototype.onBuild = function (oDom)
; ;
this.initUploader(); this.initUploader();
}; };
PopupsContactsViewModel.prototype.onShow = function () PopupsContactsViewModel.prototype.onShow = function ()
{ {
kn.routeOff(); kn.routeOff();
this.reloadContactList(true); this.reloadContactList(true);
}; };
PopupsContactsViewModel.prototype.onHide = function () PopupsContactsViewModel.prototype.onHide = function ()
{ {
kn.routeOn(); kn.routeOn();
this.currentContact(null); this.currentContact(null);
this.emptySelection(true); this.emptySelection(true);
this.search(''); this.search('');
this.contactsCount(0); this.contactsCount(0);
this.contacts([]); this.contacts([]);
// _.each(this.contacts(), function (oItem) { };
// oItem.checked(false);
// }); module.exports = new PopupsContactsViewModel();
};
}(module));

View file

@ -1,11 +1,29 @@
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */ /* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
/** (function (module) {
'use strict';
var
_ = require('../../External/underscore.js'),
ko = require('../../External/ko.js'),
Enums = require('../../Common/Enums.js'),
Consts = require('../../Common/Consts.js'),
Utils = require('../../Common/Utils.js'),
Remote = require('../../Storages/AdminAjaxRemoteStorage.js'),
kn = require('../../Knoin/Knoin.js'),
KnoinAbstractViewModel = require('../../Knoin/KnoinAbstractViewModel.js')
;
/**
* @constructor * @constructor
* @extends KnoinAbstractViewModel * @extends KnoinAbstractViewModel
*/ */
function PopupsDomainViewModel() function PopupsDomainViewModel()
{ {
KnoinAbstractViewModel.call(this, 'Popups', 'PopupsDomain'); KnoinAbstractViewModel.call(this, 'Popups', 'PopupsDomain');
this.edit = ko.observable(false); this.edit = ko.observable(false);
@ -78,7 +96,7 @@ function PopupsDomainViewModel()
this.createOrAddCommand = Utils.createCommand(this, function () { this.createOrAddCommand = Utils.createCommand(this, function () {
this.saving(true); this.saving(true);
RL.remote().createOrUpdateDomain( Remote.createOrUpdateDomain(
_.bind(this.onDomainCreateOrSaveResponse, this), _.bind(this.onDomainCreateOrSaveResponse, this),
!this.edit(), !this.edit(),
this.name(), this.name(),
@ -101,7 +119,7 @@ function PopupsDomainViewModel()
this.testingImapError(false); this.testingImapError(false);
this.testingSmtpError(false); this.testingSmtpError(false);
this.testing(true); this.testing(true);
RL.remote().testConnectionForDomain( Remote.testConnectionForDomain(
_.bind(this.onTestConnectionResponse, this), _.bind(this.onTestConnectionResponse, this),
this.name(), this.name(),
this.imapServer(), this.imapServer(),
@ -179,13 +197,13 @@ function PopupsDomainViewModel()
} }
}, this); }, this);
Knoin.constructorEnd(this); kn.constructorEnd(this);
} }
Utils.extendAsViewModel('PopupsDomainViewModel', PopupsDomainViewModel); kn.extendAsViewModel('PopupsDomainViewModel', PopupsDomainViewModel);
PopupsDomainViewModel.prototype.onTestConnectionResponse = function (sResult, oData) PopupsDomainViewModel.prototype.onTestConnectionResponse = function (sResult, oData)
{ {
this.testing(false); this.testing(false);
if (Enums.StorageResultType.Success === sResult && oData.Result) if (Enums.StorageResultType.Success === sResult && oData.Result)
{ {
@ -208,10 +226,10 @@ PopupsDomainViewModel.prototype.onTestConnectionResponse = function (sResult, oD
this.testingImapError(true); this.testingImapError(true);
this.testingSmtpError(true); this.testingSmtpError(true);
} }
}; };
PopupsDomainViewModel.prototype.onDomainCreateOrSaveResponse = function (sResult, oData) PopupsDomainViewModel.prototype.onDomainCreateOrSaveResponse = function (sResult, oData)
{ {
this.saving(false); this.saving(false);
if (Enums.StorageResultType.Success === sResult && oData) if (Enums.StorageResultType.Success === sResult && oData)
{ {
@ -229,15 +247,15 @@ PopupsDomainViewModel.prototype.onDomainCreateOrSaveResponse = function (sResult
{ {
this.savingError('Unknown error'); this.savingError('Unknown error');
} }
}; };
PopupsDomainViewModel.prototype.onHide = function () PopupsDomainViewModel.prototype.onHide = function ()
{ {
this.whiteListPage(false); this.whiteListPage(false);
}; };
PopupsDomainViewModel.prototype.onShow = function (oDomain) PopupsDomainViewModel.prototype.onShow = function (oDomain)
{ {
this.saving(false); this.saving(false);
this.whiteListPage(false); this.whiteListPage(false);
@ -263,18 +281,18 @@ PopupsDomainViewModel.prototype.onShow = function (oDomain)
this.smtpAuth(!!oDomain.OutAuth); this.smtpAuth(!!oDomain.OutAuth);
this.whiteList(Utils.trim(oDomain.WhiteList)); this.whiteList(Utils.trim(oDomain.WhiteList));
} }
}; };
PopupsDomainViewModel.prototype.onFocus = function () PopupsDomainViewModel.prototype.onFocus = function ()
{ {
if ('' === this.name()) if ('' === this.name())
{ {
this.name.focused(true); this.name.focused(true);
} }
}; };
PopupsDomainViewModel.prototype.clearForm = function () PopupsDomainViewModel.prototype.clearForm = function ()
{ {
this.edit(false); this.edit(false);
this.whiteListPage(false); this.whiteListPage(false);
@ -293,4 +311,8 @@ PopupsDomainViewModel.prototype.clearForm = function ()
this.smtpShortLogin(false); this.smtpShortLogin(false);
this.smtpAuth(true); this.smtpAuth(true);
this.whiteList(''); this.whiteList('');
}; };
module.exports = new PopupsDomainViewModel();
}(module));

Some files were not shown because too many files have changed in this diff Show more