/** Datei: themes/lcars/assets/js/hooks/button.js **/ /** * /lcars/hooks/button.js * * Some Javascript codes without further description * * @author Sparky * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ import '/plugins/rest/assets/js/components/button.js'; ARUNOX.Hooks.register( 'button->config', function( config ) { return Object.assignRecursive( config, { block : 'frame', color : Object.assign( { color : 'primary', prefix : 'theme', }, config.color ), classes : [ config.classes, [ 'frame__element', 'frame__element--button', ]].flat().filter(Boolean), }); }, 5 ); if( 'vibrate' in navigator ) { ARUNOX.Hooks.register( 'button->afterRender', function() { this.instance.element.addEventListener( 'touchstart', event => { navigator.vibrate(50); }); }); } /** Datei: themes/lcars/assets/js/hooks/tabs.js **/ /** * /lcars/hooks/tabs.js * * Some Javascript codes without further description * * @author Sparky * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ ARUNOX.Hooks.register( 'tabs->afterRender', function( config ) { const section = this.instance.closest( 'layout/section' ); const tabs = this.instance.closest( 'tabs' ); const buttons = this.instance.nodes.buttons; const actions = buttons.root.querySelectorAll( '.tabs__item--action' ); if( buttons ) { section.nodes.header.nodes.after.render(); section.nodes.header.nodes.after.root.append( buttons.root ); } if( actions.length ) { section.nodes.header.nodes.before.render(); section.nodes.header.nodes.before.nodes.inner.root.append( ...actions ); } }); /** Datei: themes/lcars/assets/js/hooks/menus.js **/ /** * /lcars/hooks/_general.js * * Some Javascript codes without further description * * @author Sparky * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ import '/themes/lcars/assets/js/hooks/button.js'; ARUNOX.Hooks.register( 'addMenus', async function( anchor ) { const wrapper = this.instance.replace( 'div' ); const routes = ( await ARUNOX.Router.routes() ).map( item => { if( !Array.isArray( item.menu ) ) { item.menu = [ item.menu ]; } return item; }); const filtered = routes.filter( item => item.menu.includes( anchor ) ); for( const route of filtered ) { if( route.path ) { wrapper.apply( 'addMenus->item', route ); continue; } wrapper.apply( 'addMenus->category', route, routes ); } }); ARUNOX.Hooks.register( 'addMenus->category', async function( route, routes ) { const filtered = routes.filter( item => item.menu.includes( route.name ) ); const wrapper = this.instance.render( 'div', { classes : [ 'frame__wrapper' ], content : ARUNOX.Templates.config( 'div', { classes : [ 'frame__element', 'frame__element--label' ], content : ARUNOX.Templates.config( 'span', { classes : [ 'label' ], content : route.label, }), styles : { order : 0, } }), styles : { order : route?.order ?? 1, } }); for( const route of filtered ) { wrapper.apply( 'addMenus->item', route ); } }); ARUNOX.Hooks.register( 'addMenus->item', async function( route ) { this.instance.render( 'button', { label : route.label, icon : route.icon, action : route.path, styles : { order : route?.order ?? 1, } }); }); /** Datei: themes/lcars/assets/js/hooks/table.js **/ /** * /lcars/hooks/table.js * * Some Javascript codes without further description * * @author Sparky * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ ARUNOX.Hooks.register( 'table->afterRender', function( config ) { const section = this.instance.closest( 'layout/section' ); const toolbar = this.instance.nodes.toolbar; const search = this.instance.nodes.searchContainer; const filter = this.instance.nodes.filterContainer; const buttons = this.instance.nodes.buttons; const wrapper = this.instance.nodes.wrapper; if( search ) { section.nodes.footer.nodes.after.render(); section.nodes.footer.nodes.after.nodes.inner.replace( search ); section.nodes.aside.nodes.before.render(); section.nodes.aside.nodes.before.replace( filter ); } if( buttons ) { section.nodes.header.nodes.before.render(); section.nodes.header.nodes.before.replace( buttons ); } toolbar.root.remove(); }); ARUNOX.Hooks.register( 'table->config', function( config ) { if( config.buttons ) { for( const button of config.buttons ) { button.config.color = 'secondary'; } } return config; }); ARUNOX.Hooks.register( 'button->config.node->filterReset', function( config ) { config.styles.order = 1; config.color = 'primary'; return config; }); ARUNOX.Hooks.register( 'button->active', function( active ) { const config = this.instance.config; const nodeName = config?.nodeName; // console.log( nodeName, active ); if( nodeName == 'searchReset' ) { this.instance.root.style.display = !active ? 'none' : null; return; } if( nodeName == 'filterReset' ) { this.instance.root.disabled = !active; return; } if( nodeName.match( /^filter[A-Z][a-zA-Z]*-.*/ ) ) { // if( active ) this.instance.root.classList.remove( 'inactive' ); // else this.instance.root.classList.add( 'inactive' ); if( active ) this.instance.root.classList.add( 'active' ); else this.instance.root.classList.remove( 'active' ); return; } }); /** Datei: themes/lcars/assets/js/hooks/notifications.js **/ /** * /lcars/hooks/notifications.js * * Some Javascript codes without further description * * @author Sparky * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ import '/plugins/rest/assets/js/components/notifications.js'; ARUNOX.Hooks.register( 'notifications->afterRender', function() { const section = this.instance.closest( 'layout/section' ); if( section ) { section.nodes.header.nodes.before.render(); section.nodes.header.nodes.before.replace( this.instance ); this.instance.addNotification({ duration : 0, icon : 'bi-bell', title : 'Benachrichtigungen', message : 'Keine Benachrichtigungen', style : { order : -1, }, }); } }); ARUNOX.Hooks.register( 'notification->afterRender', function( config ) { if( config.duration === 0 ) return; config.delay ??= 2000; config.animate ??= config.delay <= 500 ? 100 : 500; if( typeof ARUNOX.Tools?.Beep === 'function' ) { if( config.type == 'danger' ) ARUNOX.Tools.Beep.alert(); else if( config.type == 'success' ) ARUNOX.Tools.Beep.short(); else if( config.type == 'warning' ) ARUNOX.Tools.Beep.long(); } window.setTimeout( () => { this.instance.parent.root.classList.add( 'hover' ); window.setTimeout( () => { this.instance.parent.root.classList.remove('hover'); // if( config.redirect !== false && config.redirect.url !== false ) { // if( config.redirect === true ) location.reload(); // else location.href = config.redirect.url; // } window.setTimeout( () => { this.instance.root.classList.add( 'fade-out' ); window.setTimeout( () => { this.instance.root.remove(); }, 250 ); }, config.message ? 2000 : 0 ); }, config.delay || 2000 ); }, config.animate || 500 ); });