Upgraded some old JavaScript to ECMAScript 1.6

Removed some jQuery references
Added JavaScript Globals.$htmlCL for frequently used window.document.documentElement.classList
This commit is contained in:
djmaze 2020-07-15 14:25:51 +02:00
parent a6a337e5ce
commit 0b0747b8dc
19 changed files with 142 additions and 151 deletions

View file

@ -7,8 +7,7 @@ import ssm from 'ssm';
import { import {
$win, $win,
$html, $htmlCL,
$doc,
leftPanelDisabled, leftPanelDisabled,
leftPanelType, leftPanelType,
sUserAgent, sUserAgent,
@ -43,7 +42,7 @@ class AbstractApp extends AbstractBoot {
this.iframe = $('<iframe class="internal-hiddden" />').appendTo('body'); this.iframe = $('<iframe class="internal-hiddden" />').appendTo('body');
$win.on('resize', () => { window.addEventListener('resize', () => {
Events.pub('window.resize'); Events.pub('window.resize');
}); });
@ -72,24 +71,21 @@ class AbstractApp extends AbstractBoot {
// } // }
// }); // });
const $doc = $(window.document);
$doc $doc
.on('keydown', (event) => { .on('keydown', (event) => {
if (event && event.ctrlKey) { if (event && event.ctrlKey) {
$html.addClass('rl-ctrl-key-pressed'); $htmlCL.add('rl-ctrl-key-pressed');
} }
}) })
.on('keyup', (event) => { .on('keyup', (event) => {
if (event && !event.ctrlKey) { if (event && !event.ctrlKey) {
$html.removeClass('rl-ctrl-key-pressed'); $htmlCL.remove('rl-ctrl-key-pressed');
} }
}); })
.on('mousemove keypress click', _.debounce(() => {
$doc.on(
'mousemove keypress click',
_.debounce(() => {
Events.pub('rl.auto-logout-refresh'); Events.pub('rl.auto-logout-refresh');
}, Magics.Time5s) }, Magics.Time5s));
);
key('esc, enter', KeyState.All, () => { key('esc, enter', KeyState.All, () => {
detectDropdownVisibility(); detectDropdownVisibility();
@ -265,17 +261,17 @@ class AbstractApp extends AbstractBoot {
}); });
if (!mobile) { if (!mobile) {
$html.addClass('rl-desktop'); $htmlCL.add('rl-desktop');
ssm.addState({ ssm.addState({
id: 'mobile', id: 'mobile',
query: '(max-width: 767px)', query: '(max-width: 767px)',
onEnter: () => { onEnter: () => {
$html.addClass('ssm-state-mobile'); $htmlCL.add('ssm-state-mobile');
Events.pub('ssm.mobile-enter'); Events.pub('ssm.mobile-enter');
}, },
onLeave: () => { onLeave: () => {
$html.removeClass('ssm-state-mobile'); $htmlCL.remove('ssm-state-mobile');
Events.pub('ssm.mobile-leave'); Events.pub('ssm.mobile-leave');
} }
}); });
@ -284,10 +280,10 @@ class AbstractApp extends AbstractBoot {
id: 'tablet', id: 'tablet',
query: '(min-width: 768px) and (max-width: 999px)', query: '(min-width: 768px) and (max-width: 999px)',
onEnter: () => { onEnter: () => {
$html.addClass('ssm-state-tablet'); $htmlCL.add('ssm-state-tablet');
}, },
onLeave: () => { onLeave: () => {
$html.removeClass('ssm-state-tablet'); $htmlCL.remove('ssm-state-tablet');
} }
}); });
@ -295,10 +291,10 @@ class AbstractApp extends AbstractBoot {
id: 'desktop', id: 'desktop',
query: '(min-width: 1000px) and (max-width: 1400px)', query: '(min-width: 1000px) and (max-width: 1400px)',
onEnter: () => { onEnter: () => {
$html.addClass('ssm-state-desktop'); $htmlCL.add('ssm-state-desktop');
}, },
onLeave: () => { onLeave: () => {
$html.removeClass('ssm-state-desktop'); $htmlCL.remove('ssm-state-desktop');
} }
}); });
@ -306,25 +302,25 @@ class AbstractApp extends AbstractBoot {
id: 'desktop-large', id: 'desktop-large',
query: '(min-width: 1401px)', query: '(min-width: 1401px)',
onEnter: () => { onEnter: () => {
$html.addClass('ssm-state-desktop-large'); $htmlCL.add('ssm-state-desktop-large');
}, },
onLeave: () => { onLeave: () => {
$html.removeClass('ssm-state-desktop-large'); $htmlCL.remove('ssm-state-desktop-large');
} }
}); });
} else { } else {
$html.addClass('ssm-state-mobile').addClass('rl-mobile'); $htmlCL.add('ssm-state-mobile', 'rl-mobile');
Events.pub('ssm.mobile-enter'); Events.pub('ssm.mobile-enter');
} }
leftPanelDisabled.subscribe((bValue) => { leftPanelDisabled.subscribe((bValue) => {
$html.toggleClass('rl-left-panel-disabled', bValue); $htmlCL.toggle('rl-left-panel-disabled', bValue);
$html.toggleClass('rl-left-panel-enabled', !bValue); $htmlCL.toggle('rl-left-panel-enabled', !bValue);
}); });
leftPanelType.subscribe((sValue) => { leftPanelType.subscribe((sValue) => {
$html.toggleClass('rl-left-panel-none', 'none' === sValue); $htmlCL.toggle('rl-left-panel-none', 'none' === sValue);
$html.toggleClass('rl-left-panel-short', 'short' === sValue); $htmlCL.toggle('rl-left-panel-short', 'short' === sValue);
}); });
leftPanelDisabled.valueHasMutated(); leftPanelDisabled.valueHasMutated();

View file

@ -34,7 +34,7 @@ import {
Magics Magics
} from 'Common/Enums'; } from 'Common/Enums';
import { $html, leftPanelWidth, leftPanelDisabled, bMobileDevice } from 'Common/Globals'; import { $htmlCL, leftPanelWidth, leftPanelDisabled, bMobileDevice } from 'Common/Globals';
import { UNUSED_OPTION_VALUE } from 'Common/Consts'; import { UNUSED_OPTION_VALUE } from 'Common/Consts';
import { runHook } from 'Common/Plugins'; import { runHook } from 'Common/Plugins';
@ -146,11 +146,10 @@ class AppUser extends AbstractApp {
if (Settings.settingsGet('UserBackgroundHash')) { if (Settings.settingsGet('UserBackgroundHash')) {
_.delay(() => { _.delay(() => {
const img = userBackground(Settings.settingsGet('UserBackgroundHash')), const img = userBackground(Settings.settingsGet('UserBackgroundHash'));
b = window.document.body;
if (img) { if (img) {
b.classList.add('UserBackground'); $htmlCL.add('UserBackground');
b.style.backgroundImage = "url("+img+")"; window.document.body.style.backgroundImage = "url("+img+")";
} }
}, Magics.Time1s); }, Magics.Time1s);
} }
@ -904,25 +903,25 @@ class AppUser extends AbstractApp {
$(event.target) $(event.target)
.find('.ui-resizable-handle') .find('.ui-resizable-handle')
.on('mousedown', () => { .on('mousedown', () => {
$html.addClass('rl-resizer'); $htmlCL.add('rl-resizer');
}) })
.on('mouseup', () => { .on('mouseup', () => {
$html.removeClass('rl-resizer'); $htmlCL.remove('rl-resizer');
}); });
} }
}, },
fResizeStartFunction = () => { fResizeStartFunction = () => {
$html.addClass('rl-resizer'); $htmlCL.add('rl-resizer');
}, },
fResizeResizeFunction = _.debounce( fResizeResizeFunction = _.debounce(
() => { () => {
$html.addClass('rl-resizer'); $htmlCL.add('rl-resizer');
}, },
500, 500,
true true
), ),
fResizeStopFunction = (oEvent, oObject) => { fResizeStopFunction = (oEvent, oObject) => {
$html.removeClass('rl-resizer'); $htmlCL.remove('rl-resizer');
if (oObject && oObject.size && oObject.size.height) { if (oObject && oObject.size && oObject.size.height) {
Local.set(sClientSideKeyName, oObject.size.height); Local.set(sClientSideKeyName, oObject.size.height);
@ -950,7 +949,7 @@ class AppUser extends AbstractApp {
if (bottom) { if (bottom) {
bottom.removeAttr('style'); bottom.removeAttr('style');
} }
} else if ($html.hasClass('rl-bottom-preview-pane')) { } else if ($htmlCL.contains('rl-bottom-preview-pane')) {
top = $('.b-message-list-wrapper'); top = $('.b-message-list-wrapper');
bottom = $('.b-message-view-wrapper'); bottom = $('.b-message-view-wrapper');
@ -980,7 +979,7 @@ class AppUser extends AbstractApp {
if (iWidth) { if (iWidth) {
leftPanelWidth(iWidth); leftPanelWidth(iWidth);
$html.removeClass('rl-resizer'); $htmlCL.remove('rl-resizer');
lLeft.css({ lLeft.css({
width: '' + iWidth + 'px' width: '' + iWidth + 'px'
@ -1006,25 +1005,25 @@ class AppUser extends AbstractApp {
$(event.target) $(event.target)
.find('.ui-resizable-handle') .find('.ui-resizable-handle')
.on('mousedown', () => { .on('mousedown', () => {
$html.addClass('rl-resizer'); $htmlCL.add('rl-resizer');
}) })
.on('mouseup', () => { .on('mouseup', () => {
$html.removeClass('rl-resizer'); $htmlCL.remove('rl-resizer');
}); });
} }
}, },
fResizeResizeFunction = _.debounce( fResizeResizeFunction = _.debounce(
() => { () => {
$html.addClass('rl-resizer'); $htmlCL.add('rl-resizer');
}, },
500, 500,
true true
), ),
fResizeStartFunction = () => { fResizeStartFunction = () => {
$html.addClass('rl-resizer'); $htmlCL.add('rl-resizer');
}, },
fResizeStopFunction = (event, obj) => { fResizeStopFunction = (event, obj) => {
$html.removeClass('rl-resizer'); $htmlCL.remove('rl-resizer');
if (obj && obj.size && obj.size.width) { if (obj && obj.size && obj.size.width) {
Local.set(sClientSideKeyName, obj.size.width); Local.set(sClientSideKeyName, obj.size.width);
@ -1086,7 +1085,8 @@ class AppUser extends AbstractApp {
} }
bootstartLoginScreen() { bootstartLoginScreen() {
$html.removeClass('rl-user-auth').addClass('rl-user-no-auth'); $htmlCL.remove('rl-user-auth');
$htmlCL.add('rl-user-no-auth');
const customLoginLink = pString(Settings.appSettingsGet('customLoginLink')); const customLoginLink = pString(Settings.appSettingsGet('customLoginLink'));
if (!customLoginLink) { if (!customLoginLink) {
@ -1135,7 +1135,7 @@ class AppUser extends AbstractApp {
this.setWindowTitle(''); this.setWindowTitle('');
if (Settings.settingsGet('Auth')) { if (Settings.settingsGet('Auth')) {
$html.addClass('rl-user-auth'); $htmlCL.add('rl-user-auth');
if ( if (
Settings.capa(Capa.TwoFactor) && Settings.capa(Capa.TwoFactor) &&

View file

@ -66,17 +66,11 @@ function getComputedStyle(id, name) {
* @returns {void} * @returns {void}
*/ */
function includeStyle(styles) { function includeStyle(styles) {
const style = window.document.createElement('style'); const doc = window.document, style = doc.createElement('style');
style.type = 'text/css'; style.type = 'text/css';
style.text = styles; style.textContent = styles;
// style.appendChild(doc.createTextNode(styles));
if (style.styleSheet) { doc.head.appendChild(style);
style.styleSheet.cssText = styles;
} else {
style.appendChild(window.document.createTextNode(styles));
}
window.document.getElementsByTagName('head')[0].appendChild(style);
} }
/** /**
@ -84,11 +78,10 @@ function includeStyle(styles) {
* @returns {void} * @returns {void}
*/ */
function includeScr(src) { function includeScr(src) {
const script = window.document.createElement('script'); const doc = window.document, script = doc.createElement('script');
script.type = 'text/javascript'; script.type = 'text/javascript';
script.src = src; script.src = src;
doc.head.appendChild(script);
window.document.getElementsByTagName('head')[0].appendChild(script);
} }
/** /**
@ -219,6 +212,7 @@ function runApp() {
jassl && jassl &&
progressJs && progressJs &&
appData && appData &&
appData.TemplatesLink &&
appData.LangLink && appData.LangLink &&
appData.StaticLibJsLink && appData.StaticLibJsLink &&
appData.StaticAppJsLink && appData.StaticAppJsLink &&
@ -232,15 +226,12 @@ function runApp() {
const libs = () => const libs = () =>
jassl(appData.StaticLibJsLink).then(() => { jassl(appData.StaticLibJsLink).then(() => {
if (window.$) { window.document.getElementById('rl-check').remove();
window.$('#rl-check').remove();
}
if (appData.IncludeBackground) { if (appData.IncludeBackground) {
const img = appData.IncludeBackground.replace('{{USER}}', window.__rlah ? window.__rlah() || '0' : '0'), const img = appData.IncludeBackground.replace('{{USER}}', window.__rlah ? window.__rlah() || '0' : '0');
b = window.document.body;
if (img) { if (img) {
b.classList.add('UserBackground'); window.document.documentElement.classList.add('UserBackground');
b.style.backgroundImage = "url("+img+")"; window.document.body.style.backgroundImage = "url("+img+")";
} }
} }
}); });
@ -248,7 +239,7 @@ function runApp() {
libs() libs()
.then(() => { .then(() => {
p.set(20); p.set(20);
return jassl(appData.LangLink); return window.Promise.all([jassl(appData.TemplatesLink), jassl(appData.LangLink)]);
}) })
.then(() => { .then(() => {
p.set(30); p.set(30);

View file

@ -10,9 +10,8 @@ $win.__sizes = [0, 0];
export { $win }; export { $win };
export const $doc = $(window.document);
export const $html = $('html'); export const $html = $('html');
export const $htmlCL = window.document.documentElement.classList;
export const $body = $('body'); export const $body = $('body');
@ -71,7 +70,7 @@ export const bMobileDevice = (/android|iphone|ipod|ipad|blackberry|mobile/i).tes
* @type {boolean} * @type {boolean}
*/ */
export const bAnimationSupported = export const bAnimationSupported =
!bMobileDevice && $html.hasClass('csstransitions') && $html.hasClass('cssanimations'); !bMobileDevice && $htmlCL.contains('csstransitions') && $htmlCL.contains('cssanimations');
/** /**
* @type {boolean} * @type {boolean}
@ -200,7 +199,7 @@ export const popupVisibilityNames = ko.observableArray([]);
export const popupVisibility = ko.computed(() => 0 < popupVisibilityNames().length); export const popupVisibility = ko.computed(() => 0 < popupVisibilityNames().length);
popupVisibility.subscribe((bValue) => { popupVisibility.subscribe((bValue) => {
$html.toggleClass('rl-modal', bValue); $htmlCL.toggle('rl-modal', bValue);
}); });
// keys // keys

View file

@ -4,7 +4,7 @@ import $ from '$';
import ko from 'ko'; import ko from 'ko';
import { Notification, UploadErrorCode } from 'Common/Enums'; import { Notification, UploadErrorCode } from 'Common/Enums';
import { pInt, isUnd, isNull, has, microtime, inArray } from 'Common/Utils'; import { pInt, isUnd, isNull, has, microtime, inArray } from 'Common/Utils';
import { $html, bAnimationSupported } from 'Common/Globals'; import { $html, $htmlCL, bAnimationSupported } from 'Common/Globals';
import { reload as momentorReload } from 'Common/Momentor'; import { reload as momentorReload } from 'Common/Momentor';
import { langLink } from 'Common/Links'; import { langLink } from 'Common/Links';
@ -272,7 +272,7 @@ export function getUploadErrorDescByCode(code) {
export function reload(admin, language) { export function reload(admin, language) {
const start = microtime(); const start = microtime();
$html.addClass('rl-changing-language'); $htmlCL.add('rl-changing-language');
return new window.Promise((resolve, reject) => { return new window.Promise((resolve, reject) => {
$.ajax({ $.ajax({
@ -287,11 +287,9 @@ export function reload(admin, language) {
const isRtl = -1 < inArray((language || '').toLowerCase(), ['ar', 'ar_sa', 'he', 'he_he', 'ur', 'ur_ir']); const isRtl = -1 < inArray((language || '').toLowerCase(), ['ar', 'ar_sa', 'he', 'he_he', 'ur', 'ur_ir']);
$html $htmlCL.remove('rl-changing-language', 'rl-rtl', 'rl-ltr');
.removeClass('rl-changing-language') // $html.attr('dir', isRtl ? 'rtl' : 'ltr')
.removeClass('rl-rtl rl-ltr') $htmlCL.add(isRtl ? 'rl-rtl' : 'rl-ltr');
// .attr('dir', isRtl ? 'rtl' : 'ltr')
.addClass(isRtl ? 'rl-rtl' : 'rl-ltr');
resolve(); resolve();
}, },
@ -299,7 +297,7 @@ export function reload(admin, language) {
); );
}, },
() => { () => {
$html.removeClass('rl-changing-language'); $htmlCL.remove('rl-changing-language');
window.rainloopI18N = null; window.rainloopI18N = null;
reject(); reject();
} }
@ -308,4 +306,4 @@ export function reload(admin, language) {
} }
// init section // init section
$html.addClass('rl-' + ($html.attr('dir') || 'ltr')); $htmlCL.add('rl-' + ($html.attr('dir') || 'ltr'));

View file

@ -1449,10 +1449,10 @@ export function domReady(fn) {
export const windowResize = _.debounce((timeout) => { export const windowResize = _.debounce((timeout) => {
if (isUnd(timeout) || isNull(timeout)) { if (isUnd(timeout) || isNull(timeout)) {
$win.resize(); $win.trigger('resize');
} else { } else {
window.setTimeout(() => { window.setTimeout(() => {
$win.resize(); $win.trigger('resize');
}, timeout); }, timeout);
} }
}, 50); }, 50);

21
dev/External/ko.js vendored
View file

@ -7,7 +7,6 @@ import Pikaday from 'pikaday';
import { SaveSettingsStep, Magics } from 'Common/Enums'; import { SaveSettingsStep, Magics } from 'Common/Enums';
const ko = window.ko, const ko = window.ko,
$win = $(window),
fDisposalTooltipHelper = (element) => { fDisposalTooltipHelper = (element) => {
ko.utils.domNodeDisposal.addDisposeCallback(element, () => { ko.utils.domNodeDisposal.addDisposeCallback(element, () => {
if (element && element.__opentip) { if (element && element.__opentip) {
@ -27,11 +26,11 @@ ko.bindingHandlers.updateWidth = {
}, Magics.Time500ms); }, Magics.Time500ms);
}; };
$win.on('resize', fInit); window.addEventListener('resize', fInit);
fInit(); fInit();
ko.utils.domNodeDisposal.addDisposeCallback(element, () => { ko.utils.domNodeDisposal.addDisposeCallback(element, () => {
$win.off('resize', fInit); window.removeEventListener('resize', fInit);
}); });
} }
}; };
@ -92,11 +91,11 @@ ko.bindingHandlers.scrollerShadows = {
if (cont) { if (cont) {
$(cont).on('scroll resize', fFunc); $(cont).on('scroll resize', fFunc);
$win.on('resize', fFunc); window.addEventListener('resize', fFunc);
ko.utils.domNodeDisposal.addDisposeCallback(cont, () => { ko.utils.domNodeDisposal.addDisposeCallback(cont, () => {
$(cont).off(); $(cont).off();
$win.off('resize', fFunc); window.removeEventListener('resize', fFunc);
}); });
} }
} }
@ -186,12 +185,12 @@ ko.bindingHandlers.tooltip = {
element.__opentip.setContent(sValue); element.__opentip.setContent(sValue);
} }
$win.on('rl.tooltips.diactivate', () => { window.addEventListener('rl.tooltips.diactivate', () => {
element.__opentip.hide(); element.__opentip.hide();
element.__opentip.deactivate(); element.__opentip.deactivate();
}); });
$win.on('rl.tooltips.activate', () => { window.addEventListener('rl.tooltips.activate', () => {
element.__opentip.activate(); element.__opentip.activate();
}); });
} }
@ -460,10 +459,10 @@ ko.bindingHandlers.modal = {
$(element).modal(ko.unwrap(fValueAccessor()) ? 'show' : 'hide'); $(element).modal(ko.unwrap(fValueAccessor()) ? 'show' : 'hide');
if (Globals.$html.hasClass('rl-anim')) { if (Globals.$htmlCL.contains('rl-anim')) {
Globals.$html.addClass('rl-modal-animation'); Globals.$htmlCL.add('rl-modal-animation');
_.delay(() => { _.delay(() => {
Globals.$html.removeClass('rl-modal-animation'); Globals.$htmlCL.remove('rl-modal-animation');
}, Magics.Time500ms); }, Magics.Time500ms);
} }
} }
@ -534,7 +533,7 @@ ko.bindingHandlers.initFixedTrigger = {
let $container = $(values[0] || null); let $container = $(values[0] || null);
$container = $container[0] ? $container : null; $container = $container[0] ? $container : null;
if ($container) { if ($container) {
$win.resize(() => { window.addEventListener('resize', () => {
const offset = $container ? $container.offset() : null; const offset = $container ? $container.offset() : null;
if (offset && offset.top) { if (offset && offset.top) {
$el.css('top', offset.top + top); $el.css('top', offset.top + top);

View file

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

View file

@ -6,7 +6,7 @@ import crossroads from 'crossroads';
import { Magics } from 'Common/Enums'; import { Magics } from 'Common/Enums';
import { runHook } from 'Common/Plugins'; import { runHook } from 'Common/Plugins';
import { $html, VIEW_MODELS, popupVisibilityNames } from 'Common/Globals'; import { $htmlCL, VIEW_MODELS, popupVisibilityNames } from 'Common/Globals';
import { isArray, isUnd, pString, log, isFunc, createCommandLegacy, delegateRun, isNonEmptyArray } from 'Common/Utils'; import { isArray, isUnd, pString, log, isFunc, createCommandLegacy, delegateRun, isNonEmptyArray } from 'Common/Utils';
@ -432,8 +432,11 @@ export function startScreens(screensClasses) {
hasher.changed.add(cross.parse, cross); hasher.changed.add(cross.parse, cross);
hasher.init(); hasher.init();
_.delay(() => $html.removeClass('rl-started-trigger').addClass('rl-started'), 100); _.delay(() => {
_.delay(() => $html.addClass('rl-started-delay'), 200); $htmlCL.remove('rl-started-trigger');
$htmlCL.add('rl-started');
}, 100);
_.delay(() => $htmlCL.add('rl-started-delay'), 200);
} }
/** /**

View file

@ -797,7 +797,7 @@ class MessageModel extends AbstractModel {
if (lazy) { if (lazy) {
this.lozad(); this.lozad();
$win.resize(); $win.trigger('resize');
} }
windowResize(500); windowResize(500);

View file

@ -48,12 +48,12 @@ class ThemesUserSettings {
}); });
this.background.hash.subscribe((value) => { this.background.hash.subscribe((value) => {
const b = window.document.body; const b = window.document.body, cl = window.document.documentElement.classList;
if (!value) { if (!value) {
b.classList.remove('UserBackground'); cl.remove('UserBackground');
b.removeAttribute('style'); b.removeAttribute('style');
} else { } else {
b.classList.add('UserBackground'); cl.add('UserBackground');
b.style.backgroundImage = "url("+userBackground(value)+")"; b.style.backgroundImage = "url("+userBackground(value)+")";
} }
}); });

View file

@ -1,5 +1,5 @@
import ko from 'ko'; import ko from 'ko';
import { $html, bMobileDevice } from 'Common/Globals'; import { $htmlCL, bMobileDevice } from 'Common/Globals';
import * as Settings from 'Storage/Settings'; import * as Settings from 'Storage/Settings';
class AbstractAppStore { class AbstractAppStore {
@ -12,7 +12,8 @@ class AbstractAppStore {
this.interfaceAnimation.subscribe((value) => { this.interfaceAnimation.subscribe((value) => {
const anim = bMobileDevice || !value; const anim = bMobileDevice || !value;
$html.toggleClass('rl-anim', !anim).toggleClass('no-rl-anim', anim); $htmlCL.toggle('rl-anim', !anim);
$htmlCL.toggle('no-rl-anim', anim);
}); });
this.interfaceAnimation.valueHasMutated(); this.interfaceAnimation.valueHasMutated();

View file

@ -3,7 +3,7 @@ import ko from 'ko';
import { MESSAGES_PER_PAGE, MESSAGES_PER_PAGE_VALUES } from 'Common/Consts'; import { MESSAGES_PER_PAGE, MESSAGES_PER_PAGE_VALUES } from 'Common/Consts';
import { Layout, EditorDefaultType, Magics } from 'Common/Enums'; import { Layout, EditorDefaultType, Magics } from 'Common/Enums';
import { $html } from 'Common/Globals'; import { $htmlCL } from 'Common/Globals';
import { pInt } from 'Common/Utils'; import { pInt } from 'Common/Utils';
import * as Events from 'Common/Events'; import * as Events from 'Common/Events';
@ -46,9 +46,9 @@ class SettingsUserStore {
subscribers() { subscribers() {
this.layout.subscribe((value) => { this.layout.subscribe((value) => {
$html.toggleClass('rl-no-preview-pane', Layout.NoPreview === value); $htmlCL.toggle('rl-no-preview-pane', Layout.NoPreview === value);
$html.toggleClass('rl-side-preview-pane', Layout.SidePreview === value); $htmlCL.toggle('rl-side-preview-pane', Layout.SidePreview === value);
$html.toggleClass('rl-bottom-preview-pane', Layout.BottomPreview === value); $htmlCL.toggle('rl-bottom-preview-pane', Layout.BottomPreview === value);
Events.pub('layout', [value]); Events.pub('layout', [value]);
}); });
} }

View file

@ -1,5 +1,5 @@
.UserBackground { .UserBackground body {
background-size: cover; background-size: cover;
background-size: contain; background-size: contain;
background-repeat: no-repeat; background-repeat: no-repeat;

View file

@ -5,7 +5,7 @@ import key from 'key';
import { trim, isNormal, isArray, windowResize } from 'Common/Utils'; import { trim, isNormal, isArray, windowResize } from 'Common/Utils';
import { Capa, Focused, Layout, KeyState, EventKeyCode, Magics } from 'Common/Enums'; import { Capa, Focused, Layout, KeyState, EventKeyCode, Magics } from 'Common/Enums';
import { $html, leftPanelDisabled, moveAction } from 'Common/Globals'; import { $htmlCL, leftPanelDisabled, moveAction } from 'Common/Globals';
import { mailBox, settings } from 'Common/Links'; import { mailBox, settings } from 'Common/Links';
import { setFolderHash } from 'Common/Cache'; import { setFolderHash } from 'Common/Cache';
@ -242,7 +242,7 @@ class FolderListMailBoxUserView extends AbstractViewNext {
messagesDrop(toFolder, ui) { messagesDrop(toFolder, ui) {
if (toFolder && ui && ui.helper) { if (toFolder && ui && ui.helper) {
const fromFolderFullNameRaw = ui.helper.data('rl-folder'), const fromFolderFullNameRaw = ui.helper.data('rl-folder'),
copy = $html.hasClass('rl-ctrl-key-pressed'), copy = $htmlCL.contains('rl-ctrl-key-pressed'),
uids = ui.helper.data('rl-uids'); uids = ui.helper.data('rl-uids');
if (isNormal(fromFolderFullNameRaw) && '' !== fromFolderFullNameRaw && isArray(uids)) { if (isNormal(fromFolderFullNameRaw) && '' !== fromFolderFullNameRaw && isArray(uids)) {

View file

@ -17,7 +17,7 @@ import {
MessageSetAction MessageSetAction
} from 'Common/Enums'; } from 'Common/Enums';
import { $html, leftPanelDisabled, keyScopeReal, useKeyboardShortcuts, moveAction } from 'Common/Globals'; import { $htmlCL, leftPanelDisabled, keyScopeReal, useKeyboardShortcuts, moveAction } from 'Common/Globals';
import { import {
inArray, inArray,
@ -323,7 +323,7 @@ class MessageViewMailBoxUserView extends AbstractViewNext {
}); });
this.fullScreenMode.subscribe((value) => { this.fullScreenMode.subscribe((value) => {
$html.toggleClass('rl-message-fullscreen', value); $htmlCL.toggle('rl-message-fullscreen', value);
windowResize(); windowResize();
}); });

View file

@ -4,12 +4,12 @@ import { progressJs } from '../vendors/Progress.js/src/progress.js';
window.progressJs = window.progressJs || progressJs(); window.progressJs = window.progressJs || progressJs();
window.progressJs.onbeforeend(() => { window.progressJs.onbeforeend(() => {
const _$ = window.$; const div = window.document.querySelector('.progressjs-container');
if (_$) { if (div) {
try { try {
_$('.progressjs-container').hide(); div.hidden = true;
window.setTimeout(() => { window.setTimeout(() => {
_$('.progressjs-container').remove(); div.remove();
}, 200); // eslint-disable-line no-magic-numbers }, 200); // eslint-disable-line no-magic-numbers
} catch (e) {} // eslint-disable-line no-empty } catch (e) {} // eslint-disable-line no-empty
} }

11
dev/bootstrap.js vendored
View file

@ -1,6 +1,6 @@
import window from 'window'; import window from 'window';
import { killCtrlACtrlS, detectDropdownVisibility, createCommandLegacy, domReady } from 'Common/Utils'; import { killCtrlACtrlS, detectDropdownVisibility, createCommandLegacy, domReady } from 'Common/Utils';
import { $win, $html, data as GlobalsData, bMobileDevice } from 'Common/Globals'; import { $html, $htmlCL, data as GlobalsData, bMobileDevice } from 'Common/Globals';
import * as Enums from 'Common/Enums'; import * as Enums from 'Common/Enums';
import * as Plugins from 'Common/Plugins'; import * as Plugins from 'Common/Plugins';
import { i18n } from 'Common/Translator'; import { i18n } from 'Common/Translator';
@ -9,11 +9,13 @@ import { EmailModel } from 'Model/Email';
export default (App) => { export default (App) => {
GlobalsData.__APP__ = App; GlobalsData.__APP__ = App;
$win.on('keydown', killCtrlACtrlS).on('unload', () => { window.addEventListener('keydown', killCtrlACtrlS);
window.addEventListener('unload', () => {
GlobalsData.bUnload = true; GlobalsData.bUnload = true;
}); });
$html.addClass(bMobileDevice ? 'mobile' : 'no-mobile').on('click.dropdown.data-api', detectDropdownVisibility); $htmlCL.add(bMobileDevice ? 'mobile' : 'no-mobile');
$html.on('click.dropdown.data-api', detectDropdownVisibility);
const rl = window.rl || {}; const rl = window.rl || {};
@ -35,7 +37,8 @@ export default (App) => {
const start = () => { const start = () => {
window.setTimeout(() => { window.setTimeout(() => {
$html.removeClass('no-js rl-booted-trigger').addClass('rl-booted'); $htmlCL.remove('no-js', 'rl-booted-trigger');
$htmlCL.add('rl-booted');
App.bootstart(); App.bootstart();
}, Enums.Magics.Time10ms); }, Enums.Magics.Time10ms);