@@ -25,7 +25,7 @@ class DropdownHandler:
25
25
val ver = JSON .parse(json).asInstanceOf [Versions ]
26
26
val ddc = document.getElementById(" version-dropdown" )
27
27
for (k, v) <- ver.versions do
28
- val child = span (cls := " text-button" , href := v)(k)
28
+ val child = a (cls := " text-button" , href := v)(k)
29
29
ddc.appendChild(child)
30
30
val arrow = span(cls := " ar" )()
31
31
document.getElementById(" dropdown-button" ).appendChild(arrow)
@@ -59,7 +59,7 @@ class DropdownHandler:
59
59
addVersionsList(json)
60
60
61
61
document.addEventListener(" click" , (e : Event ) => {
62
- document.getElementById(" dropdown-content " ).classList.remove(" show" )
62
+ document.getElementById(" version-dropdown " ).classList.remove(" show" )
63
63
document.getElementById(" dropdown-button" ).classList.remove(" expanded" )
64
64
})
65
65
@@ -68,7 +68,24 @@ end DropdownHandler
68
68
69
69
@ JSExportTopLevel (" dropdownHandler" )
70
70
def dropdownHandler () =
71
- // if document.getElementById("dropdown-content").getElementsByTagName("a").size > 0 &&
72
- // window.getSelection.toString.length == 0 then
73
- document.getElementById(" version-dropdown" ).classList.toggle(" expanded" )
74
- // document.getElementById("dropdown-button").classList.toggle("expanded")
71
+ if document.getElementById(" version-dropdown" ).getElementsByTagName(" a" ).size > 0 &&
72
+ window.getSelection.toString.length == 0 then
73
+ document.getElementById(" version-dropdown" ).classList.toggle(" show" )
74
+ document.getElementById(" dropdown-button" ).classList.toggle(" expanded" )
75
+ document.getElementById(" dropdown-input" ).asInstanceOf [html.Input ].focus()
76
+
77
+ @ JSExportTopLevel (" filterFunction" )
78
+ def filterFunction () =
79
+ val input = document.getElementById(" dropdown-input" ).asInstanceOf [html.Input ]
80
+ val filter = input.value.toUpperCase
81
+ val div = document.getElementById(" version-dropdown" )
82
+ val as = div.getElementsByTagName(" a" )
83
+
84
+ as.foreach { a =>
85
+ val txtValue = a.innerText
86
+ val cl = a.asInstanceOf [html.Anchor ].classList
87
+ if txtValue.toUpperCase.indexOf(filter) > - 1 then
88
+ cl.remove(" filtered" )
89
+ else
90
+ cl.add(" filtered" )
91
+ }
0 commit comments