diff options
Diffstat (limited to 'editor')
| -rwxr-xr-x | editor/ui.ml | 30 | 
1 files changed, 19 insertions, 11 deletions
| diff --git a/editor/ui.ml b/editor/ui.ml index a4f5416..2cd8ff8 100755 --- a/editor/ui.ml +++ b/editor/ui.ml @@ -5,7 +5,14 @@ module Js = Js_of_ocaml.Js  let popup    : title:Jstr.t -> ?form:Forms.Events.t option -> 'a option Note.E.send -> El.t    = fun ~title ?(form = None) send -> -    let _ = send in + +    (* Ensure we keep a track for the signal event. + +       This looks a bit like the old memory magment in C, as it require to +       destroy the logger each time the popup is removed. *) +    let log_opt = Option.map +        (fun (values, _) -> Note.S.log values (fun _ -> ())) +        form in      let close_btn =        El.span @@ -15,7 +22,10 @@ let popup      Evr.endless_listen        (El.as_target close_btn)        Ev.click -      (fun _ -> send None); +      (fun _ -> +         Option.iter Note.Logr.destroy log_opt; +         send None +      );      let container = match form with        | None -> El.div @@ -25,26 +35,24 @@ let popup        | None -> El.div []        | Some (_, content) -> content -      and footer = match form with        | None -> El.txt Jstr.empty        | Some (values, _) -> - -        let log = Note.S.log values (fun _ -> ()) in -          let btn = El.input ()              ~at:At.[type' (Jstr.v "submit")] in          Evr.endless_listen            (El.as_target btn)            Ev.click -          (fun _ -> Note.Logr.force log -                  ; send (Some (Note.S.value values))); +          (fun _ -> +             Option.iter Note.Logr.force log_opt; +             let form_content = (Note.S.value values) in +             Option.iter Note.Logr.destroy log_opt; +             send (Some form_content)); -        El.div ~at:At.[class' (Jstr.v "row")] -          [ btn ] -    in +        El.div [ btn ] +          ~at:At.[class' (Jstr.v "row")] in      let el = El.div          ~at:At.[class' (Jstr.v "modal")] | 
