eslint (additional rules)

This commit is contained in:
RainLoop Team 2016-06-30 03:02:45 +03:00
parent 77a1d3f3df
commit 8e8a041032
150 changed files with 21911 additions and 23106 deletions

View file

@ -1,163 +1,154 @@
(function () {
var
window = require('window'),
_ = require('_'),
ko = require('ko'),
'use strict';
Enums = require('Common/Enums'),
Links = require('Common/Links'),
var
window = require('window'),
_ = require('_'),
ko = require('ko'),
AccountStore = require('Stores/User/Account'),
IdentityStore = require('Stores/User/Identity'),
Enums = require('Common/Enums'),
Links = require('Common/Links'),
Settings = require('Storage/Settings'),
Remote = require('Remote/User/Ajax');
AccountStore = require('Stores/User/Account'),
IdentityStore = require('Stores/User/Identity'),
/**
* @constructor
*/
function AccountsUserSettings()
{
this.allowAdditionalAccount = Settings.capa(Enums.Capa.AdditionalAccounts);
this.allowIdentities = Settings.capa(Enums.Capa.Identities);
Settings = require('Storage/Settings'),
Remote = require('Remote/User/Ajax')
;
this.accounts = AccountStore.accounts;
this.identities = IdentityStore.identities;
/**
* @constructor
*/
function AccountsUserSettings()
this.accountForDeletion = ko.observable(null).deleteAccessHelper();
this.identityForDeletion = ko.observable(null).deleteAccessHelper();
}
AccountsUserSettings.prototype.scrollableOptions = function(sWrapper)
{
return {
handle: '.drag-handle',
containment: sWrapper || 'parent',
axis: 'y'
};
};
AccountsUserSettings.prototype.addNewAccount = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'));
};
AccountsUserSettings.prototype.editAccount = function(oAccountItem)
{
if (oAccountItem && oAccountItem.canBeEdit())
{
this.allowAdditionalAccount = Settings.capa(Enums.Capa.AdditionalAccounts);
this.allowIdentities = Settings.capa(Enums.Capa.Identities);
this.accounts = AccountStore.accounts;
this.identities = IdentityStore.identities;
this.accountForDeletion = ko.observable(null).deleteAccessHelper();
this.identityForDeletion = ko.observable(null).deleteAccessHelper();
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'), [oAccountItem]);
}
};
AccountsUserSettings.prototype.scrollableOptions = function (sWrapper)
{
return {
handle: '.drag-handle',
containment: sWrapper || 'parent',
axis: 'y'
};
};
AccountsUserSettings.prototype.addNewIdentity = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'));
};
AccountsUserSettings.prototype.addNewAccount = function ()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'));
};
AccountsUserSettings.prototype.editIdentity = function(oIdentity)
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'), [oIdentity]);
};
AccountsUserSettings.prototype.editAccount = function (oAccountItem)
/**
* @param {AccountModel} oAccountToRemove
*/
AccountsUserSettings.prototype.deleteAccount = function(oAccountToRemove)
{
if (oAccountToRemove && oAccountToRemove.deleteAccess())
{
if (oAccountItem && oAccountItem.canBeEdit())
this.accountForDeletion(null);
var
kn = require('Knoin/Knoin'),
fRemoveAccount = function(oAccount) {
return oAccountToRemove === oAccount;
};
if (oAccountToRemove)
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Account'), [oAccountItem]);
}
};
this.accounts.remove(fRemoveAccount);
AccountsUserSettings.prototype.addNewIdentity = function ()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'));
};
Remote.accountDelete(function(sResult, oData) {
AccountsUserSettings.prototype.editIdentity = function (oIdentity)
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'), [oIdentity]);
};
if (Enums.StorageResultType.Success === sResult && oData &&
oData.Result && oData.Reload)
{
kn.routeOff();
kn.setHash(Links.root(), true);
kn.routeOff();
/**
* @param {AccountModel} oAccountToRemove
*/
AccountsUserSettings.prototype.deleteAccount = function (oAccountToRemove)
{
if (oAccountToRemove && oAccountToRemove.deleteAccess())
{
this.accountForDeletion(null);
var
kn = require('Knoin/Knoin'),
fRemoveAccount = function (oAccount) {
return oAccountToRemove === oAccount;
_.defer(function() {
window.location.reload();
});
}
;
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(Links.root(), true);
kn.routeOff();
_.defer(function () {
window.location.reload();
});
}
else
{
require('App/User').default.accountsAndIdentities();
}
}, oAccountToRemove.email);
}
}
};
/**
* @param {IdentityModel} oIdentityToRemove
*/
AccountsUserSettings.prototype.deleteIdentity = function (oIdentityToRemove)
{
if (oIdentityToRemove && oIdentityToRemove.deleteAccess())
{
this.identityForDeletion(null);
if (oIdentityToRemove)
{
IdentityStore.identities.remove(function (oIdentity) {
return oIdentityToRemove === oIdentity;
});
Remote.identityDelete(function () {
else
{
require('App/User').default.accountsAndIdentities();
}, oIdentityToRemove.id);
}
}
}, oAccountToRemove.email);
}
};
}
};
AccountsUserSettings.prototype.accountsAndIdentitiesAfterMove = function ()
/**
* @param {IdentityModel} oIdentityToRemove
*/
AccountsUserSettings.prototype.deleteIdentity = function(oIdentityToRemove)
{
if (oIdentityToRemove && oIdentityToRemove.deleteAccess())
{
Remote.accountsAndIdentitiesSortOrder(null,
AccountStore.accountsEmails.peek(), IdentityStore.identitiesIDS.peek());
};
this.identityForDeletion(null);
AccountsUserSettings.prototype.onBuild = function (oDom)
{
var self = this;
if (oIdentityToRemove)
{
IdentityStore.identities.remove(function(oIdentity) {
return oIdentityToRemove === oIdentity;
});
oDom
.on('click', '.accounts-list .account-item .e-action', function () {
var oAccountItem = ko.dataFor(this);
if (oAccountItem)
{
self.editAccount(oAccountItem);
}
})
.on('click', '.identities-list .identity-item .e-action', function () {
var oIdentityItem = ko.dataFor(this);
if (oIdentityItem)
{
self.editIdentity(oIdentityItem);
}
})
;
};
Remote.identityDelete(function() {
require('App/User').default.accountsAndIdentities();
}, oIdentityToRemove.id);
}
}
};
module.exports = AccountsUserSettings;
AccountsUserSettings.prototype.accountsAndIdentitiesAfterMove = function()
{
Remote.accountsAndIdentitiesSortOrder(null,
AccountStore.accountsEmails.peek(), IdentityStore.identitiesIDS.peek());
};
}());
AccountsUserSettings.prototype.onBuild = function(oDom)
{
var self = this;
oDom
.on('click', '.accounts-list .account-item .e-action', function() {
var oAccountItem = ko.dataFor(this);
if (oAccountItem)
{
self.editAccount(oAccountItem);
}
})
.on('click', '.identities-list .identity-item .e-action', function() {
var oIdentityItem = ko.dataFor(this);
if (oIdentityItem)
{
self.editIdentity(oIdentityItem);
}
});
};
module.exports = AccountsUserSettings;

View file

@ -1,124 +1,117 @@
(function () {
var
_ = require('_'),
ko = require('ko'),
'use strict';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
var
_ = require('_'),
ko = require('ko'),
Remote = require('Remote/User/Ajax');
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
/**
* @constructor
*/
function ChangePasswordUserSettings()
{
this.changeProcess = ko.observable(false);
Remote = require('Remote/User/Ajax')
;
this.errorDescription = ko.observable('');
this.passwordMismatch = ko.observable(false);
this.passwordUpdateError = ko.observable(false);
this.passwordUpdateSuccess = ko.observable(false);
/**
* @constructor
*/
function ChangePasswordUserSettings()
{
this.changeProcess = ko.observable(false);
this.currentPassword = ko.observable('');
this.currentPassword.error = ko.observable(false);
this.newPassword = ko.observable('');
this.newPassword2 = ko.observable('');
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(Translator.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);
}
ChangePasswordUserSettings.prototype.onHide = function ()
{
this.changeProcess(false);
this.currentPassword('');
this.newPassword('');
this.newPassword2('');
this.errorDescription('');
this.passwordMismatch(false);
this.currentPassword.subscribe(function() {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.currentPassword.error(false);
};
}, this);
ChangePasswordUserSettings.prototype.onChangePasswordResponse = function (sResult, oData)
{
this.changeProcess(false);
this.newPassword.subscribe(function() {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.passwordMismatch(false);
this.errorDescription('');
this.currentPassword.error(false);
}, this);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
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.currentPassword('');
this.newPassword('');
this.newPassword2('');
this.passwordUpdateSuccess(true);
this.currentPassword.error(false);
require('App/User').default.setClientSideToken(oData.Result);
this.passwordMismatch(true);
this.errorDescription(Translator.i18n('SETTINGS_CHANGE_PASSWORD/ERROR_PASSWORD_MISMATCH'));
}
else
{
if (oData && Enums.Notification.CurrentPasswordIncorrect === oData.ErrorCode)
{
this.currentPassword.error(true);
}
this.changeProcess(true);
this.passwordUpdateError(true);
this.errorDescription(
Translator.getNotificationFromResponse(oData, Enums.Notification.CouldNotSaveNewPassword));
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.currentPassword.error(false);
this.passwordMismatch(false);
this.errorDescription('');
Remote.changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword());
}
};
module.exports = ChangePasswordUserSettings;
}, function() {
return !this.changeProcess() && '' !== this.currentPassword() &&
'' !== this.newPassword() && '' !== this.newPassword2();
});
}());
this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this);
}
ChangePasswordUserSettings.prototype.onHide = function()
{
this.changeProcess(false);
this.currentPassword('');
this.newPassword('');
this.newPassword2('');
this.errorDescription('');
this.passwordMismatch(false);
this.currentPassword.error(false);
};
ChangePasswordUserSettings.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);
require('App/User').default.setClientSideToken(oData.Result);
}
else
{
if (oData && Enums.Notification.CurrentPasswordIncorrect === oData.ErrorCode)
{
this.currentPassword.error(true);
}
this.passwordUpdateError(true);
this.errorDescription(
Translator.getNotificationFromResponse(oData, Enums.Notification.CouldNotSaveNewPassword));
}
};
module.exports = ChangePasswordUserSettings;

View file

@ -1,58 +1,51 @@
(function () {
var
ko = require('ko'),
'use strict';
AppStore = require('Stores/User/App'),
ContactStore = require('Stores/User/Contact'),
var
ko = require('ko'),
Remote = require('Remote/User/Ajax');
AppStore = require('Stores/User/App'),
ContactStore = require('Stores/User/Contact'),
/**
* @constructor
*/
function ContactsUserSettings()
{
this.contactsAutosave = AppStore.contactsAutosave;
Remote = require('Remote/User/Ajax')
;
this.allowContactsSync = ContactStore.allowContactsSync;
this.enableContactsSync = ContactStore.enableContactsSync;
this.contactsSyncUrl = ContactStore.contactsSyncUrl;
this.contactsSyncUser = ContactStore.contactsSyncUser;
this.contactsSyncPass = ContactStore.contactsSyncPass;
/**
* @constructor
*/
function ContactsUserSettings()
{
this.contactsAutosave = AppStore.contactsAutosave;
this.saveTrigger = ko.computed(function() {
return [
this.enableContactsSync() ? '1' : '0',
this.contactsSyncUrl(),
this.contactsSyncUser(),
this.contactsSyncPass()
].join('|');
}, this).extend({'throttle': 500});
}
this.allowContactsSync = ContactStore.allowContactsSync;
this.enableContactsSync = ContactStore.enableContactsSync;
this.contactsSyncUrl = ContactStore.contactsSyncUrl;
this.contactsSyncUser = ContactStore.contactsSyncUser;
this.contactsSyncPass = ContactStore.contactsSyncPass;
this.saveTrigger = ko.computed(function () {
return [
this.enableContactsSync() ? '1' : '0',
this.contactsSyncUrl(),
this.contactsSyncUser(),
this.contactsSyncPass()
].join('|');
}, this).extend({'throttle': 500});
}
ContactsUserSettings.prototype.onBuild = function ()
{
this.contactsAutosave.subscribe(function (bValue) {
Remote.saveSettings(null, {
'ContactsAutosave': bValue ? '1' : '0'
});
ContactsUserSettings.prototype.onBuild = function()
{
this.contactsAutosave.subscribe(function(bValue) {
Remote.saveSettings(null, {
'ContactsAutosave': bValue ? '1' : '0'
});
});
this.saveTrigger.subscribe(function () {
Remote.saveContactsSyncData(null,
this.enableContactsSync(),
this.contactsSyncUrl(),
this.contactsSyncUser(),
this.contactsSyncPass()
);
}, this);
};
this.saveTrigger.subscribe(function() {
Remote.saveContactsSyncData(null,
this.enableContactsSync(),
this.contactsSyncUrl(),
this.contactsSyncUser(),
this.contactsSyncPass()
);
}, this);
};
module.exports = ContactsUserSettings;
}());
module.exports = ContactsUserSettings;

View file

@ -1,246 +1,234 @@
(function () {
var
ko = require('ko'),
_ = require('_'),
'use strict';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
var
ko = require('ko'),
_ = require('_'),
FilterStore = require('Stores/User/Filter'),
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
Remote = require('Remote/User/Ajax');
FilterStore = require('Stores/User/Filter'),
/**
* @constructor
*/
function FiltersUserSettings()
{
var self = this;
Remote = require('Remote/User/Ajax')
;
this.modules = FilterStore.modules;
this.filters = FilterStore.filters;
/**
* @constructor
*/
function FiltersUserSettings()
{
var self = this;
this.inited = ko.observable(false);
this.serverError = ko.observable(false);
this.serverErrorDesc = ko.observable('');
this.haveChanges = ko.observable(false);
this.modules = FilterStore.modules;
this.filters = FilterStore.filters;
this.saveErrorText = ko.observable('');
this.inited = ko.observable(false);
this.serverError = ko.observable(false);
this.serverErrorDesc = ko.observable('');
this.haveChanges = ko.observable(false);
this.filters.subscribe(Utils.windowResizeCallback);
this.saveErrorText = ko.observable('');
this.filters.subscribe(Utils.windowResizeCallback);
this.serverError.subscribe(function (bValue) {
if (!bValue)
{
this.serverErrorDesc('');
}
}, this);
this.filterRaw = FilterStore.raw;
this.filterRaw.capa = FilterStore.capa;
this.filterRaw.active = ko.observable(false);
this.filterRaw.allow = ko.observable(false);
this.filterRaw.error = ko.observable(false);
this.filterForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend(
{'toggleSubscribeProperty': [this, 'deleteAccess']});
this.saveChanges = Utils.createCommand(this, function () {
if (!this.filters.saving())
{
if (this.filterRaw.active() && '' === Utils.trim(this.filterRaw()))
{
this.filterRaw.error(true);
return false;
}
this.filters.saving(true);
this.saveErrorText('');
Remote.filtersSave(function (sResult, oData) {
self.filters.saving(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
self.haveChanges(false);
self.updateList();
}
else if (oData && oData.ErrorCode)
{
self.saveErrorText(oData.ErrorMessageAdditional || Translator.getNotification(oData.ErrorCode));
}
else
{
self.saveErrorText(Translator.getNotification(Enums.Notification.CantSaveFilters));
}
}, this.filters(), this.filterRaw(), this.filterRaw.active());
}
return true;
}, function () {
return this.haveChanges();
});
this.filters.subscribe(function () {
this.haveChanges(true);
}, this);
this.filterRaw.subscribe(function () {
this.haveChanges(true);
this.filterRaw.error(false);
}, this);
this.haveChanges.subscribe(function () {
this.saveErrorText('');
}, this);
this.filterRaw.active.subscribe(function () {
this.haveChanges(true);
this.filterRaw.error(false);
}, this);
}
FiltersUserSettings.prototype.scrollableOptions = function (sWrapper)
{
return {
handle: '.drag-handle',
containment: sWrapper || 'parent',
axis: 'y'
};
};
FiltersUserSettings.prototype.updateList = function ()
{
var
self = this,
FilterModel = require('Model/Filter')
;
if (!this.filters.loading())
this.serverError.subscribe(function(bValue) {
if (!bValue)
{
this.filters.loading(true);
this.serverErrorDesc('');
}
}, this);
Remote.filtersGet(function (sResult, oData) {
this.filterRaw = FilterStore.raw;
this.filterRaw.capa = FilterStore.capa;
this.filterRaw.active = ko.observable(false);
this.filterRaw.allow = ko.observable(false);
this.filterRaw.error = ko.observable(false);
self.filters.loading(false);
self.serverError(false);
this.filterForDeletion = ko.observable(null).extend({'falseTimeout': 3000}).extend(
{'toggleSubscribeProperty': [this, 'deleteAccess']});
if (Enums.StorageResultType.Success === sResult && oData &&
oData.Result && Utils.isArray(oData.Result.Filters))
this.saveChanges = Utils.createCommand(this, function() {
if (!this.filters.saving())
{
if (this.filterRaw.active() && '' === Utils.trim(this.filterRaw()))
{
this.filterRaw.error(true);
return false;
}
this.filters.saving(true);
this.saveErrorText('');
Remote.filtersSave(function(sResult, oData) {
self.filters.saving(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
self.inited(true);
self.serverError(false);
var aResult = _.compact(_.map(oData.Result.Filters, function (aItem) {
var oNew = new FilterModel();
return (oNew && oNew.parse(aItem)) ? oNew : null;
}));
self.filters(aResult);
self.modules(oData.Result.Modules ? oData.Result.Modules : {});
self.filterRaw(oData.Result.Raw || '');
self.filterRaw.capa(Utils.isArray(oData.Result.Capa) ? oData.Result.Capa.join(' ') : '');
self.filterRaw.active(!!oData.Result.RawIsActive);
self.filterRaw.allow(!!oData.Result.RawIsAllow);
self.haveChanges(false);
self.updateList();
}
else if (oData && oData.ErrorCode)
{
self.saveErrorText(oData.ErrorMessageAdditional || Translator.getNotification(oData.ErrorCode));
}
else
{
self.filters([]);
self.modules({});
self.filterRaw('');
self.filterRaw.capa({});
self.serverError(true);
self.serverErrorDesc(oData && oData.ErrorCode ? Translator.getNotification(oData.ErrorCode) :
Translator.getNotification(Enums.Notification.CantGetFilters));
self.saveErrorText(Translator.getNotification(Enums.Notification.CantSaveFilters));
}
self.haveChanges(false);
});
}, this.filters(), this.filterRaw(), this.filterRaw.active());
}
};
FiltersUserSettings.prototype.deleteFilter = function (oFilter)
return true;
}, function() {
return this.haveChanges();
});
this.filters.subscribe(function() {
this.haveChanges(true);
}, this);
this.filterRaw.subscribe(function() {
this.haveChanges(true);
this.filterRaw.error(false);
}, this);
this.haveChanges.subscribe(function() {
this.saveErrorText('');
}, this);
this.filterRaw.active.subscribe(function() {
this.haveChanges(true);
this.filterRaw.error(false);
}, this);
}
FiltersUserSettings.prototype.scrollableOptions = function(sWrapper)
{
return {
handle: '.drag-handle',
containment: sWrapper || 'parent',
axis: 'y'
};
};
FiltersUserSettings.prototype.updateList = function()
{
var
self = this,
FilterModel = require('Model/Filter');
if (!this.filters.loading())
{
this.filters.remove(oFilter);
Utils.delegateRunOnDestroy(oFilter);
};
this.filters.loading(true);
FiltersUserSettings.prototype.addFilter = function ()
{
var
self = this,
FilterModel = require('Model/Filter'),
oNew = new FilterModel()
;
Remote.filtersGet(function(sResult, oData) {
oNew.generateID();
require('Knoin/Knoin').showScreenPopup(
require('View/Popup/Filter'), [oNew, function () {
self.filters.push(oNew);
self.filterRaw.active(false);
}, false]);
};
self.filters.loading(false);
self.serverError(false);
FiltersUserSettings.prototype.editFilter = function (oEdit)
{
var
self = this,
oCloned = oEdit.cloneSelf()
;
if (Enums.StorageResultType.Success === sResult && oData &&
oData.Result && Utils.isArray(oData.Result.Filters))
{
self.inited(true);
self.serverError(false);
require('Knoin/Knoin').showScreenPopup(
require('View/Popup/Filter'), [oCloned, function () {
var aResult = _.compact(_.map(oData.Result.Filters, function(aItem) {
var oNew = new FilterModel();
return (oNew && oNew.parse(aItem)) ? oNew : null;
}));
var
aFilters = self.filters(),
iIndex = aFilters.indexOf(oEdit)
;
self.filters(aResult);
if (-1 < iIndex && aFilters[iIndex])
{
Utils.delegateRunOnDestroy(aFilters[iIndex]);
aFilters[iIndex] = oCloned;
self.modules(oData.Result.Modules ? oData.Result.Modules : {});
self.filters(aFilters);
self.haveChanges(true);
}
self.filterRaw(oData.Result.Raw || '');
self.filterRaw.capa(Utils.isArray(oData.Result.Capa) ? oData.Result.Capa.join(' ') : '');
self.filterRaw.active(!!oData.Result.RawIsActive);
self.filterRaw.allow(!!oData.Result.RawIsAllow);
}
else
{
self.filters([]);
self.modules({});
self.filterRaw('');
self.filterRaw.capa({});
}, true]);
};
self.serverError(true);
self.serverErrorDesc(oData && oData.ErrorCode ? Translator.getNotification(oData.ErrorCode) :
Translator.getNotification(Enums.Notification.CantGetFilters));
}
FiltersUserSettings.prototype.onBuild = function (oDom)
{
var self = this;
self.haveChanges(false);
});
}
};
oDom
.on('click', '.filter-item .e-action', function () {
var oFilterItem = ko.dataFor(this);
if (oFilterItem)
{
self.editFilter(oFilterItem);
}
})
;
};
FiltersUserSettings.prototype.deleteFilter = function(oFilter)
{
this.filters.remove(oFilter);
Utils.delegateRunOnDestroy(oFilter);
};
FiltersUserSettings.prototype.onShow = function ()
{
this.updateList();
};
FiltersUserSettings.prototype.addFilter = function()
{
var
self = this,
FilterModel = require('Model/Filter'),
oNew = new FilterModel();
module.exports = FiltersUserSettings;
oNew.generateID();
require('Knoin/Knoin').showScreenPopup(
require('View/Popup/Filter'), [oNew, function() {
self.filters.push(oNew);
self.filterRaw.active(false);
}, false]);
};
}());
FiltersUserSettings.prototype.editFilter = function(oEdit)
{
var
self = this,
oCloned = oEdit.cloneSelf();
require('Knoin/Knoin').showScreenPopup(
require('View/Popup/Filter'), [oCloned, function() {
var
aFilters = self.filters(),
iIndex = aFilters.indexOf(oEdit);
if (-1 < iIndex && aFilters[iIndex])
{
Utils.delegateRunOnDestroy(aFilters[iIndex]);
aFilters[iIndex] = oCloned;
self.filters(aFilters);
self.haveChanges(true);
}
}, true]);
};
FiltersUserSettings.prototype.onBuild = function(oDom)
{
var self = this;
oDom
.on('click', '.filter-item .e-action', function() {
var oFilterItem = ko.dataFor(this);
if (oFilterItem)
{
self.editFilter(oFilterItem);
}
});
};
FiltersUserSettings.prototype.onShow = function()
{
this.updateList();
};
module.exports = FiltersUserSettings;

View file

@ -1,203 +1,192 @@
(function () {
var
ko = require('ko'),
'use strict';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
var
ko = require('ko'),
Cache = require('Common/Cache'),
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
Settings = require('Storage/Settings'),
Local = require('Storage/Client'),
Cache = require('Common/Cache'),
FolderStore = require('Stores/User/Folder'),
Settings = require('Storage/Settings'),
Local = require('Storage/Client'),
Promises = require('Promises/User/Ajax'),
Remote = require('Remote/User/Ajax');
FolderStore = require('Stores/User/Folder'),
/**
* @constructor
*/
function FoldersUserSettings()
{
this.displaySpecSetting = FolderStore.displaySpecSetting;
this.folderList = FolderStore.folderList;
Promises = require('Promises/User/Ajax'),
Remote = require('Remote/User/Ajax')
;
this.folderListHelp = ko.observable('').extend({'throttle': 100});
/**
* @constructor
*/
function FoldersUserSettings()
{
this.displaySpecSetting = FolderStore.displaySpecSetting;
this.folderList = FolderStore.folderList;
this.loading = ko.computed(function() {
this.folderListHelp = ko.observable('').extend({'throttle': 100});
var
bLoading = FolderStore.foldersLoading(),
bCreating = FolderStore.foldersCreating(),
bDeleting = FolderStore.foldersDeleting(),
bRenaming = FolderStore.foldersRenaming();
this.loading = ko.computed(function () {
return bLoading || bCreating || bDeleting || bRenaming;
var
bLoading = FolderStore.foldersLoading(),
bCreating = FolderStore.foldersCreating(),
bDeleting = FolderStore.foldersDeleting(),
bRenaming = FolderStore.foldersRenaming()
;
}, this);
return bLoading || bCreating || bDeleting || bRenaming;
this.folderForDeletion = ko.observable(null).deleteAccessHelper();
}, this);
this.folderForDeletion = ko.observable(null).deleteAccessHelper();
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.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 = !!Settings.appSettingsGet('useImapSubscribe');
this.useImapSubscribe = !!Settings.appSettingsGet('useImapSubscribe');
}
FoldersUserSettings.prototype.folderEditOnEnter = function(oFolder)
{
var
sEditName = oFolder ? Utils.trim(oFolder.nameForEdit()) : '';
if ('' !== sEditName && oFolder.name() !== sEditName)
{
Local.set(Enums.ClientSideKeyName.FoldersLashHash, '');
require('App/User').default.foldersPromisesActionHelper(
Promises.folderRename(oFolder.fullNameRaw, sEditName, FolderStore.foldersRenaming),
Enums.Notification.CantRenameFolder
);
Cache.removeFolderFromCacheList(oFolder.fullNameRaw);
oFolder.name(sEditName);
}
FoldersUserSettings.prototype.folderEditOnEnter = function (oFolder)
{
var
sEditName = oFolder ? Utils.trim(oFolder.nameForEdit()) : ''
;
oFolder.edited(false);
};
if ('' !== sEditName && oFolder.name() !== sEditName)
FoldersUserSettings.prototype.folderEditOnEsc = function(oFolder)
{
if (oFolder)
{
oFolder.edited(false);
}
};
FoldersUserSettings.prototype.onShow = function()
{
FolderStore.folderList.error('');
};
FoldersUserSettings.prototype.onBuild = function(oDom)
{
var self = this;
oDom
.on('mouseover', '.delete-folder-parent', function() {
self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_DELETE_FOLDER'));
})
.on('mouseover', '.subscribe-folder-parent', function() {
self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_SHOW_HIDE_FOLDER'));
})
.on('mouseover', '.check-folder-parent', function() {
self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_CHECK_FOR_NEW_MESSAGES'));
})
.on('mouseout', '.subscribe-folder-parent, .check-folder-parent, .delete-folder-parent', function() {
self.folderListHelp('');
});
};
FoldersUserSettings.prototype.createFolder = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/FolderCreate'));
};
FoldersUserSettings.prototype.systemFolder = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/FolderSystem'));
};
FoldersUserSettings.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)
{
Local.set(Enums.ClientSideKeyName.FoldersLashHash, '');
FolderStore.folderList.remove(fRemoveFolder);
require('App/User').default.foldersPromisesActionHelper(
Promises.folderRename(oFolder.fullNameRaw, sEditName, FolderStore.foldersRenaming),
Enums.Notification.CantRenameFolder
Promises.folderDelete(oFolderToRemove.fullNameRaw, FolderStore.foldersDeleting),
Enums.Notification.CantDeleteFolder
);
Cache.removeFolderFromCacheList(oFolder.fullNameRaw);
oFolder.name(sEditName);
Cache.removeFolderFromCacheList(oFolderToRemove.fullNameRaw);
}
oFolder.edited(false);
};
FoldersUserSettings.prototype.folderEditOnEsc = function (oFolder)
}
else if (0 < oFolderToRemove.privateMessageCountAll())
{
if (oFolder)
{
oFolder.edited(false);
}
};
FolderStore.folderList.error(Translator.getNotification(Enums.Notification.CantDeleteNonEmptyFolder));
}
};
FoldersUserSettings.prototype.onShow = function ()
{
FolderStore.folderList.error('');
};
FoldersUserSettings.prototype.subscribeFolder = function(oFolder)
{
Local.set(Enums.ClientSideKeyName.FoldersLashHash, '');
Remote.folderSetSubscribe(Utils.noop, oFolder.fullNameRaw, true);
FoldersUserSettings.prototype.onBuild = function (oDom)
{
var self = this;
oDom
.on('mouseover', '.delete-folder-parent', function () {
self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_DELETE_FOLDER'));
})
.on('mouseover', '.subscribe-folder-parent', function () {
self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_SHOW_HIDE_FOLDER'));
})
.on('mouseover', '.check-folder-parent', function () {
self.folderListHelp(Translator.i18n('SETTINGS_FOLDERS/HELP_CHECK_FOR_NEW_MESSAGES'));
})
.on('mouseout', '.subscribe-folder-parent, .check-folder-parent, .delete-folder-parent', function () {
self.folderListHelp('');
})
;
};
oFolder.subScribed(true);
};
FoldersUserSettings.prototype.createFolder = function ()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/FolderCreate'));
};
FoldersUserSettings.prototype.unSubscribeFolder = function(oFolder)
{
Local.set(Enums.ClientSideKeyName.FoldersLashHash, '');
Remote.folderSetSubscribe(Utils.noop, oFolder.fullNameRaw, false);
FoldersUserSettings.prototype.systemFolder = function ()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/FolderSystem'));
};
oFolder.subScribed(false);
};
FoldersUserSettings.prototype.deleteFolder = function (oFolderToRemove)
{
if (oFolderToRemove && oFolderToRemove.canBeDeleted() && oFolderToRemove.deleteAccess() &&
0 === oFolderToRemove.privateMessageCountAll())
{
this.folderForDeletion(null);
FoldersUserSettings.prototype.checkableTrueFolder = function(oFolder)
{
Remote.folderSetCheckable(Utils.noop, oFolder.fullNameRaw, true);
var
fRemoveFolder = function (oFolder) {
oFolder.checkable(true);
};
if (oFolderToRemove === oFolder)
{
return true;
}
FoldersUserSettings.prototype.checkableFalseFolder = function(oFolder)
{
Remote.folderSetCheckable(Utils.noop, oFolder.fullNameRaw, false);
oFolder.subFolders.remove(fRemoveFolder);
return false;
}
;
oFolder.checkable(false);
};
if (oFolderToRemove)
{
Local.set(Enums.ClientSideKeyName.FoldersLashHash, '');
FolderStore.folderList.remove(fRemoveFolder);
require('App/User').default.foldersPromisesActionHelper(
Promises.folderDelete(oFolderToRemove.fullNameRaw, FolderStore.foldersDeleting),
Enums.Notification.CantDeleteFolder
);
Cache.removeFolderFromCacheList(oFolderToRemove.fullNameRaw);
}
}
else if (0 < oFolderToRemove.privateMessageCountAll())
{
FolderStore.folderList.error(Translator.getNotification(Enums.Notification.CantDeleteNonEmptyFolder));
}
};
FoldersUserSettings.prototype.subscribeFolder = function (oFolder)
{
Local.set(Enums.ClientSideKeyName.FoldersLashHash, '');
Remote.folderSetSubscribe(Utils.noop, oFolder.fullNameRaw, true);
oFolder.subScribed(true);
};
FoldersUserSettings.prototype.unSubscribeFolder = function (oFolder)
{
Local.set(Enums.ClientSideKeyName.FoldersLashHash, '');
Remote.folderSetSubscribe(Utils.noop, oFolder.fullNameRaw, false);
oFolder.subScribed(false);
};
FoldersUserSettings.prototype.checkableTrueFolder = function (oFolder)
{
Remote.folderSetCheckable(Utils.noop, oFolder.fullNameRaw, true);
oFolder.checkable(true);
};
FoldersUserSettings.prototype.checkableFalseFolder = function (oFolder)
{
Remote.folderSetCheckable(Utils.noop, oFolder.fullNameRaw, false);
oFolder.checkable(false);
};
module.exports = FoldersUserSettings;
}());
module.exports = FoldersUserSettings;

View file

@ -1,232 +1,224 @@
(function () {
var
_ = require('_'),
ko = require('ko'),
'use strict';
Enums = require('Common/Enums'),
Consts = require('Common/Consts'),
Globals = require('Common/Globals'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
var
_ = require('_'),
ko = require('ko'),
AppStore = require('Stores/User/App'),
LanguageStore = require('Stores/Language'),
SettingsStore = require('Stores/User/Settings'),
IdentityStore = require('Stores/User/Identity'),
NotificationStore = require('Stores/User/Notification'),
MessageStore = require('Stores/User/Message'),
Enums = require('Common/Enums'),
Consts = require('Common/Consts'),
Globals = require('Common/Globals'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
Remote = require('Remote/User/Ajax');
AppStore = require('Stores/User/App'),
LanguageStore = require('Stores/Language'),
SettingsStore = require('Stores/User/Settings'),
IdentityStore = require('Stores/User/Identity'),
NotificationStore = require('Stores/User/Notification'),
MessageStore = require('Stores/User/Message'),
/**
* @constructor
*/
function GeneralUserSettings()
{
this.language = LanguageStore.language;
this.languages = LanguageStore.languages;
this.messagesPerPage = SettingsStore.messagesPerPage;
this.messagesPerPageArray = Consts.MESSAGES_PER_PAGE_VALUES;
Remote = require('Remote/User/Ajax')
;
this.editorDefaultType = SettingsStore.editorDefaultType;
this.layout = SettingsStore.layout;
this.usePreviewPane = SettingsStore.usePreviewPane;
/**
* @constructor
*/
function GeneralUserSettings()
{
this.language = LanguageStore.language;
this.languages = LanguageStore.languages;
this.messagesPerPage = SettingsStore.messagesPerPage;
this.messagesPerPageArray = Consts.MESSAGES_PER_PAGE_VALUES;
this.soundNotificationIsSupported = NotificationStore.soundNotificationIsSupported;
this.enableSoundNotification = NotificationStore.enableSoundNotification;
this.editorDefaultType = SettingsStore.editorDefaultType;
this.layout = SettingsStore.layout;
this.usePreviewPane = SettingsStore.usePreviewPane;
this.enableDesktopNotification = NotificationStore.enableDesktopNotification;
this.isDesktopNotificationSupported = NotificationStore.isDesktopNotificationSupported;
this.isDesktopNotificationDenied = NotificationStore.isDesktopNotificationDenied;
this.soundNotificationIsSupported = NotificationStore.soundNotificationIsSupported;
this.enableSoundNotification = NotificationStore.enableSoundNotification;
this.showImages = SettingsStore.showImages;
this.useCheckboxesInList = SettingsStore.useCheckboxesInList;
this.threadsAllowed = AppStore.threadsAllowed;
this.useThreads = SettingsStore.useThreads;
this.replySameFolder = SettingsStore.replySameFolder;
this.allowLanguagesOnSettings = AppStore.allowLanguagesOnSettings;
this.enableDesktopNotification = NotificationStore.enableDesktopNotification;
this.isDesktopNotificationSupported = NotificationStore.isDesktopNotificationSupported;
this.isDesktopNotificationDenied = NotificationStore.isDesktopNotificationDenied;
this.languageFullName = ko.computed(function() {
return Utils.convertLangName(this.language());
}, this);
this.showImages = SettingsStore.showImages;
this.useCheckboxesInList = SettingsStore.useCheckboxesInList;
this.threadsAllowed = AppStore.threadsAllowed;
this.useThreads = SettingsStore.useThreads;
this.replySameFolder = SettingsStore.replySameFolder;
this.allowLanguagesOnSettings = AppStore.allowLanguagesOnSettings;
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
this.languageFullName = ko.computed(function () {
return Utils.convertLangName(this.language());
}, this);
this.mppTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.editorDefaultTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.layoutTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
this.isAnimationSupported = Globals.bAnimationSupported;
this.mppTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.editorDefaultTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.layoutTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.identities = IdentityStore.identities;
this.isAnimationSupported = Globals.bAnimationSupported;
this.identityMain = ko.computed(function() {
var aList = this.identities();
return Utils.isArray(aList) ? _.find(aList, function(oItem) {
return oItem && '' === oItem.id();
}) : null;
}, this);
this.identities = IdentityStore.identities;
this.identityMain = ko.computed(function () {
var aList = this.identities();
return Utils.isArray(aList) ? _.find(aList, function (oItem) {
return oItem && '' === oItem.id() ? true : false;
}) : null;
}, this);
this.identityMainDesc = ko.computed(function () {
var oIdentity = this.identityMain();
return oIdentity ? oIdentity.formattedName() : '---';
}, this);
this.editorDefaultTypes = ko.computed(function () {
Translator.trigger();
return [
{'id': Enums.EditorDefaultType.Html, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML')},
{'id': Enums.EditorDefaultType.Plain, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN')},
{'id': Enums.EditorDefaultType.HtmlForced, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML_FORCED')},
{'id': Enums.EditorDefaultType.PlainForced, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN_FORCED')}
];
}, this);
this.layoutTypes = ko.computed(function () {
Translator.trigger();
return [
{'id': Enums.Layout.NoPreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_NO_SPLIT')},
{'id': Enums.Layout.SidePreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_VERTICAL_SPLIT')},
{'id': Enums.Layout.BottomPreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_HORIZONTAL_SPLIT')}
];
}, this);
}
GeneralUserSettings.prototype.editMainIdentity = function ()
{
this.identityMainDesc = ko.computed(function() {
var oIdentity = this.identityMain();
if (oIdentity)
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'), [oIdentity]);
}
};
return oIdentity ? oIdentity.formattedName() : '---';
}, this);
GeneralUserSettings.prototype.testSoundNotification = function ()
this.editorDefaultTypes = ko.computed(function() {
Translator.trigger();
return [
{'id': Enums.EditorDefaultType.Html, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML')},
{'id': Enums.EditorDefaultType.Plain, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN')},
{'id': Enums.EditorDefaultType.HtmlForced, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_HTML_FORCED')},
{'id': Enums.EditorDefaultType.PlainForced, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_EDITOR_PLAIN_FORCED')}
];
}, this);
this.layoutTypes = ko.computed(function() {
Translator.trigger();
return [
{'id': Enums.Layout.NoPreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_NO_SPLIT')},
{'id': Enums.Layout.SidePreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_VERTICAL_SPLIT')},
{'id': Enums.Layout.BottomPreview, 'name': Translator.i18n('SETTINGS_GENERAL/LABEL_LAYOUT_HORIZONTAL_SPLIT')}
];
}, this);
}
GeneralUserSettings.prototype.editMainIdentity = function()
{
var oIdentity = this.identityMain();
if (oIdentity)
{
NotificationStore.playSoundNotification(true);
};
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'), [oIdentity]);
}
};
GeneralUserSettings.prototype.onBuild = function ()
{
var self = this;
GeneralUserSettings.prototype.testSoundNotification = function()
{
NotificationStore.playSoundNotification(true);
};
_.delay(function () {
GeneralUserSettings.prototype.onBuild = function()
{
var self = this;
var
f0 = Utils.settingsSaveHelperSimpleFunction(self.editorDefaultTypeTrigger, self),
f1 = Utils.settingsSaveHelperSimpleFunction(self.mppTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.layoutTrigger, self),
fReloadLanguageHelper = function (iSaveSettingsStep) {
return function() {
self.languageTrigger(iSaveSettingsStep);
_.delay(function () {
self.languageTrigger(Enums.SaveSettingsStep.Idle);
}, 1000);
};
}
;
_.delay(function() {
self.language.subscribe(function (sValue) {
var
f0 = Utils.settingsSaveHelperSimpleFunction(self.editorDefaultTypeTrigger, self),
f1 = Utils.settingsSaveHelperSimpleFunction(self.mppTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.layoutTrigger, self),
fReloadLanguageHelper = function(iSaveSettingsStep) {
return function() {
self.languageTrigger(iSaveSettingsStep);
_.delay(function() {
self.languageTrigger(Enums.SaveSettingsStep.Idle);
}, 1000);
};
};
self.languageTrigger(Enums.SaveSettingsStep.Animate);
self.language.subscribe(function(sValue) {
Translator.reload(false, sValue).then(
fReloadLanguageHelper(Enums.SaveSettingsStep.TrueResult),
fReloadLanguageHelper(Enums.SaveSettingsStep.FalseResult)
).then(function() {
Remote.saveSettings(null, {
'Language': sValue
});
});
self.languageTrigger(Enums.SaveSettingsStep.Animate);
});
self.editorDefaultType.subscribe(function (sValue) {
Remote.saveSettings(f0, {
'EditorDefaultType': sValue
});
});
self.messagesPerPage.subscribe(function (iValue) {
Remote.saveSettings(f1, {
'MPP': iValue
});
});
self.showImages.subscribe(function (bValue) {
Translator.reload(false, sValue).then(
fReloadLanguageHelper(Enums.SaveSettingsStep.TrueResult),
fReloadLanguageHelper(Enums.SaveSettingsStep.FalseResult)
).then(function() {
Remote.saveSettings(null, {
'ShowImages': bValue ? '1' : '0'
'Language': sValue
});
});
self.enableDesktopNotification.subscribe(function (bValue) {
Utils.timeOutAction('SaveDesktopNotifications', function () {
Remote.saveSettings(null, {
'DesktopNotifications': bValue ? '1' : '0'
});
}, 3000);
});
self.editorDefaultType.subscribe(function(sValue) {
Remote.saveSettings(f0, {
'EditorDefaultType': sValue
});
});
self.enableSoundNotification.subscribe(function (bValue) {
Utils.timeOutAction('SaveSoundNotification', function () {
Remote.saveSettings(null, {
'SoundNotification': bValue ? '1' : '0'
});
}, 3000);
self.messagesPerPage.subscribe(function(iValue) {
Remote.saveSettings(f1, {
'MPP': iValue
});
});
self.replySameFolder.subscribe(function (bValue) {
Utils.timeOutAction('SaveReplySameFolder', function () {
Remote.saveSettings(null, {
'ReplySameFolder': bValue ? '1' : '0'
});
}, 3000);
self.showImages.subscribe(function(bValue) {
Remote.saveSettings(null, {
'ShowImages': bValue ? '1' : '0'
});
});
self.useThreads.subscribe(function (bValue) {
MessageStore.messageList([]);
self.enableDesktopNotification.subscribe(function(bValue) {
Utils.timeOutAction('SaveDesktopNotifications', function() {
Remote.saveSettings(null, {
'UseThreads': bValue ? '1' : '0'
'DesktopNotifications': bValue ? '1' : '0'
});
});
}, 3000);
});
self.layout.subscribe(function (nValue) {
MessageStore.messageList([]);
Remote.saveSettings(f2, {
'Layout': nValue
});
});
self.useCheckboxesInList.subscribe(function (bValue) {
self.enableSoundNotification.subscribe(function(bValue) {
Utils.timeOutAction('SaveSoundNotification', function() {
Remote.saveSettings(null, {
'UseCheckboxesInList': bValue ? '1' : '0'
'SoundNotification': bValue ? '1' : '0'
});
}, 3000);
});
self.replySameFolder.subscribe(function(bValue) {
Utils.timeOutAction('SaveReplySameFolder', function() {
Remote.saveSettings(null, {
'ReplySameFolder': bValue ? '1' : '0'
});
}, 3000);
});
self.useThreads.subscribe(function(bValue) {
MessageStore.messageList([]);
Remote.saveSettings(null, {
'UseThreads': bValue ? '1' : '0'
});
});
}, 50);
};
self.layout.subscribe(function(nValue) {
GeneralUserSettings.prototype.onShow = function ()
{
this.enableDesktopNotification.valueHasMutated();
};
MessageStore.messageList([]);
GeneralUserSettings.prototype.selectLanguage = function ()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [
this.language, this.languages(), LanguageStore.userLanguage()
]);
};
Remote.saveSettings(f2, {
'Layout': nValue
});
});
module.exports = GeneralUserSettings;
self.useCheckboxesInList.subscribe(function(bValue) {
Remote.saveSettings(null, {
'UseCheckboxesInList': bValue ? '1' : '0'
});
});
}());
}, 50);
};
GeneralUserSettings.prototype.onShow = function()
{
this.enableDesktopNotification.valueHasMutated();
};
GeneralUserSettings.prototype.selectLanguage = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [
this.language, this.languages(), LanguageStore.userLanguage()
]);
};
module.exports = GeneralUserSettings;

View file

@ -1,83 +1,76 @@
(function () {
var
_ = require('_'),
ko = require('ko'),
window = require('window'),
'use strict';
Utils = require('Common/Utils'),
var
_ = require('_'),
ko = require('ko'),
window = require('window'),
kn = require('Knoin/Knoin'),
Utils = require('Common/Utils'),
PgpStore = require('Stores/User/Pgp');
kn = require('Knoin/Knoin'),
/**
* @constructor
*/
function OpenPgpUserSettings()
{
this.openpgpkeys = PgpStore.openpgpkeys;
this.openpgpkeysPublic = PgpStore.openpgpkeysPublic;
this.openpgpkeysPrivate = PgpStore.openpgpkeysPrivate;
PgpStore = require('Stores/User/Pgp')
;
this.openPgpKeyForDeletion = ko.observable(null).deleteAccessHelper();
/**
* @constructor
*/
function OpenPgpUserSettings()
this.isHttps = window.document && window.document.location ? 'https:' === window.document.location.protocol : false;
}
OpenPgpUserSettings.prototype.addOpenPgpKey = function()
{
kn.showScreenPopup(require('View/Popup/AddOpenPgpKey'));
};
OpenPgpUserSettings.prototype.generateOpenPgpKey = function()
{
kn.showScreenPopup(require('View/Popup/NewOpenPgpKey'));
};
OpenPgpUserSettings.prototype.viewOpenPgpKey = function(oOpenPgpKey)
{
if (oOpenPgpKey)
{
this.openpgpkeys = PgpStore.openpgpkeys;
this.openpgpkeysPublic = PgpStore.openpgpkeysPublic;
this.openpgpkeysPrivate = PgpStore.openpgpkeysPrivate;
this.openPgpKeyForDeletion = ko.observable(null).deleteAccessHelper();
this.isHttps = window.document && window.document.location ? 'https:' === window.document.location.protocol : false;
kn.showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [oOpenPgpKey]);
}
};
OpenPgpUserSettings.prototype.addOpenPgpKey = function ()
/**
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove
*/
OpenPgpUserSettings.prototype.deleteOpenPgpKey = function(oOpenPgpKeyToRemove)
{
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
{
kn.showScreenPopup(require('View/Popup/AddOpenPgpKey'));
};
this.openPgpKeyForDeletion(null);
OpenPgpUserSettings.prototype.generateOpenPgpKey = function ()
{
kn.showScreenPopup(require('View/Popup/NewOpenPgpKey'));
};
OpenPgpUserSettings.prototype.viewOpenPgpKey = function (oOpenPgpKey)
{
if (oOpenPgpKey)
if (oOpenPgpKeyToRemove && PgpStore.openpgpKeyring)
{
kn.showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [oOpenPgpKey]);
}
};
var oFindedItem = _.find(PgpStore.openpgpkeys(), function(oOpenPgpKey) {
return oOpenPgpKeyToRemove === oOpenPgpKey;
});
/**
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove
*/
OpenPgpUserSettings.prototype.deleteOpenPgpKey = function (oOpenPgpKeyToRemove)
{
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
{
this.openPgpKeyForDeletion(null);
if (oOpenPgpKeyToRemove && PgpStore.openpgpKeyring)
if (oFindedItem)
{
var oFindedItem = _.find(PgpStore.openpgpkeys(), function (oOpenPgpKey) {
return oOpenPgpKeyToRemove === oOpenPgpKey;
});
PgpStore.openpgpkeys.remove(oFindedItem);
Utils.delegateRunOnDestroy(oFindedItem);
if (oFindedItem)
{
PgpStore.openpgpkeys.remove(oFindedItem);
Utils.delegateRunOnDestroy(oFindedItem);
PgpStore.openpgpKeyring[oFindedItem.isPrivate ? 'privateKeys' : 'publicKeys']
.removeForId(oFindedItem.guid);
PgpStore.openpgpKeyring[oFindedItem.isPrivate ? 'privateKeys' : 'publicKeys']
.removeForId(oFindedItem.guid);
PgpStore.openpgpKeyring.store();
}
require('App/User').default.reloadOpenPgpKeys();
PgpStore.openpgpKeyring.store();
}
require('App/User').default.reloadOpenPgpKeys();
}
};
}
};
module.exports = OpenPgpUserSettings;
}());
module.exports = OpenPgpUserSettings;

View file

@ -1,76 +1,68 @@
(function () {
var
_ = require('_'),
ko = require('ko'),
'use strict';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
var
_ = require('_'),
ko = require('ko'),
SettinsStore = require('Stores/User/Settings'),
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
Settings = require('Storage/Settings'),
SettinsStore = require('Stores/User/Settings'),
Remote = require('Remote/User/Ajax');
Settings = require('Storage/Settings'),
/**
* @constructor
*/
function SecurityUserSettings()
{
this.capaAutoLogout = Settings.capa(Enums.Capa.AutoLogout);
this.capaTwoFactor = Settings.capa(Enums.Capa.TwoFactor);
Remote = require('Remote/User/Ajax')
;
this.autoLogout = SettinsStore.autoLogout;
this.autoLogout.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
/**
* @constructor
*/
function SecurityUserSettings()
this.autoLogoutOptions = ko.computed(function() {
Translator.trigger();
return [
{'id': 0, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_NEVER_OPTION_NAME')},
{'id': 5, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 5})},
{'id': 10, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 10})},
{'id': 30, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 30})},
{'id': 60, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 60})},
{'id': 60 * 2, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 2})},
{'id': 60 * 5, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 5})},
{'id': 60 * 10, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 10})}
];
});
}
SecurityUserSettings.prototype.configureTwoFactor = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/TwoFactorConfiguration'));
};
SecurityUserSettings.prototype.onBuild = function()
{
if (this.capaAutoLogout)
{
this.capaAutoLogout = Settings.capa(Enums.Capa.AutoLogout);
this.capaTwoFactor = Settings.capa(Enums.Capa.TwoFactor);
var self = this;
this.autoLogout = SettinsStore.autoLogout;
this.autoLogout.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
_.delay(function() {
var
f0 = Utils.settingsSaveHelperSimpleFunction(self.autoLogout.trigger, self);
self.autoLogout.subscribe(function(sValue) {
Remote.saveSettings(f0, {
'AutoLogout': Utils.pInt(sValue)
});
});
this.autoLogoutOptions = ko.computed(function () {
Translator.trigger();
return [
{'id': 0, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_NEVER_OPTION_NAME')},
{'id': 5, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 5})},
{'id': 10, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 10})},
{'id': 30, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 30})},
{'id': 60, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_MINUTES_OPTION_NAME', {'MINUTES': 60})},
{'id': 60 * 2, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 2})},
{'id': 60 * 5, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 5})},
{'id': 60 * 10, 'name': Translator.i18n('SETTINGS_SECURITY/AUTOLOGIN_HOURS_OPTION_NAME', {'HOURS': 10})}
];
});
}
};
SecurityUserSettings.prototype.configureTwoFactor = function ()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/TwoFactorConfiguration'));
};
SecurityUserSettings.prototype.onBuild = function ()
{
if (this.capaAutoLogout)
{
var self = this;
_.delay(function () {
var
f0 = Utils.settingsSaveHelperSimpleFunction(self.autoLogout.trigger, self)
;
self.autoLogout.subscribe(function (sValue) {
Remote.saveSettings(f0, {
'AutoLogout': Utils.pInt(sValue)
});
});
});
}
};
module.exports = SecurityUserSettings;
}());
module.exports = SecurityUserSettings;

View file

@ -1,80 +1,73 @@
(function () {
/**
* @constructor
*/
function SocialUserSettings()
{
var
Utils = require('Common/Utils'),
SocialStore = require('Stores/Social');
'use strict';
this.googleEnable = SocialStore.google.enabled;
this.googleEnableAuth = SocialStore.google.capa.auth;
this.googleEnableAuthFast = SocialStore.google.capa.authFast;
this.googleEnableDrive = SocialStore.google.capa.drive;
this.googleEnablePreview = SocialStore.google.capa.preview;
/**
* @constructor
*/
function SocialUserSettings()
{
var
Utils = require('Common/Utils'),
SocialStore = require('Stores/Social')
;
this.googleActions = SocialStore.google.loading;
this.googleLoggined = SocialStore.google.loggined;
this.googleUserName = SocialStore.google.userName;
this.googleEnable = SocialStore.google.enabled;
this.googleEnableAuth = SocialStore.google.capa.auth;
this.googleEnableAuthFast = SocialStore.google.capa.authFast;
this.googleEnableDrive = SocialStore.google.capa.drive;
this.googleEnablePreview = SocialStore.google.capa.preview;
this.facebookEnable = SocialStore.facebook.enabled;
this.googleActions = SocialStore.google.loading;
this.googleLoggined = SocialStore.google.loggined;
this.googleUserName = SocialStore.google.userName;
this.facebookActions = SocialStore.facebook.loading;
this.facebookLoggined = SocialStore.facebook.loggined;
this.facebookUserName = SocialStore.facebook.userName;
this.facebookEnable = SocialStore.facebook.enabled;
this.twitterEnable = SocialStore.twitter.enabled;
this.facebookActions = SocialStore.facebook.loading;
this.facebookLoggined = SocialStore.facebook.loggined;
this.facebookUserName = SocialStore.facebook.userName;
this.twitterActions = SocialStore.twitter.loading;
this.twitterLoggined = SocialStore.twitter.loggined;
this.twitterUserName = SocialStore.twitter.userName;
this.twitterEnable = SocialStore.twitter.enabled;
this.connectGoogle = Utils.createCommand(this, function() {
if (!this.googleLoggined())
{
require('App/User').default.googleConnect();
}
}, function() {
return !this.googleLoggined() && !this.googleActions();
});
this.twitterActions = SocialStore.twitter.loading;
this.twitterLoggined = SocialStore.twitter.loggined;
this.twitterUserName = SocialStore.twitter.userName;
this.disconnectGoogle = Utils.createCommand(this, function() {
require('App/User').default.googleDisconnect();
});
this.connectGoogle = Utils.createCommand(this, function () {
if (!this.googleLoggined())
{
require('App/User').default.googleConnect();
}
}, function () {
return !this.googleLoggined() && !this.googleActions();
});
this.connectFacebook = Utils.createCommand(this, function() {
if (!this.facebookLoggined())
{
require('App/User').default.facebookConnect();
}
}, function() {
return !this.facebookLoggined() && !this.facebookActions();
});
this.disconnectGoogle = Utils.createCommand(this, function () {
require('App/User').default.googleDisconnect();
});
this.disconnectFacebook = Utils.createCommand(this, function() {
require('App/User').default.facebookDisconnect();
});
this.connectFacebook = Utils.createCommand(this, function () {
if (!this.facebookLoggined())
{
require('App/User').default.facebookConnect();
}
}, function () {
return !this.facebookLoggined() && !this.facebookActions();
});
this.connectTwitter = Utils.createCommand(this, function() {
if (!this.twitterLoggined())
{
require('App/User').default.twitterConnect();
}
}, function() {
return !this.twitterLoggined() && !this.twitterActions();
});
this.disconnectFacebook = Utils.createCommand(this, function () {
require('App/User').default.facebookDisconnect();
});
this.disconnectTwitter = Utils.createCommand(this, function() {
require('App/User').default.twitterDisconnect();
});
}
this.connectTwitter = Utils.createCommand(this, function () {
if (!this.twitterLoggined())
{
require('App/User').default.twitterConnect();
}
}, function () {
return !this.twitterLoggined() && !this.twitterActions();
});
this.disconnectTwitter = Utils.createCommand(this, function () {
require('App/User').default.twitterDisconnect();
});
}
module.exports = SocialUserSettings;
}());
module.exports = SocialUserSettings;

View file

@ -1,107 +1,98 @@
(function () {
var
ko = require('ko'),
'use strict';
Translator = require('Common/Translator'),
var
ko = require('ko'),
TemplateStore = require('Stores/User/Template'),
Translator = require('Common/Translator'),
Remote = require('Remote/User/Ajax');
TemplateStore = require('Stores/User/Template'),
/**
* @constructor
*/
function TemplatesUserSettings()
{
this.templates = TemplateStore.templates;
Remote = require('Remote/User/Ajax')
;
this.processText = ko.computed(function() {
return TemplateStore.templates.loading() ? Translator.i18n('SETTINGS_TEMPLETS/LOADING_PROCESS') : '';
}, this);
/**
* @constructor
*/
function TemplatesUserSettings()
this.visibility = ko.computed(function() {
return '' === this.processText() ? 'hidden' : 'visible';
}, this);
this.templateForDeletion = ko.observable(null).deleteAccessHelper();
}
TemplatesUserSettings.prototype.scrollableOptions = function(sWrapper)
{
return {
handle: '.drag-handle',
containment: sWrapper || 'parent',
axis: 'y'
};
};
TemplatesUserSettings.prototype.addNewTemplate = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Template'));
};
TemplatesUserSettings.prototype.editTemplate = function(oTemplateItem)
{
if (oTemplateItem)
{
this.templates = TemplateStore.templates;
this.processText = ko.computed(function () {
return TemplateStore.templates.loading() ? Translator.i18n('SETTINGS_TEMPLETS/LOADING_PROCESS') : '';
}, this);
this.visibility = ko.computed(function () {
return '' === this.processText() ? 'hidden' : 'visible';
}, this);
this.templateForDeletion = ko.observable(null).deleteAccessHelper();
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Template'), [oTemplateItem]);
}
};
TemplatesUserSettings.prototype.scrollableOptions = function (sWrapper)
/**
* @param {AccountModel} oTemplateToRemove
*/
TemplatesUserSettings.prototype.deleteTemplate = function(oTemplateToRemove)
{
if (oTemplateToRemove && oTemplateToRemove.deleteAccess())
{
return {
handle: '.drag-handle',
containment: sWrapper || 'parent',
axis: 'y'
};
};
this.templateForDeletion(null);
TemplatesUserSettings.prototype.addNewTemplate = function ()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Template'));
};
var
self = this,
fRemoveAccount = function(oAccount) {
return oTemplateToRemove === oAccount;
};
TemplatesUserSettings.prototype.editTemplate = function (oTemplateItem)
{
if (oTemplateItem)
if (oTemplateToRemove)
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Template'), [oTemplateItem]);
this.templates.remove(fRemoveAccount);
Remote.templateDelete(function() {
self.reloadTemplates();
}, oTemplateToRemove.id);
}
};
}
};
/**
* @param {AccountModel} oTemplateToRemove
*/
TemplatesUserSettings.prototype.deleteTemplate = function (oTemplateToRemove)
{
if (oTemplateToRemove && oTemplateToRemove.deleteAccess())
{
this.templateForDeletion(null);
TemplatesUserSettings.prototype.reloadTemplates = function()
{
require('App/User').default.templates();
};
var
self = this,
fRemoveAccount = function (oAccount) {
return oTemplateToRemove === oAccount;
}
;
TemplatesUserSettings.prototype.onBuild = function(oDom)
{
var self = this;
if (oTemplateToRemove)
oDom
.on('click', '.templates-list .template-item .e-action', function() {
var oTemplateItem = ko.dataFor(this);
if (oTemplateItem)
{
this.templates.remove(fRemoveAccount);
Remote.templateDelete(function () {
self.reloadTemplates();
}, oTemplateToRemove.id);
self.editTemplate(oTemplateItem);
}
}
};
});
TemplatesUserSettings.prototype.reloadTemplates = function ()
{
require('App/User').default.templates();
};
this.reloadTemplates();
};
TemplatesUserSettings.prototype.onBuild = function (oDom)
{
var self = this;
oDom
.on('click', '.templates-list .template-item .e-action', function () {
var oTemplateItem = ko.dataFor(this);
if (oTemplateItem)
{
self.editTemplate(oTemplateItem);
}
})
;
this.reloadTemplates();
};
module.exports = TemplatesUserSettings;
}());
module.exports = TemplatesUserSettings;

View file

@ -1,185 +1,177 @@
(function () {
var
_ = require('_'),
$ = require('$'),
ko = require('ko'),
'use strict';
Jua = require('Jua'),
var
_ = require('_'),
$ = require('$'),
ko = require('ko'),
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Links = require('Common/Links'),
Translator = require('Common/Translator'),
Jua = require('Jua'),
ThemeStore = require('Stores/Theme'),
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Links = require('Common/Links'),
Translator = require('Common/Translator'),
Settings = require('Storage/Settings'),
ThemeStore = require('Stores/Theme'),
Remote = require('Remote/User/Ajax');
Settings = require('Storage/Settings'),
/**
* @constructor
*/
function ThemesUserSettings()
{
this.theme = ThemeStore.theme;
this.themes = ThemeStore.themes;
this.themesObjects = ko.observableArray([]);
Remote = require('Remote/User/Ajax')
;
this.background = {};
this.background.name = ThemeStore.themeBackgroundName;
this.background.hash = ThemeStore.themeBackgroundHash;
this.background.uploaderButton = ko.observable(null);
this.background.loading = ko.observable(false);
this.background.error = ko.observable('');
/**
* @constructor
*/
function ThemesUserSettings()
this.capaUserBackground = ko.observable(Settings.capa(Enums.Capa.UserBackground));
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
this.iTimer = 0;
this.oThemeAjaxRequest = null;
this.theme.subscribe(function(sValue) {
_.each(this.themesObjects(), function(oTheme) {
oTheme.selected(sValue === oTheme.name);
});
Utils.changeTheme(sValue, this.themeTrigger);
Remote.saveSettings(null, {
'Theme': sValue
});
}, this);
this.background.hash.subscribe(function(sValue) {
var $oBg = $('#rl-bg');
if (!sValue)
{
if ($oBg.data('backstretch'))
{
$oBg.backstretch('destroy').attr('style', '');
}
}
else
{
$('#rl-bg').attr('style', 'background-image: none !important;').backstretch(
Links.userBackground(sValue), {
'fade': 1000, 'centeredX': true, 'centeredY': true
}).removeAttr('style');
}
}, this);
}
ThemesUserSettings.prototype.onBuild = function()
{
var sCurrentTheme = this.theme();
this.themesObjects(_.map(this.themes(), function(sTheme) {
return {
'name': sTheme,
'nameDisplay': Utils.convertThemeName(sTheme),
'selected': ko.observable(sTheme === sCurrentTheme),
'themePreviewSrc': Links.themePreviewLink(sTheme)
};
}));
this.initUploader();
};
ThemesUserSettings.prototype.onShow = function()
{
this.background.error('');
};
ThemesUserSettings.prototype.clearBackground = function()
{
if (this.capaUserBackground())
{
this.theme = ThemeStore.theme;
this.themes = ThemeStore.themes;
this.themesObjects = ko.observableArray([]);
this.background = {};
this.background.name = ThemeStore.themeBackgroundName;
this.background.hash = ThemeStore.themeBackgroundHash;
this.background.uploaderButton = ko.observable(null);
this.background.loading = ko.observable(false);
this.background.error = ko.observable('');
this.capaUserBackground = ko.observable(Settings.capa(Enums.Capa.UserBackground));
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
this.iTimer = 0;
this.oThemeAjaxRequest = null;
this.theme.subscribe(function (sValue) {
_.each(this.themesObjects(), function (oTheme) {
oTheme.selected(sValue === oTheme.name);
});
Utils.changeTheme(sValue, this.themeTrigger);
Remote.saveSettings(null, {
'Theme': sValue
});
}, this);
this.background.hash.subscribe(function (sValue) {
var $oBg = $('#rl-bg');
if (!sValue)
{
if ($oBg.data('backstretch'))
{
$oBg.backstretch('destroy').attr('style', '');
}
}
else
{
$('#rl-bg').attr('style', 'background-image: none !important;').backstretch(
Links.userBackground(sValue), {
'fade': 1000, 'centeredX': true, 'centeredY': true
}).removeAttr('style');
}
}, this);
var self = this;
Remote.clearUserBackground(function() {
self.background.name('');
self.background.hash('');
});
}
};
ThemesUserSettings.prototype.onBuild = function ()
ThemesUserSettings.prototype.initUploader = function()
{
if (this.background.uploaderButton() && this.capaUserBackground())
{
var sCurrentTheme = this.theme();
this.themesObjects(_.map(this.themes(), function (sTheme) {
return {
'name': sTheme,
'nameDisplay': Utils.convertThemeName(sTheme),
'selected': ko.observable(sTheme === sCurrentTheme),
'themePreviewSrc': Links.themePreviewLink(sTheme)
};
}));
this.initUploader();
};
ThemesUserSettings.prototype.onShow = function ()
{
this.background.error('');
};
ThemesUserSettings.prototype.clearBackground = function ()
{
if (this.capaUserBackground())
{
var self = this;
Remote.clearUserBackground(function () {
self.background.name('');
self.background.hash('');
var
oJua = new Jua({
'action': Links.uploadBackground(),
'name': 'uploader',
'queueSize': 1,
'multipleSizeLimit': 1,
'disableDragAndDrop': true,
'disableMultiple': true,
'clickElement': this.background.uploaderButton()
});
}
};
ThemesUserSettings.prototype.initUploader = function ()
{
if (this.background.uploaderButton() && this.capaUserBackground())
{
var
oJua = new Jua({
'action': Links.uploadBackground(),
'name': 'uploader',
'queueSize': 1,
'multipleSizeLimit': 1,
'disableDragAndDrop': true,
'disableMultiple': true,
'clickElement': this.background.uploaderButton()
})
;
oJua
.on('onStart', _.bind(function() {
oJua
.on('onStart', _.bind(function () {
this.background.loading(true);
this.background.error('');
this.background.loading(true);
this.background.error('');
return true;
return true;
}, this))
.on('onComplete', _.bind(function(sId, bResult, oData) {
}, this))
.on('onComplete', _.bind(function (sId, bResult, oData) {
this.background.loading(false);
this.background.loading(false);
if (bResult && sId && oData && oData.Result && oData.Result.Name && oData.Result.Hash)
{
this.background.name(oData.Result.Name);
this.background.hash(oData.Result.Hash);
}
else
{
this.background.name('');
this.background.hash('');
if (bResult && sId && oData && oData.Result && oData.Result.Name && oData.Result.Hash)
var sError = '';
if (oData.ErrorCode)
{
this.background.name(oData.Result.Name);
this.background.hash(oData.Result.Hash);
}
else
{
this.background.name('');
this.background.hash('');
var sError = '';
if (oData.ErrorCode)
switch (oData.ErrorCode)
{
switch (oData.ErrorCode)
{
case Enums.UploadErrorCode.FileIsTooBig:
sError = Translator.i18n('SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG');
break;
case Enums.UploadErrorCode.FileType:
sError = Translator.i18n('SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR');
break;
}
case Enums.UploadErrorCode.FileIsTooBig:
sError = Translator.i18n('SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG');
break;
case Enums.UploadErrorCode.FileType:
sError = Translator.i18n('SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR');
break;
// no default
}
if (!sError && oData.ErrorMessage)
{
sError = oData.ErrorMessage;
}
this.background.error(sError || Translator.i18n('SETTINGS_THEMES/ERROR_UNKNOWN'));
}
return true;
if (!sError && oData.ErrorMessage)
{
sError = oData.ErrorMessage;
}
}, this))
;
}
};
this.background.error(sError || Translator.i18n('SETTINGS_THEMES/ERROR_UNKNOWN'));
}
module.exports = ThemesUserSettings;
return true;
}());
}, this));
}
};
module.exports = ThemesUserSettings;