445
437
(Js.number_of_float 0.));
446
438
Js._true
447
439
448
-
Removed:
(* The feedback modal uses the same native dialog behavior as workout
449
-
Removed:
cancellation. The trigger remains a normal link, so no-script clients open
450
-
Removed:
the server-rendered modal page instead, and Close is a link back to the
451
-
Removed:
logbook that the client turns into an in-place dismiss. The form itself
452
-
Removed:
submits through the shared app-form path. *)
440
+
Added:
(* The feedback modal page renders the dialog with [open]. The client upgrades
441
+
Added:
it to a true modal after each swap. Close is a link back to the logbook that
442
+
Added:
the client turns into an in-place dismiss. The form itself submits through
443
+
Added:
the shared app-form path. *)
453
444
let feedback_click event =
454
-
Removed:
let target = Dom_html.eventTarget event in
455
-
Removed:
match closest "[data-hito-feedback-open]" target with
456
-
Removed:
| Some _ ->
445
+
Added:
match closest "[data-hito-feedback-dismiss]" (Dom_html.eventTarget event) with
446
+
Added:
| Some dismiss ->
457
447
Dom.preventDefault event;
458
-
Removed:
open_feedback_modal ();
448
+
Added:
close_feedback_modal ();
449
+
Added:
(match href dismiss with
450
+
Added:
| Some url ->
451
+
Added:
Dom_html.window##.history##replaceState
452
+
Added:
Js.null (Js.string "")
453
+
Added:
(Js.some (Js.string url))
454
+
Added:
| None -> ());
459
455
Js._false
460
-
Removed:
| None -> (
461
-
Removed:
match closest "[data-hito-feedback-dismiss]" target with
462
-
Removed:
| Some dismiss ->
463
-
Removed:
Dom.preventDefault event;
464
-
Removed:
close_feedback_modal ();
465
-
Removed:
(match href dismiss with
466
-
Removed:
| Some url ->
467
-
Removed:
Dom_html.window##.history##replaceState
468
-
Removed:
Js.null (Js.string "")
469
-
Removed:
(Js.some (Js.string url))
470
-
Removed:
| None -> ());
471
-
Removed:
Js._false
472
-
Removed:
| None -> Js._true)
456
+
Added:
| None -> Js._true
473
457
458
+
Added:
(* One delegated click listener. Every handler sees every click, as separate
459
+
Added:
listeners would. A handler that consumes the click returns [false]. *)
460
+
Added:
let click event =
461
+
Added:
let handled =
462
+
Added:
List.map
463
+
Added:
(fun handler -> Js.to_bool (handler event))
464
+
Added:
[ link_click; feedback_click; dialog_click; confirm_click ]
465
+
Added:
in
466
+
Added:
Js.bool (List.for_all Fun.id handled)
467
+
Added:
474
468
let () =
475
469
Dom_html.addEventListener document Dom_html.Event.click
476
-
Removed:
(Dom_html.handler link_click)
477
-
Removed:
Js._false
470
+
Added:
(Dom_html.handler click) Js._false
478
471
|> ignore;
479
472
Dom_html.addEventListener document Dom_html.Event.submit
480
473
(Dom_html.handler form_submit)