Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Button
- {
- constructor(name, width, height)
- {
- this._name = name
- this._styles = [{name: 'width', value: width},{name: 'height', value: height}];
- };
- getName() { return this._name;};
- setName(name) {this._name = name;};
- _getStyle(styleName){ return this._styles.find((it)=>{ if (it.name === styleName){return it};}) };
- _setStyle(styleName,value) {this._getStyle(styleName).value = value;};
- getSize(){return {width: this._getStyle('width').value, height: this._getStyle('height').value};};
- setSize(width, height){ this._setStyle('width', width); this._setStyle('height', height); };
- _toStyle(){ return this._styles.reduce((prev,it)=>{
- return `${prev}${it.name}: ${it.value}; `;
- },'');};
- _toHtml(){return `<button style="${this._toStyle()}">${this._name}</button>`;};
- showBtn() { document.write(this._toHtml());};
- }
- class BootstrapButton extends Button
- {
- constructor(name, width, height, color)
- {
- super(name, width, height);
- this._styles.push({name: 'background-color', value: color});
- }
- getColor(){return this._getStyle('background-color').value;};
- setColor(color){ this._setStyle('background-color', color);};
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement