Add more strict rules (eslint)

This commit is contained in:
RainLoop Team 2016-07-02 01:49:59 +03:00
parent b43bb17cdb
commit 52e2698cdf
38 changed files with 488 additions and 434 deletions

View file

@ -1,5 +1,8 @@
import {window, _, $, key} from 'common';
import window from 'window';
import $ from '$';
import _ from '_';
import key from 'key';
import {
$win, $html, $doc,

View file

@ -1,5 +1,6 @@
import {window, _} from 'common';
import window from 'window';
import _ from '_';
import ko from 'ko';
import progressJs from 'progressJs';
@ -39,14 +40,12 @@ class AdminApp extends AbstractApp
DomainStore.domains.loading(false);
if (StorageResultType.Success === result && data && data.Result)
{
DomainStore.domains(_.map(data.Result, ([enabled, alias], name) => {
return {
name: name,
disabled: ko.observable(!enabled),
alias: alias,
deleteAccess: ko.observable(false)
};
}));
DomainStore.domains(_.map(data.Result, ([enabled, alias], name) => ({
name: name,
disabled: ko.observable(!enabled),
alias: alias,
deleteAccess: ko.observable(false)
})));
}
});
}
@ -57,13 +56,11 @@ class AdminApp extends AbstractApp
PluginStore.plugins.loading(false);
if (StorageResultType.Success === result && data && data.Result)
{
PluginStore.plugins(_.map(data.Result, (item) => {
return {
name: item.Name,
disabled: ko.observable(!item.Enabled),
configured: ko.observable(!!item.Configured)
};
}));
PluginStore.plugins(_.map(data.Result, (item) => ({
name: item.Name,
disabled: ko.observable(!item.Enabled),
configured: ko.observable(!!item.Configured)
})));
}
});
}
@ -203,15 +200,15 @@ class AdminApp extends AbstractApp
}, force);
}
bootend(callback = null) {
bootend(bootendCallback = null) {
if (progressJs)
{
progressJs.end();
}
if (callback)
if (bootendCallback)
{
callback();
bootendCallback();
}
}

View file

@ -1,10 +1,12 @@
import {window, _, $} from 'common';
import window from 'window';
import _ from '_';
import $ from '$';
import progressJs from 'progressJs';
import Tinycon from 'Tinycon';
import {
noop, trim, log, isArray, inArray, isUnd, isNormal, isPosNumeric, isNonEmptyArray,
noop, trim, log, has, isArray, inArray, isUnd, isNormal, isPosNumeric, isNonEmptyArray,
pInt, pString, delegateRunOnDestroy, mailToHelper, windowResize
} from 'Common/Utils';
@ -411,18 +413,17 @@ class AppUser extends AbstractApp
* @param {Function=} callback = null
*/
foldersReload(callback = null) {
Promises.foldersReload(FolderStore.foldersLoading).then((value) => {
if (callback)
{
const prom = Promises.foldersReload(FolderStore.foldersLoading);
if (callback)
{
prom.then((value) => {
callback(!!value);
}
}).catch(() => {
if (callback)
{
_.delay(() => callback(false), 1);
}
});
}).catch(() => {
_.delay(() => {
callback(false);
}, 1);
});
}
}
foldersPromisesActionHelper(promise, errorDefCode) {
@ -481,7 +482,9 @@ class AppUser extends AbstractApp
iIndex,
oItem.primaryKey.getFingerprint(),
oItem.primaryKey.getKeyId().toHex().toLowerCase(),
_.uniq(_.compact(_.map(oItem.getKeyIds(), (item) => item && item.toHex ? item.toHex() : null))),
_.uniq(_.compact(_.map(
oItem.getKeyIds(), (item) => (item && item.toHex ? item.toHex() : null)
))),
aUsers,
aEmails,
oItem.isPrivate(),
@ -672,7 +675,7 @@ class AppUser extends AbstractApp
{
for (uid in data.Result.Flags)
{
if (data.Result.Flags.hasOwnProperty(uid))
if (has(data.Result.Flags, uid))
{
check = true;
const flags = data.Result.Flags[uid];
@ -808,7 +811,7 @@ class AppUser extends AbstractApp
aMessages = MessageStore.messageListChecked();
}
aRootUids = _.uniq(_.compact(_.map(aMessages, (oMessage) => (oMessage && oMessage.uid) ? oMessage.uid : null)));
aRootUids = _.uniq(_.compact(_.map(aMessages, (oMessage) => (oMessage && oMessage.uid ? oMessage.uid : null))));
if ('' !== sFolderFullNameRaw && 0 < aRootUids.length)
{
@ -934,18 +937,17 @@ class AppUser extends AbstractApp
/**
* @param {string} query
* @param {Function} callback
* @param {Function} autocompleteCallback
*/
getAutocomplete(query, callback) {
getAutocomplete(query, autocompleteCallback) {
Remote.suggestions((result, data) => {
if (StorageResultType.Success === result && data && isArray(data.Result))
{
callback(_.compact(_.map(data.Result,
(item) => item && item[0] ? new EmailModel(item[0], item[1]) : null)));
autocompleteCallback(_.compact(_.map(data.Result, (item) => (item && item[0] ? new EmailModel(item[0], item[1]) : null))));
}
else if (StorageResultType.Abort !== result)
{
callback([]);
autocompleteCallback([]);
}
}, query);
}
@ -1407,7 +1409,7 @@ class AppUser extends AbstractApp
window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s',
'' + (Settings.settingsGet('Title') || 'RainLoop'));
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
if (Settings.settingsGet('MailToEmail'))
{

View file

@ -1,5 +1,6 @@
import {window, $} from 'common';
import window from 'window';
import $ from '$';
import {bMobileDevice, bSafari} from 'Common/Globals';
import * as Links from 'Common/Links';
import * as Events from 'Common/Events';

View file

@ -1,6 +1,7 @@
import window from 'window';
import progressJs from 'progressJs';
import Promise from 'Promise';
import STYLES_CSS from 'Styles/@Boot.css';
import LAYOUT_HTML from 'Html/Layout.html';
@ -32,7 +33,7 @@ function getComputedStyle(id, name)
*/
function includeStyle(styles)
{
window.document.write(unescape('%3Csty' + 'le%3E' + styles + '"%3E%3C/' + 'sty' + 'le%3E'));
window.document.write(unescape('%3Csty' + 'le%3E' + styles + '"%3E%3C/' + 'sty' + 'le%3E')); // eslint-disable-line no-useless-concat
}
/**
@ -41,7 +42,7 @@ function includeStyle(styles)
*/
function includeScr(src)
{
window.document.write(unescape('%3Csc' + 'ript type="text/jav' + 'ascr' + 'ipt" data-cfasync="false" sr' + 'c="' + src + '"%3E%3C/' + 'scr' + 'ipt%3E'));
window.document.write(unescape('%3Csc' + 'ript type="text/jav' + 'ascr' + 'ipt" data-cfasync="false" sr' + 'c="' + src + '"%3E%3C/' + 'scr' + 'ipt%3E')); // eslint-disable-line no-useless-concat
}
/**
@ -203,27 +204,30 @@ function runApp()
}
}
}),
common = window.Promise.all([
common = Promise.all([
window.jassl(appData.TemplatesLink),
window.jassl(appData.LangLink)
]);
window.Promise.all([libs, common])
Promise.all([libs, common])
.then(() => {
p.set(30);
return window.jassl(appData.StaticAppJsLink);
}).then(() => {
})
.then(() => {
p.set(50);
return appData.PluginsLink ? window.jassl(appData.PluginsLink) : window.Promise.resolve();
}).then(() => {
})
.then(() => {
p.set(70);
runMainBoot(false);
}).catch((e) => {
})
.catch((e) => {
runMainBoot(true);
throw e;
}).then(() => {
return window.jassl(appData.StaticEditorJsLink);
}).then(() => {
})
.then(() => window.jassl(appData.StaticEditorJsLink))
.then(() => {
if (window.CKEDITOR && window.__initEditor) {
window.__initEditor();
window.__initEditor = null;

View file

@ -1,5 +1,5 @@
import {_} from 'common';
import _ from '_';
import {Capa, MessageSetAction} from 'Common/Enums';
import {trim, pInt, isArray} from 'Common/Utils';
import * as Links from 'Common/Links';

View file

@ -1,5 +1,7 @@
import {window, JSON, $} from 'common';
import window from 'window';
import $ from '$';
import JSON from 'JSON';
import {isUnd} from 'Common/Utils';
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
@ -21,7 +23,7 @@ class CookieDriver
const storageValue = $.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME);
storageResult = null === storageValue ? null : JSON.parse(storageValue);
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
(storageResult || (storageResult = {}))[key] = data;
@ -33,7 +35,7 @@ class CookieDriver
result = true;
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
return result;
}
@ -54,7 +56,7 @@ class CookieDriver
result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
return result;
}

View file

@ -1,5 +1,6 @@
import {window, JSON} from 'common';
import window from 'window';
import JSON from 'JSON';
import {isUnd} from 'Common/Utils';
import {CLIENT_SIDE_STORAGE_INDEX_NAME} from 'Common/Consts';
@ -21,7 +22,7 @@ class LocalStorageDriver
const storageValue = window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] || null;
storageResult = null === storageValue ? null : JSON.parse(storageValue);
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
(storageResult || (storageResult = {}))[key] = data;
@ -30,7 +31,7 @@ class LocalStorageDriver
window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] = JSON.stringify(storageResult);
result = true;
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
return result;
}
@ -51,7 +52,7 @@ class LocalStorageDriver
result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
return result;
}

View file

@ -1,5 +1,5 @@
import {_} from 'common';
import _ from '_';
import {isObject, isUnd} from 'Common/Utils';
import * as Plugins from 'Common/Plugins';

View file

@ -1,6 +1,9 @@
/* global RL_COMMUNITY */
import {window, _, $, key} from 'common';
import window from 'window';
import _ from '_';
import $ from '$';
import key from 'key';
import ko from 'ko';
import {KeyState} from 'Common/Enums';
@ -182,9 +185,7 @@ export const leftPanelWidth = ko.observable(0);
// popups
export const popupVisibilityNames = ko.observableArray([]);
export const popupVisibility = ko.computed(() => {
return 0 < popupVisibilityNames().length;
});
export const popupVisibility = ko.computed(() => 0 < popupVisibilityNames().length);
popupVisibility.subscribe((bValue) => {
$html.toggleClass('rl-modal', bValue);
@ -196,9 +197,7 @@ export const keyScopeFake = ko.observable(KeyState.All);
export const keyScope = ko.computed({
owner: this,
read: () => {
return keyScopeFake();
},
read: () => keyScopeFake(),
write: function(sValue) {
if (KeyState.Menu !== sValue)

View file

@ -1,5 +1,7 @@
import {window, _, $} from 'common';
import window from 'window';
import _ from '_';
import $ from '$';
import {oHtmlEditorDefaultConfig, oHtmlEditorLangsMap} from 'Common/Globals';
import * as Settings from 'Storage/Settings';
@ -115,7 +117,7 @@ class HtmlEditor
this.editor.getData() + '</div>' : this.editor.getData();
}
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
if (clearSignatureSigns)
{
@ -154,7 +156,7 @@ class HtmlEditor
}
}
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
if (resize)
{
@ -184,7 +186,7 @@ class HtmlEditor
try {
this.editor.setData(html);
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
if (focus)
{
@ -200,7 +202,7 @@ class HtmlEditor
this.editor.setData(
this.editor.getData().replace(find, replaceHtml));
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
}
}
@ -217,7 +219,7 @@ class HtmlEditor
try {
this.editor.setData(plain);
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
}
if (focus)
@ -358,7 +360,7 @@ class HtmlEditor
try {
this.editor.focus();
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
}
}
@ -368,7 +370,7 @@ class HtmlEditor
try {
return !!this.editor.focusManager.hasFocus;
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
}
return false;
@ -380,7 +382,7 @@ class HtmlEditor
try {
this.editor.focusManager.blur(true);
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
}
}
@ -390,7 +392,7 @@ class HtmlEditor
try {
this.editor.resize(this.$element.width(), this.$element.innerHeight());
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
}
}
@ -400,7 +402,7 @@ class HtmlEditor
try {
this.editor.setReadOnly(!!value);
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
}
}

View file

@ -1,5 +1,5 @@
import {window} from 'common';
import window from 'window';
import {pString, pInt, isUnd, isNormal, trim, encodeURIComponent} from 'Common/Utils';
import * as Settings from 'Storage/Settings';

View file

@ -1,5 +1,8 @@
import {window, $, _, moment} from 'common';
import window from 'window';
import _ from '_';
import $ from '$';
import moment from 'moment';
import {i18n} from 'Common/Translator';
let _moment = null;

View file

@ -1,12 +1,13 @@
import {_} from 'common';
import _ from '_';
import {isFunc, isArray, isUnd} from 'Common/Utils';
import {data as GlobalsData} from 'Common/Globals';
import * as Settings from 'Storage/Settings';
const SIMPLE_HOOKS = {};
const USER_VIEW_MODELS_HOOKS = [];
const ADMIN_VIEW_MODELS_HOOKS = [];
const
SIMPLE_HOOKS = {},
USER_VIEW_MODELS_HOOKS = [],
ADMIN_VIEW_MODELS_HOOKS = [];
/**
* @param {string} name
@ -34,7 +35,7 @@ export function runHook(name, args = [])
if (isArray(SIMPLE_HOOKS[name]))
{
_.each(SIMPLE_HOOKS[name], (callback) => {
callback.apply(null, args);
callback(...args);
});
}
}

View file

@ -1,5 +1,7 @@
import {$, _, key} from 'common';
import $ from '$';
import _ from '_';
import key from 'key';
import ko from 'ko';
import {EventKeyCode} from 'Common/Enums';
import {isArray, inArray, noop, noopTrue} from 'Common/Utils';
@ -21,10 +23,7 @@ class Selector
{
this.list = koList;
this.listChecked = ko.computed(() => {
return _.filter(this.list(), (item) => item.checked());
}, this).extend({rateLimit: 0});
this.listChecked = ko.computed(() => _.filter(this.list(), (item) => item.checked())).extend({rateLimit: 0});
this.isListChecked = ko.computed(() => 0 < this.listChecked().length);
this.focusedItem = koFocusedItem || ko.observable(null);

View file

@ -1,5 +1,7 @@
import {window, $, _} from 'common';
import window from 'window';
import _ from '_';
import $ from '$';
import ko from 'ko';
import {Notification, UploadErrorCode} from 'Common/Enums';
import {pInt, isUnd, isNull, has, microtime, inArray} from 'Common/Utils';

View file

@ -19,21 +19,21 @@ const isUnd = _.isUndefined;
const isNull = _.isNull;
const has = _.has;
const bind = _.bind;
const noop = () => {};
const noop = () => {}; // eslint-disable-line no-empty-function
const noopTrue = () => true;
const noopFalse = () => false;
export {trim, inArray, isArray, isObject, isFunc, isUnd, isNull, has, bind, noop, noopTrue, noopFalse};
/**
* @param {Function} callback
* @param {Function} func
*/
export function silentTryCatch(callback)
export function silentTryCatch(func)
{
try {
callback();
func();
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
}
/**
@ -314,7 +314,7 @@ export function removeInFocus(force)
window.document.activeElement.blur();
}
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
}
}
@ -337,7 +337,7 @@ export function removeSelection()
window.document.selection.empty();
}
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
}
/**
@ -453,14 +453,16 @@ export function delegateRun(object, methodName, params, delay = 0)
if (object && object[methodName])
{
delay = pInt(delay);
params = isArray(params) ? params : [];
if (0 >= delay)
{
object[methodName].apply(object, isArray(params) ? params : []);
object[methodName](...params);
}
else
{
_.delay(() => {
object[methodName].apply(object, isArray(params) ? params : []);
object[methodName](...params);
}, delay);
}
}
@ -511,7 +513,6 @@ export function kill_CtrlA_CtrlS(event)
*/
export function createCommand(context, fExecute, fCanExecute = true)
{
let fResult = null;
const fNonEmpty = (...args) => {
if (fResult && fResult.canExecute && fResult.canExecute())
@ -526,15 +527,11 @@ export function createCommand(context, fExecute, fCanExecute = true)
if (isFunc(fCanExecute))
{
fResult.canExecute = ko.computed(() => {
return fResult.enabled() && fCanExecute.call(context);
});
fResult.canExecute = ko.computed(() => fResult.enabled() && fCanExecute.call(context));
}
else
{
fResult.canExecute = ko.computed(() => {
return fResult.enabled() && !!fCanExecute;
});
fResult.canExecute = ko.computed(() => fResult.enabled() && !!fCanExecute);
}
return fResult;
@ -848,14 +845,11 @@ export function htmlToPlain(html)
text = '';
const
convertBlockquote = (blockquoteText) => {
blockquoteText = '> ' + trim(blockquoteText).replace(/\n/gm, '\n> ');
return blockquoteText.replace(/(^|\n)([> ]+)/gm, (...args) => {
return (args && 2 < args.length) ? args[1] + trim(args[2].replace(/[\s]/g, '')) + ' ' : '';
});
return blockquoteText.replace(/(^|\n)([> ]+)/gm,
(...args) => (args && 2 < args.length ? args[1] + trim(args[2].replace(/[\s]/g, '')) + ' ' : ''));
},
convertDivs = (...args) => {
if (args && 1 < args.length)
{
@ -871,19 +865,9 @@ export function htmlToPlain(html)
return '';
},
convertPre = (...args) => {
return (args && 1 < args.length) ?
args[1].toString().replace(/[\n]/gm, '<br />').replace(/[\r]/gm, '') : '';
},
fixAttibuteValue = (...args) => {
return (args && 1 < args.length) ? '' + args[1] + _.escape(args[2]) : '';
},
convertLinks = (...args) => {
return (args && 1 < args.length) ? trim(args[1]) : '';
};
convertPre = (...args) => (args && 1 < args.length ? args[1].toString().replace(/[\n]/gm, '<br />').replace(/[\r]/gm, '') : ''),
fixAttibuteValue = (...args) => (args && 1 < args.length ? '' + args[1] + _.escape(args[2]) : ''),
convertLinks = (...args) => (args && 1 < args.length ? trim(args[1]) : '');
text = html
.replace(/\u0002([\s\S]*)\u0002/gm, '\u200C$1\u200C')
@ -971,10 +955,7 @@ export function htmlToPlain(html)
export function plainToHtml(plain, findEmailAndLinksInText = false)
{
plain = plain.toString().replace(/\r/g, '');
plain = plain.replace(/^>[> ]>+/gm, ([match]) => {
return match ? match.replace(/[ ]+/g, '') : match;
});
plain = plain.replace(/^>[> ]>+/gm, ([match]) => (match ? match.replace(/[ ]+/g, '') : match));
let
bIn = false,
@ -1110,7 +1091,7 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
for (iIndex = 0, iLen = aSystem.length; iIndex < iLen; iIndex++)
{
oItem = aSystem[iIndex];
if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true)
if (fVisibleCallback ? fVisibleCallback(oItem) : true)
{
if (bSep && 0 < aResult.length)
{
@ -1126,11 +1107,11 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
bSep = false;
aResult.push({
id: oItem.fullNameRaw,
name: fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name(),
name: fRenameCallback ? fRenameCallback(oItem) : oItem.name(),
system: true,
seporator: false,
disabled: !oItem.selectable || -1 < inArray(oItem.fullNameRaw, aDisabled) ||
(fDisableCallback ? fDisableCallback.call(null, oItem) : false)
(fDisableCallback ? fDisableCallback(oItem) : false)
});
}
}
@ -1142,7 +1123,7 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
// if (oItem.subScribed() || !oItem.existen || bBuildUnvisible)
if ((oItem.subScribed() || !oItem.existen || bBuildUnvisible) && (oItem.selectable || oItem.hasSubScribedSubfolders()))
{
if (fVisibleCallback ? fVisibleCallback.call(null, oItem) : true)
if (fVisibleCallback ? fVisibleCallback(oItem) : true)
{
if (FolderType.User === oItem.type() || !bSystem || oItem.hasSubScribedSubfolders())
{
@ -1161,11 +1142,11 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
aResult.push({
id: oItem.fullNameRaw,
name: (new window.Array(oItem.deep + 1 - iUnDeep)).join(sDeepPrefix) +
(fRenameCallback ? fRenameCallback.call(null, oItem) : oItem.name()),
(fRenameCallback ? fRenameCallback(oItem) : oItem.name()),
system: false,
seporator: false,
disabled: !oItem.selectable || -1 < inArray(oItem.fullNameRaw, aDisabled) ||
(fDisableCallback ? fDisableCallback.call(null, oItem) : false)
(fDisableCallback ? fDisableCallback(oItem) : false)
});
}
}
@ -1187,7 +1168,7 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
*/
export function selectElement(element)
{
let sel, range;
let sel = null, range = null;
if (window.getSelection)
{
sel = window.getSelection();
@ -1205,9 +1186,7 @@ export function selectElement(element)
}
export const detectDropdownVisibility = _.debounce(() => {
dropdownVisibility(!!_.find(GlobalsData.aBootstrapDropdowns, (item) => {
return item.hasClass('open');
}));
dropdownVisibility(!!_.find(GlobalsData.aBootstrapDropdowns, (item) => item.hasClass('open')));
}, 50);
/**
@ -1246,7 +1225,7 @@ export function getConfigurationFromScriptTag(configuration)
{
return JSON.parse(configurationScriptTagCache[configuration].text());
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
return {};
}
@ -1615,13 +1594,12 @@ export function mailToHelper(mailToUrl, PopupComposeVoreModel)
email = mailToUrl.replace(/\?.+$/, ''),
query = mailToUrl.replace(/^[^\?]*\?/, ''),
EmailModel = require('Model/Email'),
fParseEmailLine = (line) => {
return line ? _.compact(_.map(decodeURIComponent(line).split(/[,]/), (item) => {
const emailObj = new EmailModel();
emailObj.mailsoParse(item);
return '' !== emailObj.email ? emailObj : null;
})) : null;
};
emailObj = new EmailModel(),
fParseEmailLine = (line) => (line ? _.compact(_.map(decodeURIComponent(line).split(/[,]/), (item) => {
emailObj.clear();
emailObj.mailsoParse(item);
return '' !== emailObj.email ? emailObj : null;
})) : null);
to = fParseEmailLine(email);
params = simpleQueryParser(query);

View file

@ -1,5 +1,5 @@
import {_} from 'common';
import _ from '_';
import ko from 'ko';
import {isUnd} from 'Common/Utils';
import {AbstractComponent} from 'Component/Abstract';
@ -27,9 +27,7 @@ class AbstracRadio extends AbstractComponent
if (params.values)
{
this.values(_.map(params.values, (label, value) => {
return {label: label, value: value};
}));
this.values(_.map(params.values, (label, value) => ({label: label, value: value})));
}
this.click = _.bind(this.click, this);

View file

@ -1,7 +1,7 @@
import {$} from 'common';
import {isUnd} from 'Common/Utils';
import $ from '$';
import ko from 'ko';
import {isUnd} from 'Common/Utils';
class AbstractComponent
{
@ -24,32 +24,30 @@ class AbstractComponent
* @param {string} templateID = ''
* @returns {Object}
*/
const componentExportHelper = (ClassObject, templateID = '') => {
return {
template: templateID ? {element: templateID} : '<b></b>',
viewModel: {
createViewModel: (params, componentInfo) => {
const componentExportHelper = (ClassObject, templateID = '') => ({
template: templateID ? {element: templateID} : '<b></b>',
viewModel: {
createViewModel: (params, componentInfo) => {
params = params || {};
params.element = null;
params = params || {};
params.element = null;
if (componentInfo && componentInfo.element)
if (componentInfo && componentInfo.element)
{
params.component = componentInfo;
params.element = $(componentInfo.element);
require('Common/Translator').i18nToNodes(params.element);
if (!isUnd(params.inline) && ko.unwrap(params.inline))
{
params.component = componentInfo;
params.element = $(componentInfo.element);
require('Common/Translator').i18nToNodes(params.element);
if (!isUnd(params.inline) && ko.unwrap(params.inline))
{
params.element.css('display', 'inline-block');
}
params.element.css('display', 'inline-block');
}
return new ClassObject(params);
}
return new ClassObject(params);
}
};
};
}
});
export {AbstractComponent, componentExportHelper};

View file

@ -1,5 +1,5 @@
import {_} from 'common';
import _ from '_';
import ko from 'ko';
import {componentExportHelper} from 'Component/Abstract';
import {AbstracCheckbox} from 'Component/AbstracCheckbox';

View file

@ -1,5 +1,5 @@
import {$} from 'common';
import $ from '$';
import {AbstractComponent, componentExportHelper} from 'Component/Abstract';
class ScriptComponent extends AbstractComponent

View file

@ -1,5 +1,5 @@
import {$} from 'common';
import $ from '$';
let cachedUrl = null;
const getUrl = () => {

5
dev/External/ko.js vendored
View file

@ -120,7 +120,8 @@ ko.bindingHandlers.scrollerShadows = {
ko.bindingHandlers.pikaday = {
init: function(oElement, fValueAccessor, fAllBindingsAccessor, oViewModel) {
ko.bindingHandlers.textInput.init.apply(oViewModel, Array.prototype.slice.call(arguments));
ko.bindingHandlers.textInput
.init.apply(oViewModel, Array.prototype.slice.call(arguments)); // eslint-disable-line prefer-rest-params
if (Pikaday)
{
@ -971,7 +972,7 @@ ko.bindingHandlers.command = {
jqElement.addClass('command');
ko.bindingHandlers[jqElement.is('form') ? 'submit' : 'click']
.init.apply(oViewModel, Array.prototype.slice.call(arguments));
.init.apply(oViewModel, Array.prototype.slice.call(arguments)); // eslint-disable-line prefer-rest-params
},
update: function(oElement, fValueAccessor) {

View file

@ -4,11 +4,6 @@ import EmailModel from 'Model/Email';
class MessageHelper
{
/**
* @constructor
*/
constructor() {}
/**
* @param {Array.<EmailModel>} emails
* @param {boolean=} friendlyView = false

View file

@ -84,8 +84,8 @@ AbstractView.prototype.viewModelPosition = function()
return this.sPosition;
};
AbstractView.prototype.cancelCommand = function() {};
AbstractView.prototype.closeCommand = function() {};
AbstractView.prototype.cancelCommand = Utils.noop;
AbstractView.prototype.closeCommand = Utils.noop;
AbstractView.prototype.storeAndSetKeyScope = function()
{

View file

@ -37,7 +37,7 @@ Knoin.prototype.constructorEnd = function(context)
{
if (Utils.isFunc(context.__constructor_end))
{
context.__constructor_end.call(context);
context.__constructor_end();
}
};

View file

@ -250,10 +250,11 @@ EmailModel.prototype.mailsoParse = function($sEmailAddress)
var
substr = function(str, start, len) {
str += '';
str = Utils.pString(str);
var end = str.length;
if (0 > start) {
if (0 > start)
{
start += end;
}
@ -263,11 +264,15 @@ EmailModel.prototype.mailsoParse = function($sEmailAddress)
},
substrReplace = function(str, replace, start, length) {
if (0 > start) {
str = Utils.pString(str);
if (0 > start)
{
start += str.length;
}
length = 'undefined' === typeof length ? length : str.length;
if (0 > length) {
length = 'undefined' !== typeof length ? length : str.length;
if (0 > length)
{
length = length + str.length - start;
}
return str.slice(0, start) + replace.substr(0, length) + replace.slice(length) + str.slice(start + length);

View file

@ -1,5 +1,5 @@
import {_} from 'common';
import _ from '_';
import {CookieDriver} from 'Common/ClientStorageDriver/Cookie';
import {LocalStorageDriver} from 'Common/ClientStorageDriver/LocalStorage';

View file

@ -1,5 +1,5 @@
import {window} from 'common';
import window from 'window';
import {isUnd, isNormal, isArray, inArray} from 'Common/Utils';
let SETTINGS = window.__rlah_data() || null;

View file

@ -1,5 +1,5 @@
import {_} from 'common';
import _ from '_';
import ko from 'ko';
class IdentityUserStore
@ -9,9 +9,7 @@ class IdentityUserStore
this.identities = ko.observableArray([]);
this.identities.loading = ko.observable(false).extend({throttle: 100});
this.identitiesIDS = ko.computed(() => {
return _.compact(_.map(this.identities(), (item) => item ? item.id : null));
}, this);
this.identitiesIDS = ko.computed(() => _.compact(_.map(this.identities(), (item) => (item ? item.id : null))));
}
}

View file

@ -916,7 +916,7 @@ ComposePopupView.prototype.converSignature = function(sSignature)
sSignature = sSignature.replace(/{{MOMENT:[^}]+}}/g, '');
}
catch (e) {/* eslint-disable-line no-empty */}
catch (e) {} // eslint-disable-line no-empty
}
return sSignature;
@ -1324,7 +1324,7 @@ ComposePopupView.prototype.onMessageUploadAttachments = function(sResult, oData)
{
for (sTempName in oData.Result)
{
if (oData.Result.hasOwnProperty(sTempName))
if (Utils.has(oData.Result, oData.Result))
{
oAttachment = this.getAttachmentById(oData.Result[sTempName]);
if (oAttachment)

View file

@ -695,8 +695,9 @@ MessageViewMailBoxUserView.prototype.onBuild = function(oDom)
oDom
.on('click', 'a', function(oEvent) {
// setup maito protocol
return !(!!oEvent && 3 !== oEvent.which && Utils.mailToHelper($(this).attr('href'),
Settings.capa(Enums.Capa.Composer) ? require('View/Popup/Compose') : null));
return !(!!oEvent && 3 !== oEvent.which && Utils.mailToHelper(
$(this).attr('href'), Settings.capa(Enums.Capa.Composer) ? require('View/Popup/Compose') : null
));
})
// .on('mouseover', 'a', _.debounce(function(oEvent) {
//

View file

@ -35,11 +35,6 @@ _.extend(MenuSettingsUserView.prototype, AbstractView.prototype);
MenuSettingsUserView.prototype.onBuild = function(oDom)
{
// var self = this;
// key('esc', Enums.KeyState.Settings, function() {
// self.backToMailBoxClick();
// });
if (this.mobile)
{
oDom
@ -75,7 +70,7 @@ MenuSettingsUserView.prototype.onBuild = function(oDom)
}
}
}, 200));
}, 200)); // eslint-disable-line no-magic-numbers
};
MenuSettingsUserView.prototype.link = function(sRoute)

View file

@ -1,10 +0,0 @@
import window from 'window';
import $ from '$';
import JSON from 'JSON';
import _ from '_';
import Promise from 'Promise';
import moment from 'moment';
import key from 'key';
export {window, $, JSON, _, Promise, moment, key};