This commit is contained in:
2025-11-26 16:13:16 +02:00
parent d4df355de4
commit 43f8b17930
2 changed files with 54 additions and 68 deletions
+53 -25
View File
@@ -1,5 +1,5 @@
import { Rt } from './Rt'; import { Rt } from './Rt';
import { dxReady } from '../utils/dom'; import { dxReady, EvtOptions } from '../utils/dom';
/* /*
* Loader Class * Loader Class
@@ -15,9 +15,6 @@ export class Boot {
// Static Global Data // Static Global Data
static data = {}; static data = {};
// Widget Stack
static widgetStack = {};
// Root data // Root data
static r = {}; static r = {};
@@ -29,46 +26,77 @@ export class Boot {
static vars = {}; static vars = {};
static ready(callback) { static ready(callback) {
dxReady(() => { dxReady(() => {
let dirPath = '/'; Boot.lang = document.documentElement.getAttribute('lang') ?? 'en';
const h = document.documentElement;
if (h.classList.contains('app') && location.pathname != '/') { import(`/js/${Boot.lang}/interface.js`).then((mod) => {
dirPath = location.pathname + '/';
}
Boot.lang = h.getAttribute('lang') ?? 'en';
Rt.setCsrfToken(h.dxFind('meta[name="csrf-token"]')?.content);
import(dirPath + `js/${Boot.lang}/interface.js`).then((mod) => {
if (!mod.intData) { if (!mod.intData) {
Boot.log('Invalid interface data!');
return; return;
} }
Boot.preInit();
Rt.setCsrfToken(document.documentElement.dxFind('meta[name="csrf-token"]')?.content);
Boot.intData = mod.intData; Boot.intData = mod.intData;
callback(); callback();
}).catch((e) => {}); }).catch((err) => Boot.log('Module Err: ', err));
}); });
}
/**
* Some optimisations at this point
*/
static preInit() {
document.body.dxOn('click', 'a[href="#"]', e => e.preventDefault() ) ;
} }
/** /**
* Set Config Directive * Load Section
*/ */
setConfig(name, value) { static loadSection(id, vars) {
Boot.config[name] = value;
}
// Clear Global Data Boot.vars = vars || {};
clearGlobalData() { const _section = id.split('.');
Boot.data = {};
let rootNode = Boot.intData.section[ _section[0] ];
// RootNode is missing
if (!Ut.isSet(rootNode)) {
if (Boot.DEBUG) {
console.log('Section not found');
}
return;
}
// Set sectionList as global
Boot._section = _section;
// Subsection present
if (_section.length == 2) {
// assign (that) object
rootNode = Object.assign({}, rootNode, { that: rootNode.children.section[_section[1]] });
}
// Set section root (rootnode children)
Boot.r = rootNode.children || {};
// This is the current section
Boot.section = id;
// Set listener evt options
EvtOptions.nsEvent = true;
EvtOptions.section = id;
} }
/** /**
+1 -43
View File
@@ -1,7 +1,7 @@
import './css/app-ui.css'; import './css/app-ui.css';
import { Ut } from '../utils/Ut'; import { Ut } from '../utils/Ut';
import { El } from '../utils/dom'; import { El, EvtOptions } from '../utils/dom';
import { Boot } from './Boot'; import { Boot } from './Boot';
import { Cancelable } from '../widgets/cancelable/Cancelable'; import { Cancelable } from '../widgets/cancelable/Cancelable';
import { DatePicker } from '../widgets/date-picker/DatePicker'; import { DatePicker } from '../widgets/date-picker/DatePicker';
@@ -1099,48 +1099,6 @@ export class Render {
nodesList.forEach(props => Render.makeElement(props, parent)); nodesList.forEach(props => Render.makeElement(props, parent));
} }
/**
* Init Module
*/
static loadSection(id, vars) {
Boot.vars = vars || {};
const _section = id.split('.');
let rootNode = Boot.intData.section[ _section[0] ];
// RootNode is missing
if (!Ut.isSet(rootNode)) {
if (Boot.DEBUG) {
console.log('Section not found');
}
return;
}
// Set sectionList as global
Boot._section = _section;
// Subsection present
if (_section.length == 2) {
// assign (that) object
rootNode = Object.assign({}, rootNode, { that: rootNode.children.section[_section[1]] });
}
// Set section root (rootnode children)
Boot.r = rootNode.children || {};
// This is the current section
Boot.section = id;
// Set listener evt options
EvtOptions.nsEvent = true;
EvtOptions.section = id;
}
/** /**
* Render UI Component * Render UI Component
* *