mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-12-30 19:41:46 +08: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 { staticLink } from 'Common/Links';
|
||||
import { FolderUserStore } from 'Stores/User/Folder';
|
||||
import { SettingsGet } from 'Common/Globals';
|
||||
|
||||
//export class UserSettingsFilters /*extends AbstractViewSettings*/ {
|
||||
export class UserSettingsFilters /*extends AbstractViewSettings*/ {
|
||||
|
@ -12,7 +12,7 @@ export class UserSettingsFilters /*extends AbstractViewSettings*/ {
|
|||
serverErrorDesc: ''
|
||||
});
|
||||
|
||||
rl.loadScript(staticLink('js/sieve.js')).then(() => {
|
||||
rl.loadScript(SettingsGet('StaticLibsJs').replace('/libs.', '/sieve.')).then(() => {
|
||||
const Sieve = window.Sieve;
|
||||
Sieve.folderList = FolderUserStore.folderList;
|
||||
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
|
||||
doc = document,
|
||||
eId = id => doc.getElementById('rl-'+id),
|
||||
app = eId('app'),
|
||||
admin = app && '1' == app.dataset.admin,
|
||||
|
||||
cb = () => rl.app.bootstart(),
|
||||
|
||||
showError = msg => {
|
||||
let div = eId('loading-error');
|
||||
div.append(' ' + msg);
|
||||
eId('loading').hidden = true;
|
||||
div.hidden = false;
|
||||
},
|
||||
layout = doc.cookie.match(/(^|;) ?rllayout=([^;]+)/) || '',
|
||||
|
||||
loadScript = src => {
|
||||
if (!src) {
|
||||
|
@ -31,16 +23,11 @@ const
|
|||
});
|
||||
};
|
||||
|
||||
if (!navigator.cookieEnabled) {
|
||||
doc.location.href = './?/NoCookie';
|
||||
}
|
||||
|
||||
let RL_APP_DATA = {},
|
||||
layout = doc.cookie.match(/(^|;) ?rllayout=([^;]+)/) || '';
|
||||
let RL_APP_DATA = {};
|
||||
|
||||
doc.documentElement.classList.toggle('rl-mobile', 'mobile' === layout[2] || (!layout && 1000 > innerWidth));
|
||||
|
||||
win.rl = {
|
||||
window.rl = {
|
||||
adminArea: () => admin,
|
||||
settings: {
|
||||
get: name => RL_APP_DATA[name],
|
||||
|
@ -53,8 +40,16 @@ win.rl = {
|
|||
|
||||
initData: appData => {
|
||||
RL_APP_DATA = appData;
|
||||
loadScript(appData.StaticLibJsLink)
|
||||
.then(() => loadScript(appData.StaticAppJsLink))
|
||||
const url = appData.StaticLibsJs,
|
||||
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(() => ('loading' !== doc.readyState) ? cb() : doc.addEventListener('DOMContentLoaded', cb))
|
||||
.catch(e => {
|
||||
|
@ -74,4 +69,4 @@ win.rl = {
|
|||
loadScript(`./?/${admin ? 'Admin' : ''}AppData/0/${Math.random().toString().slice(2)}/`)
|
||||
.then(() => 0);
|
||||
|
||||
})(this);
|
||||
})(document);
|
||||
|
|
|
@ -927,10 +927,8 @@ class Actions
|
|||
|
||||
$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');
|
||||
$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'] : 'Plain';
|
||||
|
|
Loading…
Reference in a new issue