forked from extern/easydiffusion
Add support for disabled state to model dropdown (#886)
* Add support for disabled state to model dropdown As per https://discord.com/channels/1014774730907209781/1021695193499582494/1075068193753804831 The only limitation is that we cannot visually gray out the chevron itself because the corresponding font-awesome icon is a Pro icon (https://fontawesome.com/icons/angle-down?s=duotone&f=classic). * Gray out the chevron when the control is disabled * Remove empty line * Disable the transition on the chevron Apply effect immediately when the dropdown is enabled/disabled.
This commit is contained in:
parent
9f5f213cd3
commit
282c4cca82
@ -75,6 +75,7 @@
|
||||
padding-top: 3px;
|
||||
cursor: pointer;
|
||||
font-size: 8pt;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
.model-input {
|
||||
|
@ -53,6 +53,15 @@ class ModelDropdown
|
||||
this.modelFilter.dataset.path = path
|
||||
this.selectEntry(path)
|
||||
}
|
||||
get disabled() {
|
||||
return this.modelFilter.disabled
|
||||
}
|
||||
set disabled(state) {
|
||||
this.modelFilter.disabled = state
|
||||
if (this.modelFilterArrow) {
|
||||
this.modelFilterArrow.style.color = state ? 'dimgray' : ''
|
||||
}
|
||||
}
|
||||
addEventListener(type, listener, options) {
|
||||
return this.modelFilter.addEventListener(type, listener, options)
|
||||
}
|
||||
@ -350,13 +359,15 @@ class ModelDropdown
|
||||
|
||||
toggleModelList(e) {
|
||||
e.preventDefault()
|
||||
if (this.modelList.style.display != 'block') {
|
||||
this.showModelList()
|
||||
}
|
||||
else
|
||||
{
|
||||
this.hideModelList()
|
||||
this.modelFilter.select()
|
||||
if (!this.modelFilter.disabled) {
|
||||
if (this.modelList.style.display != 'block') {
|
||||
this.showModelList()
|
||||
}
|
||||
else
|
||||
{
|
||||
this.hideModelList()
|
||||
this.modelFilter.select()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -547,6 +558,9 @@ class ModelDropdown
|
||||
this.modelFilter.insertAdjacentHTML('afterend', this.parseModels(this.flatModelList))
|
||||
this.modelFilter.classList.add('model-selector')
|
||||
this.modelFilterArrow = document.querySelector(`#${this.modelFilter.id}-model-filter-arrow`)
|
||||
if (this.modelFilterArrow) {
|
||||
this.modelFilterArrow.style.color = state ? 'dimgray' : ''
|
||||
}
|
||||
this.modelList = document.querySelector(`#${this.modelFilter.id}-model-list`)
|
||||
this.modelResult = document.querySelector(`#${this.modelFilter.id}-model-result`)
|
||||
this.modelNoResult = document.querySelector(`#${this.modelFilter.id}-model-no-result`)
|
||||
|
Loading…
Reference in New Issue
Block a user