From f2f3ed71d46baf1e87a2146586b45143f8eb6bf2 Mon Sep 17 00:00:00 2001 From: AssassinJN Date: Fri, 10 Feb 2023 12:28:07 -0500 Subject: [PATCH] Hide Image buttons hides task (#854) * hide task when all images are hidden * Update main.css * remove console logs * remove another console log * Update main.js * Update main.js --- ui/media/css/main.css | 4 ++++ ui/media/js/main.js | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ui/media/css/main.css b/ui/media/css/main.css index 03350a67..346fb73a 100644 --- a/ui/media/css/main.css +++ b/ui/media/css/main.css @@ -1204,3 +1204,7 @@ body.wait-pause { .jconfirm.jconfirm-modern .jconfirm-box { background-color: var(--background-color1); } + +.displayNone { + display:none !important; +} diff --git a/ui/media/js/main.js b/ui/media/js/main.js index c57b8a4b..41e0aafb 100644 --- a/ui/media/js/main.js +++ b/ui/media/js/main.js @@ -279,9 +279,21 @@ function showImages(reqBody, res, outputContainer, livePreview) { imageElem.setAttribute('data-guidance', imageGuidanceScale) const imageRemoveBtn = imageItemElem.querySelector('.imgPreviewItemClearBtn') + let parentTaskContainer = imageRemoveBtn.closest('.imageTaskContainer') imageRemoveBtn.addEventListener('click', (e) => { console.log(e) - shiftOrConfirm(e, "Remove the image from the results?", () => { imageItemElem.style.display = 'none' }) + shiftOrConfirm(e, "Remove the image from the results?", () => { + imageItemElem.style.display = 'none' + let allHidden = true; + let children = parentTaskContainer.querySelectorAll('.imgItem'); + for(let x = 0; x < children.length; x++) { + let child = children[x]; + if(child.style.display != "none") { + allHidden = false; + } + } + if(allHidden === true) {parentTaskContainer.classList.add("displayNone")} + }) }) const imageInfo = imageItemElem.querySelector('.imgItemInfo')