eslint (additional rules)

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

View file

@ -17,8 +17,7 @@ const Base64 = {
let
output = '',
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
i = 0
;
i = 0;
input = Base64._utf8_encode(input);
@ -56,8 +55,7 @@ const Base64 = {
let
output = '',
chr1, chr2, chr3, enc1, enc2, enc3, enc4,
i = 0
;
i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
@ -97,8 +95,7 @@ const Base64 = {
utftext = '',
n = 0,
l = string.length,
c = 0
;
c = 0;
for (; n < l; n++) {
@ -132,8 +129,7 @@ const Base64 = {
i = 0,
c = 0,
c2 = 0,
c3 = 0
;
c3 = 0;
while ( i < utftext.length )
{

View file

@ -14,6 +14,11 @@ window.__rlah_set = () => setHash();
window.__rlah_clear = () => clearHash();
window.__rlah_data = () => RL_APP_DATA_STORAGE;
/**
* @param {string} id
* @param {string} name
* @returns {string}
*/
function getComputedStyle(id, name)
{
var element = window.document.getElementById(id);
@ -21,16 +26,27 @@ function getComputedStyle(id, name)
(window.getComputedStyle ? window.getComputedStyle(element, null).getPropertyValue(name) : null);
}
/**
* @param {string} styles
* @returns {void}
*/
function includeStyle(styles)
{
window.document.write(unescape('%3Csty' + 'le%3E' + styles + '"%3E%3C/' + 'sty' + 'le%3E'));
}
/**
* @param {string} src
* @returns {void}
*/
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'));
}
/**
* @returns {boolean}
*/
function includeLayout()
{
const app = window.document.getElementById('rl-app');
@ -49,18 +65,25 @@ function includeLayout()
return false;
}
function includeAppScr(data = {})
/**
* @param {mixed} data
* @returns {void}
*/
function includeAppScr({admin = false, mobile = false, mobileDevice = false})
{
let src = './?/';
src += data.admin ? 'Admin' : '';
src += admin ? 'Admin' : '';
src += 'AppData@';
src += data.mobile ? 'mobile' : 'no-mobile';
src += data.mobileDevice ? '-1' : '-0';
src += mobile ? 'mobile' : 'no-mobile';
src += mobileDevice ? '-1' : '-0';
src += '/';
includeScr(src + (window.__rlah ? window.__rlah() || '0' : '0') + '/' + window.Math.random().toString().substr(2) + '/');
}
/**
* @returns {object}
*/
function getRainloopBootData()
{
let result = {};
@ -74,13 +97,16 @@ function getRainloopBootData()
return result;
}
/**
* @param {string} additionalError
* @returns {void}
*/
function showError(additionalError)
{
const
oR = window.document.getElementById('rl-loading'),
oL = window.document.getElementById('rl-loading-error'),
oLA = window.document.getElementById('rl-loading-error-additional')
;
oLA = window.document.getElementById('rl-loading-error-additional');
if (oR)
{
@ -104,12 +130,15 @@ function showError(additionalError)
}
}
/**
* @param {string} description
* @returns {void}
*/
function showDescriptionAndLoading(description)
{
const
oE = window.document.getElementById('rl-loading'),
oElDesc = window.document.getElementById('rl-loading-desc')
;
oElDesc = window.document.getElementById('rl-loading-desc');
if (oElDesc && description)
{
@ -125,6 +154,11 @@ function showDescriptionAndLoading(description)
}
}
/**
* @param {boolean} withError
* @param {string} additionalError
* @returns {void}
*/
function runMainBoot(withError, additionalError)
{
if (window.__APP_BOOT && !withError)
@ -139,6 +173,9 @@ function runMainBoot(withError, additionalError)
}
}
/**
* @returns {void}
*/
function runApp()
{
const appData = window.__rlah_data();
@ -162,16 +199,14 @@ function runApp()
window.$('#rl-bg').attr('style', 'background-image: none !important;')
.backstretch(appData.IncludeBackground.replace('{{USER}}',
(window.__rlah ? (window.__rlah() || '0') : '0')), {fade: 100, centeredX: true, centeredY: true})
.removeAttr('style')
;
.removeAttr('style');
}
}
}),
common = window.Promise.all([
window.jassl(appData.TemplatesLink),
window.jassl(appData.LangLink)
])
;
]);
window.Promise.all([libs, common])
.then(() => {
@ -193,8 +228,7 @@ function runApp()
window.__initEditor();
window.__initEditor = null;
}
})
;
});
}
else
{
@ -202,6 +236,10 @@ function runApp()
}
}
/**
* @param {mixed} data
* @returns {void}
*/
window.__initAppData = function(data) {
RL_APP_DATA_STORAGE = data;
@ -226,6 +264,9 @@ window.__initAppData = function(data) {
runApp();
};
/**
* @returns {void}
*/
window.__runBoot = function() {
if (!window.navigator || !window.navigator.cookieEnabled)

View file

@ -5,18 +5,20 @@ import {trim, pInt, isArray} from 'Common/Utils';
import * as Links from 'Common/Links';
import * as Settings from 'Storage/Settings';
let FOLDERS_CACHE = {};
let FOLDERS_NAME_CACHE = {};
let FOLDERS_HASH_CACHE = {};
let FOLDERS_UID_NEXT_CACHE = {};
let MESSAGE_FLAGS_CACHE = {};
let FOLDERS_CACHE = {},
FOLDERS_NAME_CACHE = {},
FOLDERS_HASH_CACHE = {},
FOLDERS_UID_NEXT_CACHE = {},
MESSAGE_FLAGS_CACHE = {},
NEW_MESSAGE_CACHE = {},
inboxFolderName = '';
let NEW_MESSAGE_CACHE = {};
let REQUESTED_MESSAGE_CACHE = {};
const capaGravatar = Settings.capa(Capa.Gravatar);
let inboxFolderName = '';
const REQUESTED_MESSAGE_CACHE = {},
capaGravatar = Settings.capa(Capa.Gravatar);
/**
* @returns {void}
*/
export function clear()
{
FOLDERS_CACHE = {};
@ -29,7 +31,7 @@ export function clear()
/**
* @param {string} email
* @param {Function} callback
* @return {string}
* @returns {string}
*/
export function getUserPic(email, callback)
{
@ -40,7 +42,7 @@ export function getUserPic(email, callback)
/**
* @param {string} folderFullNameRaw
* @param {string} uid
* @return {string}
* @returns {string}
*/
export function getMessageKey(folderFullNameRaw, uid)
{
@ -59,7 +61,7 @@ export function addRequestedMessage(folder, uid)
/**
* @param {string} folder
* @param {string} uid
* @return {boolean}
* @returns {boolean}
*/
export function hasRequestedMessage(folder, uid)
{
@ -89,13 +91,16 @@ export function hasNewMessageAndRemoveFromCache(folderFullNameRaw, uid)
return false;
}
/**
* @returns {void}
*/
export function clearNewMessageCache()
{
NEW_MESSAGE_CACHE = {};
}
/**
* @return {string}
* @returns {string}
*/
export function getFolderInboxName()
{
@ -104,7 +109,7 @@ export function getFolderInboxName()
/**
* @param {string} folderHash
* @return {string}
* @returns {string}
*/
export function getFolderFullNameRaw(folderHash)
{
@ -126,7 +131,7 @@ export function setFolderFullNameRaw(folderHash, folderFullNameRaw)
/**
* @param {string} folderFullNameRaw
* @return {string}
* @returns {string}
*/
export function getFolderHash(folderFullNameRaw)
{
@ -147,7 +152,7 @@ export function setFolderHash(folderFullNameRaw, folderHash)
/**
* @param {string} folderFullNameRaw
* @return {string}
* @returns {string}
*/
export function getFolderUidNext(folderFullNameRaw)
{
@ -165,7 +170,7 @@ export function setFolderUidNext(folderFullNameRaw, uidNext)
/**
* @param {string} folderFullNameRaw
* @return {?FolderModel}
* @returns {?FolderModel}
*/
export function getFolderFromCacheList(folderFullNameRaw)
{
@ -192,7 +197,7 @@ export function removeFolderFromCacheList(folderFullNameRaw)
/**
* @param {string} folderFullName
* @param {string} uid
* @return {?Array}
* @returns {?Array}
*/
export function getMessageFlagsFromCache(folderFullName, uid)
{
@ -233,14 +238,13 @@ export function initMessageFlagsFromCache(message)
{
const
uid = message.uid,
flags = getMessageFlagsFromCache(message.folderFullNameRaw, uid)
;
flags = getMessageFlagsFromCache(message.folderFullNameRaw, uid);
if (flags && 0 < flags.length)
{
message.flagged(!!flags[1]);
if (!message.__simple_message__)
if (!message.isSimpleMessage)
{
message.unseen(!!flags[0]);
message.answered(!!flags[2]);
@ -334,6 +338,7 @@ export function storeMessageFlagsToCacheBySetAction(folder, uid, setAction)
case MessageSetAction.UnsetFlag:
flags[1] = false;
break;
// no default
}
setMessageFlagsToCache(folder, uid, flags);

View file

@ -8,14 +8,13 @@ class CookieDriver
/**
* @param {string} key
* @param {*} data
* @return {boolean}
* @returns {boolean}
*/
set(key, data) {
let
result = false,
storageResult = null
;
storageResult = null;
try
{
@ -41,7 +40,7 @@ class CookieDriver
/**
* @param {string} key
* @return {*}
* @returns {*}
*/
get(key) {
@ -51,8 +50,7 @@ class CookieDriver
{
const
storageValue = $.cookie(CLIENT_SIDE_STORAGE_INDEX_NAME),
storageResult = null === storageValue ? null : JSON.parse(storageValue)
;
storageResult = null === storageValue ? null : JSON.parse(storageValue);
result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
}
@ -62,7 +60,7 @@ class CookieDriver
}
/**
* @return {boolean}
* @returns {boolean}
*/
static supported() {
return !!(window.navigator && window.navigator.cookieEnabled);

View file

@ -8,14 +8,13 @@ class LocalStorageDriver
/**
* @param {string} key
* @param {*} data
* @return {boolean}
* @returns {boolean}
*/
set(key, data) {
let
result = false,
storageResult = null
;
storageResult = null;
try
{
@ -38,7 +37,7 @@ class LocalStorageDriver
/**
* @param {string} key
* @return {*}
* @returns {*}
*/
get(key) {
@ -48,8 +47,7 @@ class LocalStorageDriver
{
const
storageValue = window.localStorage[CLIENT_SIDE_STORAGE_INDEX_NAME] || null,
storageResult = null === storageValue ? null : JSON.parse(storageValue)
;
storageResult = null === storageValue ? null : JSON.parse(storageValue);
result = (storageResult && !isUnd(storageResult[key])) ? storageResult[key] : null;
}
@ -59,7 +57,7 @@ class LocalStorageDriver
}
/**
* @return {boolean}
* @returns {boolean}
*/
static supported() {
return !!window.localStorage;

View file

@ -43,41 +43,37 @@ export const sUserAgent = 'navigator' in window && 'userAgent' in window.navigat
/**
* @type {boolean}
*/
export const bIE = sUserAgent.indexOf('msie') > -1;
export const bIE = -1 < sUserAgent.indexOf('msie');
/**
* @type {boolean}
*/
export const bChrome = sUserAgent.indexOf('chrome') > -1;
export const bChrome = -1 < sUserAgent.indexOf('chrome');
/**
* @type {boolean}
*/
export const bSafari = !bChrome && sUserAgent.indexOf('safari') > -1;
export const bSafari = !bChrome && -1 < sUserAgent.indexOf('safari');
/**
* @type {boolean}
*/
export const bMobileDevice =
/android/i.test(sUserAgent) ||
/iphone/i.test(sUserAgent) ||
/ipod/i.test(sUserAgent) ||
/ipad/i.test(sUserAgent) ||
/blackberry/i.test(sUserAgent)
;
(/android/i).test(sUserAgent) ||
(/iphone/i).test(sUserAgent) ||
(/ipod/i).test(sUserAgent) ||
(/ipad/i).test(sUserAgent) ||
(/blackberry/i).test(sUserAgent);
/**
* @type {boolean}
*/
export let bDisableNanoScroll = bMobileDevice;
export const bDisableNanoScroll = bMobileDevice;
/**
* @type {boolean}
*/
export let bAnimationSupported = !bMobileDevice &&
$html.hasClass('csstransitions') &&
$html.hasClass('cssanimations')
;
export const bAnimationSupported = !bMobileDevice && $html.hasClass('csstransitions') && $html.hasClass('cssanimations');
/**
* @type {boolean}
@ -161,13 +157,13 @@ let bAllowPdfPreview = !bMobileDevice;
if (bAllowPdfPreview && window.navigator && window.navigator.mimeTypes)
{
bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, function (oType) {
bAllowPdfPreview = !!_.find(window.navigator.mimeTypes, function(oType) {
return oType && 'application/pdf' === oType.type;
});
if (!bAllowPdfPreview)
{
bAllowPdfPreview = (typeof window.navigator.mimeTypes['application/pdf'] !== 'undefined');
bAllowPdfPreview = 'undefined' !== typeof window.navigator.mimeTypes['application/pdf'];
}
}
@ -203,32 +199,31 @@ export const keyScope = ko.computed({
read: () => {
return keyScopeFake();
},
write: function (sValue) {
write: function(sValue) {
if (KeyState.Menu !== sValue)
{
if (KeyState.Compose === sValue)
{
// disableKeyFilter
key.filter = function () {
key.filter = function() {
return useKeyboardShortcuts();
};
}
else
{
// restoreKeyFilter
key.filter = function (event) {
key.filter = function(event) {
if (useKeyboardShortcuts())
{
var
oElement = event.target || event.srcElement,
sTagName = oElement ? oElement.tagName : ''
;
sTagName = oElement ? oElement.tagName : '';
sTagName = sTagName.toUpperCase();
return !(sTagName === 'INPUT' || sTagName === 'SELECT' || sTagName === 'TEXTAREA' ||
(oElement && sTagName === 'DIV' && ('editorHtmlArea' === oElement.className || 'true' === '' + oElement.contentEditable))
return !('INPUT' === sTagName || 'SELECT' === sTagName || 'TEXTAREA' === sTagName ||
(oElement && 'DIV' === sTagName && ('editorHtmlArea' === oElement.className || 'true' === '' + oElement.contentEditable))
);
}
@ -247,12 +242,12 @@ export const keyScope = ko.computed({
}
});
keyScopeReal.subscribe(function (sValue) {
keyScopeReal.subscribe(function(sValue) {
// window.console.log('keyScope=' + sValue); // DEBUG
key.setScope(sValue);
});
dropdownVisibility.subscribe(function (bValue) {
dropdownVisibility.subscribe(function(bValue) {
if (bValue)
{
keyScope(KeyState.Menu);

View file

@ -6,6 +6,7 @@ import * as Settings from 'Storage/Settings';
class HtmlEditor
{
/**
* @constructor
* @param {Object} element
* @param {Function=} onBlur
* @param {Function=} onReady
@ -47,7 +48,7 @@ class HtmlEditor
}
/**
* @return {boolean}
* @returns {boolean}
*/
isHtml() {
return this.editor ? 'wysiwyg' === this.editor.mode : false;
@ -70,7 +71,7 @@ class HtmlEditor
}
/**
* @return {boolean}
* @returns {boolean}
*/
checkDirty() {
return this.editor ? this.editor.checkDirty() : false;
@ -85,7 +86,7 @@ class HtmlEditor
/**
* @param {string} text
* @return {string}
* @returns {string}
*/
clearSignatureSigns(text) {
return text.replace(/(\u200C|\u0002)/g, '');
@ -94,7 +95,7 @@ class HtmlEditor
/**
* @param {boolean=} wrapIsHtml = false
* @param {boolean=} clearSignatureSigns = false
* @return {string}
* @returns {string}
*/
getData(wrapIsHtml = false, clearSignatureSigns = false) {
@ -113,7 +114,8 @@ class HtmlEditor
'<div data-html-editor-font-wrapper="true" style="font-family: arial, sans-serif; font-size: 13px;">' +
this.editor.getData() + '</div>' : this.editor.getData();
}
} catch (e) {/* eslint-disable-line no-empty */}
}
catch (e) {/* eslint-disable-line no-empty */}
if (clearSignatureSigns)
{
@ -127,7 +129,7 @@ class HtmlEditor
/**
* @param {boolean=} wrapIsHtml = false
* @param {boolean=} clearSignatureSigns = false
* @return {string}
* @returns {string}
*/
getDataWithHtmlMark(wrapIsHtml = false, clearSignatureSigns = false) {
return (this.isHtml() ? ':HTML:' : '') + this.getData(wrapIsHtml, clearSignatureSigns);
@ -151,7 +153,8 @@ class HtmlEditor
this.editor.setMode('plain');
}
}
} catch (e) {/* eslint-disable-line no-empty */}
}
catch (e) {/* eslint-disable-line no-empty */}
if (resize)
{
@ -180,7 +183,8 @@ class HtmlEditor
try {
this.editor.setData(html);
} catch (e) {/* eslint-disable-line no-empty */}
}
catch (e) {/* eslint-disable-line no-empty */}
if (focus)
{
@ -195,7 +199,8 @@ class HtmlEditor
try {
this.editor.setData(
this.editor.getData().replace(find, replaceHtml));
} catch (e) {/* eslint-disable-line no-empty */}
}
catch (e) {/* eslint-disable-line no-empty */}
}
}
@ -211,7 +216,8 @@ class HtmlEditor
{
try {
this.editor.setData(plain);
} catch (e) {/* eslint-disable-line no-empty */}
}
catch (e) {/* eslint-disable-line no-empty */}
}
if (focus)
@ -231,8 +237,7 @@ class HtmlEditor
config = oHtmlEditorDefaultConfig,
language = Settings.settingsGet('Language'),
allowSource = !!Settings.appSettingsGet('allowHtmlEditorSourceButton'),
biti = !!Settings.appSettingsGet('allowHtmlEditorBitiButtons')
;
biti = !!Settings.appSettingsGet('allowHtmlEditorBitiButtons');
if ((allowSource || !biti) && !config.toolbarGroups.__cfgInited)
{
@ -295,8 +300,7 @@ class HtmlEditor
var
id = event.data.dataTransfer.id,
imageId = `[img=${id}]`,
reader = new window.FileReader()
;
reader = new window.FileReader();
reader.onloadend = () => {
if (reader.result)
@ -333,8 +337,7 @@ class HtmlEditor
}
});
}
;
};
if (window.CKEDITOR)
{
@ -352,7 +355,8 @@ class HtmlEditor
{
try {
this.editor.focus();
} catch (e) {/* eslint-disable-line no-empty */}
}
catch (e) {/* eslint-disable-line no-empty */}
}
}
@ -361,7 +365,8 @@ class HtmlEditor
{
try {
return !!this.editor.focusManager.hasFocus;
} catch (e) {/* eslint-disable-line no-empty */}
}
catch (e) {/* eslint-disable-line no-empty */}
}
return false;
@ -372,7 +377,8 @@ class HtmlEditor
{
try {
this.editor.focusManager.blur(true);
} catch (e) {/* eslint-disable-line no-empty */}
}
catch (e) {/* eslint-disable-line no-empty */}
}
}
@ -381,7 +387,8 @@ 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 */}
}
}
@ -390,7 +397,8 @@ class HtmlEditor
{
try {
this.editor.setReadOnly(!!value);
} catch (e) {/* eslint-disable-line no-empty */}
}
catch (e) {/* eslint-disable-line no-empty */}
}
}

View file

@ -3,29 +3,33 @@ import {window} from 'common';
import {pString, pInt, isUnd, isNormal, trim, encodeURIComponent} from 'Common/Utils';
import * as Settings from 'Storage/Settings';
const ROOT = './';
const HASH_PREFIX = '#/';
const SERVER_PREFIX = './?';
const SUB_QUERY_PREFIX = '&q[]=';
const
ROOT = './',
HASH_PREFIX = '#/',
SERVER_PREFIX = './?',
SUB_QUERY_PREFIX = '&q[]=',
const VERSION = Settings.appSettingsGet('version');
VERSION = Settings.appSettingsGet('version'),
const WEB_PREFIX = Settings.appSettingsGet('webPath') || '';
const VERSION_PREFIX = Settings.appSettingsGet('webVersionPath') || 'rainloop/v/' + VERSION + '/';
const STATIC_PREFIX = VERSION_PREFIX + 'static/';
WEB_PREFIX = Settings.appSettingsGet('webPath') || '',
VERSION_PREFIX = Settings.appSettingsGet('webVersionPath') || 'rainloop/v/' + VERSION + '/',
STATIC_PREFIX = VERSION_PREFIX + 'static/',
const ADMIN_HOST_USE = !!Settings.appSettingsGet('adminHostUse');
const ADMIN_PATH = Settings.appSettingsGet('adminPath') || 'admin';
ADMIN_HOST_USE = !!Settings.appSettingsGet('adminHostUse'),
ADMIN_PATH = Settings.appSettingsGet('adminPath') || 'admin';
let AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0';
/**
* @returns {void}
*/
export function populateAuthSuffix()
{
AUTH_PREFIX = Settings.settingsGet('AuthAccountHash') || '0';
}
/**
* @return {string}
* @returns {string}
*/
export function subQueryPrefix()
{
@ -34,7 +38,7 @@ export function subQueryPrefix()
/**
* @param {string=} startupUrl
* @return {string}
* @returns {string}
*/
export function root(startupUrl = '')
{
@ -42,7 +46,7 @@ export function root(startupUrl = '')
}
/**
* @return {string}
* @returns {string}
*/
export function rootAdmin()
{
@ -51,7 +55,7 @@ export function rootAdmin()
/**
* @param {boolean=} mobile = false
* @return {string}
* @returns {string}
*/
export function rootUser(mobile = false)
{
@ -62,7 +66,7 @@ export function rootUser(mobile = false)
* @param {string} type
* @param {string} download
* @param {string=} customSpecSuffix
* @return {string}
* @returns {string}
*/
export function attachmentRaw(type, download, customSpecSuffix)
{
@ -73,7 +77,7 @@ export function attachmentRaw(type, download, customSpecSuffix)
/**
* @param {string} download
* @param {string=} customSpecSuffix
* @return {string}
* @returns {string}
*/
export function attachmentDownload(download, customSpecSuffix)
{
@ -83,7 +87,7 @@ export function attachmentDownload(download, customSpecSuffix)
/**
* @param {string} download
* @param {string=} customSpecSuffix
* @return {string}
* @returns {string}
*/
export function attachmentPreview(download, customSpecSuffix)
{
@ -93,7 +97,7 @@ export function attachmentPreview(download, customSpecSuffix)
/**
* @param {string} download
* @param {string=} customSpecSuffix
* @return {string}
* @returns {string}
*/
export function attachmentThumbnailPreview(download, customSpecSuffix)
{
@ -103,7 +107,7 @@ export function attachmentThumbnailPreview(download, customSpecSuffix)
/**
* @param {string} download
* @param {string=} customSpecSuffix
* @return {string}
* @returns {string}
*/
export function attachmentPreviewAsPlain(download, customSpecSuffix)
{
@ -113,7 +117,7 @@ export function attachmentPreviewAsPlain(download, customSpecSuffix)
/**
* @param {string} download
* @param {string=} customSpecSuffix
* @return {string}
* @returns {string}
*/
export function attachmentFramed(download, customSpecSuffix)
{
@ -122,7 +126,7 @@ export function attachmentFramed(download, customSpecSuffix)
/**
* @param {string} type
* @return {string}
* @returns {string}
*/
export function serverRequest(type)
{
@ -130,7 +134,7 @@ export function serverRequest(type)
}
/**
* @return {string}
* @returns {string}
*/
export function upload()
{
@ -138,7 +142,7 @@ export function upload()
}
/**
* @return {string}
* @returns {string}
*/
export function uploadContacts()
{
@ -146,7 +150,7 @@ export function uploadContacts()
}
/**
* @return {string}
* @returns {string}
*/
export function uploadBackground()
{
@ -154,7 +158,7 @@ export function uploadBackground()
}
/**
* @return {string}
* @returns {string}
*/
export function append()
{
@ -163,7 +167,7 @@ export function append()
/**
* @param {string} email
* @return {string}
* @returns {string}
*/
export function change(email)
{
@ -172,7 +176,7 @@ export function change(email)
/**
* @param {string} add
* @return {string}
* @returns {string}
*/
export function ajax(add)
{
@ -181,7 +185,7 @@ export function ajax(add)
/**
* @param {string} requestHash
* @return {string}
* @returns {string}
*/
export function messageViewLink(requestHash)
{
@ -190,7 +194,7 @@ export function messageViewLink(requestHash)
/**
* @param {string} requestHash
* @return {string}
* @returns {string}
*/
export function messageDownloadLink(requestHash)
{
@ -199,7 +203,7 @@ export function messageDownloadLink(requestHash)
/**
* @param {string} email
* @return {string}
* @returns {string}
*/
export function avatarLink(email)
{
@ -208,7 +212,7 @@ export function avatarLink(email)
/**
* @param {string} hash
* @return {string}
* @returns {string}
*/
export function publicLink(hash)
{
@ -217,7 +221,7 @@ export function publicLink(hash)
/**
* @param {string} hash
* @return {string}
* @returns {string}
*/
export function userBackground(hash)
{
@ -225,7 +229,7 @@ export function userBackground(hash)
}
/**
* @return {string}
* @returns {string}
*/
export function phpInfo()
{
@ -235,7 +239,7 @@ export function phpInfo()
/**
* @param {string} lang
* @param {boolean} isAdmin
* @return {string}
* @returns {string}
*/
export function langLink(lang, isAdmin)
{
@ -243,7 +247,7 @@ export function langLink(lang, isAdmin)
}
/**
* @return {string}
* @returns {string}
*/
export function exportContactsVcf()
{
@ -251,7 +255,7 @@ export function exportContactsVcf()
}
/**
* @return {string}
* @returns {string}
*/
export function exportContactsCsv()
{
@ -260,7 +264,7 @@ export function exportContactsCsv()
/**
* @param {boolean} xauth = false
* @return {string}
* @returns {string}
*/
export function socialGoogle(xauth = false)
{
@ -269,7 +273,7 @@ export function socialGoogle(xauth = false)
}
/**
* @return {string}
* @returns {string}
*/
export function socialTwitter()
{
@ -278,7 +282,7 @@ export function socialTwitter()
}
/**
* @return {string}
* @returns {string}
*/
export function socialFacebook()
{
@ -288,7 +292,7 @@ export function socialFacebook()
/**
* @param {string} path
* @return {string}
* @returns {string}
*/
export function staticPrefix(path)
{
@ -296,7 +300,7 @@ export function staticPrefix(path)
}
/**
* @return {string}
* @returns {string}
*/
export function emptyContactPic()
{
@ -305,7 +309,7 @@ export function emptyContactPic()
/**
* @param {string} fileName
* @return {string}
* @returns {string}
*/
export function sound(fileName)
{
@ -313,7 +317,7 @@ export function sound(fileName)
}
/**
* @return {string}
* @returns {string}
*/
export function notificationMailIcon()
{
@ -321,7 +325,7 @@ export function notificationMailIcon()
}
/**
* @return {string}
* @returns {string}
*/
export function openPgpJs()
{
@ -329,7 +333,7 @@ export function openPgpJs()
}
/**
* @return {string}
* @returns {string}
*/
export function openPgpWorkerJs()
{
@ -337,7 +341,7 @@ export function openPgpWorkerJs()
}
/**
* @return {string}
* @returns {string}
*/
export function openPgpWorkerPath()
{
@ -346,7 +350,7 @@ export function openPgpWorkerPath()
/**
* @param {string} theme
* @return {string}
* @returns {string}
*/
export function themePreviewLink(theme)
{
@ -362,7 +366,7 @@ export function themePreviewLink(theme)
/**
* @param {string} inboxFolderName = 'INBOX'
* @return {string}
* @returns {string}
*/
export function inbox(inboxFolderName = 'INBOX')
{
@ -371,7 +375,7 @@ export function inbox(inboxFolderName = 'INBOX')
/**
* @param {string=} screenName = ''
* @return {string}
* @returns {string}
*/
export function settings(screenName = '')
{
@ -379,7 +383,7 @@ export function settings(screenName = '')
}
/**
* @return {string}
* @returns {string}
*/
export function about()
{
@ -388,12 +392,13 @@ export function about()
/**
* @param {string} screenName
* @return {string}
* @returns {string}
*/
export function admin(screenName)
{
let result = HASH_PREFIX;
switch (screenName) {
switch (screenName)
{
case 'AdminDomains':
result += 'domains';
break;
@ -403,6 +408,7 @@ export function admin(screenName)
case 'AdminLicensing':
result += 'licensing';
break;
// no default
}
return result;
@ -413,7 +419,7 @@ export function admin(screenName)
* @param {number=} page = 1
* @param {string=} search = ''
* @param {string=} threadUid = ''
* @return {string}
* @returns {string}
*/
export function mailBox(folder, page = 1, search = '', threadUid = '')
{

View file

@ -13,12 +13,18 @@ const updateMomentNowUnix = _.debounce(() => {
_momentNow = moment().unix();
}, 500, true);
/**
* @returns {moment}
*/
export function momentNow()
{
updateMomentNow();
return _moment || moment();
}
/**
* @returns {number}
*/
export function momentNowUnix()
{
updateMomentNowUnix();
@ -27,7 +33,7 @@ export function momentNowUnix()
/**
* @param {number} date
* @return {string}
* @returns {string}
*/
export function searchSubtractFormatDateHelper(date)
{
@ -36,14 +42,14 @@ export function searchSubtractFormatDateHelper(date)
/**
* @param {Object} m
* @return {string}
* @returns {string}
*/
function formatCustomShortDate(m)
{
const now = momentNow();
if (m && now)
{
switch(true)
switch (true)
{
case 4 >= now.diff(m, 'hours'):
return m.fromNow();
@ -57,6 +63,7 @@ function formatCustomShortDate(m)
});
case now.year() === m.year():
return m.format('D MMM.');
// no default
}
}
@ -66,15 +73,14 @@ function formatCustomShortDate(m)
/**
* @param {number} timeStampInUTC
* @param {string} formatStr
* @return {string}
* @returns {string}
*/
export function format(timeStampInUTC, formatStr)
{
let
m = null,
result = ''
;
result = '';
const now = momentNowUnix();
@ -112,14 +118,14 @@ export function format(timeStampInUTC, formatStr)
/**
* @param {Object} element
* @returns {void}
*/
export function momentToNode(element)
{
var
key = '',
time = 0,
$el = $(element)
;
$el = $(element);
time = $el.data('moment-time');
if (time)
@ -138,6 +144,9 @@ export function momentToNode(element)
}
}
/**
* @returns {void}
*/
export function reload()
{
_.defer(() => {

View file

@ -41,7 +41,7 @@ export function runHook(name, args = [])
/**
* @param {string} name
* @return {?}
* @returns {?}
*/
export function mainSettingsGet(name)
{
@ -98,7 +98,7 @@ export function runSettingsViewModelHooks(admin)
/**
* @param {string} pluginSection
* @param {string} name
* @return {?}
* @returns {?}
*/
export function settingsGet(pluginSection, name)
{

View file

@ -129,8 +129,7 @@ class Selector
aCache = [],
aCheckedCache = [],
mFocused = null,
mSelected = null
;
mSelected = null;
this.list.subscribe((items) => {
@ -168,8 +167,7 @@ class Selector
mNextFocused = mFocused,
bChecked = false,
bSelected = false,
iLen = 0
;
iLen = 0;
this.selectedItemUseCallback = false;
@ -195,7 +193,7 @@ class Selector
{
bChecked = true;
oItem.checked(true);
iLen--;
iLen -= 1;
}
if (!bChecked && null !== mSelected && mSelected === sUid)
@ -350,8 +348,7 @@ class Selector
item.checked(!item.checked());
}
}
})
;
});
key('enter', keyScope, () => {
if (this.focusedItem() && !this.focusedItem().selected())
@ -397,6 +394,7 @@ class Selector
case 'pagedown':
eventKey = EventKeyCode.PageDown;
break;
// no default
}
if (0 < eventKey)
@ -410,7 +408,7 @@ class Selector
}
/**
* @return {boolean}
* @returns {boolean}
*/
autoSelect() {
return !!(this.oCallbacks.onAutoSelect || noopTrue)();
@ -425,7 +423,7 @@ class Selector
/**
* @param {Object} oItem
* @return {string}
* @returns {string}
*/
getItemUid(item) {
@ -455,8 +453,7 @@ class Selector
oResult = null,
aList = this.list(),
iListLen = aList ? aList.length : 0,
oFocused = this.focusedItem()
;
oFocused = this.focusedItem();
if (0 < iListLen)
{
@ -482,29 +479,31 @@ class Selector
_.each(aList, (item) => {
if (!bStop)
{
switch (iEventKeyCode) {
case EventKeyCode.Up:
if (oFocused === item)
{
bStop = true;
}
else
{
oResult = item;
}
break;
case EventKeyCode.Down:
case EventKeyCode.Insert:
if (bNext)
{
oResult = item;
bStop = true;
}
else if (oFocused === item)
{
bNext = true;
}
break;
switch (iEventKeyCode)
{
case EventKeyCode.Up:
if (oFocused === item)
{
bStop = true;
}
else
{
oResult = item;
}
break;
case EventKeyCode.Down:
case EventKeyCode.Insert:
if (bNext)
{
oResult = item;
bStop = true;
}
else if (oFocused === item)
{
bNext = true;
}
break;
// no default
}
}
});
@ -540,7 +539,7 @@ class Selector
}
else if (EventKeyCode.PageUp === iEventKeyCode)
{
for (iIndex = iListLen; iIndex >= 0; iIndex--)
for (iIndex = iListLen; 0 <= iIndex; iIndex--)
{
if (oFocused === aList[iIndex])
{
@ -597,7 +596,7 @@ class Selector
}
/**
* @return {boolean}
* @returns {boolean}
*/
scrollToFocused() {
@ -612,17 +611,16 @@ class Selector
$focused = $(this.sItemFocusedSelector, this.oContentScrollable),
pos = $focused.position(),
visibleHeight = this.oContentVisible.height(),
focusedHeight = $focused.outerHeight()
;
focusedHeight = $focused.outerHeight();
if (list && list[0] && list[0].focused())
{
this.oContentScrollable.scrollTop(0);
return true;
}
else if (pos && (pos.top < 0 || pos.top + focusedHeight > visibleHeight))
else if (pos && (0 > pos.top || pos.top + focusedHeight > visibleHeight))
{
this.oContentScrollable.scrollTop(pos.top < 0 ?
this.oContentScrollable.scrollTop(0 > pos.top ?
this.oContentScrollable.scrollTop() + pos.top - offset :
this.oContentScrollable.scrollTop() + pos.top - visibleHeight + focusedHeight + offset
);
@ -635,7 +633,7 @@ class Selector
/**
* @param {boolean=} fast = false
* @return {boolean}
* @returns {boolean}
*/
scrollToTop(fast = false) {
@ -666,8 +664,7 @@ class Selector
list = [],
checked = false,
listItem = null,
lineUid = ''
;
lineUid = '';
const uid = this.getItemUid(item);
if (event && event.shiftKey)

View file

@ -88,14 +88,13 @@ export const trigger = ko.observable(false);
* @param {string} key
* @param {Object=} valueList
* @param {string=} defaulValue
* @return {string}
* @returns {string}
*/
export function i18n(key, valueList, defaulValue)
{
let
valueName = '',
result = I18N_DATA[key]
;
result = I18N_DATA[key];
if (isUnd(result))
{
@ -120,8 +119,7 @@ const i18nToNode = (element) => {
const
$el = $(element),
key = $el.data('i18n')
;
key = $el.data('i18n');
if (key)
{
@ -138,6 +136,7 @@ const i18nToNode = (element) => {
case '[title':
$el.attr('title', i18n(key.substr(7)));
break;
// no default
}
}
else
@ -187,6 +186,9 @@ const reloadData = () => {
window.rainloopI18N = null;
};
/**
* @returns {void}
*/
export function initNotificationLanguage()
{
I18N_NOTIFICATION_MAP.forEach((item) => {
@ -227,7 +229,7 @@ export function initOnStartOrLangChange(callback, scope, langCallback = null)
* @param {number} code
* @param {*=} message = ''
* @param {*=} defCode = null
* @return {string}
* @returns {string}
*/
export function getNotification(code, message = '', defCode = null)
{
@ -246,7 +248,7 @@ export function getNotification(code, message = '', defCode = null)
/**
* @param {object} response
* @param {number} defCode = Notification.UnknownNotification
* @return {string}
* @returns {string}
*/
export function getNotificationFromResponse(response, defCode = Notification.UnknownNotification)
{
@ -256,7 +258,7 @@ export function getNotificationFromResponse(response, defCode = Notification.Unk
/**
* @param {*} code
* @return {string}
* @returns {string}
*/
export function getUploadErrorDescByCode(code)
{
@ -314,9 +316,8 @@ export function reload(admin, language)
$html
.removeClass('rl-changing-language')
.removeClass('rl-rtl rl-ltr')
.addClass(isRtl ? 'rl-rtl' : 'rl-ltr')
// .attr('dir', isRtl ? 'rtl' : 'ltr')
;
.addClass(isRtl ? 'rl-rtl' : 'rl-ltr');
resolve();

View file

@ -32,12 +32,13 @@ export function silentTryCatch(callback)
{
try {
callback();
} catch (e) {/* eslint-disable-line no-empty */}
}
catch (e) {/* eslint-disable-line no-empty */}
}
/**
* @param {*} value
* @return {boolean}
* @returns {boolean}
*/
export function isNormal(value)
{
@ -47,7 +48,7 @@ export function isNormal(value)
/**
* @param {(string|number)} value
* @param {boolean=} includeZero = true
* @return {boolean}
* @returns {boolean}
*/
export function isPosNumeric(value, includeZero = true)
{
@ -58,7 +59,7 @@ export function isPosNumeric(value, includeZero = true)
/**
* @param {*} value
* @param {number=} defaultValur = 0
* @return {number}
* @returns {number}
*/
export function pInt(value, defaultValur = 0)
{
@ -68,7 +69,7 @@ export function pInt(value, defaultValur = 0)
/**
* @param {*} value
* @return {string}
* @returns {string}
*/
export function pString(value)
{
@ -77,7 +78,7 @@ export function pString(value)
/**
* @param {*} value
* @return {boolean}
* @returns {boolean}
*/
export function pBool(value)
{
@ -86,7 +87,7 @@ export function pBool(value)
/**
* @param {*} values
* @return {boolean}
* @returns {boolean}
*/
export function isNonEmptyArray(values)
{
@ -95,7 +96,7 @@ export function isNonEmptyArray(values)
/**
* @param {string} component
* @return {string}
* @returns {string}
*/
export function encodeURIComponent(component)
{
@ -104,7 +105,7 @@ export function encodeURIComponent(component)
/**
* @param {string} component
* @return {string}
* @returns {string}
*/
export function decodeURIComponent(component)
{
@ -113,20 +114,17 @@ export function decodeURIComponent(component)
/**
* @param {string} queryString
* @return {Object}
* @returns {Object}
*/
export function simpleQueryParser(queryString)
{
let
params = {},
queries = [],
temp = [],
index = 0,
len = 0
;
let index = 0, len = 0, temp = null;
queries = queryString.split('&');
for (index = 0, len = queries.length; index < len; index++)
const
queries = queryString.split('&'),
params = {};
for (len = queries.length; index < len; index++)
{
temp = queries[index].split('=');
params[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
@ -137,14 +135,13 @@ export function simpleQueryParser(queryString)
/**
* @param {number=} len = 32
* @return {string}
* @returns {string}
*/
export function fakeMd5(len = 32)
{
const
line = '0123456789abcdefghijklmnopqrstuvwxyz',
lineLen = line.length
;
lineLen = line.length;
len = pInt(len);
@ -162,7 +159,7 @@ let encryptObject = null;
/**
* @param {constructor} JSEncryptClass
* @param {string} publicKey
* @return {JSEncrypt|boolean}
* @returns {JSEncrypt|boolean}
*/
const rsaObject = (JSEncryptClass, publicKey) => {
@ -184,16 +181,14 @@ const rsaObject = (JSEncryptClass, publicKey) => {
/**
* @param {string} value
* @param {string} publicKey
* @return {string}
* @returns {string}
*/
const rsaEncode = (value, publicKey) => {
if (window.crypto && window.crypto.getRandomValues && publicKey)
{
let
resultValue = false,
encrypt = rsaObject(JSEncrypt, publicKey)
;
let resultValue = false;
const encrypt = rsaObject(JSEncrypt, publicKey);
if (encrypt)
{
@ -214,7 +209,7 @@ export {rsaEncode};
/**
* @param {string} text
* @return {string}
* @returns {string}
*/
export function encodeHtml(text)
{
@ -224,7 +219,7 @@ export function encodeHtml(text)
/**
* @param {string} text
* @param {number=} iLen = 100
* @return {string}
* @returns {string}
*/
export function splitPlainText(text, len = 100)
{
@ -233,8 +228,7 @@ export function splitPlainText(text, len = 100)
subText = '',
result = text,
spacePos = 0,
newLinePos = 0
;
newLinePos = 0;
while (result.length > len)
{
@ -259,8 +253,8 @@ export function splitPlainText(text, len = 100)
return prefix + result;
}
const timeOutAction = (function () {
let timeOuts = {};
const timeOutAction = (function() {
const timeOuts = {};
return (action, fFunction, timeOut) => {
timeOuts[action] = isUnd(timeOuts[action]) ? 0 : timeOuts[action];
window.clearTimeout(timeOuts[action]);
@ -268,8 +262,8 @@ const timeOutAction = (function () {
};
}());
const timeOutActionSecond = (function () {
let timeOuts = {};
const timeOutActionSecond = (function() {
const timeOuts = {};
return (action, fFunction, timeOut) => {
if (!timeOuts[action])
{
@ -284,7 +278,7 @@ const timeOutActionSecond = (function () {
export {timeOutAction, timeOutActionSecond};
/**
* @return {boolean}
* @returns {boolean}
*/
export function inFocus()
{
@ -301,6 +295,10 @@ export function inFocus()
return false;
}
/**
* @param {boolean} force
* @returns {void}
*/
export function removeInFocus(force)
{
if (window.document && window.document.activeElement && window.document.activeElement.blur)
@ -313,12 +311,16 @@ export function removeInFocus(force)
}
else if (force)
{
window.document.activeElement.blur();
window.document.activeElement.blur();
}
} catch (e) {/* eslint-disable-line no-empty */}
}
catch (e) {/* eslint-disable-line no-empty */}
}
}
/**
* @returns {void}
*/
export function removeSelection()
{
try {
@ -334,41 +336,42 @@ export function removeSelection()
{
window.document.selection.empty();
}
} catch (e) {/* eslint-disable-line no-empty */}
}
catch (e) {/* eslint-disable-line no-empty */}
}
/**
* @param {string} prefix
* @param {string} subject
* @return {string}
* @returns {string}
*/
export function replySubjectAdd(prefix, subject)
{
prefix = trim(prefix.toUpperCase());
subject = trim(subject.replace(/[\s]+/g, ' '));
let
drop = false,
parts = [],
let drop = false,
re = 'RE' === prefix,
fwd = 'FWD' === prefix,
prefixIsRe = !fwd
;
fwd = 'FWD' === prefix;
const
parts = [],
prefixIsRe = !fwd;
if ('' !== subject)
{
_.each(subject.split(':'), (part) => {
const trimmedPart = trim(part);
if (!drop && (/^(RE|FWD)$/i.test(trimmedPart) || /^(RE|FWD)[\[\(][\d]+[\]\)]$/i.test(trimmedPart)))
if (!drop && ((/^(RE|FWD)$/i).test(trimmedPart) || (/^(RE|FWD)[\[\(][\d]+[\]\)]$/i).test(trimmedPart)))
{
if (!re)
{
re = !!(/^RE/i.test(trimmedPart));
re = !!(/^RE/i).test(trimmedPart);
}
if (!fwd)
{
fwd = !!(/^FWD/i.test(trimmedPart));
fwd = !!(/^FWD/i).test(trimmedPart);
}
}
else
@ -399,7 +402,7 @@ export function replySubjectAdd(prefix, subject)
/**
* @param {number} num
* @param {number} dec
* @return {number}
* @returns {number}
*/
export function roundNumber(num, dec)
{
@ -408,23 +411,21 @@ export function roundNumber(num, dec)
/**
* @param {(number|string)} sizeInBytes
* @return {string}
* @returns {string}
*/
export function friendlySize(sizeInBytes)
{
sizeInBytes = pInt(sizeInBytes);
if (sizeInBytes >= 1073741824)
switch (true)
{
return roundNumber(sizeInBytes / 1073741824, 1) + 'GB';
}
else if (sizeInBytes >= 1048576)
{
return roundNumber(sizeInBytes / 1048576, 1) + 'MB';
}
else if (sizeInBytes >= 1024)
{
return roundNumber(sizeInBytes / 1024, 0) + 'KB';
case 1073741824 <= sizeInBytes:
return roundNumber(sizeInBytes / 1073741824, 1) + 'GB';
case 1048576 <= sizeInBytes:
return roundNumber(sizeInBytes / 1048576, 1) + 'MB';
case 1024 <= sizeInBytes:
return roundNumber(sizeInBytes / 1024, 0) + 'KB';
// no default
}
return sizeInBytes + 'B';
@ -506,21 +507,19 @@ export function kill_CtrlA_CtrlS(event)
* @param {(Object|null|undefined)} context
* @param {Function} fExecute
* @param {(Function|boolean|null)=} fCanExecute = true
* @return {Function}
* @returns {Function}
*/
export function createCommand(context, fExecute, fCanExecute = true)
{
let
fResult = null,
fNonEmpty = (...args) => {
if (fResult && fResult.canExecute && fResult.canExecute())
{
fExecute.apply(context, args);
}
return false;
let fResult = null;
const fNonEmpty = (...args) => {
if (fResult && fResult.canExecute && fResult.canExecute())
{
fExecute.apply(context, args);
}
;
return false;
};
fResult = fExecute ? fNonEmpty : noop;
fResult.enabled = ko.observable(true);
@ -543,7 +542,7 @@ export function createCommand(context, fExecute, fCanExecute = true)
/**
* @param {string} theme
* @return {string}
* @returns {string}
*/
export const convertThemeName = _.memoize((theme) => {
@ -557,7 +556,7 @@ export const convertThemeName = _.memoize((theme) => {
/**
* @param {string} name
* @return {string}
* @returns {string}
*/
export function quoteName(name)
{
@ -565,7 +564,7 @@ export function quoteName(name)
}
/**
* @return {number}
* @returns {number}
*/
export function microtime()
{
@ -573,7 +572,7 @@ export function microtime()
}
/**
* @return {number}
* @returns {number}
*/
export function timestamp()
{
@ -584,7 +583,7 @@ export function timestamp()
*
* @param {string} language
* @param {boolean=} isEng = false
* @return {string}
* @returns {string}
*/
export function convertLangName(language, isEng = false)
{
@ -592,6 +591,9 @@ export function convertLangName(language, isEng = false)
language.toUpperCase().replace(/[^a-zA-Z0-9]+/g, '_'), null, language);
}
/**
* @returns {object}
*/
export function draggablePlace()
{
return $('<div class="draggablePlace">' +
@ -602,14 +604,18 @@ export function draggablePlace()
).appendTo('#rl-hidden');
}
export function defautOptionsAfterRender(domOption, item)
/**
* @param {object} domOption
* @param {object} item
* @returns {void}
*/
export function defautOptionsAfterRender(domItem, item)
{
if (item && !isUnd(item.disabled) && domOption)
if (item && !isUnd(item.disabled) && domItem)
{
$(domOption)
$(domItem)
.toggleClass('disabled', item.disabled)
.prop('disabled', item.disabled)
;
.prop('disabled', item.disabled);
}
}
@ -638,8 +644,7 @@ export function previewMessage(title, body, isHtml, print)
win = window.open(''),
doc = win.document,
bodyClone = body.clone(),
bodyClass = isHtml ? 'html' : 'plain'
;
bodyClass = isHtml ? 'html' : 'plain';
clearBqSwitcher(bodyClone);
@ -734,7 +739,7 @@ body.plain blockquote blockquote blockquote {
* @param {?} koTrigger
* @param {?} context = null
* @param {number=} timer = 1000
* @return {Function}
* @returns {Function}
*/
export function settingsSaveHelperFunction(fCallback, koTrigger, context = null, timer = 1000)
{
@ -751,11 +756,23 @@ export function settingsSaveHelperFunction(fCallback, koTrigger, context = null,
};
}
/**
* @param {object} koTrigger
* @param {mixed} context
* @returns {mixed}
*/
export function settingsSaveHelperSimpleFunction(koTrigger, context)
{
return settingsSaveHelperFunction(null, koTrigger, context, 1000);
}
/**
* @param {object} remote
* @param {string} settingName
* @param {string} type
* @param {function} fTriggerFunction
* @returns {function}
*/
export function settingsSaveHelperSubscribeFunction(remote, settingName, type, fTriggerFunction)
{
return (value) => {
@ -764,9 +781,6 @@ export function settingsSaveHelperSubscribeFunction(remote, settingName, type, f
{
switch (type)
{
default:
value = pString(value);
break;
case 'bool':
case 'boolean':
value = value ? '1' : '0';
@ -779,9 +793,12 @@ export function settingsSaveHelperSubscribeFunction(remote, settingName, type, f
case 'trim':
value = trim(value);
break;
default:
value = pString(value);
break;
}
let data = {};
const data = {};
data[settingName] = value;
if (remote.saveAdminConfig)
@ -798,7 +815,7 @@ export function settingsSaveHelperSubscribeFunction(remote, settingName, type, f
/**
* @param {string} html
* @return {string}
* @returns {string}
*/
export function findEmailAndLinks(html)
{
@ -809,7 +826,7 @@ export function findEmailAndLinks(html)
urls: true,
email: true,
twitter: false,
replaceFn: function (autolinker, match) {
replaceFn: function(autolinker, match) {
return !(autolinker && match && 'url' === match.getType() && match.matchedText && 0 !== match.matchedText.indexOf('http'));
}
});
@ -817,7 +834,7 @@ export function findEmailAndLinks(html)
/**
* @param {string} html
* @return {string}
* @returns {string}
*/
export function htmlToPlain(html)
{
@ -828,8 +845,7 @@ export function htmlToPlain(html)
iP2 = 0,
iP3 = 0,
text = ''
;
text = '';
const
@ -867,8 +883,7 @@ export function htmlToPlain(html)
convertLinks = (...args) => {
return (args && 1 < args.length) ? trim(args[1]) : '';
}
;
};
text = html
.replace(/\u0002([\s\S]*)\u0002/gm, '\u200C$1\u200C')
@ -893,8 +908,7 @@ export function htmlToPlain(html)
.replace(/<\/div>/gi, '\n')
.replace(/&nbsp;/gi, ' ')
.replace(/&quot;/gi, '"')
.replace(/<[^>]*>/gm, '')
;
.replace(/<[^>]*>/gm, '');
text = $div.html(text).text();
@ -903,8 +917,7 @@ export function htmlToPlain(html)
.replace(/[\n]{3,}/gm, '\n\n')
.replace(/&gt;/gi, '>')
.replace(/&lt;/gi, '<')
.replace(/&amp;/gi, '&')
;
.replace(/&amp;/gi, '&');
text = splitPlainText(trim(text));
@ -913,7 +926,7 @@ export function htmlToPlain(html)
while (0 < limit)
{
limit--;
limit -= 1;
iP1 = text.indexOf('__bq__start__', pos);
if (-1 < iP1)
{
@ -945,8 +958,7 @@ export function htmlToPlain(html)
text = text
.replace(/__bq__start__/gm, '')
.replace(/__bq__end__/gm, '')
;
.replace(/__bq__end__/gm, '');
return text;
}
@ -954,7 +966,7 @@ export function htmlToPlain(html)
/**
* @param {string} plain
* @param {boolean} findEmailAndLinksInText = false
* @return {string}
* @returns {string}
*/
export function plainToHtml(plain, findEmailAndLinksInText = false)
{
@ -971,8 +983,7 @@ export function plainToHtml(plain, findEmailAndLinksInText = false)
aNextText = [],
sLine = '',
iIndex = 0,
aText = plain.split('\n')
;
aText = plain.split('\n');
do
{
@ -1031,8 +1042,7 @@ export function plainToHtml(plain, findEmailAndLinksInText = false)
.replace(/~~~blockquote~~~[\s]*/g, '<blockquote>')
.replace(/[\s]*~~~\/blockquote~~~/g, '</blockquote>')
.replace(/\u200C([\s\S]*)\u200C/g, '\u0002$1\u0002')
.replace(/\n/g, '<br />')
;
.replace(/\n/g, '<br />');
return findEmailAndLinksInText ? findEmailAndLinks(plain) : plain;
}
@ -1051,7 +1061,7 @@ window.rainloop_Utils_plainToHtml = plainToHtml;
* @param {Function=} fRenameCallback
* @param {boolean=} bSystem
* @param {boolean=} bBuildUnvisible
* @return {Array}
* @returns {Array}
*/
export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines,
iUnDeep, fDisableCallback, fVisibleCallback, fRenameCallback, bSystem, bBuildUnvisible)
@ -1064,9 +1074,9 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
bSep = false,
iIndex = 0,
iLen = 0,
sDeepPrefix = '\u00A0\u00A0\u00A0',
aResult = []
;
aResult = [];
const sDeepPrefix = '\u00A0\u00A0\u00A0';
bBuildUnvisible = isUnd(bBuildUnvisible) ? false : !!bBuildUnvisible;
bSystem = !isNormal(bSystem) ? 0 < aSystem.length : bSystem;
@ -1171,6 +1181,10 @@ export function folderListOptionsBuilder(aSystem, aList, aDisabled, aHeaderLines
return aResult;
}
/**
* @param {object} element
* @returns {void}
*/
export function selectElement(element)
{
let sel, range;
@ -1215,26 +1229,26 @@ export function triggerAutocompleteInputChange(delay = false) {
}
}
let configurationScriptTagCache = {};
const configurationScriptTagCache = {};
/**
* @param {string} configuration
* @return {object}
* @returns {object}
*/
export function getConfigurationFromScriptTag(configuration)
{
let result = {};
if (!configurationScriptTagCache[configuration])
{
configurationScriptTagCache[configuration] = $('script[type="application/json"][data-configuration="' + configuration + '"]');
}
try {
result = JSON.parse(configurationScriptTagCache[configuration].text());
} catch (e) {/* eslint-disable-line no-empty */}
try
{
return JSON.parse(configurationScriptTagCache[configuration].text());
}
catch (e) {/* eslint-disable-line no-empty */}
return result;
return {};
}
/**
@ -1244,7 +1258,7 @@ export function getConfigurationFromScriptTag(configuration)
export function disposeOne(propOrValue, value)
{
const disposable = value || propOrValue;
if (disposable && typeof disposable.dispose === 'function')
if (disposable && 'function' === typeof disposable.dispose)
{
disposable.dispose();
}
@ -1268,6 +1282,7 @@ export function disposeObject(object)
/**
* @param {Object|Array} objectOrObjects
* @returns {void}
*/
export function delegateRunOnDestroy(objectOrObjects)
{
@ -1286,6 +1301,11 @@ export function delegateRunOnDestroy(objectOrObjects)
}
}
/**
* @param {object} $styleTag
* @param {string} css
* @returns {boolean}
*/
export function appendStyles($styleTag, css)
{
if ($styleTag && $styleTag[0])
@ -1307,20 +1327,25 @@ export function appendStyles($styleTag, css)
let
__themeTimer = 0,
__themeAjax = null
;
__themeAjax = null;
/**
* @param {string} value
* @param {function} themeTrigger
* @returns {void}
*/
export function changeTheme(value, themeTrigger)
{
let
const
themeLink = $('#app-theme-link'),
themeStyle = $('#app-theme-style'),
url = themeLink.attr('href'),
clearTimer = () => {
__themeTimer = window.setTimeout(() => themeTrigger(SaveSettingsStep.Idle), 1000);
__themeAjax = null;
}
;
};
let
themeStyle = $('#app-theme-style'),
url = themeLink.attr('href');
if (!url)
{
@ -1375,6 +1400,9 @@ export function changeTheme(value, themeTrigger)
}
}
/**
* @returns {function}
*/
export function computedPagenatorHelper(koCurrentPage, koPageCount)
{
return () => {
@ -1388,7 +1416,7 @@ export function computedPagenatorHelper(koCurrentPage, koPageCount)
const data = {
current: index === currentPage,
name: '' === customName ? index.toString() : customName.toString(),
custom: '' === customName ? false : true,
custom: '' !== customName,
title: '' === customName ? '' : index.toString(),
value: index.toString()
};
@ -1401,14 +1429,12 @@ export function computedPagenatorHelper(koCurrentPage, koPageCount)
{
result.unshift(data);
}
}
;
};
let
prev = 0,
next = 0,
limit = 2
;
limit = 2;
if (1 < pageCount || (0 < pageCount && pageCount < currentPage))
{
@ -1438,13 +1464,13 @@ export function computedPagenatorHelper(koCurrentPage, koPageCount)
if (0 < prev)
{
fAdd(prev, false);
limit--;
limit -= 1;
}
if (pageCount >= next)
{
fAdd(next, true);
limit--;
limit -= 1;
}
else if (0 >= prev)
{
@ -1488,7 +1514,7 @@ export function computedPagenatorHelper(koCurrentPage, koPageCount)
/**
* @param {string} fileName
* @return {string}
* @returns {string}
*/
export function getFileExtension(fileName)
{
@ -1500,14 +1526,13 @@ export function getFileExtension(fileName)
/**
* @param {string} fileName
* @return {string}
* @returns {string}
*/
export function mimeContentType(fileName)
{
let
ext = '',
result = 'application/octet-stream'
;
result = 'application/octet-stream';
fileName = trim(fileName).toLowerCase();
@ -1536,13 +1561,11 @@ export function resizeAndCrop(url, value, fCallback)
img.onload = function() {
let
diff = [0, 0]
;
diff = [0, 0];
const
canvas = window.document.createElement('canvas'),
ctx = canvas.getContext('2d')
;
ctx = canvas.getContext('2d');
canvas.width = value;
canvas.height = value;
@ -1569,7 +1592,7 @@ export function resizeAndCrop(url, value, fCallback)
/**
* @param {string} mailToUrl
* @param {Function} PopupComposeVoreModel
* @return {boolean}
* @returns {boolean}
*/
export function mailToHelper(mailToUrl, PopupComposeVoreModel)
{
@ -1586,22 +1609,22 @@ export function mailToHelper(mailToUrl, PopupComposeVoreModel)
to = [],
cc = null,
bcc = null,
params = {},
EmailModel = require('Model/Email'),
params = {};
const
email = mailToUrl.replace(/\?.+$/, ''),
queryString = 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;
}
;
};
to = fParseEmailLine(email);
params = simpleQueryParser(queryString);
params = simpleQueryParser(query);
if (!isUnd(params.cc))
{
@ -1638,16 +1661,19 @@ export const windowResize = _.debounce((timeout) => {
}
}, 50);
/**
* @returns {void}
*/
export function windowResizeCallback()
{
windowResize();
}
let substr = window.String.substr;
if ('ab'.substr(-1) !== 'b')
if ('b' !== 'ab'.substr(-1))
{
substr = (str, start, length) => {
start = start < 0 ? str.length + start : start;
start = 0 > start ? str.length + start : start;
return str.substr(start, length);
};