Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/widgets/ot_calendar.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,10 @@ let make :

let%server make :
?init:int * int * int
-> ?highlight:(int -> int -> int list Lwt.t) Eliom_client_value.t
-> ?highlight:(int -> int -> int list) Eliom_client_value.t
-> ?click_non_highlighted:bool
-> ?update:(int * int * int) React.E.t Eliom_client_value.t
-> ?action:(int -> int -> int -> unit Lwt.t) Eliom_client_value.t
-> ?action:(int -> int -> int -> unit) Eliom_client_value.t
-> ?period:
CalendarLib.Date.field CalendarLib.Date.date
* CalendarLib.Date.field CalendarLib.Date.date
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/ot_calendar.eliomi
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ type button_labels =

val make :
?init:int * int * int
-> ?highlight:(int -> int -> int list Lwt.t) Eliom_client_value.t
-> ?highlight:(int -> int -> int list) Eliom_client_value.t
-> ?click_non_highlighted:bool
-> ?update:(int * int * int) React.E.t Eliom_client_value.t
-> ?action:(int -> int -> int -> unit Lwt.t) Eliom_client_value.t
-> ?action:(int -> int -> int -> unit) Eliom_client_value.t
-> ?period:
CalendarLib.Date.field CalendarLib.Date.date
* CalendarLib.Date.field CalendarLib.Date.date
Expand Down
34 changes: 17 additions & 17 deletions src/widgets/ot_carousel.eliom
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
open Eio.Std

(* Ocsigen
* http://www.ocsigen.org
*
Expand Down Expand Up @@ -39,7 +41,7 @@ open%client Js_of_ocaml
[%%client open Js_of_ocaml_lwt]
[%%shared open Eliom_content.Html]
[%%shared open Eliom_content.Html.F]
[%%shared open Lwt.Syntax]
[%%shared]

let%client clX = Ot_swipe.clX
let%client clY = Ot_swipe.clY
Expand Down Expand Up @@ -587,9 +589,7 @@ let%client set_default_fail f =
:> exn -> Html_types.div_content Eliom_content.Html.elt)

let%shared generate_content generator =
Lwt.catch
(fun () -> Eliom_shared.Value.local generator ())
(fun e -> Lwt.return (default_fail e))
try Eliom_shared.Value.local generator () with e -> default_fail e

(* on the client side we generate the contents of the initially visible page
asynchronously so the tabs will be rendered right away *)
Expand All @@ -606,8 +606,8 @@ let%client generate_initial_contents ~spinner sleeper gen =

(* on the server side we generate all the visible contents right away *)
let%server generate_initial_contents ~spinner:_ _ gen =
let* contents = generate_content gen in
Lwt.return (contents, ref @@ None)
let contents = generate_content gen in
contents, ref @@ None

let%shared
make_lazy
Expand All @@ -628,30 +628,30 @@ let%shared
=
let gen_contents =
(gen_contents
:> (unit -> Html_types.div_content elt Lwt.t) Eliom_shared.Value.t list)
:> (unit -> Html_types.div_content elt) Eliom_shared.Value.t list)
in
let sleeper, wakener =
Promise.create
(* TODO: ciao-lwt: Translation is incomplete, [Promise.await] must be called on the promise when it's part of control-flow. *)
()
in
let sleeper, wakener = Lwt.wait () in
let mk_contents : int -> 'gen -> ('a elt * ('a elt * 'gen) option ref) Lwt.t =
let mk_contents : int -> 'gen -> 'a elt * ('a elt * 'gen) option ref =
fun i gen ->
if i = position
then generate_initial_contents ~spinner sleeper gen
else
Lwt.return
@@
let s = spinner () in
s, ref @@ Some (s, gen)
in
let* contents, spinners_and_generators =
Lwt.map List.split
@@ Lwt_list.map_s (fun x -> x)
@@ List.mapi mk_contents gen_contents
let contents, spinners_and_generators =
List.split (List.map (fun x -> x) (List.mapi mk_contents gen_contents))
in
let carousel =
make ?a ?vertical ~position ?transition_duration ?inertia ?swipeable
?allow_overswipe ?update ?disabled ?full_height ?make_transform
?make_page_attribute contents
in
Lwt.wakeup wakener carousel.elt;
Promise.resolve wakener carousel.elt;
(* generate initial content (client-side) *)
(* replace spinners with content when switched to for the first time *)
let _ =
Expand All @@ -677,7 +677,7 @@ let%shared
| None -> Lwt.return ())
: unit)]
in
Lwt.return carousel
carousel

let%shared bullet_class i pos size =
Eliom_shared.React.S.l2
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/ot_carousel.eliomi
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@ val make_lazy :
-> Html_types.div_attrib Eliom_content.Html.D.attrib list)
Eliom_shared.Value.t
-> ?spinner:(unit -> Html_types.div_content Eliom_content.Html.elt)
-> (unit -> [< Html_types.div_content] Eliom_content.Html.elt Lwt.t)
-> (unit -> [< Html_types.div_content] Eliom_content.Html.elt)
Eliom_shared.Value.t
list
-> [> `Div] t Lwt.t
-> [> `Div] t
(** same as [make] except for the last argument. Instead of supplying the
contents for each page directly, supply a for each page a shared content
generator function. Contents will be generated and filled lazily, i.e. when
Expand Down
8 changes: 5 additions & 3 deletions src/widgets/ot_drawer.eliom
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
open Eio.Std

[%%shared
(* Ocsigen
* http://www.ocsigen.org
Expand Down Expand Up @@ -113,11 +115,11 @@ let%shared
D.div ~a:(a_class ("ot-drawer-bckgrnd" :: bckgrnd_init_class) :: a) [d]
in
let bind_touch :
((unit -> unit) Lwt.t * (unit -> unit) Lwt.u) Eliom_client_value.t
((unit -> unit) Promise.t * (unit -> unit) Lwt.u) Eliom_client_value.t
=
[%client Lwt.wait ()]
in
let touch_thread = [%client (ref Lwt.return_unit : unit Lwt.t ref)] in
let touch_thread = [%client (ref Lwt.return_unit : unit Promise.t ref)] in
let reset_scroll_pos =
[%client
(fun () ->
Expand Down Expand Up @@ -179,7 +181,7 @@ let%shared
html_ManipClass_remove "ot-drawer-open";
html_ManipClass_remove "ot-drawer-closing");
Lwt.return_unit
: unit Lwt.t)]
: unit Promise.t)]
in
let _ =
[%client
Expand Down
9 changes: 3 additions & 6 deletions src/widgets/ot_picture_uploader.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,7 @@ let%client bind_input input preview ?container ?reset () =
type cropping = (float * float * float * float) React.S.t

type 'a upload =
?progress:(int -> int -> unit)
-> ?cropping:cropping
-> File.file Js.t
-> 'a Lwt.t]
?progress:(int -> int -> unit) -> ?cropping:cropping -> File.file Js.t -> 'a]

let%client ocaml_service_upload ~service ~arg ?progress ?cropping file =
Eliom_client.call_ocaml_service ~service () ?upload_progress:progress
Expand Down Expand Up @@ -499,7 +496,7 @@ let%server mk_service name arg_deriver =

let%shared
mk_form
?(after_submit = fun () -> Lwt.return_unit)
?(after_submit = fun () -> ())
?crop
?input:(input_a, input_content = [], [])
?submit:(submit_a, submit_content = [], [])
Expand Down Expand Up @@ -532,4 +529,4 @@ let%shared
~upload:~%upload ~after_submit:~%after_submit ()
: unit)]
in
Lwt.return form
form
9 changes: 3 additions & 6 deletions src/widgets/ot_picture_uploader.eliomi
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ open Js_of_ocaml
type cropping = (float * float * float * float) React.S.t

type 'a upload =
?progress:(int -> int -> unit)
-> ?cropping:cropping
-> File.file Js.t
-> 'a Lwt.t
?progress:(int -> int -> unit) -> ?cropping:cropping -> File.file Js.t -> 'a

type ('a, 'b) service =
( unit
Expand Down Expand Up @@ -142,7 +139,7 @@ val submit :
(** Create a button with [ot-pup-sumit] clas *)

val mk_form :
?after_submit:(unit -> unit Lwt.t)
?after_submit:(unit -> unit)
-> ?crop:float option
-> ?input:
[< Html_types.label_attrib > `Class] Eliom_content.Html.attrib list
Expand All @@ -151,7 +148,7 @@ val mk_form :
[< Html_types.button_attrib > `Class] Eliom_content.Html.attrib list
* [< Html_types.button_content_fun] Eliom_content.Html.elt list
-> 'a upload
-> [> `Form] Eliom_content.Html.elt Lwt.t
-> [> `Form] Eliom_content.Html.elt
(** Ready-to-use form. Customizable with
[input], the input button content, [submit], the submit button content.
If [crop] is present, cropping is enable, with the optional ratio it is.
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/ot_pulltorefresh.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ let make
?(refresh_timeout = 20.)
?(header = [%shared default_header])
~content
(afterPull : (unit -> bool Lwt.t) Eliom_client_value.t)
(afterPull : (unit -> bool) Eliom_client_value.t)
=
if app_only && not (Eliom_client.is_client_app ())
then div ~a [content]
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/ot_pulltorefresh.eliomi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ val make :
list)
Eliom_shared.Value.t
-> content:'a Eliom_content.Html.elt
-> (unit -> bool Lwt.t) Eliom_client_value.t
-> (unit -> bool) Eliom_client_value.t
-> 'a Eliom_content.Html.elt
(**
Creates a pull-to-refresh container from an html element.
Expand Down
25 changes: 12 additions & 13 deletions src/widgets/ot_spinner.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
open%client Js_of_ocaml

[%%shared open Eliom_content.Html]
[%%shared open Lwt.Syntax]
[%%shared]
[%%shared open Eliom_content.Html.F]
[%%client open Eliom_shared]

Expand Down Expand Up @@ -58,20 +58,19 @@ let%server with_spinner ?(a = []) ?spinner:_ ?fail thread =
let a = (a :> Html_types.div_attrib attrib list) in
let fail =
((match fail with
| Some fail -> (fail :> exn -> Html_types.div_content elt list Lwt.t)
| None -> fun e -> Lwt.return (default_fail e))
:> exn -> Html_types.div_content elt list Lwt.t)
| Some fail -> (fail :> exn -> Html_types.div_content elt list)
| None -> fun e -> default_fail e)
:> exn -> Html_types.div_content elt list)
in
let* v =
Lwt.catch
(fun () ->
let* v = thread in
Lwt.return (v :> Html_types.div_content_fun F.elt list))
(fun e ->
let* v = fail e in
Lwt.return (v :> Html_types.div_content_fun F.elt list))
let v =
try
let v = thread in
(v :> Html_types.div_content_fun F.elt list)
with e ->
let v = fail e in
(v :> Html_types.div_content_fun F.elt list)
in
Lwt.return (D.div ~a:(a_class ["ot-spinner"] :: a) v)
D.div ~a:(a_class ["ot-spinner"] :: a) v

[%%client
let num_active_spinners, set_num_active_spinners = React.S.create 0
Expand Down
8 changes: 5 additions & 3 deletions src/widgets/ot_spinner.eliomi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
open Eio.Std

(* Ocsigen Toolkit
* http://www.ocsigen.org/ocsigen-toolkit
*
Expand Down Expand Up @@ -26,9 +28,9 @@
val with_spinner :
?a:[< Html_types.div_attrib] Eliom_content.Html.attrib list
-> ?spinner:[< Html_types.div_content] Eliom_content.Html.elt list
-> ?fail:(exn -> [< Html_types.div_content] Eliom_content.Html.elt list Lwt.t)
-> [< Html_types.div_content] Eliom_content.Html.elt list Lwt.t
-> [> `Div] Eliom_content.Html.elt Lwt.t
-> ?fail:(exn -> [< Html_types.div_content] Eliom_content.Html.elt list)
-> [< Html_types.div_content] Eliom_content.Html.elt list Promise.t
-> [> `Div] Eliom_content.Html.elt
(** On client side, [with_spinner th] returns immediately a spinner
while Lwt thread [th] is not finished, that will automatically
be replaced by the result of [th] when finished.
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/ot_time_picker.eliom
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ let display_hours_minutes_seq ?h24 f =
Eliom_shared.React.S.l2 [%shared display_hours_minutes_seq ?h24:~%h24 ~%f]

let show_minutes_aux
?(action : (int * int -> unit Lwt.t) Eliom_client_value.t option)
?(action : (int * int -> unit) Eliom_client_value.t option)
e_m
hm
f_e_m
Expand All @@ -407,7 +407,7 @@ let get_angle_signal ?round =
| _, _ -> e]

let make_hours_minutes_seq_24h
?(action : (int * int -> unit Lwt.t) Eliom_client_value.t option)
?(action : (int * int -> unit) Eliom_client_value.t option)
?(init = 0, 0)
?(update : (int * int) React.E.t Eliom_client_value.t option)
?round_5
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/ot_time_picker.eliomi
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(** This module implements a clock-style time picker. *)

val make :
?action:(int * int -> unit Lwt.t) Eliom_client_value.t
?action:(int * int -> unit) Eliom_client_value.t
-> ?init:int * int
-> ?update:(int * int) React.E.t Eliom_client_value.t
-> ?round_5:bool
Expand Down Expand Up @@ -56,7 +56,7 @@ val make :
is a function that can be called to go back to hours selection. *)

val make_hours_minutes_seq :
?action:(int * int -> unit Lwt.t) Eliom_client_value.t
?action:(int * int -> unit) Eliom_client_value.t
-> ?init:int * int
-> ?update:(int * int) React.E.t Eliom_client_value.t
-> ?round_5:bool
Expand Down