-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwidgets.eliom
129 lines (113 loc) · 4.29 KB
/
widgets.eliom
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
[%%shared
open Eliom_content
open Lwt
type div_content = Html5_types.div_content_fun Eliom_content.Html5.elt
module F = struct
let list_view l =
Html5.F.ul ~a:[Html5.F.a_class ["list-view"]] l
let two_panes (child1:div_content) (child2:div_content) =
let open Html5.F in
let open Html5 in
Html5.F.(div ~a:[a_class ["two-panes"]] [ div [child1]; div [child2]])
end]
[%%client
module C = struct
let link callback l =
let open Html5.F in
let open Html5 in
let button = span ~a:[a_class ["link"]; a_onclick (fun e -> callback (); ())] l in
button
end
]
(* this must be in a separate module, as it can not be put in client's code *)
module S (M: App_stub.MIMES) = struct
open Eliom_lib
open Eliom_content
open Html5.D
open Eliom_tools.D
let forall_head = [meta
~a:[a_name "viewport";
a_content "user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi"]
();
(Unsafe.node "link" ~a:[Unsafe.string_attrib "rel" "manifest"; Unsafe.string_attrib "href" "/manifest.json"] [])
]
let main_box l =
let open Html5.F in
return (Eliom_tools.F.html
~title:"ocaloud"
~js:[["js"; "app.js"]]
~css:[["css";"ocaloud.css"]]
~other_head:forall_head
(body l))
let top_bar () =
let button_menu = Html5.D.Raw.a [pcdata " "] in
let button_back = Html5.D.Raw.a [pcdata " "] in
let _ = [%client
let a = Eliom_content.Html5.To_dom.of_a ~%button_back in
let menus = Dom_html.getElementById "main" in
let sliding_content = Dom_html.getElementById "sliding-content" in
Lwt_js_events.clicks a (fun e _ ->
Dom.preventDefault e;
menus##.classList##remove (Js.string "activated");
sliding_content##.classList##add (Js.string "activated");
Lwt.return ());
let a = Eliom_content.Html5.To_dom.of_a ~%button_menu in
Lwt_js_events.clicks a (fun e _ ->
Dom.preventDefault e;
sliding_content##.classList##remove (Js.string "activated");
menus##.classList##add (Js.string "activated");
Lwt.return ()) ] in
let is_online = [%client
React.S.map (fun b ->
if b then
Html5.F.(span [pcdata "online"])
else
Html5.F.(span ~a:[a_class ["bigred"]] [pcdata "offline"])
) Offline.is_connected
|> Html5.R.node
] |> Html5.C.node
in
Html5.F.div ~a:[a_id "top-header"] [button_menu; button_back; is_online]
let main_box_sidebar l =
let open Html5.F in
let%lwt sidebar =
M.build_sidebar ()
>>= fun a ->
return @@ Html5.F.div ~a:[a_id "sidebar"] a
in
let sidebar = Html5.F.div ~a:[a_id "main"] [sidebar] in
let main_wrapper = Html5.F.div ~a:[a_class ["main-wrapper"]]
l in
let sliding_content = Html5.F.div ~a:[a_id "sliding-content"; a_class ["activated"]] [main_wrapper;] in
Lwt.return (Eliom_tools.F.html
~title:"ocaloud"
~js:[["js"; "app.js"]]
~css:[["css";"ocaloud.css"]]
~other_head:forall_head
(body ([top_bar (); sidebar; sliding_content])))
let flex_box_sidebar l =
let open Html5.F in
let%lwt sidebar =
M.build_sidebar ()
>>= fun a ->
return @@ Html5.F.div ~a:[a_id "sidebar"] a
in
let sidebar = Html5.F.div ~a:[a_id "main"] [sidebar] in
let main_wrapper = Html5.F.div ~a:[a_class ["flex-wrapper"]]
l in
let sliding_content = Html5.F.div ~a:[a_id "sliding-content"; a_class ["activated"]] [main_wrapper;] in
Lwt.return (Eliom_tools.F.html
~title:"ocaloud"
~js:[["js"; "app.js"]]
~css:[["css";"ocaloud.css"]]
~other_head:forall_head
(body ([top_bar (); sidebar; sliding_content])))
let make_page_redirect url l =
Lwt.return (html
~title:"restricted area"
~js:[["js";"sjcl.js"]]
~css:[["css";"main.css"]]
~other_head:((meta ~a:[a_http_equiv "refresh"; a_content ("0;url="^url) ] ())::forall_head)
(body l
))
end