Code refactoring (5) (es5 -> es2015)

This commit is contained in:
RainLoop Team 2016-07-16 00:29:42 +03:00
parent c148e19ea3
commit cec53b111f
68 changed files with 2210 additions and 2472 deletions

View file

@ -1,3 +1,4 @@
module.exports = {
'extends': 'eslint:recommended',
'ecmaFeatures': {
@ -14,18 +15,7 @@ module.exports = {
'browser': true
},
'globals': {
'RL_COMMUNITY': true,
'ko': true,
'ssm': true,
'moment': true,
'ifvisible': true,
'crossroads': true,
'hasher': true,
'key': true,
'Jua': true,
'_': true,
'$': true,
'Dropbox': true
'RL_COMMUNITY': true
},
// http://eslint.org/docs/rules/
'rules': {
@ -166,7 +156,7 @@ module.exports = {
'array-bracket-spacing': 2,
'block-spacing': [2, 'never'],
// 'brace-style': [2, 'allman'],
// 'camelcase': 2,
'camelcase': 2,
'comma-dangle': [2, 'never'],
'comma-spacing': 2,
'comma-style': 2,
@ -234,9 +224,9 @@ module.exports = {
// 'one-var': [2, {
// 'var': 'always',
// 'let': 'always',
// 'const': 'never'
// 'const': 'always'
// }],
// 'one-var-declaration-per-line': [2, 'always'],
'one-var-declaration-per-line': [2, 'always'],
'operator-assignment': 2,
'operator-linebreak': [2, 'after'],
// 'padded-blocks': [2, 'never'],
@ -284,7 +274,7 @@ module.exports = {
// 'prefer-template': 2,
'require-yield': 2,
'rest-spread-spacing': 2,
'sort-imports': 0,
'sort-imports': 0, // off
'template-curly-spacing': 2,
'yield-star-spacing': 2
}

View file

@ -27,8 +27,7 @@ import {AbstractApp} from 'App/Abstract';
class AdminApp extends AbstractApp
{
constructor()
{
constructor() {
super(Remote);
}

View file

@ -66,8 +66,7 @@ import {AbstractApp} from 'App/Abstract';
class AppUser extends AbstractApp
{
constructor()
{
constructor() {
super(Remote);
this.moveCache = {};

View file

@ -8,8 +8,7 @@ import {trim} from 'Common/Utils';
class Audio
{
constructor()
{
constructor() {
this.notificator = null;
this.supportedMp3 = false;

View file

@ -158,8 +158,8 @@ const Base64 = {
return string;
}
};
/* eslint-enable */
export const decode = Base64.decode;
export const encode = Base64.encode;
export const urlsafe_encode = Base64.urlsafe_encode;
/* eslint-enable */

View file

@ -10,10 +10,12 @@ import {getHash, setHash, clearHash} from 'Storage/RainLoop';
let RL_APP_DATA_STORAGE = null;
/* eslint-disable */
window.__rlah = () => getHash();
window.__rlah_set = () => setHash();
window.__rlah_clear = () => clearHash();
window.__rlah_data = () => RL_APP_DATA_STORAGE;
/* eslint-enable */
/**
* @param {string} id

View file

@ -7,8 +7,7 @@ import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
class LocalStorageDriver
{
constructor()
{
constructor() {
this.s = window.localStorage || null;
}

View file

@ -82,15 +82,20 @@ export const bAnimationSupported = !bMobileDevice && $html.hasClass('csstransiti
*/
export const bXMLHttpRequestSupported = !!window.XMLHttpRequest;
/**
* @type {boolean}
*/
export const bIsHttps = window.document && window.document.location ? 'https:' === window.document.location.protocol : false;
/**
* @type {Object}
*/
export const oHtmlEditorDefaultConfig = {
title: false,
stylesSet: false,
customConfig: '',
contentsCss: '',
toolbarGroups: [
'title': false,
'stylesSet': false,
'customConfig': '',
'contentsCss': '',
'toolbarGroups': [
{name: 'spec'},
{name: 'styles'},
{name: 'basicstyles', groups: ['basicstyles', 'cleanup', 'bidi']},
@ -102,54 +107,54 @@ export const oHtmlEditorDefaultConfig = {
{name: 'others'}
],
removePlugins: 'liststyle',
removeButtons: 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll,Source',
removeDialogTabs: 'link:advanced;link:target;image:advanced;images:advanced',
'removePlugins': 'liststyle',
'removeButtons': 'Format,Undo,Redo,Cut,Copy,Paste,Anchor,Strike,Subscript,Superscript,Image,SelectAll,Source',
'removeDialogTabs': 'link:advanced;link:target;image:advanced;images:advanced',
extraPlugins: 'plain,signature',
'extraPlugins': 'plain,signature',
allowedContent: true,
extraAllowedContent: true,
'allowedContent': true,
'extraAllowedContent': true,
fillEmptyBlocks: false,
ignoreEmptyParagraph: true,
disableNativeSpellChecker: false,
'fillEmptyBlocks': false,
'ignoreEmptyParagraph': true,
'disableNativeSpellChecker': false,
font_defaultLabel: 'Arial',
fontSize_defaultLabel: '13',
fontSize_sizes: '10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px'
'font_defaultLabel': 'Arial',
'fontSize_defaultLabel': '13',
'fontSize_sizes': '10/10px;12/12px;13/13px;14/14px;16/16px;18/18px;20/20px;24/24px;28/28px;36/36px;48/48px'
};
/**
* @type {Object}
*/
export const oHtmlEditorLangsMap = {
bg_bg: 'bg',
de_de: 'de',
el_gr: 'el',
es_es: 'es',
fr_fr: 'fr',
hu_hu: 'hu',
is_is: 'is',
it_it: 'it',
ja_jp: 'ja',
ko_kr: 'ko',
lt_lt: 'lt',
lv_lv: 'lv',
nl_nl: 'nl',
bg_no: 'no',
pl_pl: 'pl',
pt_pt: 'pt',
pt_br: 'pt-br',
ro_ro: 'ro',
ru_ru: 'ru',
sk_sk: 'sk',
sl_si: 'sl',
sv_se: 'sv',
tr_tr: 'tr',
uk_ua: 'ru',
zh_tw: 'zh',
zh_cn: 'zh-cn'
'bg_bg': 'bg',
'de_de': 'de',
'el_gr': 'el',
'es_es': 'es',
'fr_fr': 'fr',
'hu_hu': 'hu',
'is_is': 'is',
'it_it': 'it',
'ja_jp': 'ja',
'ko_kr': 'ko',
'lt_lt': 'lt',
'lv_lv': 'lv',
'nl_nl': 'nl',
'bg_no': 'no',
'pl_pl': 'pl',
'pt_pt': 'pt',
'pt_br': 'pt-br',
'ro_ro': 'ro',
'ru_ru': 'ru',
'sk_sk': 'sk',
'sl_si': 'sl',
'sv_se': 'sv',
'tr_tr': 'tr',
'uk_ua': 'ru',
'zh_tw': 'zh',
'zh_cn': 'zh-cn'
};
/**

View file

@ -163,12 +163,12 @@ export function i18nToNodes(elements, animate = false)
if (animate && bAnimationSupported)
{
$('.i18n-animation[data-i18n]', elements).letterfx({
fx: 'fall fade',
backwards: false,
timing: 50,
fx_duration: '50ms',
letter_end: 'restore',
element_end: 'restore'
'fx': 'fall fade',
'backwards': false,
'timing': 50,
'fx_duration': '50ms',
'letter_end': 'restore',
'element_end': 'restore'
});
}
});

View file

@ -145,7 +145,10 @@ export function encodeURI(url)
*/
export function simpleQueryParser(queryString)
{
let index = 0, len = 0, temp = null;
let
index = 0,
len = 0,
temp = null;
const
queries = queryString.split('&'),
@ -498,7 +501,7 @@ export function delegateRun(object, methodName, params, delay = 0)
/**
* @param {?} event
*/
export function kill_CtrlA_CtrlS(event)
export function killCtrlACtrlS(event)
{
event = event || window.event;
if (event && event.ctrlKey && !event.shiftKey && !event.altKey)
@ -1055,8 +1058,8 @@ export function plainToHtml(plain, findEmailAndLinksInText = false)
return findEmailAndLinksInText ? findEmailAndLinks(plain) : plain;
}
window.rainloop_Utils_htmlToPlain = htmlToPlain;
window.rainloop_Utils_plainToHtml = plainToHtml;
window['rainloop_Utils_htmlToPlain'] = htmlToPlain; // eslint-disable-line dot-notation
window['rainloop_Utils_plainToHtml'] = plainToHtml; // eslint-disable-line dot-notation
/**
* @param {Array} aSystem
@ -1195,7 +1198,10 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
*/
export function selectElement(element)
{
let sel = null, range = null;
let
sel = null,
range = null;
if (window.getSelection)
{
sel = window.getSelection();

5
dev/External/ko.js vendored
View file

@ -1210,6 +1210,11 @@ ko.extenders.idleTrigger = function(oTarget)
// functions
ko.observable.fn.idleTrigger = function()
{
return this.extend({'idleTrigger': true});
};
ko.observable.fn.validateNone = function()
{
this.hasError = ko.observable(false);

View file

@ -9,10 +9,11 @@ import {EmailModel} from 'Model/Email';
* @returns {string}
*/
export function emailArrayToString(emails, friendlyView = false, wrapWithLink = false) {
let
index = 0,
len = 0;
let index = 0, len = 0;
const result = [];
if (isNonEmptyArray(emails))
{
for (len = emails.length; index < len; index++)
@ -29,10 +30,11 @@ export function emailArrayToString(emails, friendlyView = false, wrapWithLink =
* @returns {string}
*/
export function emailArrayToStringClear(emails) {
let
index = 0,
len = 0;
let index = 0, len = 0;
const result = [];
if (isNonEmptyArray(emails))
{
for (len = emails.length; index < len; index++)
@ -52,10 +54,12 @@ export function emailArrayToStringClear(emails) {
* @returns {Array.<EmailModel>}
*/
export function emailArrayFromJson(json) {
let
index = 0,
len = 0,
email = null;
let index = 0, len = 0, email = null;
const result = [];
if (isNonEmptyArray(json))
{
for (index = 0, len = json.length; index < len; index++)

View file

@ -233,8 +233,7 @@ export const staticCombinedIconClass = (data) => {
class AttachmentModel extends AbstractModel
{
constructor()
{
constructor() {
super('AttachmentModel');
this.checked = ko.observable(false);

View file

@ -10,8 +10,7 @@ import {AbstractModel} from 'Knoin/AbstractModel';
class ContactModel extends AbstractModel
{
constructor()
{
constructor() {
super('ContactModel');
this.idContact = 0;

View file

@ -12,8 +12,7 @@ import {AbstractModel} from 'Knoin/AbstractModel';
class FilterModel extends AbstractModel
{
constructor()
{
constructor() {
super('FilterModel');
this.enabled = ko.observable(true);

View file

@ -8,8 +8,7 @@ import {AbstractModel} from 'Knoin/AbstractModel';
class FilterConditionModel extends AbstractModel
{
constructor()
{
constructor() {
super('FilterConditionModel');
this.field = ko.observable(FilterConditionField.From);

View file

@ -12,8 +12,7 @@ import {AbstractModel} from 'Knoin/AbstractModel';
class FolderModel extends AbstractModel
{
constructor()
{
constructor() {
super('FolderModel');
this.name = ko.observable('');

View file

@ -20,8 +20,7 @@ import {AbstractModel} from 'Knoin/AbstractModel';
class MessageModel extends AbstractModel
{
constructor()
{
constructor() {
super('MessageModel');
this.folderFullNameRaw = '';

View file

@ -81,8 +81,11 @@ AbstractAjaxPromises.prototype.ajaxRequest = function(sAction, bPost, iTimeOut,
timeout: iTimeOut,
global: true
}).always(function(oData, sTextStatus) {
var
bCached = false,
oErrorData = null,
sType = Enums.StorageResultType.Error;
var bCached = false, oErrorData = null, sType = Enums.StorageResultType.Error;
if (oData && oData.Time)
{
bCached = Utils.pInt(oData.Time) > Utils.microtime() - iStart;

View file

@ -83,10 +83,10 @@ AbstractAjaxRemote.prototype.defaultResponse = function(fCallback, sRequestActio
Globals.data.iTokenErrorCount = 0;
}
if (fCallback)
{
Plugins.runHook('ajax-default-response', [sRequestAction, Enums.StorageResultType.Success === sType ? oData : null, sType, bCached, oRequestParameters]);
if (fCallback)
{
fCallback(
sType,
Enums.StorageResultType.Success === sType ? oData : null,

View file

@ -10,21 +10,21 @@ var
* @constructor
* @extends AbstractAjaxRemote
*/
function RemoteAdminStorage()
function RemoteAdminAjax()
{
AbstractAjaxRemote.call(this);
this.oRequests = {};
}
_.extend(RemoteAdminStorage.prototype, AbstractAjaxRemote.prototype);
_.extend(RemoteAdminAjax.prototype, AbstractAjaxRemote.prototype);
/**
* @param {?Function} fCallback
* @param {string} sLogin
* @param {string} sPassword
*/
RemoteAdminStorage.prototype.adminLogin = function(fCallback, sLogin, sPassword)
RemoteAdminAjax.prototype.adminLogin = function(fCallback, sLogin, sPassword)
{
this.defaultRequest(fCallback, 'AdminLogin', {
'Login': sLogin,
@ -35,7 +35,7 @@ RemoteAdminStorage.prototype.adminLogin = function(fCallback, sLogin, sPassword)
/**
* @param {?Function} fCallback
*/
RemoteAdminStorage.prototype.adminLogout = function(fCallback)
RemoteAdminAjax.prototype.adminLogout = function(fCallback)
{
this.defaultRequest(fCallback, 'AdminLogout');
};
@ -44,16 +44,31 @@ RemoteAdminStorage.prototype.adminLogout = function(fCallback)
* @param {?Function} fCallback
* @param {?} oData
*/
RemoteAdminStorage.prototype.saveAdminConfig = function(fCallback, oData)
RemoteAdminAjax.prototype.saveAdminConfig = function(fCallback, oData)
{
this.defaultRequest(fCallback, 'AdminSettingsUpdate', oData);
};
/**
* @param {string} key
* @param {?Function} valueFn
* @param {?Function} fn
*/
RemoteAdminAjax.prototype.saveAdminConfigHelper = function(key, valueFn, fn)
{
var self = this;
return function(value) {
var data = {};
data[key] = valueFn ? valueFn(value) : value;
self.saveAdminConfig(fn || null, data);
};
};
/**
* @param {?Function} fCallback
* @param {boolean=} bIncludeAliases = true
*/
RemoteAdminStorage.prototype.domainList = function(fCallback, bIncludeAliases)
RemoteAdminAjax.prototype.domainList = function(fCallback, bIncludeAliases)
{
bIncludeAliases = Utils.isUnd(bIncludeAliases) ? true : bIncludeAliases;
this.defaultRequest(fCallback, 'AdminDomainList', {
@ -64,7 +79,7 @@ RemoteAdminStorage.prototype.domainList = function(fCallback, bIncludeAliases)
/**
* @param {?Function} fCallback
*/
RemoteAdminStorage.prototype.pluginList = function(fCallback)
RemoteAdminAjax.prototype.pluginList = function(fCallback)
{
this.defaultRequest(fCallback, 'AdminPluginList');
};
@ -72,7 +87,7 @@ RemoteAdminStorage.prototype.pluginList = function(fCallback)
/**
* @param {?Function} fCallback
*/
RemoteAdminStorage.prototype.packagesList = function(fCallback)
RemoteAdminAjax.prototype.packagesList = function(fCallback)
{
this.defaultRequest(fCallback, 'AdminPackagesList');
};
@ -80,7 +95,7 @@ RemoteAdminStorage.prototype.packagesList = function(fCallback)
/**
* @param {?Function} fCallback
*/
RemoteAdminStorage.prototype.coreData = function(fCallback)
RemoteAdminAjax.prototype.coreData = function(fCallback)
{
this.defaultRequest(fCallback, 'AdminCoreData');
};
@ -88,7 +103,7 @@ RemoteAdminStorage.prototype.coreData = function(fCallback)
/**
* @param {?Function} fCallback
*/
RemoteAdminStorage.prototype.updateCoreData = function(fCallback)
RemoteAdminAjax.prototype.updateCoreData = function(fCallback)
{
this.defaultRequest(fCallback, 'AdminUpdateCoreData', {}, 90000);
};
@ -97,7 +112,7 @@ RemoteAdminStorage.prototype.updateCoreData = function(fCallback)
* @param {?Function} fCallback
* @param {Object} oPackage
*/
RemoteAdminStorage.prototype.packageInstall = function(fCallback, oPackage)
RemoteAdminAjax.prototype.packageInstall = function(fCallback, oPackage)
{
this.defaultRequest(fCallback, 'AdminPackageInstall', {
'Id': oPackage.id,
@ -110,7 +125,7 @@ RemoteAdminStorage.prototype.packageInstall = function(fCallback, oPackage)
* @param {?Function} fCallback
* @param {Object} oPackage
*/
RemoteAdminStorage.prototype.packageDelete = function(fCallback, oPackage)
RemoteAdminAjax.prototype.packageDelete = function(fCallback, oPackage)
{
this.defaultRequest(fCallback, 'AdminPackageDelete', {
'Id': oPackage.id
@ -121,7 +136,7 @@ RemoteAdminStorage.prototype.packageDelete = function(fCallback, oPackage)
* @param {?Function} fCallback
* @param {string} sName
*/
RemoteAdminStorage.prototype.domain = function(fCallback, sName)
RemoteAdminAjax.prototype.domain = function(fCallback, sName)
{
this.defaultRequest(fCallback, 'AdminDomainLoad', {
'Name': sName
@ -132,7 +147,7 @@ RemoteAdminStorage.prototype.domain = function(fCallback, sName)
* @param {?Function} fCallback
* @param {string} sName
*/
RemoteAdminStorage.prototype.plugin = function(fCallback, sName)
RemoteAdminAjax.prototype.plugin = function(fCallback, sName)
{
this.defaultRequest(fCallback, 'AdminPluginLoad', {
'Name': sName
@ -143,7 +158,7 @@ RemoteAdminStorage.prototype.plugin = function(fCallback, sName)
* @param {?Function} fCallback
* @param {string} sName
*/
RemoteAdminStorage.prototype.domainDelete = function(fCallback, sName)
RemoteAdminAjax.prototype.domainDelete = function(fCallback, sName)
{
this.defaultRequest(fCallback, 'AdminDomainDelete', {
'Name': sName
@ -155,7 +170,7 @@ RemoteAdminStorage.prototype.domainDelete = function(fCallback, sName)
* @param {string} sName
* @param {boolean} bDisabled
*/
RemoteAdminStorage.prototype.domainDisable = function(fCallback, sName, bDisabled)
RemoteAdminAjax.prototype.domainDisable = function(fCallback, sName, bDisabled)
{
return this.defaultRequest(fCallback, 'AdminDomainDisable', {
Name: sName,
@ -167,7 +182,7 @@ RemoteAdminStorage.prototype.domainDisable = function(fCallback, sName, bDisable
* @param {?Function} fCallback
* @param {Object} oConfig
*/
RemoteAdminStorage.prototype.pluginSettingsUpdate = function(fCallback, oConfig)
RemoteAdminAjax.prototype.pluginSettingsUpdate = function(fCallback, oConfig)
{
return this.defaultRequest(fCallback, 'AdminPluginSettingsUpdate', oConfig);
};
@ -176,7 +191,7 @@ RemoteAdminStorage.prototype.pluginSettingsUpdate = function(fCallback, oConfig)
* @param {?Function} fCallback
* @param {boolean} bForce
*/
RemoteAdminStorage.prototype.licensing = function(fCallback, bForce)
RemoteAdminAjax.prototype.licensing = function(fCallback, bForce)
{
return this.defaultRequest(fCallback, 'AdminLicensing', {
Force: bForce ? '1' : '0'
@ -188,7 +203,7 @@ RemoteAdminStorage.prototype.licensing = function(fCallback, bForce)
* @param {string} sDomain
* @param {string} sKey
*/
RemoteAdminStorage.prototype.licensingActivate = function(fCallback, sDomain, sKey)
RemoteAdminAjax.prototype.licensingActivate = function(fCallback, sDomain, sKey)
{
return this.defaultRequest(fCallback, 'AdminLicensingActivate', {
Domain: sDomain,
@ -201,7 +216,7 @@ RemoteAdminStorage.prototype.licensingActivate = function(fCallback, sDomain, sK
* @param {string} sName
* @param {boolean} bDisabled
*/
RemoteAdminStorage.prototype.pluginDisable = function(fCallback, sName, bDisabled)
RemoteAdminAjax.prototype.pluginDisable = function(fCallback, sName, bDisabled)
{
return this.defaultRequest(fCallback, 'AdminPluginDisable', {
Name: sName,
@ -209,7 +224,7 @@ RemoteAdminStorage.prototype.pluginDisable = function(fCallback, sName, bDisable
});
};
RemoteAdminStorage.prototype.createDomainAlias = function(fCallback, sName, sAlias)
RemoteAdminAjax.prototype.createDomainAlias = function(fCallback, sName, sAlias)
{
this.defaultRequest(fCallback, 'AdminDomainAliasSave', {
Name: sName,
@ -217,7 +232,7 @@ RemoteAdminStorage.prototype.createDomainAlias = function(fCallback, sName, sAli
});
};
RemoteAdminStorage.prototype.createOrUpdateDomain = function(fCallback,
RemoteAdminAjax.prototype.createOrUpdateDomain = function(fCallback,
bCreate, sName,
sIncHost, iIncPort, sIncSecure, bIncShortLogin,
bUseSieve, sSieveAllowRaw, sSieveHost, iSievePort, sSieveSecure,
@ -250,7 +265,7 @@ RemoteAdminStorage.prototype.createOrUpdateDomain = function(fCallback,
});
};
RemoteAdminStorage.prototype.testConnectionForDomain = function(fCallback, sName,
RemoteAdminAjax.prototype.testConnectionForDomain = function(fCallback, sName,
sIncHost, iIncPort, sIncSecure,
bUseSieve, sSieveHost, iSievePort, sSieveSecure,
sOutHost, iOutPort, sOutSecure, bOutAuth, bOutPhpMail)
@ -276,7 +291,7 @@ RemoteAdminStorage.prototype.testConnectionForDomain = function(fCallback, sName
* @param {?Function} fCallback
* @param {?} oData
*/
RemoteAdminStorage.prototype.testContacts = function(fCallback, oData)
RemoteAdminAjax.prototype.testContacts = function(fCallback, oData)
{
this.defaultRequest(fCallback, 'AdminContactsTest', oData);
};
@ -285,7 +300,7 @@ RemoteAdminStorage.prototype.testContacts = function(fCallback, oData)
* @param {?Function} fCallback
* @param {?} oData
*/
RemoteAdminStorage.prototype.saveNewAdminPassword = function(fCallback, oData)
RemoteAdminAjax.prototype.saveNewAdminPassword = function(fCallback, oData)
{
this.defaultRequest(fCallback, 'AdminPasswordUpdate', oData);
};
@ -293,9 +308,9 @@ RemoteAdminStorage.prototype.saveNewAdminPassword = function(fCallback, oData)
/**
* @param {?Function} fCallback
*/
RemoteAdminStorage.prototype.adminPing = function(fCallback)
RemoteAdminAjax.prototype.adminPing = function(fCallback)
{
this.defaultRequest(fCallback, 'AdminPing');
};
module.exports = new RemoteAdminStorage();
module.exports = new RemoteAdminAjax();

View file

@ -669,6 +669,21 @@ RemoteUserAjax.prototype.saveSettings = function(fCallback, oData)
this.defaultRequest(fCallback, 'SettingsUpdate', oData);
};
/**
* @param {string} key
* @param {?Function} valueFn
* @param {?Function} fn
*/
RemoteUserAjax.prototype.saveSettingsHelper = function(key, valueFn, fn)
{
var self = this;
return function(value) {
var data = {};
data[key] = valueFn ? valueFn(value) : value;
self.saveSettings(fn || null, data);
};
};
/**
* @param {?Function} fCallback
* @param {string} sPrevPassword

View file

@ -4,8 +4,7 @@ import App from 'App/Admin';
class LoginAdminScreen extends AbstractScreen
{
constructor()
{
constructor() {
super('login', [
require('View/Admin/Login')
]);

View file

@ -13,12 +13,11 @@ import {SecurityAdminSettings} from 'Settings/Admin/Security';
import {SocialAdminSettings} from 'Settings/Admin/Social';
import {PluginsAdminSettings} from 'Settings/Admin/Plugins';
import {PackagesAdminSettings} from 'Settings/Admin/Packages';
// import {AboutAdminSettings} from 'Settings/Admin/About';
import {AboutAdminSettings} from 'Settings/Admin/About';
class SettingsAdminScreen extends AbstractSettingsScreen
{
constructor()
{
constructor() {
super([
require('View/Admin/Settings/Menu'),
require('View/Admin/Settings/Pane')
@ -70,8 +69,8 @@ class SettingsAdminScreen extends AbstractSettingsScreen
'AdminSettingsLicensing', 'TABS_LABELS/LABEL_LICENSING_NAME', 'licensing');
}
// addSettingsViewModel(AboutAdminSettings,
// 'AdminSettingsAbout', 'TABS_LABELS/LABEL_ABOUT_NAME', 'about');
addSettingsViewModel(AboutAdminSettings,
'AdminSettingsAbout', 'TABS_LABELS/LABEL_ABOUT_NAME', 'about');
runSettingsViewModelHooks(true);

View file

@ -4,8 +4,7 @@ import App from 'App/User';
class AboutUserScreen extends AbstractScreen
{
constructor()
{
constructor() {
super('about', [
require('View/User/About')
]);

View file

@ -4,8 +4,7 @@ import App from 'App/User';
class LoginUserScreen extends AbstractScreen
{
constructor()
{
constructor() {
super('login', [
require('View/User/Login')
]);

View file

@ -21,8 +21,7 @@ import App from 'App/User';
class MailBoxUserScreen extends AbstractScreen
{
constructor()
{
constructor() {
super('mailbox', [
require('View/User/MailBox/SystemDropDown'),
require('View/User/MailBox/FolderList'),

View file

@ -27,8 +27,7 @@ import {OpenPgpUserSettings} from 'Settings/User/OpenPgp';
class SettingsUserScreen extends AbstractSettingsScreen
{
constructor()
{
constructor() {
super([
require('View/User/Settings/SystemDropDown'),
require('View/User/Settings/Menu'),

View file

@ -1,20 +1,17 @@
var
ko = require('ko'),
import ko from 'ko';
Translator = require('Common/Translator'),
import {i18n, trigger as translatorTrigger} from 'Common/Translator';
import {appSettingsGet, settingsGet} from 'Storage/Settings';
Settings = require('Storage/Settings'),
CoreStore = require('Stores/Admin/Core'),
AppStore = require('Stores/Admin/App');
import CoreStore from 'Stores/Admin/Core';
import AppStore from 'Stores/Admin/App';
/**
* @constructor
*/
function AboutAdminSettings()
class AboutAdminSettings
{
this.version = ko.observable(Settings.appSettingsGet('version'));
this.access = ko.observable(!!Settings.settingsGet('CoreAccess'));
constructor() {
this.version = ko.observable(appSettingsGet('version'));
this.access = ko.observable(!!settingsGet('CoreAccess'));
this.errorDesc = ko.observable('');
this.coreReal = CoreStore.coreReal;
@ -32,61 +29,58 @@ function AboutAdminSettings()
this.community = RL_COMMUNITY || AppStore.community();
this.coreRemoteVersionHtmlDesc = ko.computed(function() {
Translator.trigger();
return Translator.i18n('TAB_ABOUT/HTML_NEW_VERSION', {'VERSION': this.coreRemoteVersion()});
}, this);
this.coreRemoteVersionHtmlDesc = ko.computed(() => {
translatorTrigger();
return i18n('TAB_ABOUT/HTML_NEW_VERSION', {'VERSION': this.coreRemoteVersion()});
});
this.statusType = ko.computed(function() {
this.statusType = ko.computed(() => {
let type = '';
const
versionToCompare = this.coreVersionCompare(),
isChecking = this.coreChecking(),
isUpdating = this.coreUpdating(),
isReal = this.coreReal();
var
sType = '',
iVersionCompare = this.coreVersionCompare(),
bChecking = this.coreChecking(),
bUpdating = this.coreUpdating(),
bReal = this.coreReal();
if (bChecking)
if (isChecking)
{
sType = 'checking';
type = 'checking';
}
else if (bUpdating)
else if (isUpdating)
{
sType = 'updating';
type = 'updating';
}
else if (bReal && 0 === iVersionCompare)
else if (isReal && 0 === versionToCompare)
{
sType = 'up-to-date';
type = 'up-to-date';
}
else if (bReal && -1 === iVersionCompare)
else if (isReal && -1 === versionToCompare)
{
sType = 'available';
type = 'available';
}
else if (!bReal)
else if (!isReal)
{
sType = 'error';
type = 'error';
this.errorDesc('Cannot access the repository at the moment.');
}
return sType;
}, this);
return type;
});
}
AboutAdminSettings.prototype.onBuild = function()
{
onBuild() {
if (this.access() && !this.community)
{
require('App/Admin').default.reloadCoreData();
}
};
}
AboutAdminSettings.prototype.updateCoreData = function()
{
updateCoreData() {
if (!this.coreUpdating() && !this.community)
{
require('App/Admin').default.updateCoreData();
}
};
}
}
export {AboutAdminSettings, AboutAdminSettings as default};

View file

@ -9,26 +9,25 @@ import {settingsGet} from 'Storage/Settings';
class BrandingAdminSettings
{
constructor()
{
constructor() {
const AppStore = require('Stores/Admin/App');
this.capa = AppStore.prem;
this.title = ko.observable(settingsGet('Title')).extend({idleTrigger: true});
this.loadingDesc = ko.observable(settingsGet('LoadingDescription')).extend({idleTrigger: true});
this.faviconUrl = ko.observable(settingsGet('FaviconUrl')).extend({idleTrigger: true});
this.loginLogo = ko.observable(settingsGet('LoginLogo') || '').extend({idleTrigger: true});
this.loginBackground = ko.observable(settingsGet('LoginBackground') || '').extend({idleTrigger: true});
this.userLogo = ko.observable(settingsGet('UserLogo') || '').extend({idleTrigger: true});
this.userLogoMessage = ko.observable(settingsGet('UserLogoMessage') || '').extend({idleTrigger: true});
this.userIframeMessage = ko.observable(settingsGet('UserIframeMessage') || '').extend({idleTrigger: true});
this.userLogoTitle = ko.observable(settingsGet('UserLogoTitle') || '').extend({idleTrigger: true});
this.loginDescription = ko.observable(settingsGet('LoginDescription')).extend({idleTrigger: true});
this.loginCss = ko.observable(settingsGet('LoginCss')).extend({idleTrigger: true});
this.userCss = ko.observable(settingsGet('UserCss')).extend({idleTrigger: true});
this.welcomePageUrl = ko.observable(settingsGet('WelcomePageUrl')).extend({idleTrigger: true});
this.welcomePageDisplay = ko.observable(settingsGet('WelcomePageDisplay')).extend({idleTrigger: true});
this.title = ko.observable(settingsGet('Title')).idleTrigger();
this.loadingDesc = ko.observable(settingsGet('LoadingDescription')).idleTrigger();
this.faviconUrl = ko.observable(settingsGet('FaviconUrl')).idleTrigger();
this.loginLogo = ko.observable(settingsGet('LoginLogo') || '').idleTrigger();
this.loginBackground = ko.observable(settingsGet('LoginBackground') || '').idleTrigger();
this.userLogo = ko.observable(settingsGet('UserLogo') || '').idleTrigger();
this.userLogoMessage = ko.observable(settingsGet('UserLogoMessage') || '').idleTrigger();
this.userIframeMessage = ko.observable(settingsGet('UserIframeMessage') || '').idleTrigger();
this.userLogoTitle = ko.observable(settingsGet('UserLogoTitle') || '').idleTrigger();
this.loginDescription = ko.observable(settingsGet('LoginDescription')).idleTrigger();
this.loginCss = ko.observable(settingsGet('LoginCss')).idleTrigger();
this.userCss = ko.observable(settingsGet('UserCss')).idleTrigger();
this.welcomePageUrl = ko.observable(settingsGet('WelcomePageUrl')).idleTrigger();
this.welcomePageDisplay = ko.observable(settingsGet('WelcomePageDisplay')).idleTrigger();
this.welcomePageDisplay.options = ko.computed(() => {
translatorTrigger();
return [

View file

@ -1,88 +1,85 @@
var
_ = require('_'),
ko = require('ko'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
import {
settingsSaveHelperSimpleFunction,
defautOptionsAfterRender, createCommand,
inArray, trim, boolToAjax
} from 'Common/Utils';
Translator = require('Common/Translator'),
import {SaveSettingsStep, StorageResultType, Magics} from 'Common/Enums';
import {i18n} from 'Common/Translator';
import {settingsGet} from 'Storage/Settings';
Settings = require('Storage/Settings');
/**
* @constructor
*/
function ContactsAdminSettings()
class ContactsAdminSettings
{
var
Remote = require('Remote/Admin/Ajax');
constructor() {
this.defautOptionsAfterRender = defautOptionsAfterRender;
this.enableContacts = ko.observable(!!settingsGet('ContactsEnable'));
this.contactsSharing = ko.observable(!!settingsGet('ContactsSharing'));
this.contactsSync = ko.observable(!!settingsGet('ContactsSync'));
this.defautOptionsAfterRender = Utils.defautOptionsAfterRender;
this.enableContacts = ko.observable(!!Settings.settingsGet('ContactsEnable'));
this.contactsSharing = ko.observable(!!Settings.settingsGet('ContactsSharing'));
this.contactsSync = ko.observable(!!Settings.settingsGet('ContactsSync'));
var
aTypes = ['sqlite', 'mysql', 'pgsql'],
aSupportedTypes = [],
getTypeName = function(sName) {
switch (sName)
const
Remote = require('Remote/Admin/Ajax'),
supportedTypes = [],
types = ['sqlite', 'mysql', 'pgsql'],
getTypeName = (name) => {
switch (name)
{
case 'sqlite':
sName = 'SQLite';
name = 'SQLite';
break;
case 'mysql':
sName = 'MySQL';
name = 'MySQL';
break;
case 'pgsql':
sName = 'PostgreSQL';
name = 'PostgreSQL';
break;
// no default
}
return sName;
return name;
};
if (Settings.settingsGet('SQLiteIsSupported'))
if (settingsGet('SQLiteIsSupported'))
{
aSupportedTypes.push('sqlite');
supportedTypes.push('sqlite');
}
if (Settings.settingsGet('MySqlIsSupported'))
if (settingsGet('MySqlIsSupported'))
{
aSupportedTypes.push('mysql');
supportedTypes.push('mysql');
}
if (Settings.settingsGet('PostgreSqlIsSupported'))
if (settingsGet('PostgreSqlIsSupported'))
{
aSupportedTypes.push('pgsql');
supportedTypes.push('pgsql');
}
this.contactsSupported = 0 < aSupportedTypes.length;
this.contactsSupported = 0 < supportedTypes.length;
this.contactsTypes = ko.observableArray([]);
this.contactsTypesOptions = this.contactsTypes.map(function(sValue) {
var bDisabled = -1 === Utils.inArray(sValue, aSupportedTypes);
this.contactsTypesOptions = this.contactsTypes.map((value) => {
const disabled = -1 === inArray(value, supportedTypes);
return {
'id': sValue,
'name': getTypeName(sValue) + (bDisabled ? ' (' + Translator.i18n('HINTS/NOT_SUPPORTED') + ')' : ''),
'disabled': bDisabled
'id': value,
'name': getTypeName(value) + (disabled ? ' (' + i18n('HINTS/NOT_SUPPORTED') + ')' : ''),
'disabled': disabled
};
});
this.contactsTypes(aTypes);
this.contactsTypes(types);
this.contactsType = ko.observable('');
this.mainContactsType = ko.computed({
'owner': this,
'read': this.contactsType,
'write': function(sValue) {
if (sValue !== this.contactsType())
'write': (value) => {
if (value !== this.contactsType())
{
if (-1 < Utils.inArray(sValue, aSupportedTypes))
if (-1 < inArray(value, supportedTypes))
{
this.contactsType(sValue);
this.contactsType(value);
}
else if (0 < aSupportedTypes.length)
else if (0 < supportedTypes.length)
{
this.contactsType('');
}
@ -92,7 +89,7 @@ function ContactsAdminSettings()
this.contactsType.valueHasMutated();
}
}
}).extend({'notify': 'always'});
}).extend({notify: 'always'});
this.contactsType.subscribe(function() {
this.testContactsSuccess(false);
@ -100,21 +97,21 @@ function ContactsAdminSettings()
this.testContactsErrorMessage('');
}, this);
this.pdoDsn = ko.observable(Settings.settingsGet('ContactsPdoDsn'));
this.pdoUser = ko.observable(Settings.settingsGet('ContactsPdoUser'));
this.pdoPassword = ko.observable(Settings.settingsGet('ContactsPdoPassword'));
this.pdoDsn = ko.observable(settingsGet('ContactsPdoDsn'));
this.pdoUser = ko.observable(settingsGet('ContactsPdoUser'));
this.pdoPassword = ko.observable(settingsGet('ContactsPdoPassword'));
this.pdoDsnTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.pdoUserTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.pdoPasswordTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.contactsTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.pdoDsnTrigger = ko.observable(SaveSettingsStep.Idle);
this.pdoUserTrigger = ko.observable(SaveSettingsStep.Idle);
this.pdoPasswordTrigger = ko.observable(SaveSettingsStep.Idle);
this.contactsTypeTrigger = ko.observable(SaveSettingsStep.Idle);
this.testing = ko.observable(false);
this.testContactsSuccess = ko.observable(false);
this.testContactsError = ko.observable(false);
this.testContactsErrorMessage = ko.observable('');
this.testContactsCommand = Utils.createCommand(this, function() {
this.testContactsCommand = createCommand(this, () => {
this.testContactsSuccess(false);
this.testContactsError(false);
@ -128,31 +125,28 @@ function ContactsAdminSettings()
'ContactsPdoPassword': this.pdoPassword()
});
}, function() {
return '' !== this.pdoDsn() && '' !== this.pdoUser();
});
}, () => '' !== this.pdoDsn() && '' !== this.pdoUser());
this.contactsType(Settings.settingsGet('ContactsPdoType'));
this.contactsType(settingsGet('ContactsPdoType'));
this.onTestContactsResponse = _.bind(this.onTestContactsResponse, this);
}
ContactsAdminSettings.prototype.onTestContactsResponse = function(sResult, oData)
{
onTestContactsResponse(result, data) {
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.Result)
if (StorageResultType.Success === result && data && data.Result && data.Result.Result)
{
this.testContactsSuccess(true);
}
else
{
this.testContactsError(true);
if (oData && oData.Result)
if (data && data.Result)
{
this.testContactsErrorMessage(oData.Result.Message || '');
this.testContactsErrorMessage(data.Result.Message || '');
}
else
{
@ -161,74 +155,68 @@ ContactsAdminSettings.prototype.onTestContactsResponse = function(sResult, oData
}
this.testing(false);
};
}
ContactsAdminSettings.prototype.onShow = function()
{
onShow() {
this.testContactsSuccess(false);
this.testContactsError(false);
this.testContactsErrorMessage('');
};
}
ContactsAdminSettings.prototype.onBuild = function()
{
var
self = this,
Remote = require('Remote/Admin/Ajax');
onBuild() {
_.delay(() => {
const
Remote = require('Remote/Admin/Ajax'),
f1 = settingsSaveHelperSimpleFunction(this.pdoDsnTrigger, this),
f3 = settingsSaveHelperSimpleFunction(this.pdoUserTrigger, this),
f4 = settingsSaveHelperSimpleFunction(this.pdoPasswordTrigger, this),
f5 = settingsSaveHelperSimpleFunction(this.contactsTypeTrigger, this);
_.delay(function() {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.pdoDsnTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.pdoUserTrigger, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.pdoPasswordTrigger, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.contactsTypeTrigger, self);
self.enableContacts.subscribe(function(bValue) {
this.enableContacts.subscribe((value) => {
Remote.saveAdminConfig(null, {
'ContactsEnable': bValue ? '1' : '0'
'ContactsEnable': boolToAjax(value)
});
});
self.contactsSharing.subscribe(function(bValue) {
this.contactsSharing.subscribe((value) => {
Remote.saveAdminConfig(null, {
'ContactsSharing': bValue ? '1' : '0'
'ContactsSharing': boolToAjax(value)
});
});
self.contactsSync.subscribe(function(bValue) {
this.contactsSync.subscribe((value) => {
Remote.saveAdminConfig(null, {
'ContactsSync': bValue ? '1' : '0'
'ContactsSync': boolToAjax(value)
});
});
self.contactsType.subscribe(function(sValue) {
this.contactsType.subscribe((value) => {
Remote.saveAdminConfig(f5, {
'ContactsPdoType': sValue
'ContactsPdoType': trim(value)
});
});
self.pdoDsn.subscribe(function(sValue) {
this.pdoDsn.subscribe((value) => {
Remote.saveAdminConfig(f1, {
'ContactsPdoDsn': Utils.trim(sValue)
'ContactsPdoDsn': trim(value)
});
});
self.pdoUser.subscribe(function(sValue) {
this.pdoUser.subscribe((value) => {
Remote.saveAdminConfig(f3, {
'ContactsPdoUser': Utils.trim(sValue)
'ContactsPdoUser': trim(value)
});
});
self.pdoPassword.subscribe(function(sValue) {
this.pdoPassword.subscribe((value) => {
Remote.saveAdminConfig(f4, {
'ContactsPdoPassword': Utils.trim(sValue)
'ContactsPdoPassword': trim(value)
});
});
self.contactsType(Settings.settingsGet('ContactsPdoType'));
}, 50);
};
this.contactsType(settingsGet('ContactsPdoType'));
}, Magics.Time50ms);
}
}
export {ContactsAdminSettings, ContactsAdminSettings as default};

View file

@ -1,23 +1,19 @@
var
_ = require('_'),
ko = require('ko'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
import {StorageResultType} from 'Common/Enums';
import {showScreenPopup} from 'Knoin/Knoin';
DomainStore = require('Stores/Admin/Domain'),
Remote = require('Remote/Admin/Ajax');
import DomainStore from 'Stores/Admin/Domain';
import Remote from 'Remote/Admin/Ajax';
/**
* @constructor
*/
function DomainsAdminSettings()
class DomainsAdminSettings
{
constructor() {
this.domains = DomainStore.domains;
this.visibility = ko.computed(function() {
return this.domains.loading() ? 'visible' : 'hidden';
}, this);
this.visibility = ko.computed(() => (this.domains.loading() ? 'visible' : 'hidden'));
this.domainForDeletion = ko.observable(null).deleteAccessHelper();
@ -25,54 +21,48 @@ function DomainsAdminSettings()
this.onDomainLoadRequest = _.bind(this.onDomainLoadRequest, this);
}
DomainsAdminSettings.prototype.createDomain = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Domain'));
};
createDomain() {
showScreenPopup(require('View/Popup/Domain'));
}
DomainsAdminSettings.prototype.createDomainAlias = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/DomainAlias'));
};
createDomainAlias() {
showScreenPopup(require('View/Popup/DomainAlias'));
}
DomainsAdminSettings.prototype.deleteDomain = function(oDomain)
{
this.domains.remove(oDomain);
Remote.domainDelete(this.onDomainListChangeRequest, oDomain.name);
};
deleteDomain(domain) {
this.domains.remove(domain);
Remote.domainDelete(this.onDomainListChangeRequest, domain.name);
}
DomainsAdminSettings.prototype.disableDomain = function(oDomain)
{
oDomain.disabled(!oDomain.disabled());
Remote.domainDisable(this.onDomainListChangeRequest, oDomain.name, oDomain.disabled());
};
disableDomain(domain) {
domain.disabled(!domain.disabled());
Remote.domainDisable(this.onDomainListChangeRequest, domain.name, domain.disabled());
}
DomainsAdminSettings.prototype.onBuild = function(oDom)
{
var self = this;
onBuild(oDom) {
const self = this;
oDom
.on('click', '.b-admin-domains-list-table .e-item .e-action', function() {
var oDomainItem = ko.dataFor(this);
if (oDomainItem)
const domainItem = ko.dataFor(this);
if (domainItem)
{
Remote.domain(self.onDomainLoadRequest, oDomainItem.name);
Remote.domain(self.onDomainLoadRequest, domainItem.name);
}
});
require('App/Admin').default.reloadDomainList();
};
DomainsAdminSettings.prototype.onDomainLoadRequest = function(sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Domain'), [oData.Result]);
}
};
DomainsAdminSettings.prototype.onDomainListChangeRequest = function()
onDomainLoadRequest(sResult, oData) {
if (StorageResultType.Success === sResult && oData && oData.Result)
{
showScreenPopup(require('View/Popup/Domain'), [oData.Result]);
}
}
onDomainListChangeRequest() {
require('App/Admin').default.reloadDomainList();
};
}
}
export {DomainsAdminSettings, DomainsAdminSettings as default};

View file

@ -1,25 +1,27 @@
var
_ = require('_'),
ko = require('ko'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Links = require('Common/Links'),
Translator = require('Common/Translator'),
import {
trim, pInt, boolToAjax, settingsSaveHelperSimpleFunction,
changeTheme, convertThemeName, convertLangName
} from 'Common/Utils';
ThemeStore = require('Stores/Theme'),
LanguageStore = require('Stores/Language'),
AppAdminStore = require('Stores/Admin/App'),
CapaAdminStore = require('Stores/Admin/Capa'),
import {SaveSettingsStep, Magics} from 'Common/Enums';
import {reload as translatorReload} from 'Common/Translator';
import {phpInfo} from 'Common/Links';
Settings = require('Storage/Settings');
import {settingsGet} from 'Storage/Settings';
import {showScreenPopup} from 'Knoin/Knoin';
/**
* @constructor
*/
function GeneralAdminSettings()
import ThemeStore from 'Stores/Theme';
import LanguageStore from 'Stores/Language';
import AppAdminStore from 'Stores/Admin/App';
import CapaAdminStore from 'Stores/Admin/Capa';
class GeneralAdminSettings
{
constructor() {
this.language = LanguageStore.language;
this.languages = LanguageStore.languages;
this.languageAdmin = LanguageStore.languageAdmin;
@ -39,164 +41,136 @@ function GeneralAdminSettings()
this.allowLanguagesOnSettings = AppAdminStore.allowLanguagesOnSettings;
this.weakPassword = AppAdminStore.weakPassword;
this.mainAttachmentLimit = ko.observable(Utils.pInt(Settings.settingsGet('AttachmentLimit')) / (1024 * 1024)).extend({'posInterer': 25});
this.uploadData = Settings.settingsGet('PhpUploadSizes');
this.mainAttachmentLimit = ko.observable(pInt(settingsGet('AttachmentLimit')) / (Magics.BitLength1024 * Magics.BitLength1024)).extend({posInterer: 25});
this.uploadData = settingsGet('PhpUploadSizes');
this.uploadDataDesc = this.uploadData && (this.uploadData.upload_max_filesize || this.uploadData.post_max_size) ? [
this.uploadData.upload_max_filesize ? 'upload_max_filesize = ' + this.uploadData.upload_max_filesize + '; ' : '',
this.uploadData.post_max_size ? 'post_max_size = ' + this.uploadData.post_max_size : ''
].join('') : '';
this.themesOptions = ko.computed(function() {
return _.map(this.themes(), function(sTheme) {
return {
optValue: sTheme,
optText: Utils.convertThemeName(sTheme)
};
});
}, this);
this.themesOptions = ko.computed(() => _.map(this.themes(), (theme) => ({optValue: theme, optText: convertThemeName(theme)})));
this.languageFullName = ko.computed(function() {
return Utils.convertLangName(this.language());
}, this);
this.languageFullName = ko.computed(() => convertLangName(this.language()));
this.languageAdminFullName = ko.computed(() => convertLangName(this.languageAdmin()));
this.languageAdminFullName = ko.computed(function() {
return Utils.convertLangName(this.languageAdmin());
}, this);
this.attachmentLimitTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.languageAdminTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.attachmentLimitTrigger = ko.observable(SaveSettingsStep.Idle);
this.languageTrigger = ko.observable(SaveSettingsStep.Idle);
this.languageAdminTrigger = ko.observable(SaveSettingsStep.Idle).extend({throttle: Magics.Time100ms});
this.themeTrigger = ko.observable(SaveSettingsStep.Idle);
}
GeneralAdminSettings.prototype.onBuild = function()
{
var
self = this,
Remote = require('Remote/Admin/Ajax');
_.delay(function() {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.attachmentLimitTrigger, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.languageTrigger, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.themeTrigger, self),
fReloadLanguageHelper = function(iSaveSettingsStep) {
return function() {
self.languageAdminTrigger(iSaveSettingsStep);
_.delay(function() {
self.languageAdminTrigger(Enums.SaveSettingsStep.Idle);
}, 1000);
};
onBuild() {
_.delay(() => {
const
Remote = require('Remote/Admin/Ajax'),
f1 = settingsSaveHelperSimpleFunction(this.attachmentLimitTrigger, this),
f2 = settingsSaveHelperSimpleFunction(this.languageTrigger, this),
f3 = settingsSaveHelperSimpleFunction(this.themeTrigger, this),
fReloadLanguageHelper = (saveSettingsStep) => () => {
this.languageAdminTrigger(saveSettingsStep);
_.delay(() => this.languageAdminTrigger(SaveSettingsStep.Idle), Magics.Time1s);
};
self.mainAttachmentLimit.subscribe(function(sValue) {
this.mainAttachmentLimit.subscribe((value) => {
Remote.saveAdminConfig(f1, {
'AttachmentLimit': Utils.pInt(sValue)
'AttachmentLimit': pInt(value)
});
});
self.language.subscribe(function(sValue) {
this.language.subscribe((value) => {
Remote.saveAdminConfig(f2, {
'Language': Utils.trim(sValue)
'Language': trim(value)
});
});
self.languageAdmin.subscribe(function(sValue) {
self.languageAdminTrigger(Enums.SaveSettingsStep.Animate);
Translator.reload(true, sValue).then(
fReloadLanguageHelper(Enums.SaveSettingsStep.TrueResult),
fReloadLanguageHelper(Enums.SaveSettingsStep.FalseResult)
).then(function() {
this.languageAdmin.subscribe((value) => {
this.languageAdminTrigger(SaveSettingsStep.Animate);
translatorReload(true, value).then(
fReloadLanguageHelper(SaveSettingsStep.TrueResult),
fReloadLanguageHelper(SaveSettingsStep.FalseResult)
).then(() => {
Remote.saveAdminConfig(null, {
'LanguageAdmin': Utils.trim(sValue)
'LanguageAdmin': trim(value)
});
});
});
});
self.theme.subscribe(function(sValue) {
Utils.changeTheme(sValue, self.themeTrigger);
this.theme.subscribe((value) => {
changeTheme(value, this.themeTrigger);
Remote.saveAdminConfig(f3, {
'Theme': Utils.trim(sValue)
'Theme': trim(value)
});
});
self.capaAdditionalAccounts.subscribe(function(bValue) {
this.capaAdditionalAccounts.subscribe((value) => {
Remote.saveAdminConfig(null, {
'CapaAdditionalAccounts': bValue ? '1' : '0'
'CapaAdditionalAccounts': boolToAjax(value)
});
});
self.capaIdentities.subscribe(function(bValue) {
this.capaIdentities.subscribe((value) => {
Remote.saveAdminConfig(null, {
'CapaIdentities': bValue ? '1' : '0'
'CapaIdentities': boolToAjax(value)
});
});
self.capaTemplates.subscribe(function(bValue) {
this.capaTemplates.subscribe((value) => {
Remote.saveAdminConfig(null, {
'CapaTemplates': bValue ? '1' : '0'
'CapaTemplates': boolToAjax(value)
});
});
self.capaGravatar.subscribe(function(bValue) {
this.capaGravatar.subscribe((value) => {
Remote.saveAdminConfig(null, {
'CapaGravatar': bValue ? '1' : '0'
'CapaGravatar': boolToAjax(value)
});
});
self.capaAttachmentThumbnails.subscribe(function(bValue) {
this.capaAttachmentThumbnails.subscribe((value) => {
Remote.saveAdminConfig(null, {
'CapaAttachmentThumbnails': bValue ? '1' : '0'
'CapaAttachmentThumbnails': boolToAjax(value)
});
});
self.capaThemes.subscribe(function(bValue) {
this.capaThemes.subscribe((value) => {
Remote.saveAdminConfig(null, {
'CapaThemes': bValue ? '1' : '0'
'CapaThemes': boolToAjax(value)
});
});
self.capaUserBackground.subscribe(function(bValue) {
this.capaUserBackground.subscribe((value) => {
Remote.saveAdminConfig(null, {
'CapaUserBackground': bValue ? '1' : '0'
'CapaUserBackground': boolToAjax(value)
});
});
self.allowLanguagesOnSettings.subscribe(function(bValue) {
this.allowLanguagesOnSettings.subscribe((value) => {
Remote.saveAdminConfig(null, {
'AllowLanguagesOnSettings': bValue ? '1' : '0'
'AllowLanguagesOnSettings': boolToAjax(value)
});
});
}, Magics.Time50ms);
}
}, 50);
};
GeneralAdminSettings.prototype.selectLanguage = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [
selectLanguage() {
showScreenPopup(require('View/Popup/Languages'), [
this.language, this.languages(), LanguageStore.userLanguage()
]);
};
}
GeneralAdminSettings.prototype.selectLanguageAdmin = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [
selectLanguageAdmin() {
showScreenPopup(require('View/Popup/Languages'), [
this.languageAdmin, this.languagesAdmin(), LanguageStore.userLanguageAdmin()
]);
};
}
/**
* @returns {string}
*/
GeneralAdminSettings.prototype.phpInfoLink = function()
{
return Links.phpInfo();
};
phpInfoLink() {
return phpInfo();
}
}
export {GeneralAdminSettings, GeneralAdminSettings as default};

View file

@ -1,66 +1,55 @@
var
_ = require('_'),
ko = require('ko'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
import {settingsSaveHelperSimpleFunction, boolToAjax, trim} from 'Common/Utils';
import {settingsGet} from 'Storage/Settings';
AppAdminStore = require('Stores/Admin/App'),
import AppAdminStore from 'Stores/Admin/App';
Settings = require('Storage/Settings');
/**
* @constructor
*/
function LoginAdminSettings()
class LoginAdminSettings
{
constructor() {
this.determineUserLanguage = AppAdminStore.determineUserLanguage;
this.determineUserDomain = AppAdminStore.determineUserDomain;
this.defaultDomain = ko.observable(Settings.settingsGet('LoginDefaultDomain'));
this.defaultDomain = ko.observable(settingsGet('LoginDefaultDomain')).idleTrigger();
this.allowLanguagesOnLogin = AppAdminStore.allowLanguagesOnLogin;
this.defaultDomainTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.dummy = ko.observable(false);
}
LoginAdminSettings.prototype.onBuild = function()
{
var
self = this,
Remote = require('Remote/Admin/Ajax');
onBuild() {
_.delay(() => {
const
Remote = require('Remote/Admin/Ajax'),
f1 = settingsSaveHelperSimpleFunction(this.defaultDomain.trigger, this);
_.delay(function() {
var f1 = Utils.settingsSaveHelperSimpleFunction(self.defaultDomainTrigger, self);
self.determineUserLanguage.subscribe(function(bValue) {
this.determineUserLanguage.subscribe((value) => {
Remote.saveAdminConfig(null, {
'DetermineUserLanguage': bValue ? '1' : '0'
'DetermineUserLanguage': boolToAjax(value)
});
});
self.determineUserDomain.subscribe(function(bValue) {
this.determineUserDomain.subscribe((value) => {
Remote.saveAdminConfig(null, {
'DetermineUserDomain': bValue ? '1' : '0'
'DetermineUserDomain': boolToAjax(value)
});
});
self.allowLanguagesOnLogin.subscribe(function(bValue) {
this.allowLanguagesOnLogin.subscribe((value) => {
Remote.saveAdminConfig(null, {
'AllowLanguagesOnLogin': bValue ? '1' : '0'
'AllowLanguagesOnLogin': boolToAjax(value)
});
});
self.defaultDomain.subscribe(function(sValue) {
this.defaultDomain.subscribe((value) => {
Remote.saveAdminConfig(f1, {
'LoginDefaultDomain': Utils.trim(sValue)
'LoginDefaultDomain': trim(value)
});
});
}, 50);
};
}
}
export {LoginAdminSettings, LoginAdminSettings as default};

View file

@ -1,80 +1,63 @@
var
window = require('window'),
_ = require('_'),
ko = require('ko'),
import window from 'window';
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Translator = require('Common/Translator'),
import {StorageResultType, Notification} from 'Common/Enums';
import {getNotification} from 'Common/Translator';
PackageStore = require('Stores/Admin/Package'),
Remote = require('Remote/Admin/Ajax');
import PackageStore from 'Stores/Admin/Package';
import Remote from 'Remote/Admin/Ajax';
/**
* @constructor
*/
function PackagesAdminSettings()
class PackagesAdminSettings
{
constructor() {
this.packagesError = ko.observable('');
this.packages = PackageStore.packages;
this.packagesReal = PackageStore.packagesReal;
this.packagesMainUpdatable = PackageStore.packagesMainUpdatable;
this.packagesCurrent = this.packages.filter(function(item) {
return item && '' !== item.installed && !item.compare;
});
this.packagesCurrent = this.packages.filter((item) => item && '' !== item.installed && !item.compare);
this.packagesAvailableForUpdate = this.packages.filter((item) => item && '' !== item.installed && !!item.compare);
this.packagesAvailableForInstallation = this.packages.filter((item) => item && '' === item.installed);
this.packagesAvailableForUpdate = this.packages.filter(function(item) {
return item && '' !== item.installed && !!item.compare;
});
this.packagesAvailableForInstallation = this.packages.filter(function(item) {
return item && '' === item.installed;
});
this.visibility = ko.computed(function() {
return PackageStore.packages.loading() ? 'visible' : 'hidden';
}, this);
this.visibility = ko.computed(() => (PackageStore.packages.loading() ? 'visible' : 'hidden'));
}
PackagesAdminSettings.prototype.onShow = function()
{
onShow() {
this.packagesError('');
};
}
PackagesAdminSettings.prototype.onBuild = function()
{
onBuild() {
require('App/Admin').default.reloadPackagesList();
};
}
PackagesAdminSettings.prototype.requestHelper = function(oPackage, bInstall)
{
var self = this;
return function(sResult, oData) {
requestHelper(packageToRequest, install) {
return (result, data) => {
if (Enums.StorageResultType.Success !== sResult || !oData || !oData.Result)
if (StorageResultType.Success !== result || !data || !data.Result)
{
if (oData && oData.ErrorCode)
if (data && data.ErrorCode)
{
self.packagesError(Translator.getNotification(oData.ErrorCode));
this.packagesError(getNotification(data.ErrorCode));
}
else
{
self.packagesError(Translator.getNotification(
bInstall ? Enums.Notification.CantInstallPackage : Enums.Notification.CantDeletePackage));
this.packagesError(getNotification(
install ? Notification.CantInstallPackage : Notification.CantDeletePackage));
}
}
_.each(self.packages(), function(item) {
if (item && oPackage && item.loading && item.loading() && oPackage.file === item.file)
_.each(this.packages(), (item) => {
if (item && packageToRequest && item.loading && item.loading() && packageToRequest.file === item.file)
{
oPackage.loading(false);
packageToRequest.loading(false);
item.loading(false);
}
});
if (Enums.StorageResultType.Success === sResult && oData && oData.Result && oData.Result.Reload)
if (StorageResultType.Success === result && data && data.Result && data.Result.Reload)
{
window.location.reload();
}
@ -83,24 +66,23 @@ PackagesAdminSettings.prototype.requestHelper = function(oPackage, bInstall)
require('App/Admin').default.reloadPackagesList();
}
};
};
PackagesAdminSettings.prototype.deletePackage = function(oPackage)
{
if (oPackage)
{
oPackage.loading(true);
Remote.packageDelete(this.requestHelper(oPackage, false), oPackage);
}
};
PackagesAdminSettings.prototype.installPackage = function(oPackage)
deletePackage(packageToDelete) {
if (packageToDelete)
{
if (oPackage)
{
oPackage.loading(true);
Remote.packageInstall(this.requestHelper(oPackage, true), oPackage);
packageToDelete.loading(true);
Remote.packageDelete(this.requestHelper(packageToDelete, false), packageToDelete);
}
}
installPackage(packageToInstall) {
if (packageToInstall)
{
packageToInstall.loading(true);
Remote.packageInstall(this.requestHelper(packageToInstall, true), packageToInstall);
}
}
}
};
export {PackagesAdminSettings, PackagesAdminSettings as default};

View file

@ -1,109 +1,99 @@
var
_ = require('_'),
ko = require('ko'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
import {StorageResultType, Notification} from 'Common/Enums';
import {getNotification} from 'Common/Translator';
import {boolToAjax} from 'Common/Utils';
Settings = require('Storage/Settings'),
import {settingsGet} from 'Storage/Settings';
import {showScreenPopup} from 'Knoin/Knoin';
AppStore = require('Stores/Admin/App'),
PluginStore = require('Stores/Admin/Plugin'),
import AppStore from 'Stores/Admin/App';
import PluginStore from 'Stores/Admin/Plugin';
Remote = require('Remote/Admin/Ajax');
import Remote from 'Remote/Admin/Ajax';
/**
* @constructor
*/
function PluginsAdminSettings()
class PluginsAdminSettings
{
this.enabledPlugins = ko.observable(!!Settings.settingsGet('EnabledPlugins'));
constructor() {
this.enabledPlugins = ko.observable(!!settingsGet('EnabledPlugins'));
this.plugins = PluginStore.plugins;
this.pluginsError = PluginStore.plugins.error;
this.community = RL_COMMUNITY || AppStore.community();
this.visibility = ko.computed(function() {
return PluginStore.plugins.loading() ? 'visible' : 'hidden';
}, this);
this.visibility = ko.computed(() => (PluginStore.plugins.loading() ? 'visible' : 'hidden'));
this.onPluginLoadRequest = _.bind(this.onPluginLoadRequest, this);
this.onPluginDisableRequest = _.bind(this.onPluginDisableRequest, this);
}
PluginsAdminSettings.prototype.disablePlugin = function(oPlugin)
{
oPlugin.disabled(!oPlugin.disabled());
Remote.pluginDisable(this.onPluginDisableRequest, oPlugin.name, oPlugin.disabled());
};
disablePlugin(plugin) {
plugin.disabled(!plugin.disabled());
Remote.pluginDisable(this.onPluginDisableRequest, plugin.name, plugin.disabled());
}
PluginsAdminSettings.prototype.configurePlugin = function(oPlugin)
{
Remote.plugin(this.onPluginLoadRequest, oPlugin.name);
};
PluginsAdminSettings.prototype.onBuild = function(oDom)
{
var self = this;
configurePlugin(plugin) {
Remote.plugin(this.onPluginLoadRequest, plugin.name);
}
onBuild(oDom) {
const self = this;
oDom
.on('click', '.e-item .configure-plugin-action', function() {
var oPlugin = ko.dataFor(this);
if (oPlugin)
const plugin = ko.dataFor(this);
if (plugin)
{
self.configurePlugin(oPlugin);
self.configurePlugin(plugin);
}
})
.on('click', '.e-item .disabled-plugin', function() {
var oPlugin = ko.dataFor(this);
if (oPlugin)
const plugin = ko.dataFor(this);
if (plugin)
{
self.disablePlugin(oPlugin);
self.disablePlugin(plugin);
}
});
this.enabledPlugins.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'EnabledPlugins': bValue ? '1' : '0'
this.enabledPlugins.subscribe((value) => {
Remote.saveAdminConfig(null, {
'EnabledPlugins': boolToAjax(value)
});
});
};
}
PluginsAdminSettings.prototype.onShow = function()
{
onShow() {
PluginStore.plugins.error('');
require('App/Admin').default.reloadPluginList();
};
PluginsAdminSettings.prototype.onPluginLoadRequest = function(sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Plugin'), [oData.Result]);
}
};
PluginsAdminSettings.prototype.onPluginDisableRequest = function(sResult, oData)
onPluginLoadRequest(result, data) {
if (StorageResultType.Success === result && data && data.Result)
{
if (Enums.StorageResultType.Success === sResult && oData)
showScreenPopup(require('View/Popup/Plugin'), [data.Result]);
}
}
onPluginDisableRequest(result, data) {
if (StorageResultType.Success === result && data)
{
if (!oData.Result && oData.ErrorCode)
if (!data.Result && data.ErrorCode)
{
if (Enums.Notification.UnsupportedPluginPackage === oData.ErrorCode && oData.ErrorMessage && '' !== oData.ErrorMessage)
if (Notification.UnsupportedPluginPackage === data.ErrorCode && data.ErrorMessage && '' !== data.ErrorMessage)
{
PluginStore.plugins.error(oData.ErrorMessage);
PluginStore.plugins.error(data.ErrorMessage);
}
else
{
PluginStore.plugins.error(Translator.getNotification(oData.ErrorCode));
PluginStore.plugins.error(getNotification(data.ErrorCode));
}
}
}
require('App/Admin').default.reloadPluginList();
};
}
}
export {PluginsAdminSettings, PluginsAdminSettings as default};

View file

@ -1,23 +1,21 @@
var
_ = require('_'),
ko = require('ko'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Links = require('Common/Links'),
import {createCommand, trim, boolToAjax} from 'Common/Utils';
import {phpInfo} from 'Common/Links';
import {StorageResultType} from 'Common/Enums';
AppAdminStore = require('Stores/Admin/App'),
CapaAdminStore = require('Stores/Admin/Capa'),
import {settingsGet} from 'Storage/Settings';
Settings = require('Storage/Settings'),
Remote = require('Remote/Admin/Ajax');
import AppAdminStore from 'Stores/Admin/App';
import CapaAdminStore from 'Stores/Admin/Capa';
/**
* @constructor
*/
function SecurityAdminSettings()
import Remote from 'Remote/Admin/Ajax';
class SecurityAdminSettings
{
constructor() {
this.useLocalProxyForExternalImages = AppAdminStore.useLocalProxyForExternalImages;
this.weakPassword = AppAdminStore.weakPassword;
@ -27,24 +25,24 @@ function SecurityAdminSettings()
this.capaTwoFactorAuth = CapaAdminStore.twoFactorAuth;
this.capaTwoFactorAuthForce = CapaAdminStore.twoFactorAuthForce;
this.capaTwoFactorAuth.subscribe(function(bValue) {
if (!bValue)
this.capaTwoFactorAuth.subscribe((value) => {
if (!value)
{
this.capaTwoFactorAuthForce(false);
}
}, this);
});
this.verifySslCertificate = ko.observable(!!Settings.settingsGet('VerifySslCertificate'));
this.allowSelfSigned = ko.observable(!!Settings.settingsGet('AllowSelfSigned'));
this.verifySslCertificate = ko.observable(!!settingsGet('VerifySslCertificate'));
this.allowSelfSigned = ko.observable(!!settingsGet('AllowSelfSigned'));
this.verifySslCertificate.subscribe(function(bValue) {
if (!bValue)
this.verifySslCertificate.subscribe((value) => {
if (!value)
{
this.allowSelfSigned(true);
}
}, this);
});
this.adminLogin = ko.observable(Settings.settingsGet('AdminLogin'));
this.adminLogin = ko.observable(settingsGet('AdminLogin'));
this.adminLoginError = ko.observable(false);
this.adminPassword = ko.observable('');
this.adminPasswordNew = ko.observable('');
@ -54,30 +52,30 @@ function SecurityAdminSettings()
this.adminPasswordUpdateError = ko.observable(false);
this.adminPasswordUpdateSuccess = ko.observable(false);
this.adminPassword.subscribe(function() {
this.adminPassword.subscribe(() => {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
}, this);
});
this.adminLogin.subscribe(function() {
this.adminLogin.subscribe(() => {
this.adminLoginError(false);
}, this);
});
this.adminPasswordNew.subscribe(function() {
this.adminPasswordNew.subscribe(() => {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false);
}, this);
});
this.adminPasswordNew2.subscribe(function() {
this.adminPasswordNew2.subscribe(() => {
this.adminPasswordUpdateError(false);
this.adminPasswordUpdateSuccess(false);
this.adminPasswordNewError(false);
}, this);
});
this.saveNewAdminPasswordCommand = Utils.createCommand(this, function() {
this.saveNewAdminPasswordCommand = createCommand(this, () => {
if ('' === Utils.trim(this.adminLogin()))
if ('' === trim(this.adminLogin()))
{
this.adminLoginError(true);
return false;
@ -99,17 +97,13 @@ function SecurityAdminSettings()
});
return true;
}, function() {
return '' !== Utils.trim(this.adminLogin()) && '' !== this.adminPassword();
});
}, () => '' !== trim(this.adminLogin()) && '' !== this.adminPassword());
this.onNewAdminPasswordResponse = _.bind(this.onNewAdminPasswordResponse, this);
}
SecurityAdminSettings.prototype.onNewAdminPasswordResponse = function(sResult, oData)
{
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
onNewAdminPasswordResponse(result, data) {
if (StorageResultType.Success === result && data && data.Result)
{
this.adminPassword('');
this.adminPasswordNew('');
@ -117,66 +111,64 @@ SecurityAdminSettings.prototype.onNewAdminPasswordResponse = function(sResult, o
this.adminPasswordUpdateSuccess(true);
this.weakPassword(!!oData.Result.Weak);
this.weakPassword(!!data.Result.Weak);
}
else
{
this.adminPasswordUpdateError(true);
}
};
}
SecurityAdminSettings.prototype.onBuild = function()
{
this.capaOpenPGP.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'CapaOpenPGP': bValue ? '1' : '0'
});
});
this.capaTwoFactorAuth.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'CapaTwoFactorAuth': bValue ? '1' : '0'
});
});
this.capaTwoFactorAuthForce.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'CapaTwoFactorAuthForce': bValue ? '1' : '0'
});
});
this.useLocalProxyForExternalImages.subscribe(function(bValue) {
onBuild() {
this.capaOpenPGP.subscribe((value) => {
Remote.saveAdminConfig(null, {
'UseLocalProxyForExternalImages': bValue ? '1' : '0'
'CapaOpenPGP': boolToAjax(value)
});
});
this.verifySslCertificate.subscribe(function(bValue) {
this.capaTwoFactorAuth.subscribe((value) => {
Remote.saveAdminConfig(null, {
'VerifySslCertificate': bValue ? '1' : '0'
'CapaTwoFactorAuth': boolToAjax(value)
});
});
this.allowSelfSigned.subscribe(function(bValue) {
this.capaTwoFactorAuthForce.subscribe((value) => {
Remote.saveAdminConfig(null, {
'AllowSelfSigned': bValue ? '1' : '0'
'CapaTwoFactorAuthForce': boolToAjax(value)
});
});
};
SecurityAdminSettings.prototype.onHide = function()
{
this.useLocalProxyForExternalImages.subscribe((value) => {
Remote.saveAdminConfig(null, {
'UseLocalProxyForExternalImages': boolToAjax(value)
});
});
this.verifySslCertificate.subscribe((value) => {
Remote.saveAdminConfig(null, {
'VerifySslCertificate': boolToAjax(value)
});
});
this.allowSelfSigned.subscribe((value) => {
Remote.saveAdminConfig(null, {
'AllowSelfSigned': boolToAjax(value)
});
});
}
onHide() {
this.adminPassword('');
this.adminPasswordNew('');
this.adminPasswordNew2('');
};
}
/**
* @returns {string}
*/
SecurityAdminSettings.prototype.phpInfoLink = function()
{
return Links.phpInfo();
};
phpInfoLink() {
return phpInfo();
}
}
export {SecurityAdminSettings, SecurityAdminSettings as default};

View file

@ -1,18 +1,15 @@
var
_ = require('_'),
ko = require('ko'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Utils = require('Common/Utils');
import {SaveSettingsStep, Magics} from 'Common/Enums';
import {settingsSaveHelperSimpleFunction, trim, boolToAjax} from 'Common/Utils';
/**
* @constructor
*/
function SocialAdminSettings()
import SocialStore from 'Stores/Social';
class SocialAdminSettings
{
var SocialStore = require('Stores/Social');
constructor() {
this.googleEnable = SocialStore.google.enabled;
this.googleEnableAuth = SocialStore.google.capa.auth;
this.googleEnableAuthFast = SocialStore.google.capa.authFast;
@ -26,149 +23,87 @@ function SocialAdminSettings()
this.googleClientSecret = SocialStore.google.clientSecret;
this.googleApiKey = SocialStore.google.apiKey;
this.googleTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.googleTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.googleTrigger3 = ko.observable(Enums.SaveSettingsStep.Idle);
this.googleTrigger1 = ko.observable(SaveSettingsStep.Idle);
this.googleTrigger2 = ko.observable(SaveSettingsStep.Idle);
this.googleTrigger3 = ko.observable(SaveSettingsStep.Idle);
this.facebookSupported = SocialStore.facebook.supported;
this.facebookEnable = SocialStore.facebook.enabled;
this.facebookAppID = SocialStore.facebook.appID;
this.facebookAppSecret = SocialStore.facebook.appSecret;
this.facebookTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.facebookTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.facebookTrigger1 = ko.observable(SaveSettingsStep.Idle);
this.facebookTrigger2 = ko.observable(SaveSettingsStep.Idle);
this.twitterEnable = SocialStore.twitter.enabled;
this.twitterConsumerKey = SocialStore.twitter.consumerKey;
this.twitterConsumerSecret = SocialStore.twitter.consumerSecret;
this.twitterTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.twitterTrigger2 = ko.observable(Enums.SaveSettingsStep.Idle);
this.twitterTrigger1 = ko.observable(SaveSettingsStep.Idle);
this.twitterTrigger2 = ko.observable(SaveSettingsStep.Idle);
this.dropboxEnable = SocialStore.dropbox.enabled;
this.dropboxApiKey = SocialStore.dropbox.apiKey;
this.dropboxTrigger1 = ko.observable(Enums.SaveSettingsStep.Idle);
this.dropboxTrigger1 = ko.observable(SaveSettingsStep.Idle);
}
SocialAdminSettings.prototype.onBuild = function()
onBuild() {
_.delay(() => {
const
Remote = require('Remote/Admin/Ajax'),
f1 = settingsSaveHelperSimpleFunction(this.facebookTrigger1, this),
f2 = settingsSaveHelperSimpleFunction(this.facebookTrigger2, this),
f3 = settingsSaveHelperSimpleFunction(this.twitterTrigger1, this),
f4 = settingsSaveHelperSimpleFunction(this.twitterTrigger2, this),
f5 = settingsSaveHelperSimpleFunction(this.googleTrigger1, this),
f6 = settingsSaveHelperSimpleFunction(this.googleTrigger2, this),
f7 = settingsSaveHelperSimpleFunction(this.googleTrigger3, this),
f8 = settingsSaveHelperSimpleFunction(this.dropboxTrigger1, this);
this.facebookEnable.subscribe((value) => {
if (this.facebookSupported())
{
var
self = this,
Remote = require('Remote/Admin/Ajax');
_.delay(function() {
var
f1 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger1, self),
f2 = Utils.settingsSaveHelperSimpleFunction(self.facebookTrigger2, self),
f3 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger1, self),
f4 = Utils.settingsSaveHelperSimpleFunction(self.twitterTrigger2, self),
f5 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger1, self),
f6 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger2, self),
f7 = Utils.settingsSaveHelperSimpleFunction(self.googleTrigger3, self),
f8 = Utils.settingsSaveHelperSimpleFunction(self.dropboxTrigger1, self);
self.facebookEnable.subscribe(function(bValue) {
if (self.facebookSupported())
{
Remote.saveAdminConfig(Utils.noop, {
'FacebookEnable': bValue ? '1' : '0'
Remote.saveAdminConfig(null, {
'FacebookEnable': boolToAjax(value)
});
}
});
self.facebookAppID.subscribe(function(sValue) {
if (self.facebookSupported())
this.facebookAppID.subscribe((value) => {
if (this.facebookSupported())
{
Remote.saveAdminConfig(f1, {
'FacebookAppID': Utils.trim(sValue)
'FacebookAppID': trim(value)
});
}
});
self.facebookAppSecret.subscribe(function(sValue) {
if (self.facebookSupported())
this.facebookAppSecret.subscribe((value) => {
if (this.facebookSupported())
{
Remote.saveAdminConfig(f2, {
'FacebookAppSecret': Utils.trim(sValue)
'FacebookAppSecret': trim(value)
});
}
});
self.twitterEnable.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'TwitterEnable': bValue ? '1' : '0'
});
});
this.twitterEnable.subscribe(Remote.saveAdminConfigHelper('TwitterEnable', boolToAjax));
this.twitterConsumerKey.subscribe(Remote.saveAdminConfigHelper('TwitterConsumerKey', trim, f3));
this.twitterConsumerSecret.subscribe(Remote.saveAdminConfigHelper('TwitterConsumerSecret', trim, f4));
self.twitterConsumerKey.subscribe(function(sValue) {
Remote.saveAdminConfig(f3, {
'TwitterConsumerKey': Utils.trim(sValue)
});
});
this.googleEnable.subscribe(Remote.saveAdminConfigHelper('GoogleEnable', boolToAjax));
this.googleEnableAuth.subscribe(Remote.saveAdminConfigHelper('GoogleEnableAuth', boolToAjax));
this.googleEnableDrive.subscribe(Remote.saveAdminConfigHelper('GoogleEnableDrive', boolToAjax));
this.googleEnablePreview.subscribe(Remote.saveAdminConfigHelper('GoogleEnablePreview', boolToAjax));
this.googleClientID.subscribe(Remote.saveAdminConfigHelper('GoogleClientID', trim, f5));
this.googleClientSecret.subscribe(Remote.saveAdminConfigHelper('GoogleClientSecret', trim, f6));
this.googleApiKey.subscribe(Remote.saveAdminConfigHelper('GoogleApiKey', trim, f7));
self.twitterConsumerSecret.subscribe(function(sValue) {
Remote.saveAdminConfig(f4, {
'TwitterConsumerSecret': Utils.trim(sValue)
});
});
self.googleEnable.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'GoogleEnable': bValue ? '1' : '0'
});
});
self.googleEnableAuth.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'GoogleEnableAuth': bValue ? '1' : '0'
});
});
self.googleEnableDrive.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'GoogleEnableDrive': bValue ? '1' : '0'
});
});
self.googleEnablePreview.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'GoogleEnablePreview': bValue ? '1' : '0'
});
});
self.googleClientID.subscribe(function(sValue) {
Remote.saveAdminConfig(f5, {
'GoogleClientID': Utils.trim(sValue)
});
});
self.googleClientSecret.subscribe(function(sValue) {
Remote.saveAdminConfig(f6, {
'GoogleClientSecret': Utils.trim(sValue)
});
});
self.googleApiKey.subscribe(function(sValue) {
Remote.saveAdminConfig(f7, {
'GoogleApiKey': Utils.trim(sValue)
});
});
self.dropboxEnable.subscribe(function(bValue) {
Remote.saveAdminConfig(Utils.noop, {
'DropboxEnable': bValue ? '1' : '0'
});
});
self.dropboxApiKey.subscribe(function(sValue) {
Remote.saveAdminConfig(f8, {
'DropboxApiKey': Utils.trim(sValue)
});
});
}, 50);
};
this.dropboxEnable.subscribe(Remote.saveAdminConfigHelper('DropboxEnable', boolToAjax));
this.dropboxApiKey.subscribe(Remote.saveAdminConfigHelper('DropboxApiKey', trim, f8));
}, Magics.Time50ms);
}
}
export {SocialAdminSettings, SocialAdminSettings as default};

View file

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

View file

@ -1,19 +1,16 @@
var
_ = require('_'),
ko = require('ko'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
import {StorageResultType, Notification} from 'Common/Enums';
import {createCommand} from 'Common/Utils';
import {getNotificationFromResponse, i18n} from 'Common/Translator';
Remote = require('Remote/User/Ajax');
import Remote from 'Remote/User/Ajax';
/**
* @constructor
*/
function ChangePasswordUserSettings()
class ChangePasswordUserSettings
{
constructor() {
this.changeProcess = ko.observable(false);
this.errorDescription = ko.observable('');
@ -26,30 +23,29 @@ function ChangePasswordUserSettings()
this.newPassword = ko.observable('');
this.newPassword2 = ko.observable('');
this.currentPassword.subscribe(function() {
this.currentPassword.subscribe(() => {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.currentPassword.error(false);
}, this);
});
this.newPassword.subscribe(function() {
this.newPassword.subscribe(() => {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.passwordMismatch(false);
}, this);
});
this.newPassword2.subscribe(function() {
this.newPassword2.subscribe(() => {
this.passwordUpdateError(false);
this.passwordUpdateSuccess(false);
this.passwordMismatch(false);
}, this);
this.saveNewPasswordCommand = Utils.createCommand(this, function() {
});
this.saveNewPasswordCommand = createCommand(this, () => {
if (this.newPassword() !== this.newPassword2())
{
this.passwordMismatch(true);
this.errorDescription(Translator.i18n('SETTINGS_CHANGE_PASSWORD/ERROR_PASSWORD_MISMATCH'));
this.errorDescription(i18n('SETTINGS_CHANGE_PASSWORD/ERROR_PASSWORD_MISMATCH'));
}
else
{
@ -64,16 +60,12 @@ function ChangePasswordUserSettings()
Remote.changePassword(this.onChangePasswordResponse, this.currentPassword(), this.newPassword());
}
}, function() {
return !this.changeProcess() && '' !== this.currentPassword() &&
'' !== this.newPassword() && '' !== this.newPassword2();
});
}, () => !this.changeProcess() && '' !== this.currentPassword() && '' !== this.newPassword() && '' !== this.newPassword2());
this.onChangePasswordResponse = _.bind(this.onChangePasswordResponse, this);
}
ChangePasswordUserSettings.prototype.onHide = function()
{
onHide() {
this.changeProcess(false);
this.currentPassword('');
this.newPassword('');
@ -81,16 +73,15 @@ ChangePasswordUserSettings.prototype.onHide = function()
this.errorDescription('');
this.passwordMismatch(false);
this.currentPassword.error(false);
};
}
ChangePasswordUserSettings.prototype.onChangePasswordResponse = function(sResult, oData)
{
onChangePasswordResponse(result, data) {
this.changeProcess(false);
this.passwordMismatch(false);
this.errorDescription('');
this.currentPassword.error(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
if (StorageResultType.Success === result && data && data.Result)
{
this.currentPassword('');
this.newPassword('');
@ -99,19 +90,19 @@ ChangePasswordUserSettings.prototype.onChangePasswordResponse = function(sResult
this.passwordUpdateSuccess(true);
this.currentPassword.error(false);
require('App/User').default.setClientSideToken(oData.Result);
require('App/User').default.setClientSideToken(data.Result);
}
else
{
if (oData && Enums.Notification.CurrentPasswordIncorrect === oData.ErrorCode)
if (data && Notification.CurrentPasswordIncorrect === data.ErrorCode)
{
this.currentPassword.error(true);
}
this.passwordUpdateError(true);
this.errorDescription(
Translator.getNotificationFromResponse(oData, Enums.Notification.CouldNotSaveNewPassword));
this.errorDescription(getNotificationFromResponse(data, Notification.CouldNotSaveNewPassword));
}
}
}
};
export {ChangePasswordUserSettings, ChangePasswordUserSettings as default};

View file

@ -1,17 +1,16 @@
var
ko = require('ko'),
import ko from 'ko';
AppStore = require('Stores/User/App'),
ContactStore = require('Stores/User/Contact'),
import {Magics} from 'Common/Enums';
import {boolToAjax} from 'Common/Utils';
Remote = require('Remote/User/Ajax');
import AppStore from 'Stores/User/App';
import ContactStore from 'Stores/User/Contact';
import Remote from 'Remote/User/Ajax';
/**
* @constructor
*/
function ContactsUserSettings()
class ContactsUserSettings
{
constructor() {
this.contactsAutosave = AppStore.contactsAutosave;
this.allowContactsSync = ContactStore.allowContactsSync;
@ -20,32 +19,30 @@ function ContactsUserSettings()
this.contactsSyncUser = ContactStore.contactsSyncUser;
this.contactsSyncPass = ContactStore.contactsSyncPass;
this.saveTrigger = ko.computed(function() {
return [
this.saveTrigger = ko.computed(() => [
this.enableContactsSync() ? '1' : '0',
this.contactsSyncUrl(),
this.contactsSyncUser(),
this.contactsSyncPass()
].join('|');
}, this).extend({'throttle': 500});
].join('|')).extend({throttle: Magics.Time500ms});
}
ContactsUserSettings.prototype.onBuild = function()
{
this.contactsAutosave.subscribe(function(bValue) {
onBuild() {
this.contactsAutosave.subscribe((value) => {
Remote.saveSettings(null, {
'ContactsAutosave': bValue ? '1' : '0'
'ContactsAutosave': boolToAjax(value)
});
});
this.saveTrigger.subscribe(function() {
this.saveTrigger.subscribe(() => {
Remote.saveContactsSyncData(null,
this.enableContactsSync(),
this.contactsSyncUrl(),
this.contactsSyncUser(),
this.contactsSyncPass()
);
}, this);
};
});
}
}
export {ContactsUserSettings, ContactsUserSettings as default};

View file

@ -1,23 +1,24 @@
var
ko = require('ko'),
_ = require('_'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
import {StorageResultType, Notification} from 'Common/Enums';
import {getNotification} from 'Common/Translator';
FilterStore = require('Stores/User/Filter'),
import {
windowResizeCallback, createCommand, isArray, trim, delegateRunOnDestroy
} from 'Common/Utils';
Remote = require('Remote/User/Ajax');
import {showScreenPopup} from 'Knoin/Knoin';
/**
* @constructor
*/
function FiltersUserSettings()
import FilterStore from 'Stores/User/Filter';
import Remote from 'Remote/User/Ajax';
import {FilterModel} from 'Model/Filter';
class FiltersUserSettings
{
var self = this;
constructor() {
this.modules = FilterStore.modules;
this.filters = FilterStore.filters;
@ -28,10 +29,10 @@ function FiltersUserSettings()
this.saveErrorText = ko.observable('');
this.filters.subscribe(Utils.windowResizeCallback);
this.filters.subscribe(windowResizeCallback);
this.serverError.subscribe(function(bValue) {
if (!bValue)
this.serverError.subscribe((value) => {
if (!value)
{
this.serverErrorDesc('');
}
@ -43,14 +44,13 @@ function FiltersUserSettings()
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() {
this.filterForDeletion = ko.observable(null)
.extend({falseTimeout: 3000}).extend({toggleSubscribeProperty: [this, 'deleteAccess']});
this.saveChanges = createCommand(this, () => {
if (!this.filters.saving())
{
if (this.filterRaw.active() && '' === Utils.trim(this.filterRaw()))
if (this.filterRaw.active() && '' === trim(this.filterRaw()))
{
this.filterRaw.error(true);
return false;
@ -59,176 +59,149 @@ function FiltersUserSettings()
this.filters.saving(true);
this.saveErrorText('');
Remote.filtersSave(function(sResult, oData) {
Remote.filtersSave((result, data) => {
this.filters.saving(false);
self.filters.saving(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
if (StorageResultType.Success === result && data && data.Result)
{
self.haveChanges(false);
self.updateList();
this.haveChanges(false);
this.updateList();
}
else if (oData && oData.ErrorCode)
else if (data && data.ErrorCode)
{
self.saveErrorText(oData.ErrorMessageAdditional || Translator.getNotification(oData.ErrorCode));
this.saveErrorText(data.ErrorMessageAdditional || getNotification(data.ErrorCode));
}
else
{
self.saveErrorText(Translator.getNotification(Enums.Notification.CantSaveFilters));
this.saveErrorText(getNotification(Notification.CantSaveFilters));
}
}, this.filters(), this.filterRaw(), this.filterRaw.active());
}
return true;
}, () => this.haveChanges());
}, function() {
return this.haveChanges();
this.filters.subscribe(() => {
this.haveChanges(true);
});
this.filters.subscribe(function() {
this.haveChanges(true);
}, this);
this.filterRaw.subscribe(function() {
this.filterRaw.subscribe(() => {
this.haveChanges(true);
this.filterRaw.error(false);
}, this);
});
this.haveChanges.subscribe(function() {
this.haveChanges.subscribe(() => {
this.saveErrorText('');
}, this);
});
this.filterRaw.active.subscribe(function() {
this.filterRaw.active.subscribe(() => {
this.haveChanges(true);
this.filterRaw.error(false);
}, this);
});
}
FiltersUserSettings.prototype.scrollableOptions = function(sWrapper)
{
scrollableOptions(wrapper) {
return {
handle: '.drag-handle',
containment: sWrapper || 'parent',
containment: wrapper || 'parent',
axis: 'y'
};
};
FiltersUserSettings.prototype.updateList = function()
{
var
self = this,
FilterModel = require('Model/Filter').default;
}
updateList() {
if (!this.filters.loading())
{
this.filters.loading(true);
Remote.filtersGet(function(sResult, oData) {
Remote.filtersGet((result, data) => {
self.filters.loading(false);
self.serverError(false);
this.filters.loading(false);
this.serverError(false);
if (Enums.StorageResultType.Success === sResult && oData &&
oData.Result && Utils.isArray(oData.Result.Filters))
if (StorageResultType.Success === result && data && data.Result && isArray(data.Result.Filters))
{
self.inited(true);
self.serverError(false);
this.inited(true);
this.serverError(false);
var aResult = _.compact(_.map(oData.Result.Filters, function(aItem) {
var oNew = new FilterModel();
return (oNew && oNew.parse(aItem)) ? oNew : null;
}));
this.filters(_.compact(_.map(data.Result.Filters, (aItem) => {
const filter = new FilterModel();
return (filter && filter.parse(aItem)) ? filter : null;
})));
self.filters(aResult);
this.modules(data.Result.Modules ? data.Result.Modules : {});
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);
this.filterRaw(data.Result.Raw || '');
this.filterRaw.capa(isArray(data.Result.Capa) ? data.Result.Capa.join(' ') : '');
this.filterRaw.active(!!data.Result.RawIsActive);
this.filterRaw.allow(!!data.Result.RawIsAllow);
}
else
{
self.filters([]);
self.modules({});
self.filterRaw('');
self.filterRaw.capa({});
this.filters([]);
this.modules({});
this.filterRaw('');
this.filterRaw.capa({});
self.serverError(true);
self.serverErrorDesc(oData && oData.ErrorCode ? Translator.getNotification(oData.ErrorCode) :
Translator.getNotification(Enums.Notification.CantGetFilters));
this.serverError(true);
this.serverErrorDesc(data && data.ErrorCode ? getNotification(data.ErrorCode) : getNotification(Notification.CantGetFilters));
}
self.haveChanges(false);
this.haveChanges(false);
});
}
};
FiltersUserSettings.prototype.deleteFilter = function(oFilter)
{
this.filters.remove(oFilter);
Utils.delegateRunOnDestroy(oFilter);
};
FiltersUserSettings.prototype.addFilter = function()
{
var
self = this,
FilterModel = require('Model/Filter').default,
oNew = new FilterModel();
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]);
};
deleteFilter(filter) {
this.filters.remove(filter);
delegateRunOnDestroy(filter);
}
FiltersUserSettings.prototype.onBuild = function(oDom)
addFilter() {
const filter = new FilterModel();
filter.generateID();
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);
if (-1 < index && filters[index])
{
var self = this;
delegateRunOnDestroy(filters[index]);
filters[index] = clonedFilter;
this.filters(filters);
this.haveChanges(true);
}
}, true]);
}
onBuild(oDom) {
const self = this;
oDom
.on('click', '.filter-item .e-action', function() {
var oFilterItem = ko.dataFor(this);
if (oFilterItem)
const filter = ko.dataFor(this);
if (filter)
{
self.editFilter(oFilterItem);
self.editFilter(filter);
}
});
};
}
FiltersUserSettings.prototype.onShow = function()
{
onShow() {
this.updateList();
};
}
}
export {FiltersUserSettings, FiltersUserSettings as default};

View file

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

View file

@ -1,32 +1,37 @@
var
_ = require('_'),
ko = require('ko'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Consts = require('Common/Consts'),
Globals = require('Common/Globals'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
import {MESSAGES_PER_PAGE_VALUES} from 'Common/Consts';
import {bAnimationSupported} from 'Common/Globals';
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'),
import {SaveSettingsStep, Magics, EditorDefaultType, Layout} from 'Common/Enums';
Remote = require('Remote/User/Ajax');
import {
settingsSaveHelperSimpleFunction,
convertLangName, isArray, timeOutAction, boolToAjax
} from 'Common/Utils';
/**
* @constructor
*/
function GeneralUserSettings()
import {i18n, trigger as translatorTrigger, reload as translatorReload} from 'Common/Translator';
import {showScreenPopup} from 'Knoin/Knoin';
import AppStore from 'Stores/User/App';
import LanguageStore from 'Stores/Language';
import SettingsStore from 'Stores/User/Settings';
import IdentityStore from 'Stores/User/Identity';
import NotificationStore from 'Stores/User/Notification';
import MessageStore from 'Stores/User/Message';
import Remote from 'Remote/User/Ajax';
class GeneralUserSettings
{
constructor() {
this.language = LanguageStore.language;
this.languages = LanguageStore.languages;
this.messagesPerPage = SettingsStore.messagesPerPage;
this.messagesPerPageArray = Consts.MESSAGES_PER_PAGE_VALUES;
this.messagesPerPageArray = MESSAGES_PER_PAGE_VALUES;
this.editorDefaultType = SettingsStore.editorDefaultType;
this.layout = SettingsStore.layout;
@ -46,179 +51,138 @@ function GeneralUserSettings()
this.replySameFolder = SettingsStore.replySameFolder;
this.allowLanguagesOnSettings = AppStore.allowLanguagesOnSettings;
this.languageFullName = ko.computed(function() {
return Utils.convertLangName(this.language());
}, this);
this.languageFullName = ko.computed(() => convertLangName(this.language()));
this.languageTrigger = ko.observable(SaveSettingsStep.Idle).extend({throttle: Magics.Time100ms});
this.languageTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': Enums.Magics.Time100ms});
this.mppTrigger = ko.observable(SaveSettingsStep.Idle);
this.editorDefaultTypeTrigger = ko.observable(SaveSettingsStep.Idle);
this.layoutTrigger = ko.observable(SaveSettingsStep.Idle);
this.mppTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.editorDefaultTypeTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.layoutTrigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.isAnimationSupported = Globals.bAnimationSupported;
this.isAnimationSupported = bAnimationSupported;
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();
}) : null;
}, this);
this.identityMain = ko.computed(() => {
const list = this.identities();
return isArray(list) ? _.find(list, (item) => item && '' === item.id()) : null;
});
this.identityMainDesc = ko.computed(function() {
var oIdentity = this.identityMain();
return oIdentity ? oIdentity.formattedName() : '---';
}, this);
this.identityMainDesc = ko.computed(() => {
const identity = this.identityMain();
return identity ? identity.formattedName() : '---';
});
this.editorDefaultTypes = ko.computed(function() {
Translator.trigger();
this.editorDefaultTypes = ko.computed(() => {
translatorTrigger();
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')}
{'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);
});
this.layoutTypes = ko.computed(function() {
Translator.trigger();
this.layoutTypes = ko.computed(() => {
translatorTrigger();
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')}
{'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')}
];
}, this);
});
}
GeneralUserSettings.prototype.editMainIdentity = function()
editMainIdentity() {
const identity = this.identityMain();
if (identity)
{
var oIdentity = this.identityMain();
if (oIdentity)
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Identity'), [oIdentity]);
showScreenPopup(require('View/Popup/Identity'), [identity]);
}
}
};
GeneralUserSettings.prototype.testSoundNotification = function()
{
testSoundNotification() {
NotificationStore.playSoundNotification(true);
}
onBuild() {
_.delay(() => {
const
f0 = settingsSaveHelperSimpleFunction(this.editorDefaultTypeTrigger, this),
f1 = settingsSaveHelperSimpleFunction(this.mppTrigger, this),
f2 = settingsSaveHelperSimpleFunction(this.layoutTrigger, this),
fReloadLanguageHelper = (saveSettingsStep) => () => {
this.languageTrigger(saveSettingsStep);
_.delay(() => this.languageTrigger(SaveSettingsStep.Idle), Magics.Time1s);
};
GeneralUserSettings.prototype.onBuild = function()
{
var self = this;
_.delay(function() {
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);
}, Enums.Magics.Time1s);
};
};
self.language.subscribe(function(sValue) {
self.languageTrigger(Enums.SaveSettingsStep.Animate);
Translator.reload(false, sValue).then(
fReloadLanguageHelper(Enums.SaveSettingsStep.TrueResult),
fReloadLanguageHelper(Enums.SaveSettingsStep.FalseResult)
).then(function() {
this.language.subscribe((value) => {
this.languageTrigger(SaveSettingsStep.Animate);
translatorReload(false, value).then(
fReloadLanguageHelper(SaveSettingsStep.TrueResult),
fReloadLanguageHelper(SaveSettingsStep.FalseResult)
).then(() => {
Remote.saveSettings(null, {
'Language': sValue
'Language': value
});
});
});
self.editorDefaultType.subscribe(function(sValue) {
Remote.saveSettings(f0, {
'EditorDefaultType': sValue
});
});
this.editorDefaultType.subscribe(Remote.saveSettingsHelper('EditorDefaultType', null, f0));
this.messagesPerPage.subscribe(Remote.saveSettingsHelper('MPP', null, f1));
this.showImages.subscribe(Remote.saveSettingsHelper('ShowImages', boolToAjax));
self.messagesPerPage.subscribe(function(iValue) {
Remote.saveSettings(f1, {
'MPP': iValue
});
});
this.useCheckboxesInList.subscribe(Remote.saveSettingsHelper('UseCheckboxesInList', boolToAjax));
self.showImages.subscribe(function(bValue) {
this.enableDesktopNotification.subscribe((value) => {
timeOutAction('SaveDesktopNotifications', () => {
Remote.saveSettings(null, {
'ShowImages': bValue ? '1' : '0'
'DesktopNotifications': boolToAjax(value)
});
}, Magics.Time3s);
});
self.enableDesktopNotification.subscribe(function(bValue) {
Utils.timeOutAction('SaveDesktopNotifications', function() {
this.enableSoundNotification.subscribe((value) => {
timeOutAction('SaveSoundNotification', () => {
Remote.saveSettings(null, {
'DesktopNotifications': bValue ? '1' : '0'
'SoundNotification': boolToAjax(value)
});
}, Enums.Magics.Time3s);
}, Magics.Time3s);
});
self.enableSoundNotification.subscribe(function(bValue) {
Utils.timeOutAction('SaveSoundNotification', function() {
this.replySameFolder.subscribe((value) => {
timeOutAction('SaveReplySameFolder', () => {
Remote.saveSettings(null, {
'SoundNotification': bValue ? '1' : '0'
'ReplySameFolder': boolToAjax(value)
});
}, Enums.Magics.Time3s);
}, Magics.Time3s);
});
self.replySameFolder.subscribe(function(bValue) {
Utils.timeOutAction('SaveReplySameFolder', function() {
Remote.saveSettings(null, {
'ReplySameFolder': bValue ? '1' : '0'
});
}, Enums.Magics.Time3s);
});
self.useThreads.subscribe(function(bValue) {
this.useThreads.subscribe((value) => {
MessageStore.messageList([]);
Remote.saveSettings(null, {
'UseThreads': bValue ? '1' : '0'
'UseThreads': boolToAjax(value)
});
});
self.layout.subscribe(function(nValue) {
this.layout.subscribe(function(value) {
MessageStore.messageList([]);
Remote.saveSettings(f2, {
'Layout': nValue
'Layout': value
});
});
}, Magics.Time50ms);
}
self.useCheckboxesInList.subscribe(function(bValue) {
Remote.saveSettings(null, {
'UseCheckboxesInList': bValue ? '1' : '0'
});
});
}, Enums.Magics.Time50ms);
};
GeneralUserSettings.prototype.onShow = function()
{
onShow() {
this.enableDesktopNotification.valueHasMutated();
};
}
GeneralUserSettings.prototype.selectLanguage = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Languages'), [
selectLanguage() {
showScreenPopup(require('View/Popup/Languages'), [
this.language, this.languages(), LanguageStore.userLanguage()
]);
};
}
}
export {GeneralUserSettings, GeneralUserSettings as default};

View file

@ -1,69 +1,61 @@
var
_ = require('_'),
ko = require('ko'),
window = require('window'),
import _ from '_';
import ko from 'ko';
Utils = require('Common/Utils'),
import {delegateRunOnDestroy} from 'Common/Utils';
import {bIsHttps} from 'Common/Globals';
kn = require('Knoin/Knoin'),
import {showScreenPopup} from 'Knoin/Knoin';
PgpStore = require('Stores/User/Pgp');
import PgpStore from 'Stores/User/Pgp';
/**
* @constructor
*/
function OpenPgpUserSettings()
class OpenPgpUserSettings
{
constructor() {
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;
this.isHttps = bIsHttps;
}
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)
{
kn.showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [oOpenPgpKey]);
addOpenPgpKey() {
showScreenPopup(require('View/Popup/AddOpenPgpKey'));
}
generateOpenPgpKey() {
showScreenPopup(require('View/Popup/NewOpenPgpKey'));
}
viewOpenPgpKey(openPgpKey) {
if (openPgpKey)
{
showScreenPopup(require('View/Popup/ViewOpenPgpKey'), [openPgpKey]);
}
}
};
/**
* @param {OpenPgpKeyModel} oOpenPgpKeyToRemove
* @param {OpenPgpKeyModel} openPgpKeyToRemove
* @returns {void}
*/
OpenPgpUserSettings.prototype.deleteOpenPgpKey = function(oOpenPgpKeyToRemove)
{
if (oOpenPgpKeyToRemove && oOpenPgpKeyToRemove.deleteAccess())
deleteOpenPgpKey(openPgpKeyToRemove) {
if (openPgpKeyToRemove && openPgpKeyToRemove.deleteAccess())
{
this.openPgpKeyForDeletion(null);
if (oOpenPgpKeyToRemove && PgpStore.openpgpKeyring)
if (openPgpKeyToRemove && PgpStore.openpgpKeyring)
{
var oFindedItem = _.find(PgpStore.openpgpkeys(), function(oOpenPgpKey) {
return oOpenPgpKeyToRemove === oOpenPgpKey;
});
if (oFindedItem)
const findedItem = _.find(PgpStore.openpgpkeys(), (key) => openPgpKeyToRemove === key);
if (findedItem)
{
PgpStore.openpgpkeys.remove(oFindedItem);
Utils.delegateRunOnDestroy(oFindedItem);
PgpStore.openpgpkeys.remove(findedItem);
delegateRunOnDestroy(findedItem);
PgpStore.openpgpKeyring[oFindedItem.isPrivate ? 'privateKeys' : 'publicKeys']
.removeForId(oFindedItem.guid);
PgpStore
.openpgpKeyring[findedItem.isPrivate ? 'privateKeys' : 'publicKeys']
.removeForId(findedItem.guid);
PgpStore.openpgpKeyring.store();
}
@ -71,6 +63,7 @@ OpenPgpUserSettings.prototype.deleteOpenPgpKey = function(oOpenPgpKeyToRemove)
require('App/User').default.reloadOpenPgpKeys();
}
}
};
}
}
export {OpenPgpUserSettings, OpenPgpUserSettings as default};

View file

@ -1,68 +1,57 @@
var
_ = require('_'),
ko = require('ko'),
import _ from '_';
import ko from 'ko';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Translator = require('Common/Translator'),
import {pInt, settingsSaveHelperSimpleFunction} from 'Common/Utils';
import {Capa, SaveSettingsStep} from 'Common/Enums';
import {i18n, trigger as translatorTrigger} from 'Common/Translator';
SettinsStore = require('Stores/User/Settings'),
import {capa} from 'Storage/Settings';
Settings = require('Storage/Settings'),
import {showScreenPopup} from 'Knoin/Knoin';
Remote = require('Remote/User/Ajax');
import SettinsStore from 'Stores/User/Settings';
/**
* @constructor
*/
function SecurityUserSettings()
import Remote from 'Remote/User/Ajax';
class SecurityUserSettings
{
this.capaAutoLogout = Settings.capa(Enums.Capa.AutoLogout);
this.capaTwoFactor = Settings.capa(Enums.Capa.TwoFactor);
constructor() {
this.capaAutoLogout = capa(Capa.AutoLogout);
this.capaTwoFactor = capa(Capa.TwoFactor);
this.autoLogout = SettinsStore.autoLogout;
this.autoLogout.trigger = ko.observable(Enums.SaveSettingsStep.Idle);
this.autoLogout.trigger = ko.observable(SaveSettingsStep.Idle);
this.autoLogoutOptions = ko.computed(function() {
Translator.trigger();
this.autoLogoutOptions = ko.computed(() => {
translatorTrigger();
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})}
{'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})}
];
});
}
SecurityUserSettings.prototype.configureTwoFactor = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/TwoFactorConfiguration'));
};
configureTwoFactor() {
showScreenPopup(require('View/Popup/TwoFactorConfiguration'));
}
SecurityUserSettings.prototype.onBuild = function()
{
onBuild() {
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)
});
});
_.delay(() => {
const f0 = settingsSaveHelperSimpleFunction(this.autoLogout.trigger, this);
this.autoLogout.subscribe(Remote.saveSettingsHelper('AutoLogout', pInt, f0));
});
}
};
}
}
export {SecurityUserSettings, SecurityUserSettings as default};

View file

@ -1,13 +1,11 @@
/**
* @constructor
*/
function SocialUserSettings()
import {createCommand} from 'Common/Utils';
import SocialStore from 'Stores/Social';
class SocialUserSettings
{
var
Utils = require('Common/Utils'),
SocialStore = require('Stores/Social');
constructor() {
this.googleEnable = SocialStore.google.enabled;
this.googleEnableAuth = SocialStore.google.capa.auth;
this.googleEnableAuthFast = SocialStore.google.capa.authFast;
@ -30,44 +28,43 @@ function SocialUserSettings()
this.twitterLoggined = SocialStore.twitter.loggined;
this.twitterUserName = SocialStore.twitter.userName;
this.connectGoogle = Utils.createCommand(this, function() {
this.connectGoogle = createCommand(this, () => {
if (!this.googleLoggined())
{
require('App/User').default.googleConnect();
this.getApp().googleConnect();
}
}, function() {
return !this.googleLoggined() && !this.googleActions();
}, () => !this.googleLoggined() && !this.googleActions());
this.disconnectGoogle = createCommand(this, () => {
this.getApp().googleDisconnect();
});
this.disconnectGoogle = Utils.createCommand(this, function() {
require('App/User').default.googleDisconnect();
});
this.connectFacebook = Utils.createCommand(this, function() {
this.connectFacebook = createCommand(this, () => {
if (!this.facebookLoggined())
{
require('App/User').default.facebookConnect();
this.getApp().facebookConnect();
}
}, function() {
return !this.facebookLoggined() && !this.facebookActions();
}, () => !this.facebookLoggined() && !this.facebookActions());
this.disconnectFacebook = createCommand(this, () => {
this.getApp().facebookDisconnect();
});
this.disconnectFacebook = Utils.createCommand(this, function() {
require('App/User').default.facebookDisconnect();
});
this.connectTwitter = Utils.createCommand(this, function() {
this.connectTwitter = createCommand(this, () => {
if (!this.twitterLoggined())
{
require('App/User').default.twitterConnect();
this.getApp().twitterConnect();
}
}, function() {
return !this.twitterLoggined() && !this.twitterActions();
});
}, () => !this.twitterLoggined() && !this.twitterActions());
this.disconnectTwitter = Utils.createCommand(this, function() {
require('App/User').default.twitterDisconnect();
this.disconnectTwitter = createCommand(this, () => {
this.getApp().twitterDisconnect();
});
}
getApp() {
return require('App/User').default;
}
}
export {SocialUserSettings, SocialUserSettings as default};

View file

@ -1,98 +1,81 @@
var
ko = require('ko'),
import ko from 'ko';
Translator = require('Common/Translator'),
import {i18n} from 'Common/Translator';
TemplateStore = require('Stores/User/Template'),
import {showScreenPopup} from 'Knoin/Knoin';
Remote = require('Remote/User/Ajax');
import TemplateStore from 'Stores/User/Template';
import Remote from 'Remote/User/Ajax';
/**
* @constructor
*/
function TemplatesUserSettings()
class TemplatesUserSettings
{
constructor() {
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.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();
}
TemplatesUserSettings.prototype.scrollableOptions = function(sWrapper)
{
scrollableOptions(sWrapper) {
return {
handle: '.drag-handle',
containment: sWrapper || 'parent',
axis: 'y'
};
};
}
TemplatesUserSettings.prototype.addNewTemplate = function()
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Template'));
};
addNewTemplate() {
showScreenPopup(require('View/Popup/Template'));
}
TemplatesUserSettings.prototype.editTemplate = function(oTemplateItem)
{
editTemplate(oTemplateItem) {
if (oTemplateItem)
{
require('Knoin/Knoin').showScreenPopup(require('View/Popup/Template'), [oTemplateItem]);
showScreenPopup(require('View/Popup/Template'), [oTemplateItem]);
}
}
};
/**
* @param {AccountModel} oTemplateToRemove
*/
TemplatesUserSettings.prototype.deleteTemplate = function(oTemplateToRemove)
{
if (oTemplateToRemove && oTemplateToRemove.deleteAccess())
deleteTemplate(templateToRemove) {
if (templateToRemove && templateToRemove.deleteAccess())
{
this.templateForDeletion(null);
var
self = this,
fRemoveAccount = function(oAccount) {
return oTemplateToRemove === oAccount;
};
if (oTemplateToRemove)
if (templateToRemove)
{
this.templates.remove(fRemoveAccount);
this.templates.remove((template) => templateToRemove === template);
Remote.templateDelete(function() {
self.reloadTemplates();
}, oTemplateToRemove.id);
Remote.templateDelete(() => {
this.reloadTemplates();
}, templateToRemove.id);
}
}
}
};
TemplatesUserSettings.prototype.reloadTemplates = function()
{
require('App/User').default.templates();
};
reloadTemplates() {
this.getApp().templates();
}
TemplatesUserSettings.prototype.onBuild = function(oDom)
{
getApp() {
return require('App/User').default;
}
onBuild(oDom) {
var self = this;
oDom
.on('click', '.templates-list .template-item .e-action', function() {
var oTemplateItem = ko.dataFor(this);
if (oTemplateItem)
const template = ko.dataFor(this);
if (template)
{
self.editTemplate(oTemplateItem);
self.editTemplate(template);
}
});
this.reloadTemplates();
};
}
}
export {TemplatesUserSettings, TemplatesUserSettings as default};

View file

@ -1,27 +1,24 @@
var
_ = require('_'),
$ = require('$'),
ko = require('ko'),
import _ from '_';
import $ from '$';
import ko from 'ko';
Jua = require('Jua'),
import Jua from 'Jua';
Enums = require('Common/Enums'),
Utils = require('Common/Utils'),
Links = require('Common/Links'),
Translator = require('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';
ThemeStore = require('Stores/Theme'),
import {capa} from 'Storage/Settings';
Settings = require('Storage/Settings'),
import ThemeStore from 'Stores/Theme';
Remote = require('Remote/User/Ajax');
import Remote from 'Remote/User/Ajax';
/**
* @constructor
*/
function ThemesUserSettings()
class ThemesUserSettings
{
constructor() {
this.theme = ThemeStore.theme;
this.themes = ThemeStore.themes;
this.themesObjects = ko.observableArray([]);
@ -33,87 +30,76 @@ function ThemesUserSettings()
this.background.loading = ko.observable(false);
this.background.error = ko.observable('');
this.capaUserBackground = ko.observable(Settings.capa(Enums.Capa.UserBackground));
this.capaUserBackground = ko.observable(capa(Capa.UserBackground));
this.themeTrigger = ko.observable(Enums.SaveSettingsStep.Idle).extend({'throttle': 100});
this.themeTrigger = ko.observable(SaveSettingsStep.Idle).extend({throttle: Magics.Time100ms});
this.iTimer = 0;
this.oThemeAjaxRequest = null;
this.theme.subscribe(function(sValue) {
_.each(this.themesObjects(), function(oTheme) {
oTheme.selected(sValue === oTheme.name);
this.theme.subscribe((value) => {
_.each(this.themesObjects(), (theme) => {
theme.selected(value === theme.name);
});
Utils.changeTheme(sValue, this.themeTrigger);
changeTheme(value, this.themeTrigger);
Remote.saveSettings(null, {
'Theme': sValue
'Theme': value
});
});
}, this);
this.background.hash.subscribe(function(sValue) {
var $oBg = $('#rl-bg');
if (!sValue)
this.background.hash.subscribe((value) => {
const $bg = $('#rl-bg');
if (!value)
{
if ($oBg.data('backstretch'))
if ($bg.data('backstretch'))
{
$oBg.backstretch('destroy').attr('style', '');
$bg.backstretch('destroy').attr('style', '');
}
}
else
{
$('#rl-bg').attr('style', 'background-image: none !important;').backstretch(
Links.userBackground(sValue), {
'fade': 1000, 'centeredX': true, 'centeredY': true
$bg.attr('style', 'background-image: none !important;').backstretch(userBackground(value), {
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())
{
var self = this;
Remote.clearUserBackground(function() {
self.background.name('');
self.background.hash('');
});
}
};
ThemesUserSettings.prototype.initUploader = function()
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.initUploader();
}
onShow() {
this.background.error('');
}
clearBackground() {
if (this.capaUserBackground())
{
Remote.clearUserBackground(() => {
this.background.name('');
this.background.hash('');
});
}
}
initUploader() {
if (this.background.uploaderButton() && this.capaUserBackground())
{
var
const
oJua = new Jua({
'action': Links.uploadBackground(),
'action': uploadBackground(),
'name': 'uploader',
'queueSize': 1,
'multipleSizeLimit': 1,
@ -123,55 +109,51 @@ ThemesUserSettings.prototype.initUploader = function()
});
oJua
.on('onStart', _.bind(function() {
.on('onStart', () => {
this.background.loading(true);
this.background.error('');
return true;
}, this))
.on('onComplete', _.bind(function(sId, bResult, oData) {
})
.on('onComplete', (id, result, data) => {
this.background.loading(false);
if (bResult && sId && oData && oData.Result && oData.Result.Name && oData.Result.Hash)
if (result && id && data && data.Result && data.Result.Name && data.Result.Hash)
{
this.background.name(oData.Result.Name);
this.background.hash(oData.Result.Hash);
this.background.name(data.Result.Name);
this.background.hash(data.Result.Hash);
}
else
{
this.background.name('');
this.background.hash('');
var sError = '';
if (oData.ErrorCode)
let errorMsg = '';
if (data.ErrorCode)
{
switch (oData.ErrorCode)
switch (data.ErrorCode)
{
case Enums.UploadErrorCode.FileIsTooBig:
sError = Translator.i18n('SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG');
case UploadErrorCode.FileIsTooBig:
errorMsg = i18n('SETTINGS_THEMES/ERROR_FILE_IS_TOO_BIG');
break;
case Enums.UploadErrorCode.FileType:
sError = Translator.i18n('SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR');
case UploadErrorCode.FileType:
errorMsg = i18n('SETTINGS_THEMES/ERROR_FILE_TYPE_ERROR');
break;
// no default
}
}
if (!sError && oData.ErrorMessage)
if (!errorMsg && data.ErrorMessage)
{
sError = oData.ErrorMessage;
errorMsg = data.ErrorMessage;
}
this.background.error(sError || Translator.i18n('SETTINGS_THEMES/ERROR_UNKNOWN'));
this.background.error(errorMsg || i18n('SETTINGS_THEMES/ERROR_UNKNOWN'));
}
return true;
}, this));
});
}
}
}
};
export {ThemesUserSettings, ThemesUserSettings as default};

View file

@ -5,8 +5,7 @@ import * as Settings from 'Storage/Settings';
class AbstractAppStore
{
constructor()
{
constructor() {
this.allowLanguagesOnSettings = ko.observable(true);
this.allowLanguagesOnLogin = ko.observable(true);

View file

@ -5,8 +5,7 @@ import {AbstractAppStore} from 'Stores/AbstractApp';
class AppAdminStore extends AbstractAppStore
{
constructor()
{
constructor() {
super();
this.determineUserLanguage = ko.observable(false);

View file

@ -9,8 +9,7 @@ import {AbstractAppStore} from 'Stores/AbstractApp';
class AppUserStore extends AbstractAppStore
{
constructor()
{
constructor() {
super();
this.currentAudio = ko.observable('');

View file

@ -4,8 +4,7 @@ import ko from 'ko';
class IdentityUserStore
{
constructor()
{
constructor() {
this.identities = ko.observableArray([]);
this.identities.loading = ko.observable(false).extend({throttle: 100});

View file

@ -75,7 +75,10 @@ PgpUserStore.prototype.findPublicKeysBySigningKeyIds = function(aSigningKeyIds)
PgpUserStore.prototype.findPrivateKeysByEncryptionKeyIds = function(aEncryptionKeyIds, aRecipients, bReturnWrapKeys)
{
var self = this, aResult = [];
var
self = this,
aResult = [];
aResult = Utils.isArray(aEncryptionKeyIds) ? _.compact(_.flatten(_.map(aEncryptionKeyIds, function(oId) {
var oKey = oId && oId.toHex ? self.findPrivateKeyByHex(oId.toHex()) : null;
return oKey ? (bReturnWrapKeys ? [oKey] : oKey.getNativeKeys()) : [null];
@ -184,7 +187,10 @@ PgpUserStore.prototype.findSelfPrivateKey = function(sPassword)
PgpUserStore.prototype.decryptMessage = function(oMessage, aRecipients, fCallback)
{
var self = this, aPrivateKeys = [];
var
self = this,
aPrivateKeys = [];
if (oMessage && oMessage.getEncryptionKeyIds)
{
aPrivateKeys = this.findPrivateKeysByEncryptionKeyIds(oMessage.getEncryptionKeyIds(), aRecipients, true);
@ -254,7 +260,12 @@ PgpUserStore.prototype.findKeyExternal = function(sEmail, fCallback)
PgpUserStore.prototype.verifyMessage = function(oMessage, fCallback)
{
var oValid = null, aResult = [], aPublicKeys = [], aSigningKeyIds = [];
var
oValid = null,
aResult = [],
aPublicKeys = [],
aSigningKeyIds = [];
if (oMessage && oMessage.getSigningKeyIds)
{
aSigningKeyIds = oMessage.getSigningKeyIds();
@ -323,8 +334,9 @@ PgpUserStore.prototype.controlsHelper = function(mDom, oVerControl, bSuccess, sT
PgpUserStore.domControlEncryptedClickHelper = function(store, mDom, sArmoredMessage, aRecipients)
{
return function() {
var oMessage = null, $this = $(this);
var
oMessage = null,
$this = $(this);
if ($this.hasClass('success'))
{
@ -393,7 +405,10 @@ PgpUserStore.domControlSignedClickHelper = function(store, mDom, sArmoredMessage
{
return function() {
var oMessage = null, $this = $(this);
var
oMessage = null,
$this = $(this);
if ($this.hasClass('success') || $this.hasClass('error'))
{
return false;

View file

@ -3,6 +3,13 @@
transform: rotate(1turn);
}
}
html, body {
padding: 0;
margin: 0;
overflow: hidden;
}
.social-icon-wrp {
position: absolute;
top: 0;

View file

@ -1,6 +1,8 @@
var
_ = require('_'),
$ = require('$'),
key = require('key'),
Globals = require('Common/Globals'),
Enums = require('Common/Enums'),

View file

@ -4,6 +4,7 @@ var
_ = require('_'),
$ = require('$'),
ko = require('ko'),
key = require('key'),
JSON = require('JSON'),
Jua = require('Jua'),
@ -928,7 +929,10 @@ ComposePopupView.prototype.setSignatureFromIdentity = function(oIdentity)
{
var self = this;
this.editor(function(oEditor) {
var bHtml = false, sSignature = oIdentity.signature();
var
bHtml = false,
sSignature = oIdentity.signature();
if ('' !== sSignature)
{
if (':HTML:' === sSignature.substr(0, 6))

View file

@ -6,6 +6,8 @@ var
ko = require('ko'),
key = require('key'),
Jua = require('Jua'),
Enums = require('Common/Enums'),
Consts = require('Common/Consts'),
Globals = require('Common/Globals'),

View file

@ -28,6 +28,7 @@ function NewOpenPgpKeyPopupView()
this.keyBitLength = ko.observable(Enums.Magics.BitLength2048);
this.submitRequest = ko.observable(false);
this.submitError = ko.observable('');
this.email.subscribe(function() {
this.email.error(false);
@ -53,6 +54,7 @@ function NewOpenPgpKeyPopupView()
}
this.submitRequest(true);
this.submitError('');
_.delay(function() {
@ -81,14 +83,15 @@ function NewOpenPgpKeyPopupView()
Utils.delegateRun(self, 'cancelCommand');
}
}).then(null, function() {
}).then(null, function(e) {
self.submitRequest(false);
self.showError(e);
});
}
catch (e)
{
Utils.log(e);
self.submitRequest(false);
self.showError(e);
}
}, Enums.Magics.Time100ms);
@ -102,6 +105,15 @@ function NewOpenPgpKeyPopupView()
kn.extendAsViewModel(['View/Popup/NewOpenPgpKey', 'PopupsNewOpenPgpKeyViewModel'], NewOpenPgpKeyPopupView);
_.extend(NewOpenPgpKeyPopupView.prototype, AbstractView.prototype);
NewOpenPgpKeyPopupView.prototype.showError = function(e)
{
Utils.log(e);
if (e && e.message)
{
this.submitError(e.message);
}
};
NewOpenPgpKeyPopupView.prototype.clearPopup = function()
{
this.name('');
@ -110,6 +122,8 @@ NewOpenPgpKeyPopupView.prototype.clearPopup = function()
this.email('');
this.email.error(false);
this.keyBitLength(Enums.Magics.BitLength2048);
this.submitError('');
};
NewOpenPgpKeyPopupView.prototype.onShow = function()

View file

@ -60,15 +60,14 @@ function PluginPopupView()
list.Name = this.name();
_.each(this.configures(), function(oItem) {
var value = oItem.value();
if (false === value || true === value)
{
value = value ? '1' : '0';
}
list['_' + oItem.Name] = value;
}, this);
this.saveError('');
@ -119,6 +118,7 @@ PluginPopupView.prototype.onShow = function(oPlugin)
this.readme(oPlugin.Readme);
var aConfig = oPlugin.Config;
if (Utils.isNonEmptyArray(aConfig))
{
this.configures(_.map(aConfig, function(aItem) {
@ -160,6 +160,7 @@ PluginPopupView.prototype.onBuild = function()
{
this.tryToClosePopup();
}
return false;
}, this));
};

View file

@ -124,9 +124,10 @@ TemplatePopupView.prototype.populateBodyFromEditor = function()
TemplatePopupView.prototype.editorSetBody = function(sBody)
{
var self = this;
if (!this.editor && this.signatureDom())
{
var self = this;
this.editor = new HtmlEditor(self.signatureDom(), function() {
self.populateBodyFromEditor();
}, function() {

View file

@ -135,7 +135,6 @@ function LoginUserView()
}, this);
this.submitCommand = Utils.createCommand(this, function() {
Utils.triggerAutocompleteInputChange();
this.emailError(false);
@ -276,7 +275,6 @@ function LoginUserView()
}
return true;
}, function() {
return !this.submitRequest();
});
@ -284,12 +282,9 @@ function LoginUserView()
this.facebookLoginEnabled = ko.observable(false);
this.facebookCommand = Utils.createCommand(this, function() {
window.open(Links.socialFacebook(), 'Facebook',
'left=200,top=100,width=650,height=450,menubar=no,status=no,resizable=yes,scrollbars=yes');
'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function() {
return !this.submitRequest() && this.facebookLoginEnabled();
});
@ -298,23 +293,17 @@ function LoginUserView()
this.googleFastLoginEnabled = ko.observable(false);
this.googleCommand = Utils.createCommand(this, function() {
window.open(Links.socialGoogle(), 'Google',
'left=200,top=100,width=650,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function() {
return !this.submitRequest() && this.googleLoginEnabled();
});
this.googleFastCommand = Utils.createCommand(this, function() {
window.open(Links.socialGoogle(true), 'Google',
'left=200,top=100,width=650,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
'left=200,top=100,width=550,height=550,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function() {
return !this.submitRequest() && this.googleFastLoginEnabled();
});
@ -322,18 +311,14 @@ function LoginUserView()
this.twitterLoginEnabled = ko.observable(false);
this.twitterCommand = Utils.createCommand(this, function() {
window.open(Links.socialTwitter(), 'Twitter',
'left=200,top=100,width=650,height=450,menubar=no,status=no,resizable=yes,scrollbars=yes');
'left=200,top=100,width=500,height=500,menubar=no,status=no,resizable=yes,scrollbars=yes');
return true;
}, function() {
return !this.submitRequest() && this.twitterLoginEnabled();
});
this.socialLoginEnabled = ko.computed(function() {
var
bF = this.facebookLoginEnabled(),
bG = this.googleLoginEnabled(),

View file

@ -182,7 +182,11 @@ FolderListMailBoxUserView.prototype.onBuild = function(oDom)
});
key('space', Enums.KeyState.FolderList, function() {
var bCollapsed = true, oFolder = null, $items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
var
bCollapsed = true,
oFolder = null,
$items = $('.b-folders .e-item .e-link:not(.hidden).focused', oDom);
if ($items.length && $items[0])
{
oFolder = ko.dataFor($items[0]);

View file

@ -1068,7 +1068,10 @@ MessageViewMailBoxUserView.prototype.getAttachmentsHashes = function()
MessageViewMailBoxUserView.prototype.downloadAsZip = function()
{
var self = this, aHashes = this.getAttachmentsHashes();
var
self = this,
aHashes = this.getAttachmentsHashes();
if (0 < aHashes.length)
{
Promises.attachmentsActions('Zip', aHashes, this.downloadAsZipLoading).then(function(oResult) {
@ -1094,7 +1097,10 @@ MessageViewMailBoxUserView.prototype.downloadAsZip = function()
MessageViewMailBoxUserView.prototype.saveToOwnCloud = function()
{
var self = this, aHashes = this.getAttachmentsHashes();
var
self = this,
aHashes = this.getAttachmentsHashes();
if (0 < aHashes.length)
{
Promises.attachmentsActions('OwnCloud', aHashes, this.saveToOwnCloudLoading).then(function(oResult) {
@ -1118,7 +1124,11 @@ MessageViewMailBoxUserView.prototype.saveToOwnCloud = function()
MessageViewMailBoxUserView.prototype.saveToDropbox = function()
{
var self = this, aFiles = [], aHashes = this.getAttachmentsHashes();
var
self = this,
aFiles = [],
aHashes = this.getAttachmentsHashes();
if (0 < aHashes.length)
{
if (window.Dropbox)

View file

@ -1,6 +1,7 @@
var
_ = require('_'),
$ = require('$'),
key = require('key'),
Enums = require('Common/Enums'),

View file

@ -1,7 +1,7 @@
import window from 'window';
import $ from '$';
import {kill_CtrlA_CtrlS, detectDropdownVisibility, createCommand} from 'Common/Utils';
import {killCtrlACtrlS, detectDropdownVisibility, createCommand} from 'Common/Utils';
import {$win, $html, data as GlobalsData, bMobileDevice} from 'Common/Globals';
import * as Enums from 'Common/Enums';
import * as Plugins from 'Common/Plugins';
@ -13,7 +13,7 @@ export default (App) => {
GlobalsData.__APP__ = App;
$win
.on('keydown', kill_CtrlA_CtrlS)
.on('keydown', killCtrlACtrlS)
.on('unload', () => {
GlobalsData.bUnload = true;
});

View file

@ -8,7 +8,7 @@
name: 'Input',
params: {
value: defaultDomain,
trigger: defaultDomainTrigger,
trigger: defaultDomain.trigger,
size: 3
}
}"></div>

View file

@ -9,6 +9,11 @@
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="alert" data-bind="visible: '' !== submitError()">
<button type="button" class="close" data-bind="click: function () { submitError('') }">&times;</button>
<span data-bind="text: submitError"></span>
</div>
<br />
<div class="control-group" data-bind="css: {'error': email.error}">
<label class="i18n control-label" data-i18n="POPUPS_GENERATE_OPEN_PGP_KEYS/LABEL_EMAIL"></label>
<div class="controls">