diff options
author | Sébastien Dailly <sebastien@chimrod.com> | 2021-05-23 22:09:50 +0200 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2022-02-07 16:43:33 +0100 |
commit | 1eeaf137bd30aff1bef34d05eeec686f6da8959d (patch) | |
tree | 63589546a32b72382e94f1ee16cf671cec911648 /editor/actions.ml | |
parent | 97f3ac8054de22b94e4ae169dae33ed5b1b41a52 (diff) |
Update editor
Diffstat (limited to 'editor/actions.ml')
-rwxr-xr-x | editor/actions.ml | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/editor/actions.ml b/editor/actions.ml deleted file mode 100755 index 0f107f9..0000000 --- a/editor/actions.ml +++ /dev/null @@ -1,120 +0,0 @@ -open StdLabels -open Js_of_ocaml -open Brr -open Brr_note - -type button_actions = - { delete : unit Note.event - ; redirect : Jstr.t option Note.event - ; add: unit Note.event - } - -let populate_menu () = - match Blog.Sidebar.get () with - | None -> None - | Some element -> - let () = Blog.Sidebar.clean element in - - let delete_button = El.button - ~at:At.[ class' (Jstr.v "action-button") ] - [ El.i [] - ~at:At.[ class' (Jstr.v "fa") - ; class' (Jstr.v "fa-2x") - ; class' (Jstr.v "fa-trash") ] ] - - and home_button = El.button - ~at:At.[ class' (Jstr.v "action-button") ] - [ El.i [] - ~at:At.[ class' (Jstr.v "fa") - ; class' (Jstr.v "fa-2x") - ; class' (Jstr.v "fa-home") ] ] - - and add_button = El.button - ~at:At.[ class' (Jstr.v "action-button") ] - [ El.i [] - ~at:At.[ class' (Jstr.v "fa") - ; class' (Jstr.v "fa-2x") - ; class' (Jstr.v "fa-plus") ] ] - - in - - let delete_event = - Evr.on_el - Ev.click - Evr.unit - delete_button - - and add_event = - Evr.on_el - Ev.click - Evr.unit - add_button in - - let stored_pages = State.Storage.get_ids () in - let pages = - List.map - stored_pages - ~f:(fun id -> - - let name_opt = (State.Storage.load (Some id))##.title in - let name = Js.Opt.get - name_opt - (fun () -> id) in - - let target = Jstr.v "#" in - El.li - [ El.a - ~at:[At.href target] - [ El.txt name ] ] - ) in - - (* Wait for a click on an existing page in order to sent the associated - event. - - We compose the resulting event with both : - - the home button - - the list for all the pages presents in the sidebar *) - let redirect_event = Note.E.select - (( Evr.on_el - Ev.click - (fun _ -> None) - home_button - ) :: ( - List.map2 stored_pages pages - ~f:(fun name el -> - Evr.on_el - Ev.click - (fun _ -> Some name) - el ))) in - - let childs = - [ home_button - ; add_button - ; El.button - ~at:At.[class' (Jstr.v "action-button")] - [ El.i - [] - ~at:At.[ class' (Jstr.v "fa") - ; class' (Jstr.v "fa-2x") - ; class' (Jstr.v "fa-download") ] - ] - ; delete_button - ; El.button - ~at:At.[class' (Jstr.v "action-button")] - [ El.i - [] - ~at:At.[ class' (Jstr.v "fa") - ; class' (Jstr.v "fa-2x") - ; class' (Jstr.v "fa-cog") ] - ] - ; El.hr () - ; El.ul - pages - ] in - - let () = El.append_children element childs in - Some - { delete = delete_event - ; redirect = redirect_event - ; add = add_event - } |