@@ -44,4 +44,30 @@ defmodule LiveCalWeb.CalendarLive.Index do
44
44
45
45
{ :noreply , stream_delete ( socket , :calendars , calendar ) }
46
46
end
47
+
48
+ def accessible_js_toggle_1 ( js \\ % JS { } , [ to: selector ] ) do
49
+ js
50
+ |> JS . remove_attribute ( "aria-hidden" , to: selector <> "[style*='display: none']" )
51
+ |> JS . set_attribute ( { "aria-hidden" , "true" } , to: selector <> ":not([style*='display: none'])" )
52
+ |> JS . remove_class ( "invisible" , to: selector <> "[style*='display: none']" )
53
+ |> JS . add_class ( "invisible" , to: selector <> ":not([style*='display: none'])" )
54
+ |> JS . toggle ( to: selector )
55
+ end
56
+
57
+ def accessible_js_toggle_2 ( js \\ % JS { } , [ to: selector ] ) do
58
+ js
59
+ |> JS . remove_attribute ( "aria-hidden" , to: selector <> ".invisible" )
60
+ |> JS . set_attribute ( { "aria-hidden" , "true" } , to: selector <> ":not(.invisible)" )
61
+ |> JS . remove_class ( "invisible" , to: selector <> ".invisible" )
62
+ |> JS . add_class ( "invisible" , to: selector <> ":not(.invisible)" )
63
+ |> JS . toggle ( to: selector )
64
+ end
65
+
66
+ # note: toggling while selecting by attribute does not work
67
+ #def accessible_js_toggle_3(js \\ %JS{}, [to: selector]) do
68
+ #js
69
+ #|> JS.remove_attribute("aria-hidden", to: selector <> "[aria-hidden='true']")
70
+ #|> JS.set_attribute({"aria-hidden", "true"}, to: selector <> ":not([aria-hidden='true'])")
71
+ #|> JS.toggle(to: selector)
72
+ #end
47
73
end
0 commit comments