mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-05-30 22:55:40 +02:00
Simplify the logic for toggling modifier cards, no need to loop through the cards, since we already have the card object in hand
This commit is contained in:
parent
f74fa8657b
commit
159c3edfe3
@ -90,7 +90,7 @@ function createModifierGroup(modifierGroup, initiallyExpanded) {
|
|||||||
if (activeTags.map(x => x.name).includes(modifierName)) {
|
if (activeTags.map(x => x.name).includes(modifierName)) {
|
||||||
// remove modifier from active array
|
// remove modifier from active array
|
||||||
activeTags = activeTags.filter(x => x.name != modifierName)
|
activeTags = activeTags.filter(x => x.name != modifierName)
|
||||||
toggleCardState(modifierName, false)
|
toggleCardState(modifierCard, false)
|
||||||
} else {
|
} else {
|
||||||
// add modifier to active array
|
// add modifier to active array
|
||||||
activeTags.push({
|
activeTags.push({
|
||||||
@ -99,7 +99,7 @@ function createModifierGroup(modifierGroup, initiallyExpanded) {
|
|||||||
'originElement': modifierCard,
|
'originElement': modifierCard,
|
||||||
'previews': modifierPreviews
|
'previews': modifierPreviews
|
||||||
})
|
})
|
||||||
toggleCardState(modifierName, true)
|
toggleCardState(modifierCard, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshTagsList()
|
refreshTagsList()
|
||||||
@ -217,7 +217,7 @@ function refreshTagsList() {
|
|||||||
let idx = activeTags.indexOf(tag)
|
let idx = activeTags.indexOf(tag)
|
||||||
|
|
||||||
if (idx !== -1 && activeTags[idx].originElement !== undefined) {
|
if (idx !== -1 && activeTags[idx].originElement !== undefined) {
|
||||||
toggleCardState(activeTags[idx].name, false)
|
toggleCardState(activeTags[idx].originElement, false)
|
||||||
|
|
||||||
activeTags.splice(idx, 1)
|
activeTags.splice(idx, 1)
|
||||||
refreshTagsList()
|
refreshTagsList()
|
||||||
@ -230,20 +230,14 @@ function refreshTagsList() {
|
|||||||
editorModifierTagsList.appendChild(brk)
|
editorModifierTagsList.appendChild(brk)
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleCardState(modifierName, makeActive) {
|
function toggleCardState(card, makeActive) {
|
||||||
document.querySelector('#editor-modifiers').querySelectorAll('.modifier-card').forEach(card => {
|
if (makeActive) {
|
||||||
const name = card.querySelector('.modifier-card-label').innerText
|
card.classList.add(activeCardClass)
|
||||||
if (modifierName == name) {
|
card.querySelector('.modifier-card-image-overlay').innerText = '-'
|
||||||
if(makeActive) {
|
} else {
|
||||||
card.classList.add(activeCardClass)
|
card.classList.remove(activeCardClass)
|
||||||
card.querySelector('.modifier-card-image-overlay').innerText = '-'
|
card.querySelector('.modifier-card-image-overlay').innerText = '+'
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
card.classList.remove(activeCardClass)
|
|
||||||
card.querySelector('.modifier-card-image-overlay').innerText = '+'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function changePreviewImages(val) {
|
function changePreviewImages(val) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user