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
+51 -23
View File
@@ -1,5 +1,5 @@
import { Rt } from './Rt';
import { dxReady } from '../utils/dom';
import { dxReady, EvtOptions } from '../utils/dom';
/*
* Loader Class
@@ -15,9 +15,6 @@ export class Boot {
// Static Global Data
static data = {};
// Widget Stack
static widgetStack = {};
// Root data
static r = {};
@@ -32,43 +29,74 @@ export class Boot {
dxReady(() => {
let dirPath = '/';
const h = document.documentElement;
Boot.lang = document.documentElement.getAttribute('lang') ?? 'en';
if (h.classList.contains('app') && location.pathname != '/') {
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) => {
import(`/js/${Boot.lang}/interface.js`).then((mod) => {
if (!mod.intData) {
Boot.log('Invalid interface data!');
return;
}
Boot.preInit();
Rt.setCsrfToken(document.documentElement.dxFind('meta[name="csrf-token"]')?.content);
Boot.intData = mod.intData;
callback();
}).catch((e) => {});
}).catch((err) => Boot.log('Module Err: ', err));
});
}
/**
* Set Config Directive
* Some optimisations at this point
*/
setConfig(name, value) {
Boot.config[name] = value;
static preInit() {
document.body.dxOn('click', 'a[href="#"]', e => e.preventDefault() ) ;
}
// Clear Global Data
/**
* Load Section
*/
static loadSection(id, vars) {
clearGlobalData() {
Boot.data = {};
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;
}
/**
+1 -43
View File
@@ -1,7 +1,7 @@
import './css/app-ui.css';
import { Ut } from '../utils/Ut';
import { El } from '../utils/dom';
import { El, EvtOptions } from '../utils/dom';
import { Boot } from './Boot';
import { Cancelable } from '../widgets/cancelable/Cancelable';
import { DatePicker } from '../widgets/date-picker/DatePicker';
@@ -1099,48 +1099,6 @@ export class Render {
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
*