mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2024-11-22 08:13:22 +01:00
Merge pull request #1376 from JeLuF/dlg2
Download dialog redesign, moveable dialogs, code cleanup
This commit is contained in:
commit
311ade1281
@ -313,7 +313,7 @@
|
||||
<div id="preview-content">
|
||||
<div id="preview-tools" class="displayNone">
|
||||
<button id="clear-all-previews" class="secondaryButton"><i class="fa-solid fa-trash-can icon"></i> Clear All</button>
|
||||
<button class="tertiaryButton" id="show-download-popup"><i class="fa-solid fa-download"></i> Download images</button>
|
||||
<button class="tertiaryButton" id="show-download-dialog"><i class="fa-solid fa-download"></i> Download images</button>
|
||||
<div class="display-settings">
|
||||
<button id="undo" class="displayNone primaryButton">
|
||||
Undo <i class="fa-solid fa-rotate-left icon"></i>
|
||||
@ -464,10 +464,16 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="popup" id="download-images-popup">
|
||||
<dialog id="download-images-dialog">
|
||||
<div class="dialog-header">
|
||||
<div class="dialog-header-left">
|
||||
<h4>Download all images</h4>
|
||||
<span></span>
|
||||
</div>
|
||||
<div>
|
||||
<i class="close-button fa-solid fa-xmark"></i>
|
||||
<h1>Download all images</h1>
|
||||
<i id="download-images-close-button" class="fa-solid fa-xmark fa-lg"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="parameters-table">
|
||||
<div>
|
||||
<div><i class="fa fa-file-zipper"></i></div>
|
||||
@ -485,10 +491,10 @@
|
||||
<div><div class="input-toggle"><input id="json_toggle" name="json_toggle" checked="" type="checkbox"><label for="json_toggle"></label></div></div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="center">
|
||||
<button id="save-all-images" class="primaryButton"><i class="fa-solid fa-images"></i> Start download</button>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
<div id="save-settings-config" class="popup">
|
||||
<div>
|
||||
<i class="close-button fa-solid fa-xmark"></i>
|
||||
|
@ -485,7 +485,7 @@ dialog {
|
||||
}
|
||||
|
||||
dialog::backdrop {
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
background: var(--backdrop-color);
|
||||
}
|
||||
|
||||
dialog > div {
|
||||
@ -1448,10 +1448,18 @@ button#save-system-settings-btn {
|
||||
line-height: 200%;
|
||||
}
|
||||
|
||||
#download-images-popup .parameters-table > div {
|
||||
#download-images-dialog .parameters-table > div {
|
||||
background: var(--background-color1);
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.fa-xmark {
|
||||
cursor: pointer;;
|
||||
}
|
||||
|
||||
/* SCROLLBARS */
|
||||
:root {
|
||||
--scrollbar-width: 14px;
|
||||
|
@ -1,4 +1,4 @@
|
||||
:root {
|
||||
:root, ::backdrop {
|
||||
--main-hue: 222;
|
||||
--main-saturation: 4%;
|
||||
--value-base: 13%;
|
||||
|
@ -565,12 +565,6 @@ modifierSettingsCloseBtn.addEventListener("click", (e) => {
|
||||
modifierSettingsDialog.close()
|
||||
})
|
||||
|
||||
modifierSettingsDialog.addEventListener('mousedown', function (event) {
|
||||
var rect = modifierSettingsDialog.getBoundingClientRect();
|
||||
var isInDialog=(rect.top <= event.clientY && event.clientY <= rect.top + rect.height
|
||||
&& rect.left <= event.clientX && event.clientX <= rect.left + rect.width);
|
||||
if (!isInDialog) {
|
||||
modifierSettingsDialog.close();
|
||||
}
|
||||
});
|
||||
modalDialogCloseOnBackdropClick(modifierSettingsDialog)
|
||||
makeDialogDraggable(modifierSettingsDialog)
|
||||
|
||||
|
@ -132,9 +132,10 @@ let initialText = document.querySelector("#initial-text")
|
||||
let versionText = document.querySelector("#version")
|
||||
let previewTools = document.querySelector("#preview-tools")
|
||||
let clearAllPreviewsBtn = document.querySelector("#clear-all-previews")
|
||||
let showDownloadPopupBtn = document.querySelector("#show-download-popup")
|
||||
let saveAllImagesPopup = document.querySelector("#download-images-popup")
|
||||
let showDownloadDialogBtn = document.querySelector("#show-download-dialog")
|
||||
let saveAllImagesDialog = document.querySelector("#download-images-dialog")
|
||||
let saveAllImagesBtn = document.querySelector("#save-all-images")
|
||||
let saveAllImagesCloseBtn = document.querySelector("#download-images-close-button")
|
||||
let saveAllZipToggle = document.querySelector("#zip_toggle")
|
||||
let saveAllTreeToggle = document.querySelector("#tree_toggle")
|
||||
let saveAllJSONToggle = document.querySelector("#json_toggle")
|
||||
@ -1503,9 +1504,10 @@ clearAllPreviewsBtn.addEventListener("click", (e) => {
|
||||
})
|
||||
|
||||
/* Download images popup */
|
||||
showDownloadPopupBtn.addEventListener("click", (e) => {
|
||||
saveAllImagesPopup.classList.add("active")
|
||||
})
|
||||
showDownloadDialogBtn.addEventListener("click", (e) => { saveAllImagesDialog.showModal() })
|
||||
saveAllImagesCloseBtn.addEventListener("click", (e) => { saveAllImagesDialog.close() })
|
||||
modalDialogCloseOnBackdropClick(saveAllImagesDialog)
|
||||
makeDialogDraggable(saveAllImagesDialog)
|
||||
|
||||
saveAllZipToggle.addEventListener("change", (e) => {
|
||||
if (saveAllZipToggle.checked) {
|
||||
|
@ -1055,3 +1055,58 @@ async function deleteKeys(keyToDelete) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function modalDialogCloseOnBackdropClick(dialog) {
|
||||
dialog.addEventListener('mousedown', function (event) {
|
||||
var rect = dialog.getBoundingClientRect()
|
||||
var isInDialog=(rect.top <= event.clientY && event.clientY <= rect.top + rect.height
|
||||
&& rect.left <= event.clientX && event.clientX <= rect.left + rect.width)
|
||||
if (!isInDialog) {
|
||||
dialog.close()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function makeDialogDraggable(element) {
|
||||
element.querySelector(".dialog-header").addEventListener('mousedown', (function() {
|
||||
let deltaX=0
|
||||
let deltaY=0
|
||||
let dragStartX=0
|
||||
let dragStartY=0
|
||||
let oldTop=0
|
||||
let oldLeft=0
|
||||
|
||||
function dlgDragStart(e) {
|
||||
e = e || window.event;
|
||||
const d = e.target.closest("dialog")
|
||||
e.preventDefault();
|
||||
dragStartX = e.clientX;
|
||||
dragStartY = e.clientY;
|
||||
oldTop = parseInt(d.style.top)
|
||||
oldLeft = parseInt(d.style.left)
|
||||
if (isNaN(oldTop)) { oldTop=0 }
|
||||
if (isNaN(oldLeft)) { oldLeft=0 }
|
||||
document.addEventListener('mouseup', dlgDragClose);
|
||||
document.addEventListener('mousemove', dlgDrag);
|
||||
}
|
||||
|
||||
function dlgDragClose(e) {
|
||||
document.removeEventListener('mouseup', dlgDragClose);
|
||||
document.removeEventListener('mousemove', dlgDrag);
|
||||
}
|
||||
|
||||
function dlgDrag(e) {
|
||||
e = e || window.event;
|
||||
const d = e.target.closest("dialog")
|
||||
e.preventDefault();
|
||||
deltaX = dragStartX - e.clientX;
|
||||
deltaY = dragStartY - e.clientY;
|
||||
d.style.left = `${oldLeft-2*deltaX}px`
|
||||
d.style.top = `${oldTop-2*deltaY}px`
|
||||
}
|
||||
|
||||
return dlgDragStart
|
||||
})() )
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
<h4>Download tiled image</h4>
|
||||
<span>Generate a larger image from this tile</span>
|
||||
</div>
|
||||
<div id="modifier-settings-header-right">
|
||||
<div id="download-header-right">
|
||||
<i id="downnload-tiled-close-button" class="fa-solid fa-xmark fa-lg"></i>
|
||||
</div>
|
||||
</div>
|
||||
@ -139,14 +139,8 @@
|
||||
// ---- Close popup
|
||||
document.getElementById("dti-cancel").addEventListener("click", (e) => downloadTiledImageDialog.close())
|
||||
document.getElementById("downnload-tiled-close-button").addEventListener("click", (e) => downloadTiledImageDialog.close())
|
||||
downloadTiledImageDialog.addEventListener('click', function (event) {
|
||||
var rect = downloadTiledImageDialog.getBoundingClientRect();
|
||||
var isInDialog=(rect.top <= event.clientY && event.clientY <= rect.top + rect.height
|
||||
&& rect.left <= event.clientX && event.clientX <= rect.left + rect.width);
|
||||
if (!isInDialog) {
|
||||
downloadTiledImageDialog.close();
|
||||
}
|
||||
});
|
||||
modalDialogCloseOnBackdropClick(downloadTiledImageDialog)
|
||||
makeDialogDraggable(downloadTiledImageDialog)
|
||||
|
||||
// ---- Stylesheet
|
||||
const styleSheet = document.createElement("style")
|
||||
|
Loading…
Reference in New Issue
Block a user