Made eslint using 'browser' environment and added globals, because RainLoop is used in browsers.

This also allowed to remove all webpack 'externals' overhead.
This commit is contained in:
djmaze 2020-08-12 00:25:36 +02:00
parent c3a213802d
commit e7180a86ce
81 changed files with 1857 additions and 1259 deletions

View file

@ -1,7 +1,4 @@
import window from 'window';
import ko from 'ko';
import key from 'key';
import ssm from 'ssm';
import {
$win,
@ -35,7 +32,7 @@ class AbstractApp extends AbstractBoot {
this.isLocalAutocomplete = true;
this.lastErrorTime = 0;
window.addEventListener('resize', () => {
addEventListener('resize', () => {
Events.pub('window.resize');
});
@ -64,14 +61,14 @@ class AbstractApp extends AbstractBoot {
// DEBUG
// Events.sub({
// 'window.resize': function() {
// window.console.log('window.resize');
// console.log('window.resize');
// },
// 'window.resize.real': function() {
// window.console.log('window.resize.real');
// console.log('window.resize.real');
// }
// });
const $doc = window.document;
const $doc = document;
$doc.addEventListener('keydown', (event) => {
if (event && event.ctrlKey) {
$htmlCL.add('rl-ctrl-key-pressed');
@ -117,14 +114,14 @@ class AbstractApp extends AbstractBoot {
*/
download(link) {
if (bMobileDevice) {
window.open(link, '_self');
window.focus();
open(link, '_self');
focus();
} else {
const oLink = window.document.createElement('a');
const oLink = document.createElement('a');
oLink.href = link;
window.document.body.appendChild(oLink).click();
document.body.appendChild(oLink).click();
oLink.remove();
// window.open(link, '_self');
// open(link, '_self');
}
return true;
}
@ -138,18 +135,18 @@ class AbstractApp extends AbstractBoot {
title += (title ? ' - ' : '') + Settings.settingsGet('Title');
}
window.document.title = title;
document.title = title;
}
redirectToAdminPanel() {
setTimeout(() => {
window.location.href = rootAdmin();
location.href = rootAdmin();
}, Magics.Time100ms);
}
clearClientSideToken() {
if (window.__rlah_clear) {
window.__rlah_clear();
__rlah_clear();
}
}
@ -158,7 +155,7 @@ class AbstractApp extends AbstractBoot {
*/
setClientSideToken(token) {
if (window.__rlah_set) {
window.__rlah_set(token);
__rlah_set(token);
Settings.settingsSet('AuthAccountHash', token);
populateAuthSuffix();
@ -184,12 +181,12 @@ class AbstractApp extends AbstractBoot {
customLogoutLink = customLogoutLink || (admin ? rootAdmin() : rootUser());
if (logout && window.location.href !== customLogoutLink) {
if (logout && location.href !== customLogoutLink) {
setTimeout(() => {
if (inIframe && window.parent) {
window.parent.location.href = customLogoutLink;
if (inIframe && parent) {
parent.location.href = customLogoutLink;
} else {
window.location.href = customLogoutLink;
location.href = customLogoutLink;
}
$win.trigger('rl.tooltips.diactivate');
@ -200,10 +197,10 @@ class AbstractApp extends AbstractBoot {
routeOff();
setTimeout(() => {
if (inIframe && window.parent) {
window.parent.location.reload();
if (inIframe && parent) {
parent.location.reload();
} else {
window.location.reload();
location.reload();
}
$win.trigger('rl.tooltips.diactivate');
@ -212,12 +209,10 @@ class AbstractApp extends AbstractBoot {
}
historyBack() {
window.history.back();
history.back();
}
bootstart() {
// log('Ps' + 'ss, hac' + 'kers! The' + 're\'s not' + 'hing inte' + 'resting :' + ')');
Events.pub('rl.bootstart');
const mobile = Settings.appSettingsGet('mobile');

View file

@ -1,4 +1,3 @@
import window from 'window';
import ko from 'ko';
import { root } from 'Common/Links';
@ -110,7 +109,7 @@ class AdminApp extends AbstractApp {
CoreStore.coreVersionCompare(-2);
if (StorageResultType.Success === result && data && data.Result) {
CoreStore.coreReal(true);
window.location.reload();
location.reload();
} else {
CoreStore.coreReal(false);
}
@ -182,7 +181,7 @@ class AdminApp extends AbstractApp {
bootend(bootendCallback = null) {
if (window.progressJs) {
window.progressJs.end();
progressJs.end();
}
if (bootendCallback) {
@ -204,7 +203,7 @@ class AdminApp extends AbstractApp {
routeOff();
setTimeout(() =>
window.location.href = '/'
location.href = '/'
, 1);
} else {
if (Settings.settingsGet('Auth')) {

View file

@ -1,7 +1,4 @@
import window from 'window';
import {
log,
isNormal,
isPosNumeric,
isNonEmptyArray,
@ -86,12 +83,12 @@ import { hideLoading, routeOff, routeOn, setHash, startScreens, showScreenPopup
import { AbstractApp } from 'App/Abstract';
const doc = window.document;
const doc = document;
if (!window.ResizeObserver) {
window.ResizeObserver = class {
constructor(callback) {
this.observer = new window.MutationObserver(mutations => {
this.observer = new MutationObserver(mutations => {
let entries = [];
mutations.forEach(mutation => {
if ('style' == mutation.attributeName) {
@ -133,19 +130,19 @@ class AppUser extends AbstractApp {
this.moveOrDeleteResponseHelper = this.moveOrDeleteResponseHelper.bind(this);
window.setInterval(() => Events.pub('interval.30s'), Magics.Time30s);
window.setInterval(() => Events.pub('interval.1m'), Magics.Time1m);
window.setInterval(() => Events.pub('interval.2m'), Magics.Time2m);
window.setInterval(() => Events.pub('interval.3m'), Magics.Time3m);
window.setInterval(() => Events.pub('interval.5m'), Magics.Time5m);
window.setInterval(() => Events.pub('interval.10m'), Magics.Time10m);
window.setInterval(() => Events.pub('interval.15m'), Magics.Time15m);
window.setInterval(() => Events.pub('interval.20m'), Magics.Time20m);
setInterval(() => Events.pub('interval.30s'), Magics.Time30s);
setInterval(() => Events.pub('interval.1m'), Magics.Time1m);
setInterval(() => Events.pub('interval.2m'), Magics.Time2m);
setInterval(() => Events.pub('interval.3m'), Magics.Time3m);
setInterval(() => Events.pub('interval.5m'), Magics.Time5m);
setInterval(() => Events.pub('interval.10m'), Magics.Time10m);
setInterval(() => Events.pub('interval.15m'), Magics.Time15m);
setInterval(() => Events.pub('interval.20m'), Magics.Time20m);
window.setTimeout(() => window.setInterval(() => Events.pub('interval.2m-after5m'), Magics.Time2m), Magics.Time5m);
window.setTimeout(() => window.setInterval(() => Events.pub('interval.5m-after5m'), Magics.Time5m), Magics.Time5m);
window.setTimeout(
() => window.setInterval(() => Events.pub('interval.10m-after5m'), Magics.Time10m),
setTimeout(() => setInterval(() => Events.pub('interval.2m-after5m'), Magics.Time2m), Magics.Time5m);
setTimeout(() => setInterval(() => Events.pub('interval.5m-after5m'), Magics.Time5m), Magics.Time5m);
setTimeout(
() => setInterval(() => Events.pub('interval.10m-after5m'), Magics.Time10m),
Magics.Time5m
);
@ -187,10 +184,10 @@ class AppUser extends AbstractApp {
}
reload() {
if (window.parent && !!Settings.appSettingsGet('inIframe')) {
window.parent.location.reload();
if (parent && !!Settings.appSettingsGet('inIframe')) {
parent.location.reload();
} else {
window.location.reload();
location.reload();
}
}
@ -346,7 +343,7 @@ class AppUser extends AbstractApp {
setFolderHash(FolderStore.currentFolderFullNameRaw(), '');
if (oData && [Notification.CantMoveMessage, Notification.CantCopyMessage].includes(oData.ErrorCode)) {
window.alert(getNotification(oData.ErrorCode));
alert(getNotification(oData.ErrorCode));
}
}
@ -917,7 +914,7 @@ class AppUser extends AbstractApp {
source.classList.add('resizable');
if (!source.querySelector('.resizer')) {
const resizer = doc.createElement('div'),
cssint = s => parseFloat(window.getComputedStyle(source, null).getPropertyValue(s).replace('px', ''));
cssint = s => parseFloat(getComputedStyle(source, null).getPropertyValue(s).replace('px', ''));
resizer.className = 'resizer';
source.appendChild(resizer);
resizer.addEventListener('mousedown', {
@ -930,26 +927,26 @@ class AppUser extends AbstractApp {
this.min = cssint('min-'+this.mode);
this.max = cssint('max-'+this.mode);
this.org = cssint(this.mode);
window.addEventListener('mousemove', this);
window.addEventListener('mouseup', this);
addEventListener('mousemove', this);
addEventListener('mouseup', this);
} else if ('mousemove' == e.type) {
const length = this.org + (('width' == this.mode ? e.pageX : e.pageY) - this.pos);
if (length >= this.min && length <= this.max ) {
this.source.style[this.mode] = length + 'px';
}
} else if ('mouseup' == e.type) {
window.removeEventListener('mousemove', this);
window.removeEventListener('mouseup', this);
removeEventListener('mousemove', this);
removeEventListener('mouseup', this);
}
}
});
if ('width' == mode) {
source.observer = new window.ResizeObserver(() => {
source.observer = new ResizeObserver(() => {
target.style.left = source.offsetWidth + 'px';
Local.set(sClientSideKeyName, source.offsetWidth);
});
} else {
source.observer = new window.ResizeObserver(() => {
source.observer = new ResizeObserver(() => {
target.style.top = (4 + source.offsetTop + source.offsetHeight) + 'px';
Local.set(sClientSideKeyName, source.offsetHeight);
});
@ -1032,14 +1029,14 @@ class AppUser extends AbstractApp {
routeOff();
setTimeout(() =>
window.location.href = customLoginLink
location.href = customLoginLink
, 1);
}
}
bootend() {
if (window.progressJs) {
window.progressJs.set(100).end();
progressJs.set(100).end();
}
hideLoading();
}
@ -1058,7 +1055,7 @@ class AppUser extends AbstractApp {
const startupUrl = pString(Settings.settingsGet('StartupUrl'));
if (window.progressJs) {
window.progressJs.set(90);
progressJs.set(90);
}
leftPanelDisabled.subscribe((value) => {
@ -1091,15 +1088,18 @@ class AppUser extends AbstractApp {
routeOn();
}
if (window.crypto && window.crypto.getRandomValues && Settings.capa(Capa.OpenPGP)) {
const openpgpCallback = (openpgp) => {
if (window.crypto && crypto.getRandomValues && Settings.capa(Capa.OpenPGP)) {
const openpgpCallback = () => {
if (!window.openpgp) {
return false;
}
PgpStore.openpgp = openpgp;
if (window.Worker) {
try {
PgpStore.openpgp.initWorker({ path: openPgpWorkerJs() });
} catch (e) {
log(e);
console.log(e);
}
}
@ -1109,22 +1109,16 @@ class AppUser extends AbstractApp {
Events.pub('openpgp.init');
this.reloadOpenPgpKeys();
return true;
};
if (window.openpgp) {
openpgpCallback(window.openpgp);
} else {
new window.Promise((resolve, reject) => {
const script = doc.createElement('script');
script.onload = () => resolve();
script.onerror = () => reject(new Error(script.src));
script.src = openPgpJs();
doc.head.appendChild(script);
}).then(() => {
if (window.openpgp) {
openpgpCallback(window.openpgp);
}
});
if (!openpgpCallback()) {
const script = doc.createElement('script');
script.onload = openpgpCallback;
script.onerror = () => console.error(script.src);
script.src = openPgpJs();
doc.head.appendChild(script);
}
} else {
PgpStore.capaOpenPGP(false);
@ -1154,7 +1148,7 @@ class AppUser extends AbstractApp {
setTimeout(() => this.contactsSync(), Magics.Time10s);
setTimeout(() => this.folderInformationMultiply(true), Magics.Time2s);
window.setInterval(() => this.contactsSync(), contactsSyncInterval * 60000 + 5000);
setInterval(() => this.contactsSync(), contactsSyncInterval * 60000 + 5000);
this.accountsAndIdentities(true);
@ -1179,14 +1173,14 @@ class AppUser extends AbstractApp {
if (
!!Settings.settingsGet('AccountSignMe') &&
window.navigator.registerProtocolHandler &&
navigator.registerProtocolHandler &&
Settings.capa(Capa.Composer)
) {
setTimeout(() => {
try {
window.navigator.registerProtocolHandler(
navigator.registerProtocolHandler(
'mailto',
window.location.protocol + '//' + window.location.host + window.location.pathname + '?mailto&to=%s',
location.protocol + '//' + location.host + location.pathname + '?mailto&to=%s',
'' + (Settings.settingsGet('Title') || 'RainLoop')
);
} catch (e) {} // eslint-disable-line no-empty

View file

@ -1,4 +1,3 @@
import window from 'window';
import * as Links from 'Common/Links';
import * as Events from 'Common/Events';
@ -44,7 +43,7 @@ class Audio {
createNewObject() {
try {
const player = window.Audio ? new window.Audio() : null;
const player = window.Audio ? new Audio() : null;
if (player && player.canPlayType && player.pause && player.play) {
player.preload = 'none';
player.loop = false;

View file

@ -1,10 +1,8 @@
/* eslint-env browser */
import { getHash, setHash, clearHash } from 'Storage/RainLoop';
let RL_APP_DATA_STORAGE = null;
const doc = window.document;
const doc = document;
/* eslint-disable camelcase,spaced-comment */
window.__rlah_set = () => setHash();
@ -27,7 +25,7 @@ function showError() {
}
if (window.progressJs) {
window.progressJs.set(100).end();
progressJs.set(100).end();
}
}
@ -55,7 +53,7 @@ function loadScript(src) {
if (!src) {
throw new Error('src should not be empty.');
}
return new window.Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
const script = doc.createElement('script');
script.onload = () => resolve();
script.onerror = () => reject(new Error(src));
@ -93,11 +91,11 @@ window.__initAppData = data => {
}
if (oE && oE.style) {
oE.style.opacity = 0;
window.setTimeout(() => oE.style.opacity = 1, 300);
setTimeout(() => oE.style.opacity = 1, 300);
}
}
const appData = window.__rlah_data(), p = window.progressJs;
const appData = window.__rlah_data(), p = progressJs;
if (
p &&
@ -125,7 +123,7 @@ window.__initAppData = data => {
libs()
.then(() => {
p.set(20);
return window.Promise.all([loadScript(appData.TemplatesLink), loadScript(appData.LangLink)]);
return Promise.all([loadScript(appData.TemplatesLink), loadScript(appData.LangLink)]);
})
.then(() => {
p.set(30);
@ -133,7 +131,7 @@ window.__initAppData = data => {
})
.then(() => {
p.set(50);
return appData.PluginsLink ? loadScript(appData.PluginsLink) : window.Promise.resolve();
return appData.PluginsLink ? loadScript(appData.PluginsLink) : Promise.resolve();
})
.then(() => {
p.set(70);
@ -161,7 +159,7 @@ window.__initAppData = data => {
window.__runBoot = () => {
const app = doc.getElementById('rl-app');
if (!window.navigator || !window.navigator.cookieEnabled) {
if (!navigator || !navigator.cookieEnabled) {
doc.location.replace('./?/NoCookie');
}
@ -183,7 +181,7 @@ window.__runBoot = () => {
+ '/'
+ (getHash() || '0')
+ '/'
+ window.Math.random().toString().substr(2)
+ Math.random().toString().substr(2)
+ '/').then(() => {});
}
};

View file

@ -1,4 +1,3 @@
import window from 'window';
import Cookies from 'js-cookie';
import { CLIENT_SIDE_STORAGE_INDEX_NAME } from 'Common/Consts';
@ -48,7 +47,7 @@ class CookieDriver {
* @returns {boolean}
*/
static supported() {
return !!(window.navigator && window.navigator.cookieEnabled);
return !!(navigator && navigator.cookieEnabled);
}
}

View file

@ -1,4 +1,3 @@
import window from 'window';
import { isStorageSupported } from 'Storage/RainLoop';
import { CLIENT_SIDE_STORAGE_INDEX_NAME } from 'Common/Consts';
@ -22,13 +21,13 @@ class LocalStorageDriver {
let storageResult = null;
try {
const storageValue = this.s.getItem(CLIENT_SIDE_STORAGE_INDEX_NAME) || null;
storageResult = null === storageValue ? null : window.JSON.parse(storageValue);
storageResult = null === storageValue ? null : JSON.parse(storageValue);
} catch (e) {} // eslint-disable-line no-empty
(storageResult || (storageResult = {}))[key] = data;
try {
this.s.setItem(CLIENT_SIDE_STORAGE_INDEX_NAME, window.JSON.stringify(storageResult));
this.s.setItem(CLIENT_SIDE_STORAGE_INDEX_NAME, JSON.stringify(storageResult));
return true;
} catch (e) {} // eslint-disable-line no-empty
@ -46,7 +45,7 @@ class LocalStorageDriver {
try {
const storageValue = this.s.getItem(CLIENT_SIDE_STORAGE_INDEX_NAME) || null,
storageResult = null === storageValue ? null : window.JSON.parse(storageValue);
storageResult = null === storageValue ? null : JSON.parse(storageValue);
return storageResult && undefined !== storageResult[key] ? storageResult[key] : null;
} catch (e) {} // eslint-disable-line no-empty

View file

@ -1,16 +1,13 @@
import window from 'window';
import $ from '$';
import key from 'key';
import ko from 'ko';
import { KeyState } from 'Common/Enums';
const $win = $(window);
const $win = jQuery(window);
$win.__sizes = [0, 0];
export { $win };
export const $html = $('html');
export const $htmlCL = window.document.documentElement.classList;
export const $html = jQuery('html');
export const $htmlCL = document.documentElement.classList;
/**
* @type {boolean}
@ -31,7 +28,7 @@ export const useKeyboardShortcuts = ko.observable(true);
* @type {string}
*/
const sUserAgent =
('navigator' in window && 'userAgent' in window.navigator && window.navigator.userAgent.toLowerCase()) || '';
('navigator' in window && 'userAgent' in navigator && navigator.userAgent.toLowerCase()) || '';
/**
* @type {boolean}
@ -189,7 +186,7 @@ export const keyScope = ko.computed({
});
keyScopeReal.subscribe((value) => {
// window.console.log('keyScope=' + sValue); // DEBUG
// console.log('keyScope=' + sValue); // DEBUG
key.setScope(value);
});

View file

@ -1,5 +1,3 @@
import window from 'window';
import $ from '$';
import { htmlEditorDefaultConfig, htmlEditorLangsMap } from 'Common/Globals';
import { EventKeyCode, Magics } from 'Common/Enums';
import * as Settings from 'Storage/Settings';
@ -32,7 +30,7 @@ class HtmlEditor {
this.onModeChange = onModeChange;
this.element = element;
this.$element = $(element);
this.$element = jQuery(element);
// throttle
var t, o = this;
@ -56,8 +54,8 @@ class HtmlEditor {
blurTrigger() {
if (this.onBlur) {
window.clearTimeout(this.blurTimer);
this.blurTimer = window.setTimeout(() => {
clearTimeout(this.blurTimer);
this.blurTimer = setTimeout(() => {
this.runOnBlur();
}, Magics.Time200ms);
}
@ -65,7 +63,7 @@ class HtmlEditor {
focusTrigger() {
if (this.onBlur) {
window.clearTimeout(this.blurTimer);
clearTimeout(this.blurTimer);
}
}
@ -275,10 +273,10 @@ class HtmlEditor {
this.editor.on('drop', (event) => {
if (0 < event.data.dataTransfer.getFilesCount()) {
const file = event.data.dataTransfer.getFile(0);
if (file && window.FileReader && event.data.dataTransfer.id && file.type && file.type.match(/^image/i)) {
if (file && event.data.dataTransfer.id && file.type && file.type.match(/^image/i)) {
const id = event.data.dataTransfer.id,
imageId = `[img=${id}]`,
reader = new window.FileReader();
reader = new FileReader();
reader.onloadend = () => {
if (reader.result) {

View file

@ -1,4 +1,3 @@
import window from 'window';
// let rainloopCaches = window.caches && window.caches.open ? window.caches : null;
@ -12,9 +11,8 @@ export function jassl(src, async = false) {
throw new Error('src should not be empty.');
}
return new window.Promise((resolve, reject) => {
const doc = window.document,
element = doc.createElement('script');
return new Promise((resolve, reject) => {
const element = document.createElement('script');
element.onload = () => {
resolve(src);
@ -27,7 +25,7 @@ export function jassl(src, async = false) {
element.async = !!async;
element.src = src;
doc.body.appendChild(element);
document.body.appendChild(element);
}) /* .then((s) => {
const found = s && rainloopCaches ? s.match(/rainloop\/v\/([^\/]+)\/static\//) : null;

View file

@ -1,4 +1,3 @@
import window from 'window';
import { pString, pInt, isNormal } from 'Common/Utils';
import * as Settings from 'Storage/Settings';
@ -160,7 +159,7 @@ export function append() {
* @returns {string}
*/
export function change(email) {
return serverRequest('Change') + window.encodeURIComponent(email) + '/';
return serverRequest('Change') + encodeURIComponent(email) + '/';
}
/**
@ -204,7 +203,7 @@ export function messageDownloadLink(requestHash) {
* @returns {string}
*/
export function avatarLink(email) {
return SERVER_PREFIX + '/Raw/0/Avatar/' + window.encodeURIComponent(email) + '/';
return SERVER_PREFIX + '/Raw/0/Avatar/' + encodeURIComponent(email) + '/';
}
/**
@ -231,7 +230,7 @@ export function userBackground(hash) {
* @returns {string}
*/
export function langLink(lang, isAdmin) {
return SERVER_PREFIX + '/Lang/0/' + (isAdmin ? 'Admin' : 'App') + '/' + window.encodeURI(lang) + '/' + VERSION + '/';
return SERVER_PREFIX + '/Lang/0/' + (isAdmin ? 'Admin' : 'App') + '/' + encodeURI(lang) + '/' + VERSION + '/';
}
/**
@ -310,7 +309,7 @@ export function themePreviewLink(theme) {
prefix = WEB_PREFIX;
}
return prefix + 'themes/' + window.encodeURI(theme) + '/images/preview.png';
return prefix + 'themes/' + encodeURI(theme) + '/images/preview.png';
}
/**
@ -373,7 +372,7 @@ export function mailBox(folder, page = 1, search = '', threadUid = '') {
if (folder) {
const resultThreadUid = pInt(threadUid);
result += window.encodeURI(folder) + (0 < resultThreadUid ? '~' + resultThreadUid : '');
result += encodeURI(folder) + (0 < resultThreadUid ? '~' + resultThreadUid : '');
}
if (1 < page) {
@ -383,7 +382,7 @@ export function mailBox(folder, page = 1, search = '', threadUid = '') {
if (search) {
result = result.replace(/[/]+$/, '');
result += '/' + window.encodeURI(search);
result += '/' + encodeURI(search);
}
return result;

View file

@ -1,5 +1,3 @@
import window from 'window';
import $ from '$';
import { i18n } from 'Common/Translator';
let _moment = null;
@ -98,7 +96,7 @@ export function format(timeStampInUTC, formatStr) {
export function momentToNode(element) {
let key = '',
time = 0;
const $el = $(element);
const $el = jQuery(element);
time = $el.data('moment-time');
if (time) {
@ -119,7 +117,7 @@ export function momentToNode(element) {
*/
export function reload() {
setTimeout(() =>
$('.moment', window.document).each((index, item) => {
jQuery('.moment', document).each((index, item) => {
momentToNode(item);
})
, 1);

View file

@ -1,5 +1,3 @@
import $ from '$';
import key from 'key';
import ko from 'ko';
import { EventKeyCode } from 'Common/Enums';
@ -274,7 +272,7 @@ class Selector {
this.oContentScrollable = contentScrollable ? contentScrollable[0] : null;
if (this.oContentVisible && this.oContentScrollable) {
$(this.oContentVisible)
jQuery(this.oContentVisible)
.on('selectstart', (event) => {
if (event && event.preventDefault) {
event.preventDefault();
@ -513,7 +511,7 @@ class Selector {
const offset = 20,
list = this.list(),
$focused = $(this.sItemFocusedSelector, this.oContentScrollable),
$focused = jQuery(this.sItemFocusedSelector, this.oContentScrollable),
pos = $focused.position(),
visibleHeight = this.oContentVisible.height(),
focusedHeight = $focused.outerHeight();

View file

@ -1,5 +1,3 @@
import window from 'window';
import $ from '$';
import ko from 'ko';
import { Notification, UploadErrorCode } from 'Common/Enums';
import { pInt } from 'Common/Utils';
@ -109,7 +107,7 @@ export function i18n(key, valueList, defaulValue) {
}
const i18nToNode = (element) => {
const $el = $(element),
const $el = jQuery(element),
key = $el.data('i18n');
if (key) {
@ -138,7 +136,7 @@ const i18nToNode = (element) => {
*/
export function i18nToNodes(elements) {
setTimeout(() =>
$('[data-i18n]', elements).each((index, item) => {
jQuery('[data-i18n]', elements).each((index, item) => {
i18nToNode(item);
})
, 1);
@ -148,7 +146,7 @@ const reloadData = () => {
if (window.rainloopI18N) {
I18N_DATA = window.rainloopI18N || {};
i18nToNodes(window.document);
i18nToNodes(document);
momentorReload();
trigger(!trigger());
@ -196,12 +194,12 @@ export function initOnStartOrLangChange(startCallback, langCallback = null) {
* @returns {string}
*/
export function getNotification(code, message = '', defCode = null) {
code = window.parseInt(code, 10) || 0;
code = parseInt(code, 10) || 0;
if (Notification.ClientViewError === code && message) {
return message;
}
defCode = defCode ? window.parseInt(defCode, 10) || 0 : 0;
defCode = defCode ? parseInt(defCode, 10) || 0 : 0;
return undefined === I18N_NOTIFICATION_DATA[code]
? defCode && undefined === I18N_NOTIFICATION_DATA[defCode]
? I18N_NOTIFICATION_DATA[defCode]
@ -226,7 +224,7 @@ export function getNotificationFromResponse(response, defCode = Notification.Unk
*/
export function getUploadErrorDescByCode(code) {
let result = '';
switch (window.parseInt(code, 10) || 0) {
switch (parseInt(code, 10) || 0) {
case UploadErrorCode.FileIsTooBig:
result = i18n('UPLOAD/ERROR_FILE_IS_TOO_BIG');
break;
@ -263,7 +261,7 @@ export function reload(admin, language) {
$htmlCL.add('rl-changing-language');
return new Promise((resolve, reject) => {
return window.fetch(langLink(language, admin), {cache: 'reload'})
return fetch(langLink(language, admin), {cache: 'reload'})
.then(response => {
if (response.ok) {
const type = response.headers.get('Content-Type');
@ -276,9 +274,9 @@ export function reload(admin, language) {
reject(new Error(error.message))
})
.then(data => {
var doc = window.document, script = doc.createElement('script');
var script = document.createElement('script');
script.text = data;
doc.head.appendChild(script).parentNode.removeChild(script);
document.head.appendChild(script).parentNode.removeChild(script);
setTimeout(
() => {
reloadData();

View file

@ -1,5 +1,3 @@
import window from 'window';
import $ from '$';
import ko from 'ko';
import { $win, dropdownVisibility, data as GlobalsData } from 'Common/Globals';
@ -7,9 +5,9 @@ import { ComposeType, SaveSettingsStep, FolderType } from 'Common/Enums';
import { Mime } from 'Common/Mime';
const
$ = jQuery,
$div = $('<div></div>'),
isArray = Array.isArray,
decodeURIComponent = component => window.decodeURIComponent(component);
isArray = Array.isArray;
var htmlspecialchars = ((de,se,gt,lt,sq,dq,bt) => {
return (str, quote_style = 3, double_encode = true) => {
@ -50,8 +48,8 @@ export function isPosNumeric(value, includeZero = true) {
* @returns {number}
*/
export function pInt(value, defaultValur = 0) {
const result = isNormal(value) && value ? window.parseInt(value, 10) : defaultValur;
return window.isNaN(result) ? defaultValur : result;
const result = isNormal(value) && value ? parseInt(value, 10) : defaultValur;
return isNaN(result) ? defaultValur : result;
}
/**
@ -98,7 +96,7 @@ export function fakeMd5(len = 32) {
let result = '';
while (result.length < len) {
result += line.substr(window.Math.round(window.Math.random() * lineLen), 1);
result += line.substr(Math.round(Math.random() * lineLen), 1);
}
return result;
@ -148,8 +146,8 @@ const timeOutAction = (() => {
const timeOuts = {};
return (action, fFunction, timeOut) => {
timeOuts[action] = undefined === timeOuts[action] ? 0 : timeOuts[action];
window.clearTimeout(timeOuts[action]);
timeOuts[action] = window.setTimeout(fFunction, timeOut);
clearTimeout(timeOuts[action]);
timeOuts[action] = setTimeout(fFunction, timeOut);
};
})();
@ -168,14 +166,14 @@ export function deModule(m) {
*/
export function inFocus() {
try {
if (window.document.activeElement) {
if (undefined === window.document.activeElement.__inFocusCache) {
window.document.activeElement.__inFocusCache = $(window.document.activeElement).is(
if (document.activeElement) {
if (undefined === document.activeElement.__inFocusCache) {
document.activeElement.__inFocusCache = $(document.activeElement).is(
'input,textarea,iframe,.cke_editable'
);
}
return !!window.document.activeElement.__inFocusCache;
return !!document.activeElement.__inFocusCache;
}
} catch (e) {} // eslint-disable-line no-empty
@ -187,13 +185,11 @@ export function inFocus() {
* @returns {void}
*/
export function removeInFocus(force) {
if (window.document && window.document.activeElement && window.document.activeElement.blur) {
if (document.activeElement && document.activeElement.blur) {
try {
const activeEl = $(window.document.activeElement);
if (activeEl && activeEl.is('input,textarea')) {
window.document.activeElement.blur();
} else if (force) {
window.document.activeElement.blur();
const activeEl = $(document.activeElement);
if (force || (activeEl && activeEl.is('input,textarea'))) {
document.activeElement.blur();
}
} catch (e) {} // eslint-disable-line no-empty
}
@ -204,14 +200,7 @@ export function removeInFocus(force) {
*/
export function removeSelection() {
try {
if (window && window.getSelection) {
const sel = window.getSelection();
if (sel && sel.removeAllRanges) {
sel.removeAllRanges();
}
} else if (window.document && window.document.selection && window.document.selection.empty) {
window.document.selection.empty();
}
getSelection().removeAllRanges();
} catch (e) {} // eslint-disable-line no-empty
}
@ -264,7 +253,7 @@ export function replySubjectAdd(prefix, subject) {
* @returns {number}
*/
export function roundNumber(num, dec) {
return window.Math.round(num * window.Math.pow(10, dec)) / window.Math.pow(10, dec);
return Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
}
/**
@ -287,15 +276,6 @@ export function friendlySize(sizeInBytes) {
return sizeInBytes + 'B';
}
/**
* @param {string} desc
*/
export function log(desc) {
if (window.console && window.console.log) {
window.console.log(desc);
}
}
/**
* @param {?} object
* @param {string} methodName
@ -429,7 +409,7 @@ export function previewMessage(
isHtml,
print
) {
const win = window.open(''),
const win = open(''),
doc = win.document,
bodyClone = body.clone(),
bodyClass = isHtml ? 'html' : 'plain';
@ -456,7 +436,7 @@ export function previewMessage(
doc.close();
if (print) {
window.setTimeout(() => win.print(), 100);
setTimeout(() => win.print(), 100);
}
}
@ -830,7 +810,7 @@ export function folderListOptionsBuilder(
aResult.push({
id: oItem.fullNameRaw,
name:
new window.Array(oItem.deep + 1 - iUnDeep).join(sDeepPrefix) +
new Array(oItem.deep + 1 - iUnDeep).join(sDeepPrefix) +
(fRenameCallback ? fRenameCallback(oItem) : oItem.name()),
system: false,
seporator: false,
@ -869,20 +849,11 @@ export function folderListOptionsBuilder(
* @returns {void}
*/
export function selectElement(element) {
let sel = null,
range = null;
if (window.getSelection) {
sel = window.getSelection();
sel.removeAllRanges();
range = window.document.createRange();
range.selectNodeContents(element);
sel.addRange(range);
} else if (window.document.selection) {
range = window.document.body.createTextRange();
range.moveToElementText(element);
range.select();
}
let sel = getSelection(),
range = document.createRange();
sel.removeAllRanges();
range.selectNodeContents(element);
sel.addRange(range);
}
var dv;
@ -975,7 +946,7 @@ let __themeTimer = 0,
export function changeTheme(value, themeTrigger = ()=>{}) {
const themeLink = $('#app-theme-link'),
clearTimer = () => {
__themeTimer = window.setTimeout(() => themeTrigger(SaveSettingsStep.Idle), 1000);
__themeTimer = setTimeout(() => themeTrigger(SaveSettingsStep.Idle), 1000);
__themeAjax = null;
};
@ -995,7 +966,7 @@ export function changeTheme(value, themeTrigger = ()=>{}) {
url += 'Json/';
}
window.clearTimeout(__themeTimer);
clearTimeout(__themeTimer);
themeTrigger(SaveSettingsStep.Animate);
@ -1004,10 +975,10 @@ export function changeTheme(value, themeTrigger = ()=>{}) {
}
let init = {};
if (window.AbortController) {
__themeAjax = new window.AbortController();
__themeAjax = new AbortController();
init.signal = __themeAjax.signal;
}
window.fetch(url, init)
fetch(url, init)
.then(response => response.json())
.then(data => {
if (data && isArray(data) && 2 === data.length) {
@ -1163,11 +1134,11 @@ export function isTransparent(color) {
* @param {Function} fCallback
*/
export function resizeAndCrop(url, value, fCallback) {
const img = new window.Image();
const img = new Image();
img.onload = function() {
let diff = [0, 0];
const canvas = window.document.createElement('canvas'),
const canvas = document.createElement('canvas'),
ctx = canvas.getContext('2d');
canvas.width = value;
@ -1264,23 +1235,6 @@ export function mailToHelper(mailToUrl, PopupComposeViewModel) {
return false;
}
/**
* @param {Function} fn
* @returns {void}
*/
export function domReady(fn) {
$(() => fn());
//
// if ('loading' !== window.document.readyState)
// {
// fn();
// }
// else
// {
// window.document.addEventListener('DOMContentLoaded', fn);
// }
}
var wr;
export const windowResize = timeout => {
wr && clearTimeout(wr);
@ -1298,12 +1252,12 @@ export function windowResizeCallback() {
windowResize();
}
let substr = window.String.substr;
let substr = String.substr;
if ('b' !== 'ab'.substr(-1)) {
substr = (str, start, length) => {
start = 0 > start ? str.length + start : start;
return str.substr(start, length);
};
window.String.substr = substr;
String.substr = substr;
}

View file

@ -1,4 +1,3 @@
import $ from '$';
import ko from 'ko';
import { i18nToNodes } from 'Common/Translator';
@ -29,7 +28,7 @@ const componentExportHelper = (ClassObject, templateID = '') => ({
if (componentInfo && componentInfo.element) {
params.component = componentInfo;
params.element = $(componentInfo.element);
params.element = jQuery(componentInfo.element);
i18nToNodes(params.element);

View file

@ -1,4 +1,3 @@
import $ from '$';
import { AbstractComponent, componentExportHelper } from 'Component/Abstract';
class ScriptComponent extends AbstractComponent {
@ -21,7 +20,7 @@ class ScriptComponent extends AbstractComponent {
if (script) {
params.element.text('');
params.element.replaceWith(
$(script).text(
jQuery(script).text(
params.component.templateNodes[0] && params.component.templateNodes[0].nodeValue
? params.component.templateNodes[0].nodeValue
: ''

View file

@ -1,9 +1,7 @@
import $ from '$';
let cachedUrl = null;
const getUrl = () => {
if (!cachedUrl) {
const version = $('#rlAppVersion').attr('content') || '0.0.0';
const version = jQuery('#rlAppVersion').attr('content') || '0.0.0';
cachedUrl = `rainloop/v/${version}/static/css/svg/icons.svg`;
}
@ -15,7 +13,7 @@ export default {
viewModel: {
createViewModel: ({ icon = 'null' }, componentInfo) => {
if (componentInfo && componentInfo.element) {
$(componentInfo.element).replaceWith(
jQuery(componentInfo.element).replaceWith(
`<svg class="svg-icon svg-icon-${icon}"><use xlink:href="${getUrl()}#svg-icon-${icon}"></use></svg>`
);
}

View file

@ -1,5 +1,3 @@
import window from 'window';
const Opentip = window.Opentip || {};
Opentip.styles = Opentip.styles || {};

94
dev/External/ko.js vendored
View file

@ -1,10 +1,10 @@
import window from 'window';
import $ from '$';
import Opentip from 'Opentip';
import { SaveSettingsStep, Magics } from 'Common/Enums';
const ko = window.ko,
const
$ = jQuery,
ko = window.ko,
fDisposalTooltipHelper = (element) => {
ko.utils.domNodeDisposal.addDisposeCallback(element, () => {
if (element && element.__opentip) {
@ -14,26 +14,6 @@ const ko = window.ko,
},
isFunction = v => typeof v === 'function';
ko.bindingHandlers.updateWidth = {
init: (element, fValueAccessor) => {
const $el = $(element),
fValue = fValueAccessor(),
fInit = () => {
fValue($el.width());
setTimeout(() => {
fValue($el.width());
}, Magics.Time500ms);
};
window.addEventListener('resize', fInit);
fInit();
ko.utils.domNodeDisposal.addDisposeCallback(element, () => {
window.removeEventListener('resize', fInit);
});
}
};
ko.bindingHandlers.editor = {
init: (element, fValueAccessor) => {
let editor = null;
@ -70,10 +50,10 @@ ko.bindingHandlers.editor = {
ko.bindingHandlers.json = {
init: (element, fValueAccessor) => {
$(element).text(window.JSON.stringify(ko.unwrap(fValueAccessor())));
$(element).text(JSON.stringify(ko.unwrap(fValueAccessor())));
},
update: (element, fValueAccessor) => {
$(element).text(window.JSON.stringify(ko.unwrap(fValueAccessor())));
$(element).text(JSON.stringify(ko.unwrap(fValueAccessor())));
}
};
@ -97,11 +77,11 @@ ko.bindingHandlers.scrollerShadows = {
if (cont) {
$(cont).on('scroll resize', fFunc);
window.addEventListener('resize', fFunc);
addEventListener('resize', fFunc);
ko.utils.domNodeDisposal.addDisposeCallback(cont, () => {
$(cont).off();
window.removeEventListener('resize', fFunc);
removeEventListener('resize', fFunc);
});
}
}
@ -179,12 +159,12 @@ ko.bindingHandlers.tooltip = {
element.__opentip.setContent(sValue);
}
window.addEventListener('rl.tooltips.diactivate', () => {
addEventListener('rl.tooltips.diactivate', () => {
element.__opentip.hide();
element.__opentip.deactivate();
});
window.addEventListener('rl.tooltips.activate', () => {
addEventListener('rl.tooltips.activate', () => {
element.__opentip.activate();
});
}
@ -223,7 +203,7 @@ ko.bindingHandlers.tooltipErrorTip = {
element.__opentip.deactivate();
$(window.document).on('click', () => {
$(document).on('click', () => {
if (element && element.__opentip) {
element.__opentip.hide();
}
@ -303,7 +283,7 @@ ko.bindingHandlers.dropdownCloser = {
ko.bindingHandlers.popover = {
init: function(element, fValueAccessor) {
window.console.log('TODO: $(element).popover removed', element, fValueAccessor);
console.log('TODO: $(element).popover removed', element, fValueAccessor);
/*
$(element).popover(ko.unwrap(fValueAccessor()));
ko.utils.domNodeDisposal.addDisposeCallback(element, () => {
@ -313,36 +293,6 @@ ko.bindingHandlers.popover = {
}
};
ko.bindingHandlers.csstext = {};
ko.bindingHandlers.csstext.init = ko.bindingHandlers.csstext.update = (element, fValueAccessor) => {
if (element && element.styleSheet && 'undefined' !== typeof element.styleSheet.cssText) {
element.styleSheet.cssText = ko.unwrap(fValueAccessor());
} else {
$(element).text(ko.unwrap(fValueAccessor()));
}
};
ko.bindingHandlers.resizecrop = {
init: (element) => {
$(element)
.addClass('resizecrop')
.resizecrop({
'width': '100',
'height': '100',
'wrapperCSS': {
'border-radius': '10px'
}
});
},
update: (element, fValueAccessor) => {
fValueAccessor()();
$(element).resizecrop({
'width': '100',
'height': '100'
});
}
};
ko.bindingHandlers.onKeyDown = {
init: (element, fValueAccessor, fAllBindingsAccessor, viewModel) => {
$(element).on('keydown.koOnKeyDown', (event) => {
@ -362,7 +312,7 @@ ko.bindingHandlers.onKeyDown = {
ko.bindingHandlers.onEnter = {
init: (element, fValueAccessor, fAllBindingsAccessor, viewModel) => {
$(element).on('keypress.koOnEnter', (event) => {
if (event && 13 === window.parseInt(event.keyCode, 10)) {
if (event && 13 === parseInt(event.keyCode, 10)) {
$(element).trigger('change');
fValueAccessor().call(viewModel);
}
@ -377,7 +327,7 @@ ko.bindingHandlers.onEnter = {
ko.bindingHandlers.onSpace = {
init: (element, fValueAccessor, fAllBindingsAccessor, viewModel) => {
$(element).on('keyup.koOnSpace', (event) => {
if (event && 32 === window.parseInt(event.keyCode, 10)) {
if (event && 32 === parseInt(event.keyCode, 10)) {
fValueAccessor().call(viewModel, event);
}
});
@ -391,7 +341,7 @@ ko.bindingHandlers.onSpace = {
ko.bindingHandlers.onTab = {
init: (element, fValueAccessor, fAllBindingsAccessor, viewModel) => {
$(element).on('keydown.koOnTab', (event) => {
if (event && 9 === window.parseInt(event.keyCode, 10)) {
if (event && 9 === parseInt(event.keyCode, 10)) {
return fValueAccessor().call(viewModel, !!event.shiftKey);
}
return true;
@ -406,7 +356,7 @@ ko.bindingHandlers.onTab = {
ko.bindingHandlers.onEsc = {
init: (element, fValueAccessor, fAllBindingsAccessor, viewModel) => {
$(element).on('keyup.koOnEsc', (event) => {
if (event && 27 === window.parseInt(event.keyCode, 10)) {
if (event && 27 === parseInt(event.keyCode, 10)) {
$(element).trigger('change');
fValueAccessor().call(viewModel);
}
@ -529,7 +479,7 @@ ko.bindingHandlers.initFixedTrigger = {
let $container = $(values[0] || null);
$container = $container[0] ? $container : null;
if ($container) {
window.addEventListener('resize', () => {
addEventListener('resize', () => {
const offset = $container ? $container.offset() : null;
if (offset && offset.top) {
$el.css('top', offset.top + top);
@ -610,7 +560,7 @@ ko.bindingHandlers.draggable = {
offset = $this.offset(),
bottomPos = offset.top + $this.height();
window.clearInterval($this.data('timerScroll'));
clearInterval($this.data('timerScroll'));
$this.data('timerScroll', false);
if (event.pageX >= offset.left && event.pageX <= offset.left + $this.width()) {
@ -620,7 +570,7 @@ ko.bindingHandlers.draggable = {
Utils.windowResize();
};
$this.data('timerScroll', window.setInterval(moveUp, 10));
$this.data('timerScroll', setInterval(moveUp, 10));
moveUp();
}
@ -630,7 +580,7 @@ ko.bindingHandlers.draggable = {
Utils.windowResize();
};
$this.data('timerScroll', window.setInterval(moveDown, 10));
$this.data('timerScroll', setInterval(moveDown, 10));
moveDown();
}
}
@ -640,7 +590,7 @@ ko.bindingHandlers.draggable = {
conf.stop = () => {
$(droppableSelector).each(function() {
const $this = $(this); // eslint-disable-line no-invalid-this
window.clearInterval($this.data('timerScroll'));
clearInterval($this.data('timerScroll'));
$this.data('timerScroll', false);
});
};
@ -1022,7 +972,7 @@ ko.extenders.falseTimeout = (target, option) => {
target.iFalseTimeoutTimeout = 0;
target.subscribe((value) => {
if (value) {
window.clearTimeout(target.iFalseTimeoutTimeout);
clearTimeout(target.iFalseTimeoutTimeout);
target.iFalseTimeoutTimeout = setTimeout(() => {
target(false);
target.iFalseTimeoutTimeout = 0;
@ -1046,7 +996,7 @@ ko.extenders.specialThrottle = (target, option) => {
target.valueForRead(bValue);
} else {
if (target.valueForRead()) {
window.clearTimeout(target.iSpecialThrottleTimeout);
clearTimeout(target.iSpecialThrottleTimeout);
target.iSpecialThrottleTimeout = setTimeout(() => {
target.valueForRead(false);
target.iSpecialThrottleTimeout = 0;

View file

@ -1,6 +1,3 @@
import crossroads from 'crossroads';
import { isNonEmptyArray } from 'Common/Utils';
export class AbstractScreen {
oCross = null;
sScreenName;
@ -47,9 +44,9 @@ export class AbstractScreen {
fMatcher = null;
const routes = this.routes();
if (isNonEmptyArray(routes)) {
if (Array.isArray(routes) && routes.length) {
fMatcher = (this.onRoute || (()=>{})).bind(this);
route = crossroads.create();
route = new Crossroads();
routes.forEach((item) => {
if (item && route) {

View file

@ -1,5 +1,4 @@
import ko from 'ko';
import window from 'window';
import { delegateRun, inFocus } from 'Common/Utils';
import { KeyState, EventKeyCode } from 'Common/Enums';
@ -36,7 +35,7 @@ export class AbstractViewNext {
* @returns {void}
*/
registerPopupKeyDown() {
window.addEventListener('keydown', (event) => {
addEventListener('keydown', (event) => {
if (event && this.modalVisibility && this.modalVisibility()) {
if (!this.bDisabeCloseOnEsc && EventKeyCode.Esc === event.keyCode) {
delegateRun(this, 'cancelCommand');

View file

@ -1,18 +1,15 @@
import $ from '$';
import ko from 'ko';
import hasher from 'hasher';
import crossroads from 'crossroads';
import { Magics } from 'Common/Enums';
import { runHook } from 'Common/Plugins';
import { $htmlCL, VIEW_MODELS, popupVisibilityNames } from 'Common/Globals';
import { pString, log, createCommandLegacy, delegateRun, isNonEmptyArray } from 'Common/Utils';
import { pString, createCommandLegacy, delegateRun, isNonEmptyArray } from 'Common/Utils';
let currentScreen = null,
defaultScreenName = '';
const SCREENS = {};
const SCREENS = {}, $ = jQuery;
export const ViewType = {
Popup: 'Popups',
@ -224,7 +221,7 @@ export function buildViewModel(ViewModelClass, vmScreen) {
vmRunHook('view-model-post-build', ViewModelClass, vmDom);
} else {
log('Cannot find view model position: ' + position);
console.log('Cannot find view model position: ' + position);
}
}
@ -424,7 +421,7 @@ export function startScreens(screensClasses) {
}
});
const cross = crossroads.create();
const cross = new Crossroads();
cross.addRoute(/^([a-zA-Z0-9-]*)\/?(.*)$/, screenOnRoute);
hasher.initialized.add(cross.parse, cross);

View file

@ -1,4 +1,3 @@
import window from 'window';
import ko from 'ko';
import { FileType } from 'Common/Enums';
@ -16,7 +15,7 @@ import { AbstractModel } from 'Knoin/AbstractModel';
import Audio from 'Common/Audio';
const bAllowPdfPreview = !bMobileDevice && undefined !== window.navigator.mimeTypes['application/pdf'];
const bAllowPdfPreview = !bMobileDevice && undefined !== navigator.mimeTypes['application/pdf'];
/**
* @param {string} sExt
@ -405,7 +404,7 @@ class AttachmentModel extends AbstractModel {
generateTransferDownloadUrl() {
let link = this.linkDownload();
if ('http' !== link.substr(0, 4)) {
link = window.location.protocol + '//' + window.location.host + window.location.pathname + link;
link = location.protocol + '//' + location.host + location.pathname + link;
}
return this.mimeType + ':' + this.fileName + ':' + link;

View file

@ -1,4 +1,3 @@
import $ from '$';
import ko from 'ko';
import classnames from 'classnames';
@ -23,6 +22,8 @@ import { emailArrayFromJson, emailArrayToStringClear, emailArrayToString, replyH
import { AttachmentModel, staticCombinedIconClass } from 'Model/Attachment';
import { AbstractModel } from 'Knoin/AbstractModel';
const $ = jQuery;
class MessageModel extends AbstractModel {
constructor() {
super('MessageModel');

View file

@ -1,6 +1,6 @@
import ko from 'ko';
import { isNonEmptyArray, log } from 'Common/Utils';
import { isNonEmptyArray } from 'Common/Utils';
import { AbstractModel } from 'Knoin/AbstractModel';
@ -45,7 +45,7 @@ class OpenPgpKeyModel extends AbstractModel {
return key;
}
} catch (e) {
log(e);
console.log(e);
}
return null;

View file

@ -1,5 +1,3 @@
import window from 'window';
import { ajax } from 'Common/Links';
import { isNormal, pString } from 'Common/Utils';
import { DEFAULT_AJAX_TIMEOUT, TOKEN_ERROR_LIMIT, AJAX_ERROR_LIMIT } from 'Common/Consts';
@ -56,7 +54,7 @@ class AbstractAjaxPromises extends AbstractBasicPromises {
};
params.XToken = Settings.appSettingsGet('token');
// init.body = JSON.stringify(params);
const formData = new window.FormData();
const formData = new FormData();
Object.keys(params).forEach(key => {
formData.append(key, params[key])
});
@ -69,13 +67,13 @@ class AbstractAjaxPromises extends AbstractBasicPromises {
if (window.AbortController) {
this.abort(action);
const controller = new window.AbortController();
const controller = new AbortController();
setTimeout(() => controller.abort(), isNormal(timeOut) ? timeOut : DEFAULT_AJAX_TIMEOUT);
init.signal = controller.signal;
this.oRequests[action] = controller;
}
return window.fetch(ajax(additionalGetString), init)
return fetch(ajax(additionalGetString), init)
.then(response => response.json())
.then(data => {
this.abort(action, true);

View file

@ -1,5 +1,3 @@
import window from 'window';
export class AbstractBasicPromises {
oPromisesStack = {};
@ -9,11 +7,11 @@ export class AbstractBasicPromises {
}
fastResolve(mData) {
return window.Promise.resolve(mData);
return Promise.resolve(mData);
}
fastReject(mData) {
return window.Promise.reject(mData);
return Promise.reject(mData);
}
setTrigger(trigger, value) {

View file

@ -1,5 +1,3 @@
import window from 'window';
import PromisesPopulator from 'Promises/User/Populator';
import { AbstractAjaxPromises } from 'Promises/AbstractAjax';
@ -23,8 +21,8 @@ class UserAjaxUserPromises extends AbstractAjaxPromises {
foldersReloadWithTimeout(fTrigger) {
this.setTrigger(fTrigger, true);
window.clearTimeout(this.foldersTimeout);
this.foldersTimeout = window.setTimeout(() => {
clearTimeout(this.foldersTimeout);
this.foldersTimeout = setTimeout(() => {
this.foldersReload(fTrigger);
}, 500);
}

View file

@ -1,5 +1,3 @@
import window from 'window';
import { TOKEN_ERROR_LIMIT, AJAX_ERROR_LIMIT, DEFAULT_AJAX_TIMEOUT } from 'Common/Consts';
import { StorageResultType, Notification } from 'Common/Enums';
import { pInt, pString } from 'Common/Utils';
@ -154,7 +152,7 @@ class AbstractAjaxRemote {
};
params.XToken = Settings.appSettingsGet('token');
// init.body = JSON.stringify(params);
const formData = new window.FormData();
const formData = new FormData();
Object.keys(params).forEach(key => {
formData.append(key, params[key])
});
@ -163,7 +161,7 @@ class AbstractAjaxRemote {
if (window.AbortController) {
this.abort(action);
const controller = new window.AbortController();
const controller = new AbortController();
if (iTimeOut) {
setTimeout(() => controller.abort(), iTimeOut);
}
@ -171,12 +169,12 @@ class AbstractAjaxRemote {
this.oRequests[action] = controller;
}
window.fetch(ajax(sGetAdd), init)
fetch(ajax(sGetAdd), init)
.then(response => response.json())
.then(oData => {
let cached = false;
if (oData && oData.Time) {
cached = pInt(oData.Time) > new window.Date().getTime() - start;
cached = pInt(oData.Time) > new Date().getTime() - start;
}
if (oData && oData.UpdateToken) {

View file

@ -1,8 +1,7 @@
import $ from '$';
import ko from 'ko';
import { VIEW_MODELS } from 'Common/Globals';
import { delegateRun, windowResize, log, pString } from 'Common/Utils';
import { delegateRun, windowResize, pString } from 'Common/Utils';
import { settings } from 'Common/Links';
import { setHash } from 'Knoin/Knoin';
@ -72,7 +71,7 @@ class AbstractSettingsScreen extends AbstractScreen {
if (viewModelPlace && 1 === viewModelPlace.length) {
settingsScreen = new RoutedSettingsViewModel();
viewModelDom = $('<div></div>')
viewModelDom = jQuery('<div></div>')
.addClass('rl-settings-view-model')
.hide();
viewModelDom.appendTo(viewModelPlace);
@ -97,7 +96,7 @@ class AbstractSettingsScreen extends AbstractScreen {
delegateRun(settingsScreen, 'onBuild', [viewModelDom]);
} else {
log('Cannot find sub settings view model position: SettingsSubScreen');
console.log('Cannot find sub settings view model position: SettingsSubScreen');
}
}
@ -128,7 +127,7 @@ class AbstractSettingsScreen extends AbstractScreen {
);
});
$('#rl-content .b-settings .b-content')[0].scrollTop = 0;
jQuery('#rl-content .b-settings .b-content')[0].scrollTop = 0;
}
// --
@ -167,7 +166,7 @@ class AbstractSettingsScreen extends AbstractScreen {
}
});
this.oViewModelPlace = $('#rl-content #rl-settings-subscreen');
this.oViewModelPlace = jQuery('#rl-content #rl-settings-subscreen');
}
routes() {

View file

@ -1,5 +1,3 @@
import window from 'window';
import { Focused, Capa, ClientSideKeyName, Magics } from 'Common/Enums';
import { $html, leftPanelDisabled, leftPanelType, moveAction, bMobileDevice } from 'Common/Globals';
import { pString, pInt, windowResizeCallback } from 'Common/Utils';
@ -157,7 +155,7 @@ class MailBoxUserScreen extends AbstractScreen {
vals[1] = 1;
}
return [window.decodeURI(vals[0]), vals[1], window.decodeURI(vals[2])];
return [decodeURI(vals[0]), vals[1], decodeURI(vals[2])];
},
fNormD = (request, vals) => {
vals[0] = pString(vals[0]);
@ -167,7 +165,7 @@ class MailBoxUserScreen extends AbstractScreen {
vals[0] = inboxFolderName;
}
return [window.decodeURI(vals[0]), 1, window.decodeURI(vals[1])];
return [decodeURI(vals[0]), 1, decodeURI(vals[1])];
};
return [

View file

@ -1,4 +1,3 @@
import window from 'window';
import ko from 'ko';
import { StorageResultType, Notification } from 'Common/Enums';
@ -58,7 +57,7 @@ class PackagesAdminSettings {
});
if (StorageResultType.Success === result && data && data.Result && data.Result.Reload) {
window.location.reload();
location.reload();
} else {
getApp().reloadPackagesList();
}

View file

@ -1,4 +1,3 @@
import window from 'window';
import ko from 'ko';
import { Capa, StorageResultType } from 'Common/Enums';
@ -68,7 +67,7 @@ class AccountsUserSettings {
setHash(root(), true);
routeOff();
setTimeout(() => window.location.reload(), 1);
setTimeout(() => location.reload(), 1);
} else {
getApp().accountsAndIdentities();
}

View file

@ -1,8 +1,5 @@
import window from 'window';
import ko from 'ko';
import Jua from 'Jua';
import { SaveSettingsStep, UploadErrorCode, Capa, Magics } from 'Common/Enums';
import { changeTheme, convertThemeName } from 'Common/Utils';
import { userBackground, themePreviewLink, uploadBackground } from 'Common/Links';
@ -47,7 +44,7 @@ class ThemesUserSettings {
});
this.background.hash.subscribe((value) => {
const b = window.document.body, cl = window.document.documentElement.classList;
const b = document.body, cl = document.documentElement.classList;
if (!value) {
cl.remove('UserBackground');
b.removeAttribute('style');

View file

@ -1,5 +1,3 @@
/* eslint-env browser */
const STORAGE_KEY = '__rlA';
const TIME_KEY = '__rlT';
@ -16,7 +14,7 @@ export function isStorageSupported(storageName) {
if (storageIsAvailable) {
const s = window[storageName],
key = 'testLocalStorage_' + window.Math.random();
key = 'testLocalStorage_' + Math.random();
try {
s.setItem(key, key);
@ -40,7 +38,7 @@ const __get = (key) => {
} else if (WIN_STORAGE) {
const data =
WIN_STORAGE.name && '{' === WIN_STORAGE.name.toString()[0]
? window.JSON.parse(WIN_STORAGE.name.toString())
? JSON.parse(WIN_STORAGE.name.toString())
: null;
result = data ? data[key] || null : null;
}

View file

@ -1,4 +1,3 @@
import window from 'window';
import { isNormal } from 'Common/Utils';
let SETTINGS = window.__rlah_data() || null;

View file

@ -25,7 +25,7 @@ class AppAdminStore extends AbstractAppStore {
this.useLocalProxyForExternalImages(!!settingsGet('UseLocalProxyForExternalImages'));
/*
if (settingsGet('Auth')) {
window.fetch('./data/VERSION?' + window.Math.random()).then(() => this.dataFolderAccess(true));
fetch('./data/VERSION?' + Math.random()).then(() => this.dataFolderAccess(true));
}
*/
}

View file

@ -1,6 +1,4 @@
import window from 'window';
import ko from 'ko';
import $ from '$';
import { Magics, Layout, Focused, MessageSetAction, StorageResultType, Notification } from 'Common/Enums';
@ -50,6 +48,7 @@ import { getApp } from 'Helper/Apps/User';
import Remote from 'Remote/User/Ajax';
const
$ = jQuery,
$div = $('<div></div>'),
$hcont = $('<div></div>'),
getRealHeight = $el => {
@ -142,7 +141,7 @@ class MessageUserStore {
);
this.messageListPageCount = ko.computed(() => {
const page = window.Math.ceil(this.messageListCount() / SettingsStore.messagesPerPage());
const page = Math.ceil(this.messageListCount() / SettingsStore.messagesPerPage());
return 0 >= page ? 1 : page;
});
@ -798,7 +797,7 @@ class MessageUserStore {
this.messageListCount(iCount);
this.messageListSearch(isNormal(data.Result.Search) ? data.Result.Search : '');
this.messageListPage(window.Math.ceil(iOffset / SettingsStore.messagesPerPage() + 1));
this.messageListPage(Math.ceil(iOffset / SettingsStore.messagesPerPage() + 1));
this.messageListThreadUid(isNormal(data.Result.ThreadUid) ? pString(data.Result.ThreadUid) : '');
this.messageListEndFolder(isNormal(data.Result.Folder) ? data.Result.Folder : '');

View file

@ -1,4 +1,3 @@
import window from 'window';
import ko from 'ko';
import { DesktopNotification, Magics } from 'Common/Enums';
@ -136,7 +135,7 @@ class NotificationUserStore {
if (nessageData) {
notification.onclick = () => {
window.focus();
focus();
if (nessageData.Folder && nessageData.Uid) {
Events.pub('mailbox.message.show', [nessageData.Folder, nessageData.Uid]);
@ -144,7 +143,7 @@ class NotificationUserStore {
};
}
window.setTimeout(
setTimeout(
(function(localNotifications) {
return () => {
if (localNotifications.cancel) {
@ -169,7 +168,7 @@ class NotificationUserStore {
* @returns {*|null}
*/
notificationClass() {
return window.Notification && window.Notification.requestPermission ? window.Notification : null;
return window.Notification && Notification.requestPermission ? Notification : null;
}
}

View file

@ -1,8 +1,7 @@
import ko from 'ko';
import $ from '$';
import { i18n } from 'Common/Translator';
import { log, isNonEmptyArray, pString } from 'Common/Utils';
import { isNonEmptyArray, pString } from 'Common/Utils';
import AccountStore from 'Stores/User/Account';
@ -197,7 +196,7 @@ class PgpUserStore {
return true;
}
} catch (e) {
log(e);
console.log(e);
}
}
@ -239,7 +238,7 @@ class PgpUserStore {
static domControlEncryptedClickHelper(store, dom, armoredMessage, recipients) {
return function() {
let message = null;
const $this = $(this); // eslint-disable-line no-invalid-this
const $this = jQuery(this); // eslint-disable-line no-invalid-this
if ($this.hasClass('success')) {
return false;
@ -248,7 +247,7 @@ class PgpUserStore {
try {
message = store.openpgp.message.readArmored(armoredMessage);
} catch (e) {
log(e);
console.log(e);
}
if (message && message.getText && message.verify && message.decrypt) {
@ -300,7 +299,7 @@ class PgpUserStore {
static domControlSignedClickHelper(store, dom, armoredMessage) {
return function() {
let message = null;
const $this = $(this); // eslint-disable-line no-invalid-this
const $this = jQuery(this); // eslint-disable-line no-invalid-this
if ($this.hasClass('success') || $this.hasClass('error')) {
return false;
@ -309,7 +308,7 @@ class PgpUserStore {
try {
message = store.openpgp.cleartext.readArmored(armoredMessage);
} catch (e) {
log(e);
console.log(e);
}
if (message && message.getText && message.verify) {
@ -366,11 +365,11 @@ class PgpUserStore {
dom.data('openpgp-original', domText);
if (encrypted) {
verControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
verControl = jQuery('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
.attr('title', i18n('MESSAGE/PGP_ENCRYPTED_MESSAGE_DESC'))
.on('click', PgpUserStore.domControlEncryptedClickHelper(this, dom, domText, recipients));
} else if (signed) {
verControl = $('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
verControl = jQuery('<div class="b-openpgp-control"><i class="icon-lock"></i></div>')
.attr('title', i18n('MESSAGE/PGP_SIGNED_MESSAGE_DESC'))
.on('click', PgpUserStore.domControlSignedClickHelper(this, dom, domText));
}

View file

@ -1,4 +1,3 @@
import window from 'window';
import ko from 'ko';
import { Magics } from 'Common/Enums';
@ -12,7 +11,7 @@ class QuotaUserStore {
const quota = this.quota(),
usage = this.usage();
return 0 < quota ? window.Math.ceil((usage / quota) * 100) : 0;
return 0 < quota ? Math.ceil((usage / quota) * 100) : 0;
});
}

View file

@ -1,4 +1,3 @@
import window from 'window';
import ko from 'ko';
import { MESSAGES_PER_PAGE, MESSAGES_PER_PAGE_VALUES } from 'Common/Consts';
@ -67,9 +66,9 @@ class SettingsUserStore {
this.replySameFolder(!!Settings.settingsGet('ReplySameFolder'));
Events.sub('rl.auto-logout-refresh', () => {
window.clearTimeout(this.iAutoLogoutTimer);
clearTimeout(this.iAutoLogoutTimer);
if (0 < this.autoLogout() && !Settings.settingsGet('AccountSignMe')) {
this.iAutoLogoutTimer = window.setTimeout(() => {
this.iAutoLogoutTimer = setTimeout(() => {
Events.pub('rl.auto-logout');
}, this.autoLogout() * Magics.Time1m);
}

View file

@ -1,6 +1,3 @@
import $ from '$';
import key from 'key';
import { leftPanelDisabled } from 'Common/Globals';
import { KeyState } from 'Common/Enums';
@ -29,7 +26,7 @@ class MenuSettingsAdminView extends AbstractViewNext {
}
onBuild(dom) {
key('up, down', KeyState.Settings, settingsMenuKeysHandler($('.b-admin-menu .e-item', dom)));
key('up, down', KeyState.Settings, settingsMenuKeysHandler(jQuery('.b-admin-menu .e-item', dom)));
}
}

View file

@ -1,5 +1,5 @@
import ko from 'ko';
import { delegateRun, log } from 'Common/Utils';
import { delegateRun } from 'Common/Utils';
import PgpStore from 'Stores/User/Pgp';
@ -64,7 +64,7 @@ class AddOpenPgpKeyPopupView extends AbstractViewNext {
if (err) {
this.key.error(true);
this.key.errorMessage(err && err[0] ? '' + err[0] : '');
log(err);
console.log(err);
}
}

View file

@ -1,5 +1,4 @@
import ko from 'ko';
import key from 'key';
import { KeyState } from 'Common/Enums';
import { i18n } from 'Common/Translator';

View file

@ -1,7 +1,4 @@
import $ from '$';
import ko from 'ko';
import key from 'key';
import Jua from 'Jua';
import {
Capa,
@ -943,7 +940,7 @@ class ComposePopupView extends AbstractViewNext {
sSubject = message.subject();
aDraftInfo = message.aDraftInfo;
const clonedText = $(message.body).clone();
const clonedText = jQuery(message.body).clone();
if (clonedText) {
clearBqSwitcher(clonedText);

View file

@ -1,8 +1,6 @@
import $ from '$';
import ko from 'ko';
import key from 'key';
import { pString, log, defautOptionsAfterRender } from 'Common/Utils';
import { pString, defautOptionsAfterRender } from 'Common/Utils';
import { Magics, KeyState } from 'Common/Enums';
import { i18n } from 'Common/Translator';
@ -103,7 +101,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
this.defautOptionsAfterRender(domOption, item);
if (item && undefined !== item.class && domOption) {
$(domOption).addClass(item.class);
jQuery(domOption).addClass(item.class);
}
};
@ -203,7 +201,7 @@ class ComposeOpenPgpPopupView extends AbstractViewNext {
});
}
} catch (e) {
log(e);
console.log(e);
this.notification(
i18n('PGP_NOTIFICATIONS/PGP_ERROR', {

View file

@ -1,8 +1,4 @@
import window from 'window';
import $ from '$';
import ko from 'ko';
import key from 'key';
import Jua from 'Jua';
import {
SaveSettingsStep,
@ -80,7 +76,7 @@ class ContactsPopupView extends AbstractViewNext {
this.contactsPage = ko.observable(1);
this.contactsPageCount = ko.computed(() => {
const iPage = window.Math.ceil(this.contactsCount() / CONTACTS_PER_PAGE);
const iPage = Math.ceil(this.contactsCount() / CONTACTS_PER_PAGE);
return 0 >= iPage ? 1 : iPage;
});
@ -349,7 +345,7 @@ class ContactsPopupView extends AbstractViewNext {
syncCommand() {
getApp().contactsSync((result, data) => {
if (StorageResultType.Success !== result || !data || !data.Result) {
window.alert(getNotification(data && data.ErrorCode ? data.ErrorCode : Notification.ContactsSyncError));
alert(getNotification(data && data.ErrorCode ? data.ErrorCode : Notification.ContactsSyncError));
}
this.reloadContactList(true);
@ -441,7 +437,7 @@ class ContactsPopupView extends AbstractViewNext {
this.contacts.importing(false);
this.reloadContactList();
if (!id || !result || !data || !data.Result) {
window.alert(i18n('CONTACTS/ERROR_IMPORT_FILE'));
alert(i18n('CONTACTS/ERROR_IMPORT_FILE'));
}
});
}
@ -618,7 +614,7 @@ class ContactsPopupView extends AbstractViewNext {
}
onBuild(dom) {
this.oContentVisible = $('.b-list-content', dom);
this.oContentVisible = jQuery('.b-list-content', dom);
this.selector.init(this.oContentVisible, this.oContentVisible, KeyState.ContactList);

View file

@ -1,5 +1,3 @@
import key from 'key';
import { KeyState, Magics } from 'Common/Enums';
import { popup } from 'Knoin/Knoin';

View file

@ -1,8 +1,6 @@
import ko from 'ko';
import key from 'key';
import $ from '$';
import { pString, log } from 'Common/Utils';
import { pString } from 'Common/Utils';
import { KeyState, Magics } from 'Common/Enums';
import { popup, command } from 'Knoin/Knoin';
@ -47,19 +45,19 @@ class MessageOpenPgpPopupView extends AbstractViewNext {
if (privateKey) {
try {
if (!privateKey.decrypt(pString(this.password()))) {
log('Error: Private key cannot be decrypted');
console.log('Error: Private key cannot be decrypted');
privateKey = null;
}
} catch (e) {
log(e);
console.log(e);
privateKey = null;
}
} else {
log('Error: Private key cannot be found');
console.log('Error: Private key cannot be found');
}
}
} catch (e) {
log(e);
console.log(e);
privateKey = null;
}
@ -109,7 +107,7 @@ class MessageOpenPgpPopupView extends AbstractViewNext {
.addClass('icon-radio-unchecked')
.removeClass('icon-radio-checked');
$(this)
jQuery(this)
.find('.key-list__item__radio') // eslint-disable-line no-invalid-this
.removeClass('icon-radio-unchecked')
.addClass('icon-radio-checked');

View file

@ -1,7 +1,7 @@
import ko from 'ko';
import { Magics } from 'Common/Enums';
import { log, delegateRun, pInt } from 'Common/Utils';
import { delegateRun, pInt } from 'Common/Utils';
import PgpStore from 'Stores/User/Pgp';
@ -87,7 +87,7 @@ class NewOpenPgpKeyPopupView extends AbstractViewNext {
}
showError(e) {
log(e);
console.log(e);
if (e && e.message) {
this.submitError(e.message);
}

View file

@ -1,5 +1,4 @@
import ko from 'ko';
import key from 'key';
import { KeyState, Magics, StorageResultType, Notification } from 'Common/Enums';
import { isNonEmptyArray, delegateRun } from 'Common/Utils';

View file

@ -1,4 +1,3 @@
import window from 'window';
import ko from 'ko';
import { Capa, StorageResultType } from 'Common/Enums';
@ -137,18 +136,18 @@ class TwoFactorConfigurationPopupView extends AbstractViewNext {
onHide() {
if (this.lock()) {
window.location.reload();
location.reload();
}
}
getQr() {
return (
'otpauth://totp/' +
window.encodeURIComponent(this.viewUser()) +
encodeURIComponent(this.viewUser()) +
'?secret=' +
window.encodeURIComponent(this.viewSecret()) +
encodeURIComponent(this.viewSecret()) +
'&issuer=' +
window.encodeURIComponent('')
encodeURIComponent('')
);
}
@ -166,7 +165,7 @@ class TwoFactorConfigurationPopupView extends AbstractViewNext {
this.viewBackupCodes(pString(oData.Result.BackupCodes).replace(/[\s]+/g, ' '));
this.viewUrlTitle(pString(oData.Result.UrlTitle));
this.viewUrl(window.qr.toDataURL({ level: 'M', size: 8, value: this.getQr() }));
this.viewUrl(qr.toDataURL({ level: 'M', size: 8, value: this.getQr() }));
} else {
this.viewUser('');
this.viewEnable_(false);
@ -186,7 +185,7 @@ class TwoFactorConfigurationPopupView extends AbstractViewNext {
if (StorageResultType.Success === result && data && data.Result) {
this.viewSecret(pString(data.Result.Secret));
this.viewUrlTitle(pString(data.Result.UrlTitle));
this.viewUrl(window.qr.toDataURL({ level: 'M', size: 6, value: this.getQr() }));
this.viewUrl(qr.toDataURL({ level: 'M', size: 6, value: this.getQr() }));
} else {
this.viewSecret('');
this.viewUrlTitle('');

View file

@ -1,5 +1,4 @@
import ko from 'ko';
import key from 'key';
import { KeyState } from 'Common/Enums';
import { selectElement } from 'Common/Utils';

View file

@ -1,5 +1,4 @@
import ko from 'ko';
import key from 'key';
import AppStore from 'Stores/User/App';
import AccountStore from 'Stores/User/Account';

View file

@ -1,7 +1,4 @@
import window from 'window';
import $ from '$';
import ko from 'ko';
import key from 'key';
import { isNormal, windowResize } from 'Common/Utils';
import { Capa, Focused, Layout, KeyState, EventKeyCode, Magics } from 'Common/Enums';
@ -21,6 +18,8 @@ import { getApp } from 'Helper/Apps/User';
import { view, ViewType, showScreenPopup, setHash } from 'Knoin/Knoin';
import { AbstractViewNext } from 'Knoin/AbstractViewNext';
const $ = jQuery;
@view({
name: 'View/User/MailBox/FolderList',
type: ViewType.Left,
@ -194,9 +193,9 @@ class FolderListMailBoxUserView extends AbstractViewNext {
}
messagesDropOver(folder) {
window.clearTimeout(this.iDropOverTimer);
clearTimeout(this.iDropOverTimer);
if (folder && folder.collapsed()) {
this.iDropOverTimer = window.setTimeout(() => {
this.iDropOverTimer = setTimeout(() => {
folder.collapsed(false);
getApp().setExpandedFolder(folder.fullNameHash, true);
windowResize();
@ -205,7 +204,7 @@ class FolderListMailBoxUserView extends AbstractViewNext {
}
messagesDropOut() {
window.clearTimeout(this.iDropOverTimer);
clearTimeout(this.iDropOverTimer);
}
scrollToFocused() {

View file

@ -1,8 +1,4 @@
import window from 'window';
import $ from '$';
import ko from 'ko';
import key from 'key';
import Jua from 'Jua';
import {
Capa,
@ -400,7 +396,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
return false;
}
window.clearTimeout(this.iGoToUpUpOrDownDownTimeout);
clearTimeout(this.iGoToUpUpOrDownDownTimeout);
this.iGoToUpUpOrDownDownTimeout = setTimeout(() => {
let prev = null,
next = null,
@ -739,7 +735,7 @@ class MessageListMailBoxUserView extends AbstractViewNext {
onBuild(dom) {
const self = this;
this.oContentVisible = $('.b-content', dom);
this.oContentVisible = jQuery('.b-content', dom);
this.selector.init(this.oContentVisible, this.oContentVisible, KeyState.MessageList);

View file

@ -1,6 +1,4 @@
import $ from '$';
import ko from 'ko';
import key from 'key';
import { DATA_IMAGE_USER_DOT_PIC, UNUSED_OPTION_VALUE } from 'Common/Consts';
@ -450,7 +448,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
// aTo = [],
// EmailModel = require('Model/Email').default,
// fParseEmailLine = function(sLine) {
// return sLine ? [window.decodeURIComponent(sLine)].map(sItem => {
// return sLine ? [decodeURIComponent(sLine)].map(sItem => {
// var oEmailModel = new EmailModel();
// oEmailModel.parse(sItem);
// return oEmailModel.email ? oEmailModel : null;
@ -473,7 +471,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
let index = 0,
listIndex = 0;
const div = $('<div>'),
const div = jQuery('<div>'),
dynamicEls = this.message().attachments().map(item => {
if (item && !item.isLinked && item.isImage()) {
if (item === attachment) {
@ -561,7 +559,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
Local.set(ClientSideKeyName.MessageHeaderFullInfo, value ? '1' : '0');
});
this.oHeaderDom = $('.messageItemHeader', dom);
this.oHeaderDom = jQuery('.messageItemHeader', dom);
this.oHeaderDom = this.oHeaderDom[0] ? this.oHeaderDom : null;
if (this.mobile) {
@ -578,7 +576,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
!!event &&
Magics.EventWhichMouseMiddle !== event.which &&
mailToHelper(
$(this).attr('href'),
jQuery(this).attr('href'),
Settings.capa(Capa.Composer) ? require('View/Popup/Compose') : null // eslint-disable-line no-invalid-this
)
);

View file

@ -1,6 +1,3 @@
import $ from '$';
import key from 'key';
import { KeyState } from 'Common/Enums';
import { leftPanelDisabled } from 'Common/Globals';
import { settings, inbox } from 'Common/Links';
@ -37,7 +34,7 @@ class MenuSettingsUserView extends AbstractViewNext {
});
}
key('up, down', KeyState.Settings, settingsMenuKeysHandler($('.b-settings-menu .e-item', dom)));
key('up, down', KeyState.Settings, settingsMenuKeysHandler(jQuery('.b-settings-menu .e-item', dom)));
}
link(route) {

View file

@ -1,4 +1,4 @@
/* eslint-env browser */
import { getHash, setHash, clearHash } from 'Storage/RainLoop';
(win => {
@ -38,10 +38,204 @@ win.progressJs = new class {
}
};
require('Common/Booter');
let RL_APP_DATA_STORAGE = null;
if (win.__runBoot) {
win.__runBoot();
win.__rlah_set = () => setHash();
win.__rlah_clear = () => clearHash();
win.__rlah_data = () => RL_APP_DATA_STORAGE;
/**
* @returns {void}
*/
function showError() {
const oR = doc.getElementById('rl-loading'),
oL = doc.getElementById('rl-loading-error');
if (oR) {
oR.style.display = 'none';
}
if (oL) {
oL.style.display = 'block';
}
if (win.progressJs) {
progressJs.set(100).end();
}
}
/**
* @param {boolean} withError
* @returns {void}
*/
function runMainBoot(withError) {
if (win.__APP_BOOT && !withError) {
win.__APP_BOOT(() => showError());
} else {
showError();
}
}
function writeCSS(css) {
const style = doc.createElement('style');
style.type = 'text/css';
style.textContent = css;
// style.appendChild(doc.createTextNode(styles));
doc.head.appendChild(style);
}
function loadScript(src) {
if (!src) {
throw new Error('src should not be empty.');
}
return new Promise((resolve, reject) => {
const script = doc.createElement('script');
script.onload = () => resolve();
script.onerror = () => reject(new Error(src));
script.src = src;
// script.type = 'text/javascript';
doc.head.appendChild(script);
// doc.body.appendChild(element);
});
}
/**
* @param {mixed} data
* @returns {void}
*/
win.__initAppData = data => {
RL_APP_DATA_STORAGE = data;
win.__rlah_set();
if (RL_APP_DATA_STORAGE) {
const css = RL_APP_DATA_STORAGE.IncludeCss,
theme = RL_APP_DATA_STORAGE.NewThemeLink,
description= RL_APP_DATA_STORAGE.LoadingDescriptionEsc || '',
oE = doc.getElementById('rl-loading'),
oElDesc = doc.getElementById('rl-loading-desc');
if (theme) {
(doc.getElementById('app-theme-link') || {}).href = theme;
}
css && writeCSS(css);
if (oElDesc && description) {
oElDesc.innerHTML = description;
}
if (oE && oE.style) {
oE.style.opacity = 0;
setTimeout(() => oE.style.opacity = 1, 300);
}
}
const appData = win.__rlah_data(), p = progressJs;
if (
p &&
appData &&
appData.TemplatesLink &&
appData.LangLink &&
appData.StaticLibJsLink &&
appData.StaticAppJsLink &&
appData.StaticEditorJsLink
) {
p.set(5);
const libs = () =>
loadScript(appData.StaticLibJsLink).then(() => {
doc.getElementById('rl-check').remove();
if (appData.IncludeBackground) {
const img = appData.IncludeBackground.replace('{{USER}}', getHash() || '0');
if (img) {
doc.documentElement.classList.add('UserBackground');
doc.body.style.backgroundImage = "url("+img+")";
}
}
});
libs()
.then(() => {
p.set(20);
return Promise.all([loadScript(appData.TemplatesLink), loadScript(appData.LangLink)]);
})
.then(() => {
p.set(30);
return loadScript(appData.StaticAppJsLink);
})
.then(() => {
p.set(50);
return appData.PluginsLink ? loadScript(appData.PluginsLink) : Promise.resolve();
})
.then(() => {
p.set(70);
runMainBoot(false);
})
.catch((e) => {
runMainBoot(true);
throw e;
})
.then(() => loadScript(appData.StaticEditorJsLink))
.then(() => {
if (win.CKEDITOR && win.__initEditor) {
win.__initEditor();
win.__initEditor = null;
}
});
} else {
runMainBoot(true);
}
};
const app = doc.getElementById('rl-app');
if (!navigator || !navigator.cookieEnabled) {
doc.location.replace('./?/NoCookie');
}
// require('Styles/@Boot.css');
writeCSS('#rl-content{display:none;}.internal-hiddden{display:none !important;}');
if (app) {
const
meta = doc.getElementById('app-boot-data'),
options = meta ? JSON.parse(meta.getAttribute('content')) || {} : {};
// require('Html/Layout.html')
app.innerHTML = '<div id="rl-loading" class="thm-loading" style="opacity:0">\
<div id="rl-loading-desc"></div>\
<div class="e-spinner">\
<div class="e-bounce bounce1"></div>\
<div class="e-bounce bounce2"></div>\
<div class="e-bounce bounce3"></div>\
</div>\
</div>\
<div id="rl-loading-error" class="thm-loading">\
An error occurred. <br /> Please refresh the page and try again.\
</div>\
<div id="rl-content">\
<div id="rl-popups"></div>\
<div id="rl-center">\
<div id="rl-top"></div>\
<div id="rl-left"></div>\
<div id="rl-right"></div>\
<div id="rl-bottom"></div>\
</div>\
</div>\
<div id="rl-templates"></div>\
<div id="rl-hidden"></div>'.replace(/[\r\n\t]+/g, '');
loadScript('./?/'
+ (options.admin ? 'Admin' : '')
+ 'AppData@'
+ (options.mobile ? 'mobile' : 'no-mobile')
+ (options.mobileDevice ? '-1' : '-0')
+ '/'
+ (getHash() || '0')
+ '/'
+ Math.random().toString().substr(2)
+ '/').then(() => {});
}
})(window);

26
dev/bootstrap.js vendored
View file

@ -1,5 +1,4 @@
import window from 'window';
import { detectDropdownVisibility, createCommandLegacy, domReady } from 'Common/Utils';
import { detectDropdownVisibility } from 'Common/Utils';
import { $html, $htmlCL, data as GlobalsData, bMobileDevice } from 'Common/Globals';
import * as Enums from 'Common/Enums';
import * as Plugins from 'Common/Plugins';
@ -9,7 +8,7 @@ import { EmailModel } from 'Model/Email';
export default (App) => {
GlobalsData.__APP__ = App;
window.addEventListener('keydown', event => {
addEventListener('keydown', event => {
event = event || window.event;
if (event && event.ctrlKey && !event.shiftKey && !event.altKey) {
const key = event.keyCode || event.which;
@ -25,17 +24,13 @@ export default (App) => {
return;
}
if (window.getSelection) {
window.getSelection().removeAllRanges();
} else if (window.document.selection && window.document.selection.clear) {
window.document.selection.clear();
}
getSelection().removeAllRanges();
event.preventDefault();
}
}
});
window.addEventListener('unload', () => {
addEventListener('unload', () => {
GlobalsData.bUnload = true;
});
@ -45,7 +40,6 @@ export default (App) => {
const rl = window.rl || {};
rl.i18n = i18n;
rl.createCommand = createCommandLegacy;
rl.addSettingsViewModel = Plugins.addSettingsViewModel;
rl.addSettingsViewModelForAdmin = Plugins.addSettingsViewModelForAdmin;
@ -61,7 +55,7 @@ export default (App) => {
window.rl = rl;
const start = () => {
window.setTimeout(() => {
setTimeout(() => {
$htmlCL.remove('no-js', 'rl-booted-trigger');
$htmlCL.add('rl-booted');
@ -69,11 +63,11 @@ export default (App) => {
}, Enums.Magics.Time10ms);
};
window.__APP_BOOT = (fErrorCallback) => {
domReady(() => {
window.setTimeout(() => {
if (window.rainloopTEMPLATES && window.rainloopTEMPLATES[0]) {
window.document.getElementById('rl-templates').innerHTML = window.rainloopTEMPLATES[0];
window.__APP_BOOT = fErrorCallback => {
jQuery(() => {
setTimeout(() => {
if (window.rainloopTEMPLATES && rainloopTEMPLATES[0]) {
document.getElementById('rl-templates').innerHTML = rainloopTEMPLATES[0];
start();
} else {
fErrorCallback();