blob: fe71098d6966817bf94d2e4146b20949fab1e702 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
class AminoAcidSelector {
constructor(elt) {
this.elt = elt
for (const elt of this.elt.querySelectorAll('li')) {
elt.addEventListener('click', this.select.bind(this))
}
}
attach() {
this.elt.classList.remove('hidden')
}
detach() {
this.elt.classList.add('hidden')
}
get onItemSelected() {
if (this._onItemSelected !== undefined) {
return this._onItemSelected
}
return () => {}
}
set onItemSelected(fn) {
this._onItemSelected = fn
}
select(evt) {
this.onItemSelected(evt.currentTarget.innerText)
}
}
export default AminoAcidSelector
|