menu/dropdown/switch: unfinished unification
This commit is contained in:
parent
e21ffa520d
commit
41f2ce5210
5 changed files with 10 additions and 8 deletions
|
|
@ -69,7 +69,7 @@ class Dropdown extends MenuBase {
|
|||
|
||||
setValue(v,options={}) {
|
||||
|
||||
var i = this.values.indexOf(v)
|
||||
var i = this.getIndex(v)
|
||||
|
||||
this.value = this.values[i]
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class MenuBase extends Widget {
|
|||
if (deepEqual(value, this.values[i])) return i
|
||||
}
|
||||
}
|
||||
return i
|
||||
return index
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -251,16 +251,17 @@ class Menu extends MenuBase {
|
|||
|
||||
setValue(v,options={}) {
|
||||
|
||||
var i = this.values.indexOf(v)
|
||||
var i = this.getIndex(v)
|
||||
|
||||
if (i > -1) {
|
||||
if (i !== -1) {
|
||||
this.value = this.values[i]
|
||||
this.selected = i
|
||||
DOM.each(this.menu, '.on', (el)=>{el.classList.remove('on')})
|
||||
DOM.get(this.menu, '.item')[i].classList.add('on')
|
||||
this.text.innerHTML = iconify(this.keys[i])
|
||||
|
||||
}
|
||||
|
||||
DOM.each(this.menu, '.on', (el)=>{el.classList.remove('on')})
|
||||
if (i > -1) DOM.get(this.menu, '.item')[i].classList.add('on')
|
||||
this.text.innerHTML = iconify(this.keys[i])
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.changed(options)
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class Switch extends MenuBase {
|
|||
|
||||
setValue(v, options={}) {
|
||||
|
||||
var i = this.values.indexOf(v)
|
||||
var i = this.getIndex(v)
|
||||
|
||||
|
||||
if (i !== -1) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue