mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2026-03-14 09:27:25 +00:00
Add back enabled checkbox and sync (#30)
* Add back enabled checkbox and sync * Better state management
This commit is contained in:
@@ -68,7 +68,8 @@
|
||||
this.accordion = accordion;
|
||||
this.isImg2Img = tab.querySelector('.cnet-mask-upload').id.includes('img2img');
|
||||
|
||||
this.enabledCheckbox = tab.querySelector('.input-accordion-checkbox');
|
||||
this.enabledAccordionCheckbox = tab.querySelector('.input-accordion-checkbox');
|
||||
this.enabledCheckbox = tab.querySelector('.cnet-unit-enabled input');
|
||||
this.inputImage = tab.querySelector('.cnet-input-image-group .cnet-image input[type="file"]');
|
||||
this.inputImageContainer = tab.querySelector('.cnet-input-image-group .cnet-image');
|
||||
this.controlTypeRadios = tab.querySelectorAll('.controlnet_control_type_filter_group input[type="radio"]');
|
||||
@@ -81,9 +82,10 @@
|
||||
// By default the InputAccordion checkbox is linked with the state
|
||||
// of accordion's open/close state. To disable this link, we can
|
||||
// simulate click to check the checkbox and uncheck it.
|
||||
this.enabledCheckbox.click();
|
||||
this.enabledCheckbox.click();
|
||||
this.enabledAccordionCheckbox.click();
|
||||
this.enabledAccordionCheckbox.click();
|
||||
|
||||
this.sync_enabled_checkbox();
|
||||
this.attachEnabledButtonListener();
|
||||
this.attachControlTypeRadioListener();
|
||||
this.attachImageUploadListener();
|
||||
@@ -92,6 +94,21 @@
|
||||
this.attachPresetDropdownObserver();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sync the states of enabledCheckbox and enabledAccordionCheckbox.
|
||||
*/
|
||||
sync_enabled_checkbox() {
|
||||
this.enabledCheckbox.addEventListener("change", () => {
|
||||
if (this.enabledAccordionCheckbox.checked != this.enabledCheckbox.checked) {
|
||||
this.enabledAccordionCheckbox.click();
|
||||
}
|
||||
});
|
||||
this.enabledAccordionCheckbox.addEventListener("change", () => {
|
||||
if (this.enabledCheckbox.checked != this.enabledAccordionCheckbox.checked) {
|
||||
this.enabledCheckbox.click();
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Get the span that has text "Unit {X}".
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user