/** Datei: plugins/rest/assets.OLD/js/arunox/hooks/colorize.js **/ /** * rest/arunox/hooks/colorize.js * * Some Javascript codes without further description * * @author Sparky * @copyright 2025 ARUNOX * @version 2.0.0 * @since 2.0.0 Adaptation to new ctx method * @since 1.0.0 File is created */ ARUNOX.Hooks.register( 'colorize', function( cellColorConfig, optionColorConfig, iconContainer ) { if( typeof cellColorConfig === 'string' ) cellColorConfig = { color: cellColorConfig } if( typeof optionColorConfig === 'string' ) optionColorConfig = { color: optionColorConfig } let colorConfig = Object.assign( { target : 'background', prefix : false, }, cellColorConfig, optionColorConfig ); if( colorConfig.prefix ) { this.instance.root.classList.removeRexEx( /.*--colored-.*/ ); this.instance.root.classList.add( `${colorConfig.prefix}--colored-${colorConfig.color || 'default'}` ); return ; } if( this.instance.root && ['button'].includes( colorConfig.target ) ) { this.instance.root.classList.removeRexEx( /button--colored-.*/ ); this.instance.root.classList.add( `button--colored-${colorConfig.color || 'default'}` ); this.instance.root.style.backgroundColor = colorConfig.value; } if( this.instance.root && ['background'].includes( colorConfig.target ) ) { this.instance.root.classList.removeRexEx( /bg--colored-.*/ ); this.instance.root.classList.add( `bg--colored-${colorConfig.color || 'default'}` ); this.instance.root.style.backgroundColor = colorConfig.value; } if( iconContainer && ['icon','both'].includes( colorConfig.target ) ) { iconContainer.classList.removeRexEx( /text--colored-.*/ ); iconContainer.classList.add( `text--colored-${colorConfig.color || 'default'}` ); iconContainer.style.color = colorConfig.value; } if( this.instance.root && ['text','both'].includes( colorConfig.target ) ) { this.instance.root.classList.removeRexEx( /text--colored-.*/ ); this.instance.root.classList.add( `text--colored-${colorConfig.color || 'default'}` ); this.instance.root.style.color = colorConfig.value; } });