mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Dynamic load app.js/admin.js/sieve.js based on minification
This commit is contained in:
parent
088d6cab55
commit
ea25d9bce4
3 changed files with 20 additions and 27 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
import { addObservablesTo } from 'External/ko';
|
import { addObservablesTo } from 'External/ko';
|
||||||
import { staticLink } from 'Common/Links';
|
|
||||||
import { FolderUserStore } from 'Stores/User/Folder';
|
import { FolderUserStore } from 'Stores/User/Folder';
|
||||||
|
import { SettingsGet } from 'Common/Globals';
|
||||||
|
|
||||||
//export class UserSettingsFilters /*extends AbstractViewSettings*/ {
|
//export class UserSettingsFilters /*extends AbstractViewSettings*/ {
|
||||||
export class UserSettingsFilters /*extends AbstractViewSettings*/ {
|
export class UserSettingsFilters /*extends AbstractViewSettings*/ {
|
||||||
|
|
@ -12,7 +12,7 @@ export class UserSettingsFilters /*extends AbstractViewSettings*/ {
|
||||||
serverErrorDesc: ''
|
serverErrorDesc: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
rl.loadScript(staticLink('js/sieve.js')).then(() => {
|
rl.loadScript(SettingsGet('StaticLibsJs').replace('/libs.', '/sieve.')).then(() => {
|
||||||
const Sieve = window.Sieve;
|
const Sieve = window.Sieve;
|
||||||
Sieve.folderList = FolderUserStore.folderList;
|
Sieve.folderList = FolderUserStore.folderList;
|
||||||
Sieve.serverError.subscribe(value => this.serverError(value));
|
Sieve.serverError.subscribe(value => this.serverError(value));
|
||||||
|
|
|
||||||
39
dev/boot.js
39
dev/boot.js
|
|
@ -1,21 +1,13 @@
|
||||||
[].flat||document.location.replace('./?/BadBrowser');
|
(doc => {
|
||||||
|
|
||||||
(win => {
|
[].flat || doc.location.replace('./?/BadBrowser');
|
||||||
|
navigator.cookieEnabled || doc.location.replace('./?/NoCookie');
|
||||||
|
|
||||||
const
|
const
|
||||||
doc = document,
|
|
||||||
eId = id => doc.getElementById('rl-'+id),
|
eId = id => doc.getElementById('rl-'+id),
|
||||||
app = eId('app'),
|
app = eId('app'),
|
||||||
admin = app && '1' == app.dataset.admin,
|
admin = app && '1' == app.dataset.admin,
|
||||||
|
layout = doc.cookie.match(/(^|;) ?rllayout=([^;]+)/) || '',
|
||||||
cb = () => rl.app.bootstart(),
|
|
||||||
|
|
||||||
showError = msg => {
|
|
||||||
let div = eId('loading-error');
|
|
||||||
div.append(' ' + msg);
|
|
||||||
eId('loading').hidden = true;
|
|
||||||
div.hidden = false;
|
|
||||||
},
|
|
||||||
|
|
||||||
loadScript = src => {
|
loadScript = src => {
|
||||||
if (!src) {
|
if (!src) {
|
||||||
|
|
@ -31,16 +23,11 @@ const
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!navigator.cookieEnabled) {
|
let RL_APP_DATA = {};
|
||||||
doc.location.href = './?/NoCookie';
|
|
||||||
}
|
|
||||||
|
|
||||||
let RL_APP_DATA = {},
|
|
||||||
layout = doc.cookie.match(/(^|;) ?rllayout=([^;]+)/) || '';
|
|
||||||
|
|
||||||
doc.documentElement.classList.toggle('rl-mobile', 'mobile' === layout[2] || (!layout && 1000 > innerWidth));
|
doc.documentElement.classList.toggle('rl-mobile', 'mobile' === layout[2] || (!layout && 1000 > innerWidth));
|
||||||
|
|
||||||
win.rl = {
|
window.rl = {
|
||||||
adminArea: () => admin,
|
adminArea: () => admin,
|
||||||
settings: {
|
settings: {
|
||||||
get: name => RL_APP_DATA[name],
|
get: name => RL_APP_DATA[name],
|
||||||
|
|
@ -53,8 +40,16 @@ win.rl = {
|
||||||
|
|
||||||
initData: appData => {
|
initData: appData => {
|
||||||
RL_APP_DATA = appData;
|
RL_APP_DATA = appData;
|
||||||
loadScript(appData.StaticLibJsLink)
|
const url = appData.StaticLibsJs,
|
||||||
.then(() => loadScript(appData.StaticAppJsLink))
|
cb = () => rl.app.bootstart(),
|
||||||
|
div = eId('loading-error'),
|
||||||
|
showError = msg => {
|
||||||
|
div.append(' ' + msg);
|
||||||
|
eId('loading').hidden = true;
|
||||||
|
div.hidden = false;
|
||||||
|
};
|
||||||
|
loadScript(url)
|
||||||
|
.then(() => loadScript(url.replace('/libs.', `/${admin?'admin':'app'}.`)))
|
||||||
.then(() => appData.PluginsLink ? loadScript(appData.PluginsLink) : Promise.resolve())
|
.then(() => appData.PluginsLink ? loadScript(appData.PluginsLink) : Promise.resolve())
|
||||||
.then(() => ('loading' !== doc.readyState) ? cb() : doc.addEventListener('DOMContentLoaded', cb))
|
.then(() => ('loading' !== doc.readyState) ? cb() : doc.addEventListener('DOMContentLoaded', cb))
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
|
@ -74,4 +69,4 @@ win.rl = {
|
||||||
loadScript(`./?/${admin ? 'Admin' : ''}AppData/0/${Math.random().toString().slice(2)}/`)
|
loadScript(`./?/${admin ? 'Admin' : ''}AppData/0/${Math.random().toString().slice(2)}/`)
|
||||||
.then(() => 0);
|
.then(() => 0);
|
||||||
|
|
||||||
})(this);
|
})(document);
|
||||||
|
|
|
||||||
|
|
@ -927,10 +927,8 @@ class Actions
|
||||||
|
|
||||||
$bAppJsDebug = $this->oConfig->Get('labs', 'use_app_debug_js', false);
|
$bAppJsDebug = $this->oConfig->Get('labs', 'use_app_debug_js', false);
|
||||||
|
|
||||||
$aResult['StaticLibJsLink'] = $this->StaticPath('js/' . ($bAppJsDebug ? '' : 'min/') .
|
$aResult['StaticLibsJs'] = $this->StaticPath('js/' . ($bAppJsDebug ? '' : 'min/') .
|
||||||
'libs' . ($bAppJsDebug ? '' : '.min') . '.js');
|
'libs' . ($bAppJsDebug ? '' : '.min') . '.js');
|
||||||
$aResult['StaticAppJsLink'] = $this->StaticPath('js/' . ($bAppJsDebug ? '' : 'min/') .
|
|
||||||
($bAdmin ? 'admin' : 'app') . ($bAppJsDebug ? '' : '.min') . '.js');
|
|
||||||
|
|
||||||
$aResult['EditorDefaultType'] = \in_array($aResult['EditorDefaultType'], array('Plain', 'Html', 'HtmlForced', 'PlainForced'))
|
$aResult['EditorDefaultType'] = \in_array($aResult['EditorDefaultType'], array('Plain', 'Html', 'HtmlForced', 'PlainForced'))
|
||||||
? $aResult['EditorDefaultType'] : 'Plain';
|
? $aResult['EditorDefaultType'] : 'Plain';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue