alexanderroese 2024-06-21 17:40:12 +02:00
commit e2d7653e5d
1 changed files with 18 additions and 9 deletions

View File

@ -74,7 +74,7 @@
width: calc(100% + 8px); width: calc(100% + 8px);
height: calc(100% + 8px); height: calc(100% + 8px);
border-radius: 2px; border-radius: 4px;
border: 1px solid #0003; border: 1px solid #0003;
} }
@ -157,11 +157,6 @@
return html; return html;
} }
const defaultStyle = `<style>.custom.form__label{margin-bottom: 0.6rem}.field.custom{margin-top: 0.6rem}.custom .field__input{padding-top:0.8rem}</style>`; const defaultStyle = `<style>.custom.form__label{margin-bottom: 0.6rem}.field.custom{margin-top: 0.6rem}.custom .field__input{padding-top:0.8rem}</style>`;
let globalInputFormsObj = { let globalInputFormsObj = {
@ -318,8 +313,6 @@
// Clean up the element when it is removed from the DOM. // Clean up the element when it is removed from the DOM.
} }
renderView() { renderView() {
// request data from server // request data from server
let tJS = this.tJS; let tJS = this.tJS;
@ -366,6 +359,14 @@
} }
updateSelectSwatch(event) {
let target = event.target;
let input = target.previousElementSibling;
input.checked = true;
this.renderView();
}
reloadCurrentVariant(id, openAnimation = false) { reloadCurrentVariant(id, openAnimation = false) {
this.currentVariant = id; this.currentVariant = id;
let content = this.content; let content = this.content;
@ -381,7 +382,15 @@
if(key === this.currentVariant) { if(key === this.currentVariant) {
content.innerHTML = globalInputFormsObj[key].renderHTML(this.section_id); content.innerHTML = globalInputFormsObj[key].renderHTML(this.section_id);
} }
} }
const inputs = content.querySelectorAll('input');
for(let i = 0; i < inputs.length; i++) {
if(inputs[i].type === 'radio') {
inputs[i].addEventListener('change', this.updateSelectSwatch.bind(this));
}
}
console.log('reloadCurrentVariant', id, openAnimation); console.log('reloadCurrentVariant', id, openAnimation);