mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-31 04:59:21 +03:00
prettier --write
This commit is contained in:
parent
450528ff00
commit
8a0be3212d
164 changed files with 7053 additions and 9008 deletions
|
|
@ -1,23 +1,21 @@
|
|||
|
||||
import window from 'window';
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import {Capa, StorageResultType} from 'Common/Enums';
|
||||
import {root} from 'Common/Links';
|
||||
import { Capa, StorageResultType } from 'Common/Enums';
|
||||
import { root } from 'Common/Links';
|
||||
|
||||
import {capa} from 'Storage/Settings';
|
||||
import { capa } from 'Storage/Settings';
|
||||
|
||||
import AccountStore from 'Stores/User/Account';
|
||||
import IdentityStore from 'Stores/User/Identity';
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
import { getApp } from 'Helper/Apps/User';
|
||||
|
||||
import {showScreenPopup, routeOff, setHash} from 'Knoin/Knoin';
|
||||
import { showScreenPopup, routeOff, setHash } from 'Knoin/Knoin';
|
||||
|
||||
class AccountsUserSettings
|
||||
{
|
||||
class AccountsUserSettings {
|
||||
constructor() {
|
||||
this.allowAdditionalAccount = capa(Capa.AdditionalAccounts);
|
||||
this.allowIdentities = capa(Capa.Identities);
|
||||
|
|
@ -42,8 +40,7 @@ class AccountsUserSettings
|
|||
}
|
||||
|
||||
editAccount(account) {
|
||||
if (account && account.canBeEdit())
|
||||
{
|
||||
if (account && account.canBeEdit()) {
|
||||
showScreenPopup(require('View/Popup/Account'), [account]);
|
||||
}
|
||||
}
|
||||
|
|
@ -61,28 +58,21 @@ class AccountsUserSettings
|
|||
* @returns {void}
|
||||
*/
|
||||
deleteAccount(accountToRemove) {
|
||||
if (accountToRemove && accountToRemove.deleteAccess())
|
||||
{
|
||||
if (accountToRemove && accountToRemove.deleteAccess()) {
|
||||
this.accountForDeletion(null);
|
||||
if (accountToRemove)
|
||||
{
|
||||
if (accountToRemove) {
|
||||
this.accounts.remove((account) => accountToRemove === account);
|
||||
|
||||
Remote.accountDelete((result, data) => {
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result && data.Reload)
|
||||
{
|
||||
if (StorageResultType.Success === result && data && data.Result && data.Reload) {
|
||||
routeOff();
|
||||
setHash(root(), true);
|
||||
routeOff();
|
||||
|
||||
_.defer(() => window.location.reload());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
getApp().accountsAndIdentities();
|
||||
}
|
||||
|
||||
}, accountToRemove.email);
|
||||
}
|
||||
}
|
||||
|
|
@ -93,12 +83,10 @@ class AccountsUserSettings
|
|||
* @returns {void}
|
||||
*/
|
||||
deleteIdentity(identityToRemove) {
|
||||
if (identityToRemove && identityToRemove.deleteAccess())
|
||||
{
|
||||
if (identityToRemove && identityToRemove.deleteAccess()) {
|
||||
this.identityForDeletion(null);
|
||||
|
||||
if (identityToRemove)
|
||||
{
|
||||
if (identityToRemove) {
|
||||
IdentityStore.identities.remove((oIdentity) => identityToRemove === oIdentity);
|
||||
|
||||
Remote.identityDelete(() => {
|
||||
|
|
@ -109,30 +97,28 @@ class AccountsUserSettings
|
|||
}
|
||||
|
||||
accountsAndIdentitiesAfterMove() {
|
||||
Remote.accountsAndIdentitiesSortOrder(null,
|
||||
AccountStore.accountsEmails.peek(), IdentityStore.identitiesIDS.peek());
|
||||
Remote.accountsAndIdentitiesSortOrder(null, AccountStore.accountsEmails.peek(), IdentityStore.identitiesIDS.peek());
|
||||
}
|
||||
|
||||
onBuild(oDom) {
|
||||
|
||||
const self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.accounts-list .account-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||
.on('click', '.accounts-list .account-item .e-action', function() {
|
||||
// eslint-disable-line prefer-arrow-callback
|
||||
const account = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (account)
|
||||
{
|
||||
if (account) {
|
||||
self.editAccount(account);
|
||||
}
|
||||
})
|
||||
.on('click', '.identities-list .identity-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||
.on('click', '.identities-list .identity-item .e-action', function() {
|
||||
// eslint-disable-line prefer-arrow-callback
|
||||
const identity = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (identity)
|
||||
{
|
||||
if (identity) {
|
||||
self.editIdentity(identity);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export {AccountsUserSettings, AccountsUserSettings as default};
|
||||
export { AccountsUserSettings, AccountsUserSettings as default };
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {getNotificationFromResponse, i18n} from 'Common/Translator';
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { getNotificationFromResponse, i18n } from 'Common/Translator';
|
||||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
import {command} from 'Knoin/Knoin';
|
||||
import { getApp } from 'Helper/Apps/User';
|
||||
import { command } from 'Knoin/Knoin';
|
||||
|
||||
class ChangePasswordUserSettings
|
||||
{
|
||||
class ChangePasswordUserSettings {
|
||||
constructor() {
|
||||
this.changeProcess = ko.observable(false);
|
||||
|
||||
|
|
@ -46,15 +44,15 @@ class ChangePasswordUserSettings
|
|||
this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this);
|
||||
}
|
||||
|
||||
@command((self) => !self.changeProcess() && '' !== self.currentPassword() && '' !== self.newPassword() && '' !== self.newPassword2())
|
||||
@command(
|
||||
(self) =>
|
||||
!self.changeProcess() && '' !== self.currentPassword() && '' !== self.newPassword() && '' !== self.newPassword2()
|
||||
)
|
||||
saveNewPasswordCommand() {
|
||||
if (this.newPassword() !== this.newPassword2())
|
||||
{
|
||||
if (this.newPassword() !== this.newPassword2()) {
|
||||
this.passwordMismatch(true);
|
||||
this.errorDescription(i18n('SETTINGS_CHANGE_PASSWORD/ERROR_PASSWORD_MISMATCH'));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.changeProcess(true);
|
||||
|
||||
this.passwordUpdateError(false);
|
||||
|
|
@ -83,8 +81,7 @@ class ChangePasswordUserSettings
|
|||
this.errorDescription('');
|
||||
this.currentPassword.error(false);
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result)
|
||||
{
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
this.currentPassword('');
|
||||
this.newPassword('');
|
||||
this.newPassword2('');
|
||||
|
|
@ -93,11 +90,8 @@ class ChangePasswordUserSettings
|
|||
this.currentPassword.error(false);
|
||||
|
||||
getApp().setClientSideToken(data.Result);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data && Notification.CurrentPasswordIncorrect === data.ErrorCode)
|
||||
{
|
||||
} else {
|
||||
if (data && Notification.CurrentPasswordIncorrect === data.ErrorCode) {
|
||||
this.currentPassword.error(true);
|
||||
}
|
||||
|
||||
|
|
@ -107,4 +101,4 @@ class ChangePasswordUserSettings
|
|||
}
|
||||
}
|
||||
|
||||
export {ChangePasswordUserSettings, ChangePasswordUserSettings as default};
|
||||
export { ChangePasswordUserSettings, ChangePasswordUserSettings as default };
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
import {Magics} from 'Common/Enums';
|
||||
import {boolToAjax} from 'Common/Utils';
|
||||
import { Magics } from 'Common/Enums';
|
||||
import { boolToAjax } from 'Common/Utils';
|
||||
|
||||
import AppStore from 'Stores/User/App';
|
||||
import ContactStore from 'Stores/User/Contact';
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
class ContactsUserSettings
|
||||
{
|
||||
class ContactsUserSettings {
|
||||
constructor() {
|
||||
this.contactsAutosave = AppStore.contactsAutosave;
|
||||
|
||||
|
|
@ -19,12 +17,16 @@ class ContactsUserSettings
|
|||
this.contactsSyncUser = ContactStore.contactsSyncUser;
|
||||
this.contactsSyncPass = ContactStore.contactsSyncPass;
|
||||
|
||||
this.saveTrigger = ko.computed(() => [
|
||||
this.enableContactsSync() ? '1' : '0',
|
||||
this.contactsSyncUrl(),
|
||||
this.contactsSyncUser(),
|
||||
this.contactsSyncPass()
|
||||
].join('|')).extend({throttle: Magics.Time500ms});
|
||||
this.saveTrigger = ko
|
||||
.computed(() =>
|
||||
[
|
||||
this.enableContactsSync() ? '1' : '0',
|
||||
this.contactsSyncUrl(),
|
||||
this.contactsSyncUser(),
|
||||
this.contactsSyncPass()
|
||||
].join('|')
|
||||
)
|
||||
.extend({ throttle: Magics.Time500ms });
|
||||
}
|
||||
|
||||
onBuild() {
|
||||
|
|
@ -35,7 +37,8 @@ class ContactsUserSettings
|
|||
});
|
||||
|
||||
this.saveTrigger.subscribe(() => {
|
||||
Remote.saveContactsSyncData(null,
|
||||
Remote.saveContactsSyncData(
|
||||
null,
|
||||
this.enableContactsSync(),
|
||||
this.contactsSyncUrl(),
|
||||
this.contactsSyncUser(),
|
||||
|
|
@ -45,4 +48,4 @@ class ContactsUserSettings
|
|||
}
|
||||
}
|
||||
|
||||
export {ContactsUserSettings, ContactsUserSettings as default};
|
||||
export { ContactsUserSettings, ContactsUserSettings as default };
|
||||
|
|
|
|||
|
|
@ -1,20 +1,18 @@
|
|||
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import {windowResizeCallback, isArray, trim, delegateRunOnDestroy} from 'Common/Utils';
|
||||
import {StorageResultType, Notification} from 'Common/Enums';
|
||||
import {getNotification} from 'Common/Translator';
|
||||
import { windowResizeCallback, isArray, trim, delegateRunOnDestroy } from 'Common/Utils';
|
||||
import { StorageResultType, Notification } from 'Common/Enums';
|
||||
import { getNotification } from 'Common/Translator';
|
||||
|
||||
import FilterStore from 'Stores/User/Filter';
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {FilterModel} from 'Model/Filter';
|
||||
import { FilterModel } from 'Model/Filter';
|
||||
|
||||
import {showScreenPopup, command} from 'Knoin/Knoin';
|
||||
import { showScreenPopup, command } from 'Knoin/Knoin';
|
||||
|
||||
class FiltersUserSettings
|
||||
{
|
||||
class FiltersUserSettings {
|
||||
constructor() {
|
||||
this.modules = FilterStore.modules;
|
||||
this.filters = FilterStore.filters;
|
||||
|
|
@ -29,8 +27,7 @@ class FiltersUserSettings
|
|||
this.filters.subscribe(windowResizeCallback);
|
||||
|
||||
this.serverError.subscribe((value) => {
|
||||
if (!value)
|
||||
{
|
||||
if (!value) {
|
||||
this.serverErrorDesc('');
|
||||
}
|
||||
}, this);
|
||||
|
|
@ -64,10 +61,8 @@ class FiltersUserSettings
|
|||
|
||||
@command((self) => self.haveChanges())
|
||||
saveChangesCommand() {
|
||||
if (!this.filters.saving())
|
||||
{
|
||||
if (this.filterRaw.active() && '' === trim(this.filterRaw()))
|
||||
{
|
||||
if (!this.filters.saving()) {
|
||||
if (this.filterRaw.active() && '' === trim(this.filterRaw())) {
|
||||
this.filterRaw.error(true);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -75,24 +70,23 @@ class FiltersUserSettings
|
|||
this.filters.saving(true);
|
||||
this.saveErrorText('');
|
||||
|
||||
Remote.filtersSave((result, data) => {
|
||||
this.filters.saving(false);
|
||||
Remote.filtersSave(
|
||||
(result, data) => {
|
||||
this.filters.saving(false);
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result)
|
||||
{
|
||||
this.haveChanges(false);
|
||||
this.updateList();
|
||||
}
|
||||
else if (data && data.ErrorCode)
|
||||
{
|
||||
this.saveErrorText(data.ErrorMessageAdditional || getNotification(data.ErrorCode));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.saveErrorText(getNotification(Notification.CantSaveFilters));
|
||||
}
|
||||
|
||||
}, this.filters(), this.filterRaw(), this.filterRaw.active());
|
||||
if (StorageResultType.Success === result && data && data.Result) {
|
||||
this.haveChanges(false);
|
||||
this.updateList();
|
||||
} else if (data && data.ErrorCode) {
|
||||
this.saveErrorText(data.ErrorMessageAdditional || getNotification(data.ErrorCode));
|
||||
} else {
|
||||
this.saveErrorText(getNotification(Notification.CantSaveFilters));
|
||||
}
|
||||
},
|
||||
this.filters(),
|
||||
this.filterRaw(),
|
||||
this.filterRaw.active()
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -107,24 +101,25 @@ class FiltersUserSettings
|
|||
}
|
||||
|
||||
updateList() {
|
||||
if (!this.filters.loading())
|
||||
{
|
||||
if (!this.filters.loading()) {
|
||||
this.filters.loading(true);
|
||||
|
||||
Remote.filtersGet((result, data) => {
|
||||
|
||||
this.filters.loading(false);
|
||||
this.serverError(false);
|
||||
|
||||
if (StorageResultType.Success === result && data && data.Result && isArray(data.Result.Filters))
|
||||
{
|
||||
if (StorageResultType.Success === result && data && data.Result && isArray(data.Result.Filters)) {
|
||||
this.inited(true);
|
||||
this.serverError(false);
|
||||
|
||||
this.filters(_.compact(_.map(data.Result.Filters, (aItem) => {
|
||||
const filter = new FilterModel();
|
||||
return (filter && filter.parse(aItem)) ? filter : null;
|
||||
})));
|
||||
this.filters(
|
||||
_.compact(
|
||||
_.map(data.Result.Filters, (aItem) => {
|
||||
const filter = new FilterModel();
|
||||
return filter && filter.parse(aItem) ? filter : null;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
this.modules(data.Result.Modules ? data.Result.Modules : {});
|
||||
|
||||
|
|
@ -132,16 +127,16 @@ class FiltersUserSettings
|
|||
this.filterRaw.capa(isArray(data.Result.Capa) ? data.Result.Capa.join(' ') : '');
|
||||
this.filterRaw.active(!!data.Result.RawIsActive);
|
||||
this.filterRaw.allow(!!data.Result.RawIsAllow);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.filters([]);
|
||||
this.modules({});
|
||||
this.filterRaw('');
|
||||
this.filterRaw.capa({});
|
||||
|
||||
this.serverError(true);
|
||||
this.serverErrorDesc(data && data.ErrorCode ? getNotification(data.ErrorCode) : getNotification(Notification.CantGetFilters));
|
||||
this.serverErrorDesc(
|
||||
data && data.ErrorCode ? getNotification(data.ErrorCode) : getNotification(Notification.CantGetFilters)
|
||||
);
|
||||
}
|
||||
|
||||
this.haveChanges(false);
|
||||
|
|
@ -158,43 +153,47 @@ class FiltersUserSettings
|
|||
const filter = new FilterModel();
|
||||
|
||||
filter.generateID();
|
||||
showScreenPopup(require('View/Popup/Filter'), [filter, () => {
|
||||
this.filters.push(filter);
|
||||
this.filterRaw.active(false);
|
||||
}, false]);
|
||||
showScreenPopup(require('View/Popup/Filter'), [
|
||||
filter,
|
||||
() => {
|
||||
this.filters.push(filter);
|
||||
this.filterRaw.active(false);
|
||||
},
|
||||
false
|
||||
]);
|
||||
}
|
||||
|
||||
editFilter(filter) {
|
||||
const clonedFilter = filter.cloneSelf();
|
||||
|
||||
showScreenPopup(require('View/Popup/Filter'), [clonedFilter, () => {
|
||||
const
|
||||
filters = this.filters(),
|
||||
index = filters.indexOf(filter);
|
||||
showScreenPopup(require('View/Popup/Filter'), [
|
||||
clonedFilter,
|
||||
() => {
|
||||
const filters = this.filters(),
|
||||
index = filters.indexOf(filter);
|
||||
|
||||
if (-1 < index && filters[index])
|
||||
{
|
||||
delegateRunOnDestroy(filters[index]);
|
||||
filters[index] = clonedFilter;
|
||||
if (-1 < index && filters[index]) {
|
||||
delegateRunOnDestroy(filters[index]);
|
||||
filters[index] = clonedFilter;
|
||||
|
||||
this.filters(filters);
|
||||
this.haveChanges(true);
|
||||
}
|
||||
}, true]);
|
||||
this.filters(filters);
|
||||
this.haveChanges(true);
|
||||
}
|
||||
},
|
||||
true
|
||||
]);
|
||||
}
|
||||
|
||||
onBuild(oDom) {
|
||||
|
||||
const self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.filter-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||
const filter = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (filter)
|
||||
{
|
||||
self.editFilter(filter);
|
||||
}
|
||||
});
|
||||
oDom.on('click', '.filter-item .e-action', function() {
|
||||
// eslint-disable-line prefer-arrow-callback
|
||||
const filter = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (filter) {
|
||||
self.editFilter(filter);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onShow() {
|
||||
|
|
@ -202,4 +201,4 @@ class FiltersUserSettings
|
|||
}
|
||||
}
|
||||
|
||||
export {FiltersUserSettings, FiltersUserSettings as default};
|
||||
export { FiltersUserSettings, FiltersUserSettings as default };
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
import {ClientSideKeyName, Notification, Magics} from 'Common/Enums';
|
||||
import {trim, noop} from 'Common/Utils';
|
||||
import {getNotification, i18n} from 'Common/Translator';
|
||||
import { ClientSideKeyName, Notification, Magics } from 'Common/Enums';
|
||||
import { trim, noop } from 'Common/Utils';
|
||||
import { getNotification, i18n } from 'Common/Translator';
|
||||
|
||||
import {removeFolderFromCacheList} from 'Common/Cache';
|
||||
import { removeFolderFromCacheList } from 'Common/Cache';
|
||||
|
||||
import {appSettingsGet} from 'Storage/Settings';
|
||||
import { appSettingsGet } from 'Storage/Settings';
|
||||
import * as Local from 'Storage/Client';
|
||||
|
||||
import FolderStore from 'Stores/User/Folder';
|
||||
|
|
@ -15,21 +14,19 @@ import FolderStore from 'Stores/User/Folder';
|
|||
import Promises from 'Promises/User/Ajax';
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
import { getApp } from 'Helper/Apps/User';
|
||||
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
class FoldersUserSettings
|
||||
{
|
||||
class FoldersUserSettings {
|
||||
constructor() {
|
||||
this.displaySpecSetting = FolderStore.displaySpecSetting;
|
||||
this.folderList = FolderStore.folderList;
|
||||
|
||||
this.folderListHelp = ko.observable('').extend({throttle: Magics.Time100ms});
|
||||
this.folderListHelp = ko.observable('').extend({ throttle: Magics.Time100ms });
|
||||
|
||||
this.loading = ko.computed(() => {
|
||||
const
|
||||
loading = FolderStore.foldersLoading(),
|
||||
const loading = FolderStore.foldersLoading(),
|
||||
creating = FolderStore.foldersCreating(),
|
||||
deleting = FolderStore.foldersDeleting(),
|
||||
renaming = FolderStore.foldersRenaming();
|
||||
|
|
@ -39,7 +36,7 @@ class FoldersUserSettings
|
|||
|
||||
this.folderForDeletion = ko.observable(null).deleteAccessHelper();
|
||||
|
||||
this.folderForEdit = ko.observable(null).extend({toggleSubscribeProperty: [this, 'edited']});
|
||||
this.folderForEdit = ko.observable(null).extend({ toggleSubscribeProperty: [this, 'edited'] });
|
||||
|
||||
this.useImapSubscribe = !!appSettingsGet('useImapSubscribe');
|
||||
}
|
||||
|
|
@ -47,8 +44,7 @@ class FoldersUserSettings
|
|||
folderEditOnEnter(folder) {
|
||||
const nameToEdit = folder ? trim(folder.nameForEdit()) : '';
|
||||
|
||||
if ('' !== nameToEdit && folder.name() !== nameToEdit)
|
||||
{
|
||||
if ('' !== nameToEdit && folder.name() !== nameToEdit) {
|
||||
Local.set(ClientSideKeyName.FoldersLashHash, '');
|
||||
|
||||
getApp().foldersPromisesActionHelper(
|
||||
|
|
@ -65,8 +61,7 @@ class FoldersUserSettings
|
|||
}
|
||||
|
||||
folderEditOnEsc(folder) {
|
||||
if (folder)
|
||||
{
|
||||
if (folder) {
|
||||
folder.edited(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -100,22 +95,22 @@ class FoldersUserSettings
|
|||
}
|
||||
|
||||
deleteFolder(folderToRemove) {
|
||||
if (folderToRemove && folderToRemove.canBeDeleted() && folderToRemove.deleteAccess() &&
|
||||
0 === folderToRemove.privateMessageCountAll())
|
||||
{
|
||||
if (
|
||||
folderToRemove &&
|
||||
folderToRemove.canBeDeleted() &&
|
||||
folderToRemove.deleteAccess() &&
|
||||
0 === folderToRemove.privateMessageCountAll()
|
||||
) {
|
||||
this.folderForDeletion(null);
|
||||
|
||||
if (folderToRemove)
|
||||
{
|
||||
const
|
||||
fRemoveFolder = function(folder) {
|
||||
if (folderToRemove === folder)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
folder.subFolders.remove(fRemoveFolder);
|
||||
return false;
|
||||
};
|
||||
if (folderToRemove) {
|
||||
const fRemoveFolder = function(folder) {
|
||||
if (folderToRemove === folder) {
|
||||
return true;
|
||||
}
|
||||
folder.subFolders.remove(fRemoveFolder);
|
||||
return false;
|
||||
};
|
||||
|
||||
Local.set(ClientSideKeyName.FoldersLashHash, '');
|
||||
|
||||
|
|
@ -128,9 +123,7 @@ class FoldersUserSettings
|
|||
|
||||
removeFolderFromCacheList(folderToRemove.fullNameRaw);
|
||||
}
|
||||
}
|
||||
else if (0 < folderToRemove.privateMessageCountAll())
|
||||
{
|
||||
} else if (0 < folderToRemove.privateMessageCountAll()) {
|
||||
FolderStore.folderList.error(getNotification(Notification.CantDeleteNonEmptyFolder));
|
||||
}
|
||||
}
|
||||
|
|
@ -158,4 +151,4 @@ class FoldersUserSettings
|
|||
}
|
||||
}
|
||||
|
||||
export {FoldersUserSettings, FoldersUserSettings as default};
|
||||
export { FoldersUserSettings, FoldersUserSettings as default };
|
||||
|
|
|
|||
|
|
@ -1,20 +1,16 @@
|
|||
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import {MESSAGES_PER_PAGE_VALUES} from 'Common/Consts';
|
||||
import {bAnimationSupported} from 'Common/Globals';
|
||||
import { MESSAGES_PER_PAGE_VALUES } from 'Common/Consts';
|
||||
import { bAnimationSupported } from 'Common/Globals';
|
||||
|
||||
import {SaveSettingsStep, Magics, EditorDefaultType, Layout} from 'Common/Enums';
|
||||
import { SaveSettingsStep, Magics, EditorDefaultType, Layout } from 'Common/Enums';
|
||||
|
||||
import {
|
||||
settingsSaveHelperSimpleFunction,
|
||||
convertLangName, isArray, timeOutAction, boolToAjax
|
||||
} from 'Common/Utils';
|
||||
import { settingsSaveHelperSimpleFunction, convertLangName, isArray, timeOutAction, boolToAjax } from 'Common/Utils';
|
||||
|
||||
import {i18n, trigger as translatorTrigger, reload as translatorReload} from 'Common/Translator';
|
||||
import { i18n, trigger as translatorTrigger, reload as translatorReload } from 'Common/Translator';
|
||||
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
import AppStore from 'Stores/User/App';
|
||||
import LanguageStore from 'Stores/Language';
|
||||
|
|
@ -25,8 +21,7 @@ import MessageStore from 'Stores/User/Message';
|
|||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
class GeneralUserSettings
|
||||
{
|
||||
class GeneralUserSettings {
|
||||
constructor() {
|
||||
this.language = LanguageStore.language;
|
||||
this.languages = LanguageStore.languages;
|
||||
|
|
@ -52,7 +47,7 @@ class GeneralUserSettings
|
|||
this.allowLanguagesOnSettings = AppStore.allowLanguagesOnSettings;
|
||||
|
||||
this.languageFullName = ko.computed(() => convertLangName(this.language()));
|
||||
this.languageTrigger = ko.observable(SaveSettingsStep.Idle).extend({throttle: Magics.Time100ms});
|
||||
this.languageTrigger = ko.observable(SaveSettingsStep.Idle).extend({ throttle: Magics.Time100ms });
|
||||
|
||||
this.mppTrigger = ko.observable(SaveSettingsStep.Idle);
|
||||
this.editorDefaultTypeTrigger = ko.observable(SaveSettingsStep.Idle);
|
||||
|
|
@ -75,27 +70,26 @@ class GeneralUserSettings
|
|||
this.editorDefaultTypes = ko.computed(() => {
|
||||
translatorTrigger();
|
||||
return [
|
||||
{'id': EditorDefaultType.Html, 'name': i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML')},
|
||||
{'id': EditorDefaultType.Plain, 'name': i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN')},
|
||||
{'id': EditorDefaultType.HtmlForced, 'name': i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML_FORCED')},
|
||||
{'id': EditorDefaultType.PlainForced, 'name': i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN_FORCED')}
|
||||
{ 'id': EditorDefaultType.Html, 'name': i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML') },
|
||||
{ 'id': EditorDefaultType.Plain, 'name': i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN') },
|
||||
{ 'id': EditorDefaultType.HtmlForced, 'name': i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML_FORCED') },
|
||||
{ 'id': EditorDefaultType.PlainForced, 'name': i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN_FORCED') }
|
||||
];
|
||||
});
|
||||
|
||||
this.layoutTypes = ko.computed(() => {
|
||||
translatorTrigger();
|
||||
return [
|
||||
{'id': Layout.NoPreview, 'name': i18n('SETTINGS_GENERAL/LABEL_LAYOUT_NO_SPLIT')},
|
||||
{'id': Layout.SidePreview, 'name': i18n('SETTINGS_GENERAL/LABEL_LAYOUT_VERTICAL_SPLIT')},
|
||||
{'id': Layout.BottomPreview, 'name': i18n('SETTINGS_GENERAL/LABEL_LAYOUT_HORIZONTAL_SPLIT')}
|
||||
{ 'id': Layout.NoPreview, 'name': i18n('SETTINGS_GENERAL/LABEL_LAYOUT_NO_SPLIT') },
|
||||
{ 'id': Layout.SidePreview, 'name': i18n('SETTINGS_GENERAL/LABEL_LAYOUT_VERTICAL_SPLIT') },
|
||||
{ 'id': Layout.BottomPreview, 'name': i18n('SETTINGS_GENERAL/LABEL_LAYOUT_HORIZONTAL_SPLIT') }
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
editMainIdentity() {
|
||||
const identity = this.identityMain();
|
||||
if (identity)
|
||||
{
|
||||
if (identity) {
|
||||
showScreenPopup(require('View/Popup/Identity'), [identity]);
|
||||
}
|
||||
}
|
||||
|
|
@ -106,8 +100,7 @@ class GeneralUserSettings
|
|||
|
||||
onBuild() {
|
||||
_.delay(() => {
|
||||
const
|
||||
f0 = settingsSaveHelperSimpleFunction(this.editorDefaultTypeTrigger, this),
|
||||
const f0 = settingsSaveHelperSimpleFunction(this.editorDefaultTypeTrigger, this),
|
||||
f1 = settingsSaveHelperSimpleFunction(this.mppTrigger, this),
|
||||
f2 = settingsSaveHelperSimpleFunction(this.layoutTrigger, this),
|
||||
fReloadLanguageHelper = (saveSettingsStep) => () => {
|
||||
|
|
@ -117,15 +110,13 @@ class GeneralUserSettings
|
|||
|
||||
this.language.subscribe((value) => {
|
||||
this.languageTrigger(SaveSettingsStep.Animate);
|
||||
translatorReload(false, value).then(
|
||||
fReloadLanguageHelper(SaveSettingsStep.TrueResult),
|
||||
fReloadLanguageHelper(SaveSettingsStep.FalseResult)
|
||||
).then(() => {
|
||||
Remote.saveSettings(null, {
|
||||
'Language': value
|
||||
translatorReload(false, value)
|
||||
.then(fReloadLanguageHelper(SaveSettingsStep.TrueResult), fReloadLanguageHelper(SaveSettingsStep.FalseResult))
|
||||
.then(() => {
|
||||
Remote.saveSettings(null, {
|
||||
'Language': value
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
this.editorDefaultType.subscribe(Remote.saveSettingsHelper('EditorDefaultType', null, f0));
|
||||
|
|
@ -135,27 +126,39 @@ class GeneralUserSettings
|
|||
this.useCheckboxesInList.subscribe(Remote.saveSettingsHelper('UseCheckboxesInList', boolToAjax));
|
||||
|
||||
this.enableDesktopNotification.subscribe((value) => {
|
||||
timeOutAction('SaveDesktopNotifications', () => {
|
||||
Remote.saveSettings(null, {
|
||||
'DesktopNotifications': boolToAjax(value)
|
||||
});
|
||||
}, Magics.Time3s);
|
||||
timeOutAction(
|
||||
'SaveDesktopNotifications',
|
||||
() => {
|
||||
Remote.saveSettings(null, {
|
||||
'DesktopNotifications': boolToAjax(value)
|
||||
});
|
||||
},
|
||||
Magics.Time3s
|
||||
);
|
||||
});
|
||||
|
||||
this.enableSoundNotification.subscribe((value) => {
|
||||
timeOutAction('SaveSoundNotification', () => {
|
||||
Remote.saveSettings(null, {
|
||||
'SoundNotification': boolToAjax(value)
|
||||
});
|
||||
}, Magics.Time3s);
|
||||
timeOutAction(
|
||||
'SaveSoundNotification',
|
||||
() => {
|
||||
Remote.saveSettings(null, {
|
||||
'SoundNotification': boolToAjax(value)
|
||||
});
|
||||
},
|
||||
Magics.Time3s
|
||||
);
|
||||
});
|
||||
|
||||
this.replySameFolder.subscribe((value) => {
|
||||
timeOutAction('SaveReplySameFolder', () => {
|
||||
Remote.saveSettings(null, {
|
||||
'ReplySameFolder': boolToAjax(value)
|
||||
});
|
||||
}, Magics.Time3s);
|
||||
timeOutAction(
|
||||
'SaveReplySameFolder',
|
||||
() => {
|
||||
Remote.saveSettings(null, {
|
||||
'ReplySameFolder': boolToAjax(value)
|
||||
});
|
||||
},
|
||||
Magics.Time3s
|
||||
);
|
||||
});
|
||||
|
||||
this.useThreads.subscribe((value) => {
|
||||
|
|
@ -179,10 +182,8 @@ class GeneralUserSettings
|
|||
}
|
||||
|
||||
selectLanguage() {
|
||||
showScreenPopup(require('View/Popup/Languages'), [
|
||||
this.language, this.languages(), LanguageStore.userLanguage()
|
||||
]);
|
||||
showScreenPopup(require('View/Popup/Languages'), [this.language, this.languages(), LanguageStore.userLanguage()]);
|
||||
}
|
||||
}
|
||||
|
||||
export {GeneralUserSettings, GeneralUserSettings as default};
|
||||
export { GeneralUserSettings, GeneralUserSettings as default };
|
||||
|
|
|
|||
|
|
@ -1,22 +1,20 @@
|
|||
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import {delegateRunOnDestroy, boolToAjax} from 'Common/Utils';
|
||||
import {Magics} from 'Common/Enums';
|
||||
import {bIsHttps} from 'Common/Globals';
|
||||
import { delegateRunOnDestroy, boolToAjax } from 'Common/Utils';
|
||||
import { Magics } from 'Common/Enums';
|
||||
import { bIsHttps } from 'Common/Globals';
|
||||
|
||||
import PgpStore from 'Stores/User/Pgp';
|
||||
import SettingsStore from 'Stores/User/Settings';
|
||||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
import { getApp } from 'Helper/Apps/User';
|
||||
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
class OpenPgpUserSettings
|
||||
{
|
||||
class OpenPgpUserSettings {
|
||||
constructor() {
|
||||
this.openpgpkeys = PgpStore.openpgpkeys;
|
||||
this.openpgpkeysPublic = PgpStore.openpgpkeysPublic;
|
||||
|
|
@ -38,8 +36,7 @@ class OpenPgpUserSettings
|
|||
}
|
||||
|
||||
viewOpenPgpKey(openPgpKey) {
|
||||
if (openPgpKey)
|
||||
{
|
||||
if (openPgpKey) {
|
||||
showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [openPgpKey]);
|
||||
}
|
||||
}
|
||||
|
|
@ -49,21 +46,16 @@ class OpenPgpUserSettings
|
|||
* @returns {void}
|
||||
*/
|
||||
deleteOpenPgpKey(openPgpKeyToRemove) {
|
||||
if (openPgpKeyToRemove && openPgpKeyToRemove.deleteAccess())
|
||||
{
|
||||
if (openPgpKeyToRemove && openPgpKeyToRemove.deleteAccess()) {
|
||||
this.openPgpKeyForDeletion(null);
|
||||
|
||||
if (openPgpKeyToRemove && PgpStore.openpgpKeyring)
|
||||
{
|
||||
if (openPgpKeyToRemove && PgpStore.openpgpKeyring) {
|
||||
const findedItem = _.find(PgpStore.openpgpkeys(), (key) => openPgpKeyToRemove === key);
|
||||
if (findedItem)
|
||||
{
|
||||
if (findedItem) {
|
||||
PgpStore.openpgpkeys.remove(findedItem);
|
||||
delegateRunOnDestroy(findedItem);
|
||||
|
||||
PgpStore
|
||||
.openpgpKeyring[findedItem.isPrivate ? 'privateKeys' : 'publicKeys']
|
||||
.removeForId(findedItem.guid);
|
||||
PgpStore.openpgpKeyring[findedItem.isPrivate ? 'privateKeys' : 'publicKeys'].removeForId(findedItem.guid);
|
||||
|
||||
PgpStore.openpgpKeyring.store();
|
||||
}
|
||||
|
|
@ -75,13 +67,9 @@ class OpenPgpUserSettings
|
|||
|
||||
onBuild() {
|
||||
_.delay(() => {
|
||||
|
||||
this.allowDraftAutosave.subscribe(
|
||||
Remote.saveSettingsHelper('AllowDraftAutosave', boolToAjax)
|
||||
);
|
||||
|
||||
this.allowDraftAutosave.subscribe(Remote.saveSettingsHelper('AllowDraftAutosave', boolToAjax));
|
||||
}, Magics.Time50ms);
|
||||
}
|
||||
}
|
||||
|
||||
export {OpenPgpUserSettings, OpenPgpUserSettings as default};
|
||||
export { OpenPgpUserSettings, OpenPgpUserSettings as default };
|
||||
|
|
|
|||
|
|
@ -1,21 +1,19 @@
|
|||
|
||||
import _ from '_';
|
||||
import ko from 'ko';
|
||||
|
||||
import {pInt, settingsSaveHelperSimpleFunction} from 'Common/Utils';
|
||||
import {Capa, SaveSettingsStep} from 'Common/Enums';
|
||||
import {i18n, trigger as translatorTrigger} from 'Common/Translator';
|
||||
import { pInt, settingsSaveHelperSimpleFunction } from 'Common/Utils';
|
||||
import { Capa, SaveSettingsStep } from 'Common/Enums';
|
||||
import { i18n, trigger as translatorTrigger } from 'Common/Translator';
|
||||
|
||||
import {capa} from 'Storage/Settings';
|
||||
import { capa } from 'Storage/Settings';
|
||||
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
import SettinsStore from 'Stores/User/Settings';
|
||||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
class SecurityUserSettings
|
||||
{
|
||||
class SecurityUserSettings {
|
||||
constructor() {
|
||||
this.capaAutoLogout = capa(Capa.AutoLogout);
|
||||
this.capaTwoFactor = capa(Capa.TwoFactor);
|
||||
|
|
@ -26,14 +24,14 @@ class SecurityUserSettings
|
|||
this.autoLogoutOptions = ko.computed(() => {
|
||||
translatorTrigger();
|
||||
return [
|
||||
{'id': 0, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_NEVER_OPTION_NAME')},
|
||||
{'id': 5, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 5})},
|
||||
{'id': 10, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 10})},
|
||||
{'id': 30, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 30})},
|
||||
{'id': 60, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 60})},
|
||||
{'id': 60 * 2, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 2})},
|
||||
{'id': 60 * 5, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 5})},
|
||||
{'id': 60 * 10, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 10})}
|
||||
{ 'id': 0, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_NEVER_OPTION_NAME') },
|
||||
{ 'id': 5, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', { 'MINUTES': 5 }) },
|
||||
{ 'id': 10, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', { 'MINUTES': 10 }) },
|
||||
{ 'id': 30, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', { 'MINUTES': 30 }) },
|
||||
{ 'id': 60, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', { 'MINUTES': 60 }) },
|
||||
{ 'id': 60 * 2, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', { 'HOURS': 2 }) },
|
||||
{ 'id': 60 * 5, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', { 'HOURS': 5 }) },
|
||||
{ 'id': 60 * 10, 'name': i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', { 'HOURS': 10 }) }
|
||||
];
|
||||
});
|
||||
}
|
||||
|
|
@ -43,8 +41,7 @@ class SecurityUserSettings
|
|||
}
|
||||
|
||||
onBuild() {
|
||||
if (this.capaAutoLogout)
|
||||
{
|
||||
if (this.capaAutoLogout) {
|
||||
_.delay(() => {
|
||||
const f0 = settingsSaveHelperSimpleFunction(this.autoLogout.trigger, this);
|
||||
|
||||
|
|
@ -54,4 +51,4 @@ class SecurityUserSettings
|
|||
}
|
||||
}
|
||||
|
||||
export {SecurityUserSettings, SecurityUserSettings as default};
|
||||
export { SecurityUserSettings, SecurityUserSettings as default };
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
|
||||
import SocialStore from 'Stores/Social';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
import { getApp } from 'Helper/Apps/User';
|
||||
|
||||
import {command} from 'Knoin/Knoin';
|
||||
import { command } from 'Knoin/Knoin';
|
||||
|
||||
class SocialUserSettings
|
||||
{
|
||||
class SocialUserSettings {
|
||||
constructor() {
|
||||
this.googleEnable = SocialStore.google.enabled;
|
||||
this.googleEnableAuth = SocialStore.google.capa.auth;
|
||||
|
|
@ -33,8 +31,7 @@ class SocialUserSettings
|
|||
|
||||
@command((self) => !self.googleLoggined() && !self.googleActions())
|
||||
connectGoogleCommand() {
|
||||
if (!this.googleLoggined())
|
||||
{
|
||||
if (!this.googleLoggined()) {
|
||||
getApp().googleConnect();
|
||||
}
|
||||
}
|
||||
|
|
@ -46,8 +43,7 @@ class SocialUserSettings
|
|||
|
||||
@command((self) => !self.facebookLoggined() && !self.facebookActions())
|
||||
connectFacebookCommand() {
|
||||
if (!this.facebookLoggined())
|
||||
{
|
||||
if (!this.facebookLoggined()) {
|
||||
getApp().facebookConnect();
|
||||
}
|
||||
}
|
||||
|
|
@ -59,8 +55,7 @@ class SocialUserSettings
|
|||
|
||||
@command((self) => !self.twitterLoggined() && !self.twitterActions())
|
||||
connectTwitterCommand() {
|
||||
if (!this.twitterLoggined())
|
||||
{
|
||||
if (!this.twitterLoggined()) {
|
||||
getApp().twitterConnect();
|
||||
}
|
||||
}
|
||||
|
|
@ -71,4 +66,4 @@ class SocialUserSettings
|
|||
}
|
||||
}
|
||||
|
||||
export {SocialUserSettings, SocialUserSettings as default};
|
||||
export { SocialUserSettings, SocialUserSettings as default };
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
|
||||
import ko from 'ko';
|
||||
|
||||
import {i18n} from 'Common/Translator';
|
||||
import { i18n } from 'Common/Translator';
|
||||
|
||||
import TemplateStore from 'Stores/User/Template';
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
import {getApp} from 'Helper/Apps/User';
|
||||
import { getApp } from 'Helper/Apps/User';
|
||||
|
||||
import {showScreenPopup} from 'Knoin/Knoin';
|
||||
import { showScreenPopup } from 'Knoin/Knoin';
|
||||
|
||||
class TemplatesUserSettings
|
||||
{
|
||||
class TemplatesUserSettings {
|
||||
constructor() {
|
||||
this.templates = TemplateStore.templates;
|
||||
|
||||
this.processText = ko.computed(() => (TemplateStore.templates.loading() ? i18n('SETTINGS_TEMPLETS/LOADING_PROCESS') : ''));
|
||||
this.processText = ko.computed(() =>
|
||||
TemplateStore.templates.loading() ? i18n('SETTINGS_TEMPLETS/LOADING_PROCESS') : ''
|
||||
);
|
||||
this.visibility = ko.computed(() => ('' === this.processText() ? 'hidden' : 'visible'));
|
||||
|
||||
this.templateForDeletion = ko.observable(null).deleteAccessHelper();
|
||||
|
|
@ -34,19 +34,16 @@ class TemplatesUserSettings
|
|||
}
|
||||
|
||||
editTemplate(oTemplateItem) {
|
||||
if (oTemplateItem)
|
||||
{
|
||||
if (oTemplateItem) {
|
||||
showScreenPopup(require('View/Popup/Template'), [oTemplateItem]);
|
||||
}
|
||||
}
|
||||
|
||||
deleteTemplate(templateToRemove) {
|
||||
if (templateToRemove && templateToRemove.deleteAccess())
|
||||
{
|
||||
if (templateToRemove && templateToRemove.deleteAccess()) {
|
||||
this.templateForDeletion(null);
|
||||
|
||||
if (templateToRemove)
|
||||
{
|
||||
if (templateToRemove) {
|
||||
this.templates.remove((template) => templateToRemove === template);
|
||||
|
||||
Remote.templateDelete(() => {
|
||||
|
|
@ -61,20 +58,18 @@ class TemplatesUserSettings
|
|||
}
|
||||
|
||||
onBuild(oDom) {
|
||||
|
||||
const self = this;
|
||||
|
||||
oDom
|
||||
.on('click', '.templates-list .template-item .e-action', function() { // eslint-disable-line prefer-arrow-callback
|
||||
const template = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (template)
|
||||
{
|
||||
self.editTemplate(template);
|
||||
}
|
||||
});
|
||||
oDom.on('click', '.templates-list .template-item .e-action', function() {
|
||||
// eslint-disable-line prefer-arrow-callback
|
||||
const template = ko.dataFor(this); // eslint-disable-line no-invalid-this
|
||||
if (template) {
|
||||
self.editTemplate(template);
|
||||
}
|
||||
});
|
||||
|
||||
this.reloadTemplates();
|
||||
}
|
||||
}
|
||||
|
||||
export {TemplatesUserSettings, TemplatesUserSettings as default};
|
||||
export { TemplatesUserSettings, TemplatesUserSettings as default };
|
||||
|
|
|
|||
|
|
@ -1,23 +1,21 @@
|
|||
|
||||
import _ from '_';
|
||||
import $ from '$';
|
||||
import ko from 'ko';
|
||||
|
||||
import Jua from 'Jua';
|
||||
|
||||
import {SaveSettingsStep, UploadErrorCode, Capa, Magics} from 'Common/Enums';
|
||||
import {changeTheme, convertThemeName} from 'Common/Utils';
|
||||
import {userBackground, themePreviewLink, uploadBackground} from 'Common/Links';
|
||||
import {i18n} from 'Common/Translator';
|
||||
import { SaveSettingsStep, UploadErrorCode, Capa, Magics } from 'Common/Enums';
|
||||
import { changeTheme, convertThemeName } from 'Common/Utils';
|
||||
import { userBackground, themePreviewLink, uploadBackground } from 'Common/Links';
|
||||
import { i18n } from 'Common/Translator';
|
||||
|
||||
import {capa} from 'Storage/Settings';
|
||||
import { capa } from 'Storage/Settings';
|
||||
|
||||
import ThemeStore from 'Stores/Theme';
|
||||
|
||||
import Remote from 'Remote/User/Ajax';
|
||||
|
||||
class ThemesUserSettings
|
||||
{
|
||||
class ThemesUserSettings {
|
||||
constructor() {
|
||||
this.theme = ThemeStore.theme;
|
||||
this.themes = ThemeStore.themes;
|
||||
|
|
@ -32,7 +30,7 @@ class ThemesUserSettings
|
|||
|
||||
this.capaUserBackground = ko.observable(capa(Capa.UserBackground));
|
||||
|
||||
this.themeTrigger = ko.observable(SaveSettingsStep.Idle).extend({throttle: Magics.Time100ms});
|
||||
this.themeTrigger = ko.observable(SaveSettingsStep.Idle).extend({ throttle: Magics.Time100ms });
|
||||
|
||||
this.iTimer = 0;
|
||||
this.oThemeAjaxRequest = null;
|
||||
|
|
@ -51,18 +49,19 @@ class ThemesUserSettings
|
|||
|
||||
this.background.hash.subscribe((value) => {
|
||||
const $bg = $('#rl-bg');
|
||||
if (!value)
|
||||
{
|
||||
if ($bg.data('backstretch'))
|
||||
{
|
||||
if (!value) {
|
||||
if ($bg.data('backstretch')) {
|
||||
$bg.backstretch('destroy').attr('style', '');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$bg.attr('style', 'background-image: none !important;').backstretch(userBackground(value), {
|
||||
fade: Magics.Time1s, centeredX: true, centeredY: true
|
||||
}).removeAttr('style');
|
||||
} else {
|
||||
$bg
|
||||
.attr('style', 'background-image: none !important;')
|
||||
.backstretch(userBackground(value), {
|
||||
fade: Magics.Time1s,
|
||||
centeredX: true,
|
||||
centeredY: true
|
||||
})
|
||||
.removeAttr('style');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -70,12 +69,14 @@ class ThemesUserSettings
|
|||
onBuild() {
|
||||
const currentTheme = this.theme();
|
||||
|
||||
this.themesObjects(_.map(this.themes(), (theme) => ({
|
||||
name: theme,
|
||||
nameDisplay: convertThemeName(theme),
|
||||
selected: ko.observable(theme === currentTheme),
|
||||
themePreviewSrc: themePreviewLink(theme)
|
||||
})));
|
||||
this.themesObjects(
|
||||
_.map(this.themes(), (theme) => ({
|
||||
name: theme,
|
||||
nameDisplay: convertThemeName(theme),
|
||||
selected: ko.observable(theme === currentTheme),
|
||||
themePreviewSrc: themePreviewLink(theme)
|
||||
}))
|
||||
);
|
||||
|
||||
this.initUploader();
|
||||
}
|
||||
|
|
@ -85,8 +86,7 @@ class ThemesUserSettings
|
|||
}
|
||||
|
||||
clearBackground() {
|
||||
if (this.capaUserBackground())
|
||||
{
|
||||
if (this.capaUserBackground()) {
|
||||
Remote.clearUserBackground(() => {
|
||||
this.background.name('');
|
||||
this.background.hash('');
|
||||
|
|
@ -95,18 +95,16 @@ class ThemesUserSettings
|
|||
}
|
||||
|
||||
initUploader() {
|
||||
if (this.background.uploaderButton() && this.capaUserBackground())
|
||||
{
|
||||
const
|
||||
oJua = new Jua({
|
||||
'action': uploadBackground(),
|
||||
'name': 'uploader',
|
||||
'queueSize': 1,
|
||||
'multipleSizeLimit': 1,
|
||||
'disableDragAndDrop': true,
|
||||
'disableMultiple': true,
|
||||
'clickElement': this.background.uploaderButton()
|
||||
});
|
||||
if (this.background.uploaderButton() && this.capaUserBackground()) {
|
||||
const oJua = new Jua({
|
||||
'action': uploadBackground(),
|
||||
'name': 'uploader',
|
||||
'queueSize': 1,
|
||||
'multipleSizeLimit': 1,
|
||||
'disableDragAndDrop': true,
|
||||
'disableMultiple': true,
|
||||
'clickElement': this.background.uploaderButton()
|
||||
});
|
||||
|
||||
oJua
|
||||
.on('onStart', () => {
|
||||
|
|
@ -117,21 +115,16 @@ class ThemesUserSettings
|
|||
.on('onComplete', (id, result, data) => {
|
||||
this.background.loading(false);
|
||||
|
||||
if (result && id && data && data.Result && data.Result.Name && data.Result.Hash)
|
||||
{
|
||||
if (result && id && data && data.Result && data.Result.Name && data.Result.Hash) {
|
||||
this.background.name(data.Result.Name);
|
||||
this.background.hash(data.Result.Hash);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
this.background.name('');
|
||||
this.background.hash('');
|
||||
|
||||
let errorMsg = '';
|
||||
if (data.ErrorCode)
|
||||
{
|
||||
switch (data.ErrorCode)
|
||||
{
|
||||
if (data.ErrorCode) {
|
||||
switch (data.ErrorCode) {
|
||||
case UploadErrorCode.FileIsTooBig:
|
||||
errorMsg = i18n('SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG');
|
||||
break;
|
||||
|
|
@ -142,8 +135,7 @@ class ThemesUserSettings
|
|||
}
|
||||
}
|
||||
|
||||
if (!errorMsg && data.ErrorMessage)
|
||||
{
|
||||
if (!errorMsg && data.ErrorMessage) {
|
||||
errorMsg = data.ErrorMessage;
|
||||
}
|
||||
|
||||
|
|
@ -156,4 +148,4 @@ class ThemesUserSettings
|
|||
}
|
||||
}
|
||||
|
||||
export {ThemesUserSettings, ThemesUserSettings as default};
|
||||
export { ThemesUserSettings, ThemesUserSettings as default };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue