mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-03-26 14:56:28 +01:00
Collapsibles for the embeddings dialog
Harmonization with the modifiers dialog
This commit is contained in:
parent
14c1d17632
commit
7debd2cd97
@ -582,6 +582,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
<button id="embeddings-action-collapsibles-btn" class="tertiaryButton smallButton">
|
||||||
|
<i class="embeddings-action-icon fa-solid fa-square-plus"></i>
|
||||||
|
<span class="embeddings-action-text">Expand Categories</span>
|
||||||
|
</button>
|
||||||
<i class="fa-solid fa-magnifying-glass"></i>
|
<i class="fa-solid fa-magnifying-glass"></i>
|
||||||
<input id="embeddings-search-box" type="text" spellcheck="false" autocomplete="off" placeholder="Search...">
|
<input id="embeddings-search-box" type="text" spellcheck="false" autocomplete="off" placeholder="Search...">
|
||||||
<span style="float:right;"><label>Mode:</label> <select id="embeddings-mode"><option value="insert">Insert at cursor position</option><option value="append">Append at the end</option></select>
|
<span style="float:right;"><label>Mode:</label> <select id="embeddings-mode"><option value="insert">Insert at cursor position</option><option value="append">Append at the end</option></select>
|
||||||
|
@ -1670,7 +1670,11 @@ body.wait-pause {
|
|||||||
|
|
||||||
#embeddings-list {
|
#embeddings-list {
|
||||||
height: 70vH;
|
height: 70vH;
|
||||||
width: 40vW;
|
width: 50vW;
|
||||||
|
margin-left: 0px;
|
||||||
|
margin-right: 0px;
|
||||||
|
padding-left: 0px;
|
||||||
|
padding-right: 0px;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1679,6 +1683,30 @@ body.wait-pause {
|
|||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#embeddings-list .collapsible {
|
||||||
|
background: var(--background-color3);
|
||||||
|
margin: 0px;
|
||||||
|
padding: 0.5em;
|
||||||
|
position: sticky;
|
||||||
|
}
|
||||||
|
|
||||||
|
#embeddings-list .embedding-category:nth-child(odd) .collapsible::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background-color: rgba(255, 255, 255, 0.02);
|
||||||
|
opacity: 1;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#embeddings-list .collapsible-content {
|
||||||
|
padding-top: 0.4em;
|
||||||
|
padding-bottom: 0.4em;
|
||||||
|
}
|
||||||
|
|
||||||
#embeddings-list::-webkit-scrollbar-thumb {
|
#embeddings-list::-webkit-scrollbar-thumb {
|
||||||
background: var(--background-color3);
|
background: var(--background-color3);
|
||||||
}
|
}
|
||||||
|
@ -425,27 +425,11 @@ function checkIfClickedOutsideDropdownElem(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function collapseAllModifierCategory() {
|
function collapseAllModifierCategory() {
|
||||||
const collapsibleElems = editorModifierEntries.querySelectorAll(".modifier-category .collapsible"); // needs to have ";"
|
collapseAll(".modifier-category .collapsible")
|
||||||
|
|
||||||
[...collapsibleElems].forEach((elem) => {
|
|
||||||
const isActive = elem.classList.contains("active")
|
|
||||||
|
|
||||||
if(isActive) {
|
|
||||||
elem?.click()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function expandAllModifierCategory() {
|
function expandAllModifierCategory() {
|
||||||
const collapsibleElems = editorModifierEntries.querySelectorAll(".modifier-category .collapsible"); // needs to have ";"
|
expandAll(".modifier-category .collapsible")
|
||||||
|
|
||||||
[...collapsibleElems].forEach((elem) => {
|
|
||||||
const isActive = elem.classList.contains("active")
|
|
||||||
|
|
||||||
if (!isActive) {
|
|
||||||
elem?.click()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
customModifiersTextBox.addEventListener("change", saveCustomModifiers)
|
customModifiersTextBox.addEventListener("change", saveCustomModifiers)
|
||||||
|
@ -119,6 +119,7 @@ let embeddingsDialogCloseBtn = embeddingsDialog.querySelector("#embeddings-dialo
|
|||||||
let embeddingsSearchBox = document.querySelector("#embeddings-search-box")
|
let embeddingsSearchBox = document.querySelector("#embeddings-search-box")
|
||||||
let embeddingsList = document.querySelector("#embeddings-list")
|
let embeddingsList = document.querySelector("#embeddings-list")
|
||||||
let embeddingsModeField = document.querySelector("#embeddings-mode")
|
let embeddingsModeField = document.querySelector("#embeddings-mode")
|
||||||
|
let embeddingsCollapsiblesBtn = document.querySelector("#embeddings-action-collapsibles-btn")
|
||||||
|
|
||||||
let makeImageBtn = document.querySelector("#makeImage")
|
let makeImageBtn = document.querySelector("#makeImage")
|
||||||
let stopImageBtn = document.querySelector("#stopImage")
|
let stopImageBtn = document.querySelector("#stopImage")
|
||||||
@ -2150,7 +2151,7 @@ function updateEmbeddingsList(filter = "") {
|
|||||||
} else {
|
} else {
|
||||||
let subdir = html(m[1], prefix + m[0] + "/", filter)
|
let subdir = html(m[1], prefix + m[0] + "/", filter)
|
||||||
if (subdir != "") {
|
if (subdir != "") {
|
||||||
folders += `<h4>${prefix}${m[0]}</h4>` + subdir
|
folders += `<div class="embedding-category"><h4 class="collapsible">${prefix}${m[0]}</h4><div class="collapsible-content">` + subdir + '</div></div>'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -2159,7 +2160,6 @@ function updateEmbeddingsList(filter = "") {
|
|||||||
|
|
||||||
function onButtonClick(e) {
|
function onButtonClick(e) {
|
||||||
let text = e.target.dataset["embedding"]
|
let text = e.target.dataset["embedding"]
|
||||||
console.log(e.shiftKey, text)
|
|
||||||
|
|
||||||
if (embeddingsModeField.value == "insert") {
|
if (embeddingsModeField.value == "insert") {
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
@ -2197,6 +2197,10 @@ function updateEmbeddingsList(filter = "") {
|
|||||||
embeddingsList.querySelectorAll("button").forEach((b) => {
|
embeddingsList.querySelectorAll("button").forEach((b) => {
|
||||||
b.addEventListener("click", onButtonClick)
|
b.addEventListener("click", onButtonClick)
|
||||||
})
|
})
|
||||||
|
createCollapsibles(embeddingsList)
|
||||||
|
if (filter != "") {
|
||||||
|
embeddingsExpandAll()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
embeddingsButton.addEventListener("click", () => {
|
embeddingsButton.addEventListener("click", () => {
|
||||||
@ -2214,6 +2218,51 @@ embeddingsSearchBox.addEventListener("input", (e) => {
|
|||||||
modalDialogCloseOnBackdropClick(embeddingsDialog)
|
modalDialogCloseOnBackdropClick(embeddingsDialog)
|
||||||
makeDialogDraggable(embeddingsDialog)
|
makeDialogDraggable(embeddingsDialog)
|
||||||
|
|
||||||
|
const collapseText = "Collapse Categories"
|
||||||
|
const expandText = "Expand Categories"
|
||||||
|
|
||||||
|
const collapseIconClasses = ["fa-solid", "fa-square-minus"]
|
||||||
|
const expandIconClasses = ["fa-solid", "fa-square-plus"]
|
||||||
|
|
||||||
|
function embeddingsCollapseAll() {
|
||||||
|
const btnElem = embeddingsCollapsiblesBtn
|
||||||
|
|
||||||
|
const iconElem = btnElem.querySelector(".embeddings-action-icon")
|
||||||
|
const textElem = btnElem.querySelector(".embeddings-action-text")
|
||||||
|
collapseAll("#embeddings-list .collapsible")
|
||||||
|
|
||||||
|
collapsiblesBtnState = false
|
||||||
|
|
||||||
|
collapseIconClasses.forEach((c) => iconElem.classList.remove(c))
|
||||||
|
expandIconClasses.forEach((c) => iconElem.classList.add(c))
|
||||||
|
|
||||||
|
textElem.innerText = expandText
|
||||||
|
}
|
||||||
|
|
||||||
|
function embeddingsExpandAll() {
|
||||||
|
const btnElem = embeddingsCollapsiblesBtn
|
||||||
|
|
||||||
|
const iconElem = btnElem.querySelector(".embeddings-action-icon")
|
||||||
|
const textElem = btnElem.querySelector(".embeddings-action-text")
|
||||||
|
expandAll("#embeddings-list .collapsible")
|
||||||
|
|
||||||
|
collapsiblesBtnState = true
|
||||||
|
|
||||||
|
expandIconClasses.forEach((c) => iconElem.classList.remove(c))
|
||||||
|
collapseIconClasses.forEach((c) => iconElem.classList.add(c))
|
||||||
|
|
||||||
|
textElem.innerText = collapseText
|
||||||
|
}
|
||||||
|
|
||||||
|
embeddingsCollapsiblesBtn.addEventListener("click", (e) => {
|
||||||
|
if (collapsiblesBtnState) {
|
||||||
|
embeddingsCollapseAll()
|
||||||
|
} else {
|
||||||
|
embeddingsExpandAll()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
if (testDiffusers.checked) {
|
if (testDiffusers.checked) {
|
||||||
document.getElementById("embeddings-container").classList.remove("displayNone")
|
document.getElementById("embeddings-container").classList.remove("displayNone")
|
||||||
}
|
}
|
||||||
|
@ -129,6 +129,31 @@ function tryLoadOldCollapsibles() {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function collapseAll(selector) {
|
||||||
|
const collapsibleElems = document.querySelectorAll(selector); // needs to have ";"
|
||||||
|
|
||||||
|
[...collapsibleElems].forEach((elem) => {
|
||||||
|
const isActive = elem.classList.contains("active")
|
||||||
|
|
||||||
|
if(isActive) {
|
||||||
|
elem?.click()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function expandAll(selector) {
|
||||||
|
const collapsibleElems = document.querySelectorAll(selector); // needs to have ";"
|
||||||
|
|
||||||
|
[...collapsibleElems].forEach((elem) => {
|
||||||
|
const isActive = elem.classList.contains("active")
|
||||||
|
|
||||||
|
if (!isActive) {
|
||||||
|
elem?.click()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function permute(arr) {
|
function permute(arr) {
|
||||||
let permutations = []
|
let permutations = []
|
||||||
let n = arr.length
|
let n = arr.length
|
||||||
|
Loading…
Reference in New Issue
Block a user