fire checkbox change event (#77)
parent
4a3c7a86e0
commit
3889ebc8e3
|
|
@ -1,3 +1,7 @@
|
||||||
|
let dynthres_update_enabled = function() {
|
||||||
|
return Array.from(arguments);
|
||||||
|
};
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
let accordions = {};
|
let accordions = {};
|
||||||
let enabled = {};
|
let enabled = {};
|
||||||
|
|
@ -5,6 +9,16 @@
|
||||||
let accordion_id_prefix = "#dynthres_";
|
let accordion_id_prefix = "#dynthres_";
|
||||||
let extension_checkbox_class = ".dynthres-enabled";
|
let extension_checkbox_class = ".dynthres-enabled";
|
||||||
|
|
||||||
|
dynthres_update_enabled = function() {
|
||||||
|
let res = Array.from(arguments);
|
||||||
|
let tabname = res[1] ? "img2img" : "txt2img";
|
||||||
|
|
||||||
|
let checkbox = accordions[tabname]?.querySelector(extension_checkbox_class + ' input');
|
||||||
|
checkbox?.dispatchEvent(new Event('change'));
|
||||||
|
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
function attachEnabledButtonListener(checkbox, accordion) {
|
function attachEnabledButtonListener(checkbox, accordion) {
|
||||||
let span = accordion.querySelector('.label-wrap span');
|
let span = accordion.querySelector('.label-wrap span');
|
||||||
let badge = document.createElement('input');
|
let badge = document.createElement('input');
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,8 @@ class Script(scripts.Script):
|
||||||
def vis_change(isVis):
|
def vis_change(isVis):
|
||||||
return {"visible": isVis, "__type__": "update"}
|
return {"visible": isVis, "__type__": "update"}
|
||||||
# "Dynamic Thresholding (CFG Scale Fix)"
|
# "Dynamic Thresholding (CFG Scale Fix)"
|
||||||
|
dtrue = gr.Checkbox(value=True, visible=False)
|
||||||
|
dfalse = gr.Checkbox(value=False, visible=False)
|
||||||
with gr.Accordion("Dynamic Thresholding (CFG Scale Fix)", open=False, elem_id="dynthres_" + ("img2img" if is_img2img else "txt2img")):
|
with gr.Accordion("Dynamic Thresholding (CFG Scale Fix)", open=False, elem_id="dynthres_" + ("img2img" if is_img2img else "txt2img")):
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
enabled = gr.Checkbox(value=False, label="Enable Dynamic Thresholding (CFG Scale Fix)", elem_classes=["dynthres-enabled"])
|
enabled = gr.Checkbox(value=False, label="Enable Dynamic Thresholding (CFG Scale Fix)", elem_classes=["dynthres-enabled"])
|
||||||
|
|
@ -68,8 +70,9 @@ class Script(scripts.Script):
|
||||||
cfg_mode.change(shouldShowSchedulerValue, inputs=[cfg_mode, mimic_mode], outputs=[sched_val, mimic_scale_min, cfg_scale_min])
|
cfg_mode.change(shouldShowSchedulerValue, inputs=[cfg_mode, mimic_mode], outputs=[sched_val, mimic_scale_min, cfg_scale_min])
|
||||||
mimic_mode.change(shouldShowSchedulerValue, inputs=[cfg_mode, mimic_mode], outputs=[sched_val, mimic_scale_min, cfg_scale_min])
|
mimic_mode.change(shouldShowSchedulerValue, inputs=[cfg_mode, mimic_mode], outputs=[sched_val, mimic_scale_min, cfg_scale_min])
|
||||||
enabled.change(
|
enabled.change(
|
||||||
fn=lambda x: {"visible": x, "__type__": "update"},
|
_js="dynthres_update_enabled",
|
||||||
inputs=[enabled],
|
fn=lambda x, y: {"visible": x, "__type__": "update"},
|
||||||
|
inputs=[enabled, dtrue if is_img2img else dfalse],
|
||||||
outputs=[accordion],
|
outputs=[accordion],
|
||||||
show_progress = False)
|
show_progress = False)
|
||||||
self.infotext_fields = (
|
self.infotext_fields = (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue