diff --git a/src/core/Boot.js b/src/core/Boot.js index e12c856..cf65804 100644 --- a/src/core/Boot.js +++ b/src/core/Boot.js @@ -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 = {}; @@ -29,46 +26,77 @@ export class Boot { static vars = {}; static ready(callback) { - + 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)); }); + } + + /** + * Some optimisations at this point + */ + static preInit() { + document.body.dxOn('click', 'a[href="#"]', e => e.preventDefault() ) ; } /** - * Set Config Directive + * Load Section */ - setConfig(name, value) { - Boot.config[name] = value; - } + static loadSection(id, vars) { - // Clear Global Data + Boot.vars = vars || {}; - clearGlobalData() { - Boot.data = {}; + 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; } /** diff --git a/src/core/Render.js b/src/core/Render.js index 5cfa47b..eaeb0d6 100644 --- a/src/core/Render.js +++ b/src/core/Render.js @@ -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 *