open Eliom_content.Html5.F
module Uri = struct
let local =
let css =
make_uri (Eliom_service.static_dir ())
["bootstrap"; "css"; "bootstrap.min.css"]
in
let js =
make_uri (Eliom_service.static_dir ())
["bootstrap"; "js"; "bootstrap.min.js"]
in
(css, js)
let cdn =
let css = Raw.uri_of_string "//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" in
let js = Raw.uri_of_string "//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js" in
(css, js)
end
module Column = struct
let col screen width =
if width > 12 or width < 1 then
raise (Invalid_argument (string_of_int width))
else
a_class ["col-" ^ screen ^ "-" ^ (string_of_int width)]
let extrasmall = col "xs"
let small = col "xs"
let medium = col "xs"
let large = col "xs"
let extralarge = col "xs"
end
module Navigation = struct
let simple items =
nav ~a:[
a_class ["navbar"; "navbar-default"];
(* Xml.string_attrib "role" "navigation"; *)
] [
ul ~a:[a_class ["nav"; "navbar-nav"]]
(List.map (fun x -> li [x]) items)
]
end
module Color = struct
let muted = a_class ["muted"]
let primary = a_class ["primary"]
let success = a_class ["success"]
let info = a_class ["info"]
let warning = a_class ["warning"]
let danger = a_class ["danger"]
end
module Background = struct
let primary = a_class ["bg-primary"]
let success = a_class ["bg-success"]
let info = a_class ["bg-info"]
let warning = a_class ["bg-warning"]
let danger = a_class ["bg-danger"]
end
let active = a_class ["active"]
let masthead = a_class ["masthead"]
let nav = a_class ["nav"]
let nav_tabs = a_class ["nav-tabs"]
let nav_pills = a_class ["nav-pills"]
let nav_justified = a_class ["nav-justified"]
let container = a_class ["container"]
let jumbotron = a_class ["jumbotron"]
let brand = a_class ["brand"]
let hero_unit = a_class ["hero-unit"]
let tabbable = a_class ["tabbable"]
let tab_content = a_class ["tab-content"]
let tab_pane = a_class ["tab-pane"]
let row = a_class ["row"]
let dl_horizontal = a_class ["dl-horizontal"]
module Tabs = struct
(* Should be pure caml instead of relying on bootstrap js. *)
(* Bootstrap tabs need unique identifiers *)
(* It is not a good idea to use a reference since the value is
incremented each time the page is reloaded. *)
let tabs_global_id = ref 0
let build ?(style=nav_tabs) content =
let first = !tabs_global_id in
let id = tabs_global_id in
let content = List.map (fun (title, content) ->
let tab_title =
li ~a:(if !id = first then [active] else []) [
tot (Xml.node "a"
~a:[
Xml.string_attrib "href" ("#"^(string_of_int !id));
Xml.string_attrib "data-toggle" "tab";
] [toelt title])
]
in
let tab_content =
let attribs = [tab_pane; a_id (string_of_int !id)] in
let attribs = (if !id = first then active::attribs else attribs) in
div ~a:attribs content
in
incr id;
(tab_title, tab_content)
) content in
div [
ul ~a:[style; nav] (List.map fst content);
div ~a:[tab_content] (List.map snd content);
]
end