commit
fbd31b82de
|
|
@ -4,6 +4,7 @@ state = window.state;
|
||||||
state.core = (function () {
|
state.core = (function () {
|
||||||
|
|
||||||
const TABS = ['txt2img', 'img2img'];
|
const TABS = ['txt2img', 'img2img'];
|
||||||
|
|
||||||
const ELEMENTS = {
|
const ELEMENTS = {
|
||||||
'prompt': 'prompt',
|
'prompt': 'prompt',
|
||||||
'negative_prompt': 'neg_prompt',
|
'negative_prompt': 'neg_prompt',
|
||||||
|
|
@ -29,6 +30,21 @@ state.core = (function () {
|
||||||
'resize_mode': 'resize_mode',
|
'resize_mode': 'resize_mode',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ELEMENTS_WITH_DUPLICATE_IDS = {
|
||||||
|
INPUTS: {
|
||||||
|
'upscaler_2_visibility': 'extras_upscaler_2_visibility',
|
||||||
|
'upscaler_scale_by_resize': 'extras_upscaling_resize',
|
||||||
|
'upscaler_scale_by_max_side_length': 'extras_upscale_max_side_length',
|
||||||
|
'upscaler_scale_to_w': 'extras_upscaling_resize_w',
|
||||||
|
'upscaler_scale_to_h': 'extras_upscaling_resize_h',
|
||||||
|
'upscaler_scale_to_crop': 'extras_upscaling_crop',
|
||||||
|
},
|
||||||
|
SELECTS: {
|
||||||
|
'upscaler_1': 'extras_upscaler_1',
|
||||||
|
'upscaler_2': 'extras_upscaler_2',
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const SELECTS = {
|
const SELECTS = {
|
||||||
'sampling': 'sampling',
|
'sampling': 'sampling',
|
||||||
'scheduler': 'scheduler',
|
'scheduler': 'scheduler',
|
||||||
|
|
@ -105,6 +121,14 @@ state.core = (function () {
|
||||||
handleToggleButton(`${tab}_${element}`);
|
handleToggleButton(`${tab}_${element}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
forEachElement(ELEMENTS_WITH_DUPLICATE_IDS.INPUTS, config, (element, tab) => {
|
||||||
|
handleSavedInput(`${element}`, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
forEachElement(ELEMENTS_WITH_DUPLICATE_IDS.SELECTS, config, (element, tab) => {
|
||||||
|
handleSavedSelects(`${element}`, true);
|
||||||
|
});
|
||||||
|
|
||||||
handleExtensions(config);
|
handleExtensions(config);
|
||||||
handleSettingsPage();
|
handleSettingsPage();
|
||||||
}
|
}
|
||||||
|
|
@ -213,9 +237,16 @@ state.core = (function () {
|
||||||
return gradioApp().getElementById(id);
|
return gradioApp().getElementById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSavedInput(id) {
|
function handleSavedInput(id, duplicateIds) {
|
||||||
|
|
||||||
|
let elements = null;
|
||||||
|
|
||||||
|
if (duplicateIds) {
|
||||||
|
elements = gradioApp().querySelectorAll(`[id="${id}"] textarea, [id="${id}"] input`);
|
||||||
|
} else {
|
||||||
|
elements = gradioApp().querySelectorAll(`#${id} textarea, #${id} input`);
|
||||||
|
}
|
||||||
|
|
||||||
const elements = gradioApp().querySelectorAll(`#${id} textarea, #${id} input`);
|
|
||||||
const events = ['change', 'input'];
|
const events = ['change', 'input'];
|
||||||
|
|
||||||
if (! elements || ! elements.length) {
|
if (! elements || ! elements.length) {
|
||||||
|
|
@ -264,8 +295,19 @@ state.core = (function () {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSavedSelects(id) {
|
function handleSavedSelects(id, duplicateIds) {
|
||||||
state.utils.handleSelect(getElement(id), id, store);
|
if (duplicateIds) {
|
||||||
|
const elements = gradioApp().querySelectorAll(`[id="${id}"]`);
|
||||||
|
if (! elements || ! elements.length) {
|
||||||
|
state.logging.warn(`Select not found: ${id}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
elements.forEach(function (element) {
|
||||||
|
state.utils.handleSelect(element, id, store);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
state.utils.handleSelect(getElement(id), id, store);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSavedMultiSelects(id) {
|
function handleSavedMultiSelects(id) {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,14 @@ def on_ui_settings():
|
||||||
"refiner",
|
"refiner",
|
||||||
"refiner_checkpoint",
|
"refiner_checkpoint",
|
||||||
"refiner_switch",
|
"refiner_switch",
|
||||||
|
'upscaler_scale_by_resize',
|
||||||
|
'upscaler_scale_by_max_side_length',
|
||||||
|
'upscaler_scale_to_w',
|
||||||
|
'upscaler_scale_to_h',
|
||||||
|
'upscaler_scale_to_crop',
|
||||||
|
'upscaler_1',
|
||||||
|
'upscaler_2',
|
||||||
|
'upscaler_2_visibility',
|
||||||
"script"
|
"script"
|
||||||
]
|
]
|
||||||
}, section=section))
|
}, section=section))
|
||||||
|
|
@ -53,6 +61,14 @@ def on_ui_settings():
|
||||||
"refiner",
|
"refiner",
|
||||||
"refiner_checkpoint",
|
"refiner_checkpoint",
|
||||||
"refiner_switch",
|
"refiner_switch",
|
||||||
|
'upscaler_scale_by_resize',
|
||||||
|
'upscaler_scale_by_max_side_length',
|
||||||
|
'upscaler_scale_to_w',
|
||||||
|
'upscaler_scale_to_h',
|
||||||
|
'upscaler_scale_to_crop',
|
||||||
|
'upscaler_1',
|
||||||
|
'upscaler_2',
|
||||||
|
'upscaler_2_visibility',
|
||||||
"sampling",
|
"sampling",
|
||||||
"scheduler",
|
"scheduler",
|
||||||
"resize_mode",
|
"resize_mode",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue