summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/elements/popup.ml11
-rwxr-xr-xlib/elements/transfert.ml19
2 files changed, 23 insertions, 7 deletions
diff --git a/lib/elements/popup.ml b/lib/elements/popup.ml
index bf97559..28c414e 100755
--- a/lib/elements/popup.ml
+++ b/lib/elements/popup.ml
@@ -37,7 +37,6 @@ let create:
submit_btn
end;
-
let container = match form with
| None -> El.div
| Some _ -> El.form
@@ -73,6 +72,16 @@ let create:
let () = El.append_children (Document.body G.document)
[ el ] in
+ (* Add the focus to the first input element inside the form *)
+ let () = match form with
+ | Some (_, el) when El.is_el el ->
+ begin match (El.find_by_tag_name ~root:el (Jstr.v "input")) with
+ | [] -> ()
+ | hd::_ -> El.set_has_focus true hd
+ end
+ | _ -> ()
+ in
+
(* Event handler *)
let close_event = Evr.on_el
Ev.click
diff --git a/lib/elements/transfert.ml b/lib/elements/transfert.ml
index f324509..3001e32 100755
--- a/lib/elements/transfert.ml
+++ b/lib/elements/transfert.ml
@@ -1,5 +1,15 @@
open Brr
+let send_raw
+ : filename:Jstr.t -> Jstr.t -> unit
+ = fun ~filename data ->
+ (* Create the link to download the the element, and simulate a click on it *)
+ let a = El.a
+ ~at:At.[ href Jv.Id.(of_jv @@ to_jv data)
+ ; v (Jstr.v "download") filename ]
+ [] in
+ El.click a
+
(** Send a file to the user. *)
let send
: mime_type:Jstr.t -> filename:Jstr.t -> Jstr.t -> unit
@@ -16,9 +26,6 @@ let send
; base64data
|] in
- (* Create the link to download the the element, and simulate a click on it *)
- let a = El.a
- ~at:At.[ href Jv.Id.(of_jv @@ to_jv data)
- ; v (Jstr.v "download") filename ]
- [] in
- El.click a
+ send_raw
+ ~filename
+ data