/** * This file is part of the jps-like-websites lib * URL: https://git.labos.goip.de/chris/jpc-like-websites * @copyright by its creator Christian Martin */ /** * @inheritdoc * @extends ChildbearerComponent * @abstract */ class ModifiableComponent extends ChildbearerComponent { /** * @type {Modifier} modifier */ _modifier; constructor(element, attr = {}) { super(element, attr); this._modifier = new Modifier(); } /** * Sets, updates or overwrites the Modifier-Object for this component * @param {Modifier} modifier * @param {boolean|ExtStorage|ExtStoreType|OverwriteBehaviour} [extStore=null] * @returns {Component} this component object */ modifier(modifier, underTheName = "", extStore = false) { if (underTheName === "") { underTheName = `.${this._compName}-style-${this._styles.length}`; } if (!extStore) { this._modifier = this._modifier .join(modifier.ensureModifier()); } else { this.addStyleClass(underTheName); this._styles.push( new SStoreDefinition( underTheName, modifier.ensureModifier() ) ); } return this; } /** * Returns a Modifier to chain modifications * instead of setting them within an sepperate context. * @returns {ChainableModifier} */ chainModifier() { return new ChainableModifier(this); } }