Skip to content

Commit b43ca31

Browse files
committed
Ocamlformating
1 parent 58e1a7d commit b43ca31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+899
-815
lines changed

src/widgets/ot_calendar.eliom

Lines changed: 85 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,12 @@ let select_action ?(size = 1) selector action =
185185
dom_select##.size := size;
186186
Lwt.return_unit))
187187

188-
let rec build_calendar ?prehilight
189-
~button_labels:{b_prev_year; b_prev_month; b_next_month; b_next_year} ~intl
190-
~period day
188+
let rec build_calendar
189+
?prehilight
190+
~button_labels:{b_prev_year; b_prev_month; b_next_month; b_next_year}
191+
~intl
192+
~period
193+
day
191194
=
192195
let today = CalendarLib.Date.today () in
193196
let fst_dow = fst_dow ~intl day
@@ -297,43 +300,54 @@ let get_options selector =
297300
let update_classes cal zero d =
298301
let rows = (To_dom.of_table cal)##.rows in
299302
let f i =
300-
rows ## (item (i + 2)) >>! fun r ->
303+
rows##(item (i + 2)) >>! fun r ->
301304
let cells = r##.cells in
302305
let f j =
303-
cells ## (item j) >>! fun c ->
306+
cells##(item j) >>! fun c ->
304307
let d' =
305308
CalendarLib.Calendar.Date.(j + (7 * i) |> Period.day |> add zero)
306309
in
307310
if d = d'
308-
then c ##. classList ## (add (Js.string "ot-c-current"))
309-
else c ##. classList ## (remove (Js.string "ot-c-current"))
311+
then c##.classList##(add (Js.string "ot-c-current"))
312+
else c##.classList##(remove (Js.string "ot-c-current"))
310313
in
311314
iter_interval 0 6 f
312315
in
313316
iter_interval 0 5 f
314317

315-
let in_period ?(begin_p = default_period.begin_p)
316-
?(end_p = default_period.end_p) curr_date
318+
let in_period
319+
?(begin_p = default_period.begin_p)
320+
?(end_p = default_period.end_p)
321+
curr_date
317322
=
318323
curr_date >= begin_p && curr_date <= end_p
319324

320-
let in_period_coerced ?(begin_p = default_period.begin_p)
321-
?(end_p = default_period.end_p) curr_date
325+
let in_period_coerced
326+
?(begin_p = default_period.begin_p)
327+
?(end_p = default_period.end_p)
328+
curr_date
322329
=
323330
curr_date >= (begin_p :> [`Month | `Year] CalendarLib.Date.date)
324331
&& curr_date <= (end_p :> [`Month | `Year] CalendarLib.Date.date)
325332

326-
let attach_events ?action ?(click_non_highlighted = false) ?update ~intl ~period
327-
d cal highlight
333+
let attach_events
334+
?action
335+
?(click_non_highlighted = false)
336+
?update
337+
~intl
338+
~period
339+
d
340+
cal
341+
highlight
328342
=
329343
let rows = (To_dom.of_table cal)##.rows in
330344
let fst_dow = fst_dow ~intl d and zero = zeroth_displayed_day ~intl d in
331345
let mnth = CalendarLib.Date.month fst_dow in
332346
iter_interval 0 5 @@ fun i ->
333-
rows ## (item (i + 2)) >>! fun r ->
347+
rows##(item (i + 2)) >>! fun r ->
334348
let cells = r##.cells in
335349
iter_interval 0 6 @@ fun j ->
336-
cells ## (item j) >>! fun c ->
350+
cells##(item j) >>! fun c ->
337351
let d = CalendarLib.Calendar.Date.(j + (7 * i) |> Period.day |> add zero) in
338352
if mnth = CalendarLib.Date.month d
339353
then
@@ -358,14 +372,20 @@ let attach_events ?action ?(click_non_highlighted = false) ?update ~intl ~period
358372
in
359373
if List.exists (( = ) dom) highlight
360374
then (
361-
c ##. classList ## (add (Js.string "ot-c-highlight"));
375+
c##.classList##(add (Js.string "ot-c-highlight"));
362376
set_onclick ())
363377
else if click_non_highlighted
364378
then set_onclick ()
365379
else ()
366380

367-
let attach_events_lwt ?action ?click_non_highlighted ~intl ~period d cal
368-
highlight
381+
let attach_events_lwt
382+
?action
383+
?click_non_highlighted
384+
~intl
385+
~period
386+
d
387+
cal
388+
highlight
369389
=
370390
let f () =
371391
let m = CalendarLib.Date.(month d |> int_of_month)
@@ -376,9 +396,13 @@ let attach_events_lwt ?action ?click_non_highlighted ~intl ~period d cal
376396
in
377397
Lwt.async f
378398

379-
let make_span_handler selector
380-
((get_sig, set_sig) : int React.signal * (?step:React.step -> int -> unit))
381-
apply condi fun_handler
399+
let make_span_handler
400+
selector
401+
((get_sig, set_sig) :
402+
int React.signal * (?step:React.step -> int -> unit))
403+
apply
404+
condi
405+
fun_handler
382406
=
383407
Dom_html.handler (fun _ ->
384408
if condi ()
@@ -389,9 +413,13 @@ let make_span_handler selector
389413
Js._false)
390414
else Js._false)
391415

392-
let set_selected_index selector selector_value options
393-
((get_sig, set_sig) : int React.signal * (?step:React.step -> int -> unit))
394-
()
416+
let set_selected_index
417+
selector
418+
selector_value
419+
options
420+
((get_sig, set_sig) :
421+
int React.signal * (?step:React.step -> int -> unit))
422+
()
395423
=
396424
let value = selector_value () in
397425
try
@@ -404,8 +432,15 @@ let make_selector_handler change_index condi fun_handler =
404432
Dom_html.handler (fun _ ->
405433
if condi () then (fun_handler (); change_index (); Js._false) else Js._false)
406434

407-
let attach_behavior ?highlight ?click_non_highlighted ?action ~intl ~period d
408-
(cal, prev, next, select_month, select_year, prev_year, next_year) f_d
435+
let attach_behavior
436+
?highlight
437+
?click_non_highlighted
438+
?action
439+
~intl
440+
~period
441+
d
442+
(cal, prev, next, select_month, select_year, prev_year, next_year)
443+
f_d
409444
=
410445
(match highlight with
411446
| Some highlight ->
@@ -467,18 +502,18 @@ let attach_behavior ?highlight ?click_non_highlighted ?action ~intl ~period d
467502
(fun () -> f_d (CalendarLib.Date.next d `Year))
468503

469504
let make :
470-
?init:int * int * int
471-
-> ?highlight:(int -> int -> int list Lwt.t)
472-
-> ?click_non_highlighted:bool
473-
-> ?update:(int * int * int) React.E.t
474-
-> ?action:(int -> int -> int -> unit Lwt.t)
475-
-> ?period:
476-
CalendarLib.Date.field CalendarLib.Date.date
477-
* CalendarLib.Date.field CalendarLib.Date.date
478-
-> ?button_labels:button_labels
479-
-> ?intl:intl
480-
-> unit
481-
-> [> `Div] elt
505+
?init:int * int * int
506+
-> ?highlight:(int -> int -> int list Lwt.t)
507+
-> ?click_non_highlighted:bool
508+
-> ?update:(int * int * int) React.E.t
509+
-> ?action:(int -> int -> int -> unit Lwt.t)
510+
-> ?period:
511+
CalendarLib.Date.field CalendarLib.Date.date
512+
* CalendarLib.Date.field CalendarLib.Date.date
513+
-> ?button_labels:button_labels
514+
-> ?intl:intl
515+
-> unit
516+
-> [> `Div] elt
482517
=
483518
fun ?init
484519
?highlight
@@ -525,18 +560,18 @@ let make :
525560
elt
526561

527562
let%server make :
528-
?init:int * int * int
529-
-> ?highlight:(int -> int -> int list Lwt.t) Eliom_client_value.t
530-
-> ?click_non_highlighted:bool
531-
-> ?update:(int * int * int) React.E.t Eliom_client_value.t
532-
-> ?action:(int -> int -> int -> unit Lwt.t) Eliom_client_value.t
533-
-> ?period:
534-
CalendarLib.Date.field CalendarLib.Date.date
535-
* CalendarLib.Date.field CalendarLib.Date.date
536-
-> ?button_labels:button_labels
537-
-> ?intl:intl
538-
-> unit
539-
-> [> `Div] elt
563+
?init:int * int * int
564+
-> ?highlight:(int -> int -> int list Lwt.t) Eliom_client_value.t
565+
-> ?click_non_highlighted:bool
566+
-> ?update:(int * int * int) React.E.t Eliom_client_value.t
567+
-> ?action:(int -> int -> int -> unit Lwt.t) Eliom_client_value.t
568+
-> ?period:
569+
CalendarLib.Date.field CalendarLib.Date.date
570+
* CalendarLib.Date.field CalendarLib.Date.date
571+
-> ?button_labels:button_labels
572+
-> ?intl:intl
573+
-> unit
574+
-> [> `Div] elt
540575
=
541576
fun ?init
542577
?highlight

src/widgets/ot_calendar.eliomi

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ type intl =
2626
{ i_days : string list
2727
; i_months : string list
2828
; i_start : [`Sun | `Mon | `Tue | `Wed | `Thu | `Fri | `Sat] }
29-
(** [intl] is the type of internationalization specifiers. [i_days]
30-
contains the names of the weekdays, starting with
31-
Sunday. [i_months] contains the names of the months, starting with
32-
January. [i_start] specifies the first day of the week. *)
29+
(** [intl] is the type of internationalization specifiers. [i_days] contains the
30+
names of the weekdays, starting with Sunday. [i_months] contains the names
31+
of the months, starting with January. [i_start] specifies the first day of
32+
the week. *)
3333

3434
type button_labels =
3535
{ b_prev_year : string
3636
; b_prev_month : string
3737
; b_next_month : string
3838
; b_next_year : string }
39-
(** An instance of [button_labels] is used to customize the button
40-
labels. The defaults are "<<", "<", ">", and ">>". *)
39+
(** An instance of [button_labels] is used to customize the button labels. The
40+
defaults are "<<", "<", ">", and ">>". *)
4141

4242
val make :
4343
?init:int * int * int
@@ -54,20 +54,19 @@ val make :
5454
-> [> `Div] Eliom_content.Html.elt
5555
(** [make ?highlight ?click_any ?action] produces a calendar.
5656
57-
If a client-side function [highlight] is provided, [highlight y m]
58-
needs to produce the list of days for the month [m] of the year
59-
[y] that need to be visually denoted.
57+
If a client-side function [highlight] is provided, [highlight y m] needs to
58+
produce the list of days for the month [m] of the year [y] that need to be
59+
visually denoted.
6060
61-
If [click_non_highlighted] is [true], every date is clickable;
62-
otherwise, only the dates that [highlight] returns (if [highlight]
63-
is provided) are clickable.
61+
If [click_non_highlighted] is [true], every date is clickable; otherwise,
62+
only the dates that [highlight] returns (if [highlight] is provided) are
63+
clickable.
6464
65-
If a client-side function [action] is provided, when the user
66-
clicks on the date [d]:[m]:[y], [action y m d] is called.
67-
68-
If [period] is provided, the calendar will have a period restriction
69-
between the two dates given contained in [update].
70-
*)
65+
If a client-side function [action] is provided, when the user clicks on the
66+
date [d]:[m]:[y], [action y m d] is called.
67+
68+
If [period] is provided, the calendar will have a period restriction between
69+
the two dates given contained in [update]. *)
7170

7271
val make_date_picker :
7372
?init:int * int * int
@@ -80,9 +79,7 @@ val make_date_picker :
8079
-> unit
8180
-> [> `Div] Eliom_content.Html.elt * (int * int * int) Eliom_shared.React.S.t
8281
(** [make_date_picker ?init ()] returns a client-side reactive signal
83-
[(y, m, d)] corresponding to the date [d]:[m]:[y] that the user
84-
clicks on. The optional parameter [init] provides an initial value
85-
for the signal.
82+
[(y, m, d)] corresponding to the date [d]:[m]:[y] that the user clicks on.
83+
The optional parameter [init] provides an initial value for the signal.
8684
[?intl] is used to internationalize the calendar (see {!intl}). The default
87-
behavior is for English.
88-
*)
85+
behavior is for English. *)

0 commit comments

Comments
 (0)