mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2026-01-30 12:22:26 -08:00
add a custom UI element that combines accordion and checkbox
rework hires fix UI to use accordion prevent bogus progress output in console when calculating hires fix dimensions
This commit is contained in:
parent
2c5106ed06
commit
9199b6b7eb
5 changed files with 124 additions and 59 deletions
37
javascript/inputAccordion.js
Normal file
37
javascript/inputAccordion.js
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
var observerAccordionOpen = new MutationObserver(function(mutations) {
|
||||
mutations.forEach(function(mutationRecord) {
|
||||
var elem = mutationRecord.target;
|
||||
var open = elem.classList.contains('open');
|
||||
|
||||
var accordion = elem.parentNode;
|
||||
accordion.classList.toggle('input-accordion-open', open);
|
||||
|
||||
var checkbox = gradioApp().querySelector('#' + accordion.id + "-checkbox input");
|
||||
checkbox.checked = open;
|
||||
updateInput(checkbox);
|
||||
|
||||
extra = gradioApp().querySelector('#' + accordion.id + "-extra");
|
||||
if(extra){
|
||||
extra.style.display = open ? "" : "none";
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function inputAccordionChecked(id, checked){
|
||||
var label = gradioApp().querySelector('#' + id + " .label-wrap");
|
||||
if(label.classList.contains('open') != checked){
|
||||
label.click();
|
||||
}
|
||||
}
|
||||
|
||||
onUiLoaded(function() {
|
||||
for (var accordion of gradioApp().querySelectorAll('.input-accordion')) {
|
||||
var labelWrap = accordion.querySelector('.label-wrap');
|
||||
observerAccordionOpen.observe(labelWrap, {attributes: true, attributeFilter: ['class']});
|
||||
|
||||
var extra = gradioApp().querySelector('#' + accordion.id + "-extra");
|
||||
if(extra){
|
||||
labelWrap.insertBefore(extra, labelWrap.lastElementChild)
|
||||
}
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue