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,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)
};
}));
};