isArray to native Array.isArray

isUnd(*) to native undefined === *
isFunc to native typeof * === 'function'
isObject to native typeof * === 'object'
microtime() to native Date().getTime();
noop to native ()=>{}
noopFalse to native ()=>false
noopTrue to native ()=>true
boolToAjax to native *?'1':'0'
Underscore.js to native
This commit is contained in:
djmaze 2020-07-29 21:49:41 +02:00
parent fa39c7ecba
commit ea48f5060b
72 changed files with 551 additions and 775 deletions

View file

@ -88,7 +88,6 @@ window.__initAppData = data => {
const appData = window.__rlah_data(), p = progressJs;
if (
jassl &&
p &&
appData &&
appData.TemplatesLink &&

View file

@ -1,5 +1,5 @@
import { MessageSetAction } from 'Common/Enums';
import { trim, pInt, isArray } from 'Common/Utils';
import { trim, pInt } from 'Common/Utils';
let FOLDERS_CACHE = {},
FOLDERS_NAME_CACHE = {},
@ -266,7 +266,7 @@ export function storeMessageFlagsToCache(message) {
* @param {Array} flags
*/
export function storeMessageFlagsToCacheByFolderAndUid(folder, uid, flags) {
if (isArray(flags) && flags.length) {
if (Array.isArray(flags) && flags.length) {
setMessageFlagsToCache(folder, uid, flags);
}
}
@ -280,7 +280,7 @@ export function storeMessageFlagsToCacheBySetAction(folder, uid, setAction) {
let unread = 0;
const flags = getMessageFlagsFromCache(folder, uid);
if (isArray(flags) && flags.length) {
if (Array.isArray(flags) && flags.length) {
if (flags[0]) {
unread = 1;
}

View file

@ -1,6 +1,5 @@
import window from 'window';
import Cookies from 'js-cookie';
import { isUnd } from 'Common/Utils';
import { CLIENT_SIDE_STORAGE_INDEX_NAME } from 'Common/Consts';
class CookieDriver {
@ -39,7 +38,7 @@ class CookieDriver {
try {
const storageResult = Cookies.getJSON(CLIENT_SIDE_STORAGE_INDEX_NAME);
result = storageResult && !isUnd(storageResult[key]) ? storageResult[key] : null;
result = storageResult && undefined !== storageResult[key] ? storageResult[key] : null;
} catch (e) {} // eslint-disable-line no-empty
return result;

View file

@ -1,5 +1,4 @@
import window from 'window';
import { isUnd } from 'Common/Utils';
import { isStorageSupported } from 'Storage/RainLoop';
import { CLIENT_SIDE_STORAGE_INDEX_NAME } from 'Common/Consts';
@ -49,7 +48,7 @@ class LocalStorageDriver {
const storageValue = this.s.getItem(CLIENT_SIDE_STORAGE_INDEX_NAME) || null,
storageResult = null === storageValue ? null : window.JSON.parse(storageValue);
return storageResult && !isUnd(storageResult[key]) ? storageResult[key] : null;
return storageResult && undefined !== storageResult[key] ? storageResult[key] : null;
} catch (e) {} // eslint-disable-line no-empty
return null;

View file

@ -1,4 +1,3 @@
import { isObject, isUnd } from 'Common/Utils';
import * as Plugins from 'Common/Plugins';
const SUBS = {};
@ -9,7 +8,7 @@ const SUBS = {};
* @param {Object=} context
*/
export function sub(name, func, context) {
if (isObject(name)) {
if (typeof name === 'object') {
context = func || null;
func = null;
@ -17,7 +16,7 @@ export function sub(name, func, context) {
sub(subName, subFunc, context);
});
} else {
if (isUnd(SUBS[name])) {
if (undefined === SUBS[name]) {
SUBS[name] = [];
}
@ -32,7 +31,7 @@ export function sub(name, func, context) {
export function pub(name, args) {
Plugins.runHook('rl-pub', [name, args]);
if (!isUnd(SUBS[name])) {
if (undefined !== SUBS[name]) {
SUBS[name].forEach(items => {
if (items[0]) {
items[0].apply(items[1] || null, args || []);

View file

@ -22,8 +22,6 @@ $hcont
.css({ position: 'absolute', left: -5000 })
.appendTo($body);
export const startMicrotime = new window.Date().getTime();
/**
* @type {boolean}
*/
@ -48,29 +46,13 @@ export const sUserAgent =
/**
* @type {boolean}
*/
export const bIE = sUserAgent.includes('msie');
/**
* @type {boolean}
*/
export const bChrome = sUserAgent.includes('chrome');
/**
* @type {boolean}
*/
export const bSafari = !bChrome && sUserAgent.includes('safari');
export const bSafari = !sUserAgent.includes('chrome') && sUserAgent.includes('safari');
/**
* @type {boolean}
*/
export const bMobileDevice = (/android|iphone|ipod|ipad|blackberry|mobile/i).test(sUserAgent);
/**
* @type {boolean}
*/
export const bIsHttps =
window.document && window.document.location ? 'https:' === window.document.location.protocol : false;
/**
* @type {Object}
*/
@ -148,12 +130,6 @@ export const htmlEditorLangsMap = {
'zh_tw': 'zh'
};
/**
* @type {boolean}
*/
let bAllowPdfPreview = !bMobileDevice && undefined !== window.navigator.mimeTypes['application/pdf'];
export { bAllowPdfPreview };
export const VIEW_MODELS = {
settings: [],

View file

@ -1,5 +1,4 @@
import window from 'window';
import _ from '_';
import $ from '$';
import { htmlEditorDefaultConfig, htmlEditorLangsMap } from 'Common/Globals';
import { EventKeyCode, Magics } from 'Common/Enums';
@ -35,7 +34,16 @@ class HtmlEditor {
this.element = element;
this.$element = $(element);
this.resize = _.throttle(this.resizeEditor.bind(this), 100);
// throttle
var t, o = this;
this.resize = ()=>{
if (!t) {
t = setTimeout(()=>{
o.resizeEditor();
t = 0;
}, 100);
}
};
this.init();
}

View file

@ -8,10 +8,6 @@ import window from 'window';
* @returns {Promise}
*/
export function jassl(src, async = false) {
if (!window.Promise || !window.Promise.all) {
throw new Error('Promises are not available your environment.');
}
if (!src) {
throw new Error('src should not be empty.');
}
@ -27,7 +23,7 @@ export function jassl(src, async = false) {
reject(new Error(src));
};
element.async = true === async;
element.async = !!async;
element.src = src;
window.document.body.appendChild(element);

View file

@ -1,5 +1,5 @@
import window from 'window';
import { pString, pInt, isUnd, isNormal, trim, encodeURIComponent } from 'Common/Utils';
import { pString, pInt, isNormal, trim } from 'Common/Utils';
import * as Settings from 'Storage/Settings';
const ROOT = './',
@ -58,7 +58,7 @@ export function rootUser() {
* @returns {string}
*/
export function attachmentRaw(type, download, customSpecSuffix) {
customSpecSuffix = isUnd(customSpecSuffix) ? AUTH_PREFIX : customSpecSuffix;
customSpecSuffix = undefined === customSpecSuffix ? AUTH_PREFIX : customSpecSuffix;
return (
SERVER_PREFIX +
'/Raw/' +
@ -160,7 +160,7 @@ export function append() {
* @returns {string}
*/
export function change(email) {
return serverRequest('Change') + encodeURIComponent(email) + '/';
return serverRequest('Change') + window.encodeURIComponent(email) + '/';
}
/**
@ -204,7 +204,7 @@ export function messageDownloadLink(requestHash) {
* @returns {string}
*/
export function avatarLink(email) {
return SERVER_PREFIX + '/Raw/0/Avatar/' + encodeURIComponent(email) + '/';
return SERVER_PREFIX + '/Raw/0/Avatar/' + window.encodeURIComponent(email) + '/';
}
/**

View file

@ -1,5 +1,4 @@
import window from 'window';
import _ from '_';
import $ from '$';
import moment from 'moment';
import { i18n } from 'Common/Translator';
@ -7,21 +6,22 @@ import { i18n } from 'Common/Translator';
let _moment = null;
let _momentNow = 0;
const updateMomentNow = _.debounce(
() => {
var d, du;
const updateMomentNow = ()=>{
// leading debounce
if (!d) {
d = setTimeout(()=>d=0, 500);
_moment = moment();
},
500,
true
);
}
};
const updateMomentNowUnix = _.debounce(
() => {
const updateMomentNowUnix = ()=>{
// leading debounce
if (!du) {
du = setTimeout(()=>du=0, 500);
_momentNow = moment().unix();
},
500,
true
);
}
};
/**
* @returns {moment}
@ -147,9 +147,9 @@ export function momentToNode(element) {
* @returns {void}
*/
export function reload() {
_.defer(() => {
setTimeout(() =>
$('.moment', window.document).each((index, item) => {
momentToNode(item);
});
});
})
, 1);
}

View file

@ -1,4 +1,3 @@
import { isFunc, isArray, isUnd } from 'Common/Utils';
import { data as GlobalsData } from 'Common/Globals';
import * as Settings from 'Storage/Settings';
@ -11,8 +10,8 @@ const SIMPLE_HOOKS = {},
* @param {Function} callback
*/
export function addHook(name, callback) {
if (isFunc(callback)) {
if (!isArray(SIMPLE_HOOKS[name])) {
if (typeof callback === 'function') {
if (!Array.isArray(SIMPLE_HOOKS[name])) {
SIMPLE_HOOKS[name] = [];
}
@ -25,7 +24,7 @@ export function addHook(name, callback) {
* @param {Array=} args = []
*/
export function runHook(name, args = []) {
if (isArray(SIMPLE_HOOKS[name])) {
if (Array.isArray(SIMPLE_HOOKS[name])) {
SIMPLE_HOOKS[name].forEach(callback => {
callback(...args);
});
@ -89,6 +88,6 @@ export function runSettingsViewModelHooks(admin) {
*/
export function settingsGet(pluginSection, name) {
let plugins = Settings.settingsGet('Plugins');
plugins = plugins && !isUnd(plugins[pluginSection]) ? plugins[pluginSection] : null;
return plugins ? (isUnd(plugins[name]) ? null : plugins[name]) : null;
plugins = plugins && undefined !== plugins[pluginSection] ? plugins[pluginSection] : null;
return plugins ? (undefined === plugins[name] ? null : plugins[name]) : null;
}

View file

@ -1,9 +1,7 @@
import $ from '$';
import _ from '_';
import key from 'key';
import ko from 'ko';
import { EventKeyCode } from 'Common/Enums';
import { isArray, noop, noopTrue } from 'Common/Utils';
class Selector {
list;
@ -56,7 +54,12 @@ class Selector {
this.focusedItem = koFocusedItem || ko.observable(null);
this.selectedItem = koSelectedItem || ko.observable(null);
this.itemSelectedThrottle = _.debounce(this.itemSelected.bind(this), 300);
var d, o = this;
this.itemSelectedThrottle = (item)=>{
// debounce
d && clearTimeout(d);
d = setTimeout(()=>o.itemSelected(item), 300);
};
this.listChecked.subscribe((items) => {
if (items.length) {
@ -109,7 +112,7 @@ class Selector {
this.list.subscribe(
(items) => {
if (isArray(items)) {
if (Array.isArray(items)) {
items.forEach(item => {
if (item) {
const uid = this.getItemUid(item);
@ -147,7 +150,7 @@ class Selector {
this.focusedItem(null);
this.selectedItem(null);
if (isArray(aItems)) {
if (Array.isArray(aItems)) {
len = aCheckedCache.length;
aItems.forEach(item => {
@ -240,10 +243,10 @@ class Selector {
itemSelected(item) {
if (this.isListChecked()) {
if (!item) {
(this.oCallbacks.onItemSelect || noop)(item || null);
(this.oCallbacks.onItemSelect || (()=>{}))(item || null);
}
} else if (item) {
(this.oCallbacks.onItemSelect || noop)(item);
(this.oCallbacks.onItemSelect || (()=>{}))(item);
}
}
@ -351,14 +354,14 @@ class Selector {
* @returns {boolean}
*/
autoSelect() {
return !!(this.oCallbacks.onAutoSelect || noopTrue)();
return !!(this.oCallbacks.onAutoSelect || (()=>true))();
}
/**
* @param {boolean} up
*/
doUpUpOrDownDown(up) {
(this.oCallbacks.onUpUpOrDownDown || noopTrue)(!!up);
(this.oCallbacks.onUpUpOrDownDown || (()=>true))(!!up);
}
/**

View file

@ -1,9 +1,8 @@
import window from 'window';
import _ from '_';
import $ from '$';
import ko from 'ko';
import { Notification, UploadErrorCode } from 'Common/Enums';
import { pInt, isUnd, microtime } from 'Common/Utils';
import { pInt } from 'Common/Utils';
import { $html, $htmlCL } from 'Common/Globals';
import { reload as momentorReload } from 'Common/Momentor';
import { langLink } from 'Common/Links';
@ -94,11 +93,11 @@ export function i18n(key, valueList, defaulValue) {
let valueName = '',
result = I18N_DATA[key];
if (isUnd(result)) {
result = isUnd(defaulValue) ? key : defaulValue;
if (undefined === result) {
result = undefined === defaulValue ? key : defaulValue;
}
if (!isUnd(valueList) && null !== valueList) {
if (undefined !== valueList && null !== valueList) {
for (valueName in valueList) {
if (Object.prototype.hasOwnProperty.call(valueList, valueName)) {
result = result.replace('%' + valueName + '%', valueList[valueName]);
@ -138,11 +137,11 @@ const i18nToNode = (element) => {
* @param {boolean=} animate = false
*/
export function i18nToNodes(elements) {
_.defer(() => {
setTimeout(() =>
$('[data-i18n]', elements).each((index, item) => {
i18nToNode(item);
});
});
})
, 1);
}
const reloadData = () => {
@ -203,8 +202,8 @@ export function getNotification(code, message = '', defCode = null) {
}
defCode = defCode ? window.parseInt(defCode, 10) || 0 : 0;
return isUnd(I18N_NOTIFICATION_DATA[code])
? defCode && isUnd(I18N_NOTIFICATION_DATA[defCode])
return undefined === I18N_NOTIFICATION_DATA[code]
? defCode && undefined === I18N_NOTIFICATION_DATA[defCode]
? I18N_NOTIFICATION_DATA[defCode]
: ''
: I18N_NOTIFICATION_DATA[code];
@ -259,7 +258,7 @@ export function getUploadErrorDescByCode(code) {
* @param {string} language
*/
export function reload(admin, language) {
const start = microtime();
const start = new Date().getTime();
$htmlCL.add('rl-changing-language');
@ -292,7 +291,7 @@ export function reload(admin, language) {
resolve();
},
500 < microtime() - start ? 1 : 500
500 < (new Date().getTime()) - start ? 1 : 500
);
});
});

View file

@ -1,22 +1,15 @@
import window from 'window';
import $ from '$';
import _ from '_';
import ko from 'ko';
import Autolinker from 'Autolinker';
import { $win, $div, $hcont, dropdownVisibility, data as GlobalsData } from 'Common/Globals';
import { ComposeType, EventKeyCode, SaveSettingsStep, FolderType } from 'Common/Enums';
import { ComposeType, SaveSettingsStep, FolderType } from 'Common/Enums';
import { Mime } from 'Common/Mime';
import { jassl } from 'Common/Jassl';
const trim = $.trim;
const isArray = Array.isArray;
const isObject = v => typeof v === 'object';
const isFunc = v => typeof v === 'function';
const isUnd = v => undefined === v;
const noop = () => {}; // eslint-disable-line no-empty-function
const noopTrue = () => true;
const noopFalse = () => false;
const decodeURIComponent = component => window.decodeURIComponent(component);
var htmlspecialchars = ((de,se,gt,lt,sq,dq,bt) => {
return (str, quote_style = 3, double_encode = true) => {
@ -30,23 +23,14 @@ var htmlspecialchars = ((de,se,gt,lt,sq,dq,bt) => {
};
})(/&/g,/&(?![\w#]+;)/gi,/</g,/>/g,/'/g,/"/g,/`/g);
export { trim, isArray, isObject, isFunc, isUnd, noop, noopTrue, noopFalse, jassl };
/**
* @param {Function} func
*/
export function silentTryCatch(func) {
try {
func();
} catch (e) {} // eslint-disable-line no-empty
}
export { trim };
/**
* @param {*} value
* @returns {boolean}
*/
export function isNormal(value) {
return !isUnd(value) && null !== value;
return undefined !== value && null !== value;
}
/**
@ -80,22 +64,6 @@ export function pString(value) {
return isNormal(value) ? '' + value : '';
}
/**
* @param {*} value
* @returns {boolean}
*/
export function pBool(value) {
return !!value;
}
/**
* @param {*} value
* @returns {string}
*/
export function boolToAjax(value) {
return value ? '1' : '0';
}
/**
* @param {*} values
* @returns {boolean}
@ -104,38 +72,6 @@ export function isNonEmptyArray(values) {
return isArray(values) && values.length;
}
/**
* @param {string} component
* @returns {string}
*/
export function encodeURIComponent(component) {
return window.encodeURIComponent(component);
}
/**
* @param {string} component
* @returns {string}
*/
export function decodeURIComponent(component) {
return window.decodeURIComponent(component);
}
/**
* @param {string} url
* @returns {string}
*/
export function decodeURI(url) {
return window.decodeURI(url);
}
/**
* @param {string} url
* @returns {string}
*/
export function encodeURI(url) {
return window.encodeURI(url);
}
/**
* @param {string} queryString
* @returns {Object}
@ -210,28 +146,16 @@ export function splitPlainText(text, len = 100) {
return prefix + result;
}
const timeOutAction = (function() {
const timeOutAction = (() => {
const timeOuts = {};
return (action, fFunction, timeOut) => {
timeOuts[action] = isUnd(timeOuts[action]) ? 0 : timeOuts[action];
timeOuts[action] = undefined === timeOuts[action] ? 0 : timeOuts[action];
window.clearTimeout(timeOuts[action]);
timeOuts[action] = window.setTimeout(fFunction, timeOut);
};
})();
const timeOutActionSecond = (function() {
const timeOuts = {};
return (action, fFunction, timeOut) => {
if (!timeOuts[action]) {
timeOuts[action] = window.setTimeout(() => {
fFunction();
timeOuts[action] = 0;
}, timeOut);
}
};
})();
export { timeOutAction, timeOutActionSecond };
export { timeOutAction };
/**
* @param {any} m
@ -247,7 +171,7 @@ export function deModule(m) {
export function inFocus() {
try {
if (window.document.activeElement) {
if (isUnd(window.document.activeElement.__inFocusCache)) {
if (undefined === window.document.activeElement.__inFocusCache) {
window.document.activeElement.__inFocusCache = $(window.document.activeElement).is(
'input,textarea,iframe,.cke_editable'
);
@ -395,36 +319,6 @@ export function delegateRun(object, methodName, params, delay = 0) {
}
}
/**
* @param {?} event
*/
export function killCtrlACtrlS(event) {
event = event || window.event;
if (event && event.ctrlKey && !event.shiftKey && !event.altKey) {
const key = event.keyCode || event.which;
if (key === EventKeyCode.S) {
event.preventDefault();
return;
} else if (key === EventKeyCode.A) {
const sender = event.target || event.srcElement;
if (
sender &&
('true' === '' + sender.contentEditable || (sender.tagName && sender.tagName.match(/INPUT|TEXTAREA/i)))
) {
return;
}
if (window.getSelection) {
window.getSelection().removeAllRanges();
} else if (window.document.selection && window.document.selection.clear) {
window.document.selection.clear();
}
event.preventDefault();
}
}
}
/**
* @param {(Object|null|undefined)} context
* @param {Function} fExecute
@ -440,11 +334,11 @@ export function createCommandLegacy(context, fExecute, fCanExecute = true) {
return false;
};
fResult = fExecute ? fNonEmpty : noop;
fResult = fExecute ? fNonEmpty : ()=>{};
fResult.enabled = ko.observable(true);
fResult.isCommand = true;
if (isFunc(fCanExecute)) {
if (typeof fCanExecute === 'function') {
fResult.canExecute = ko.computed(() => fResult && fResult.enabled() && fCanExecute.call(context));
} else {
fResult.canExecute = ko.computed(() => fResult && fResult.enabled() && !!fCanExecute);
@ -470,28 +364,6 @@ export const convertThemeName = theme => {
);
};
/**
* @param {string} name
* @returns {string}
*/
export function quoteName(name) {
return name.replace(/["]/g, '\\"');
}
/**
* @returns {number}
*/
export function microtime() {
return new window.Date().getTime();
}
/**
* @returns {number}
*/
export function timestamp() {
return window.Math.round(microtime() / 1000);
}
/**
*
* @param {string} language
@ -525,7 +397,7 @@ export function draggablePlace() {
* @returns {void}
*/
export function defautOptionsAfterRender(domItem, item) {
if (item && !isUnd(item.disabled) && domItem) {
if (item && undefined !== item.disabled && domItem) {
$(domItem)
.toggleClass('disabled', item.disabled)
.prop('disabled', item.disabled);
@ -886,7 +758,7 @@ export function folderListOptionsBuilder(
const sDeepPrefix = '\u00A0\u00A0\u00A0';
bBuildUnvisible = isUnd(bBuildUnvisible) ? false : !!bBuildUnvisible;
bBuildUnvisible = undefined === bBuildUnvisible ? false : !!bBuildUnvisible;
bSystem = !isNormal(bSystem) ? 0 < aSystem.length : bSystem;
iUnDeep = !isNormal(iUnDeep) ? 0 : iUnDeep;
fDisableCallback = isNormal(fDisableCallback) ? fDisableCallback : null;
@ -1016,9 +888,14 @@ export function selectElement(element) {
}
}
export const detectDropdownVisibility = _.debounce(() => {
dropdownVisibility(!!GlobalsData.aBootstrapDropdowns.find(item => item.hasClass('open')));
}, 50);
var dv;
export const detectDropdownVisibility = ()=>{
// leading debounce
dv && clearTimeout(dv);
dv = setTimeout(()=>
dropdownVisibility(!!GlobalsData.aBootstrapDropdowns.find(item => item.hasClass('open')))
, 50);
};
/**
* @param {boolean=} delay = false
@ -1055,30 +932,6 @@ export function getConfigurationFromScriptTag(configuration) {
return {};
}
/**
* @param {mixed} mPropOrValue
* @param {mixed} value
*/
export function disposeOne(propOrValue, value) {
const disposable = value || propOrValue;
if (disposable && 'function' === typeof disposable.dispose) {
disposable.dispose();
}
}
/**
* @param {Object} object
*/
export function disposeObject(object) {
if (object) {
if (isArray(object.disposables)) {
object.disposables.forEach(disposeOne);
}
ko.utils.objectForEach(object, disposeOne);
}
}
/**
* @param {Object|Array} objectOrObjects
* @returns {void}
@ -1102,7 +955,7 @@ export function delegateRunOnDestroy(objectOrObjects) {
*/
export function appendStyles($styleTag, css) {
if ($styleTag && $styleTag[0]) {
if ($styleTag[0].styleSheet && !isUnd($styleTag[0].styleSheet.cssText)) {
if ($styleTag[0].styleSheet && undefined !== $styleTag[0].styleSheet.cssText) {
$styleTag[0].styleSheet.cssText = css;
} else {
$styleTag.text(css);
@ -1122,7 +975,7 @@ let __themeTimer = 0,
* @param {function=} themeTrigger = noop
* @returns {void}
*/
export function changeTheme(value, themeTrigger = noop) {
export function changeTheme(value, themeTrigger = ()=>{}) {
const themeLink = $('#app-theme-link'),
clearTimer = () => {
__themeTimer = window.setTimeout(() => themeTrigger(SaveSettingsStep.Idle), 1000);
@ -1292,7 +1145,7 @@ export function mimeContentType(fileName) {
}
ext = getFileExtension(fileName);
if (ext && ext.length && !isUnd(Mime[ext])) {
if (ext && ext.length && undefined !== Mime[ext]) {
result = Mime[ext];
}
@ -1384,7 +1237,7 @@ export function mailToHelper(mailToUrl, PopupComposeViewModel) {
params = simpleQueryParser(query);
if (!isUnd(params.to)) {
if (undefined !== params.to) {
to = EmailModel.parseEmailLine(decodeURIComponent(email + ',' + params.to));
to = Object.values(
to.reduce((result, value) => {
@ -1404,11 +1257,11 @@ export function mailToHelper(mailToUrl, PopupComposeViewModel) {
to = EmailModel.parseEmailLine(email);
}
if (!isUnd(params.cc)) {
if (undefined !== params.cc) {
cc = EmailModel.parseEmailLine(decodeURIComponent(params.cc));
}
if (!isUnd(params.bcc)) {
if (undefined !== params.bcc) {
bcc = EmailModel.parseEmailLine(decodeURIComponent(params.bcc));
}
@ -1418,8 +1271,8 @@ export function mailToHelper(mailToUrl, PopupComposeViewModel) {
to,
cc,
bcc,
isUnd(params.subject) ? null : pString(decodeURIComponent(params.subject)),
isUnd(params.body) ? null : plainToHtml(pString(decodeURIComponent(params.body)))
undefined === params.subject ? null : pString(decodeURIComponent(params.subject)),
undefined === params.body ? null : plainToHtml(pString(decodeURIComponent(params.body)))
]);
return true;
@ -1445,15 +1298,15 @@ export function domReady(fn) {
// }
}
export const windowResize = _.debounce((timeout) => {
if (isUnd(timeout) || null === timeout) {
var wr;
export const windowResize = timeout => {
wr && clearTimeout(wr);
if (undefined === timeout || null === timeout) {
$win.trigger('resize');
} else {
window.setTimeout(() => {
$win.trigger('resize');
}, timeout);
wr = setTimeout(()=>$win.trigger('resize'), timeout);
}
}, 50);
};
/**
* @returns {void}