summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adam@chlipala.net>2014-11-16 15:20:13 -0500
committerGravatar Adam Chlipala <adam@chlipala.net>2014-11-16 15:20:13 -0500
commitf3e50f123c33c26038b601475eeaa619526ad7ab (patch)
tree2567582a726c1f617647ebd0bae71b1db2a454b5
parent049d3500132b56ac2429a8a6ee0cc5ba1fbaae5a (diff)
More HTML5 AJAX widgets
-rw-r--r--lib/js/urweb.js33
-rw-r--r--lib/ur/basis.urs9
-rw-r--r--src/monoize.sml9
-rw-r--r--src/urweb.grm1
-rw-r--r--tests/html5_cforms.ur29
5 files changed, 80 insertions, 1 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index c62670e7..342dc943 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -1078,6 +1078,39 @@ function color(s, name) {
return inpt("color", s, name);
}
+function number(s, name) {
+ return inpt("number", s, name);
+}
+
+function range(s, name) {
+ return inpt("range", s, name);
+}
+
+function date(s, name) {
+ return inpt("date", s, name);
+}
+
+function datetime(s, name) {
+ return inpt("datetime", s, name);
+}
+
+function datetime_local(s, name) {
+ return inpt("datetime-local", s, name);
+}
+
+function month(s, name) {
+ return inpt("month", s, name);
+}
+
+function week(s, name) {
+ return inpt("week", s, name);
+}
+
+function time(s, name) {
+ return inpt("time", s, name);
+}
+
+
function selectValue(x) {
if (x.options.length == 0)
return "";
diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs
index 1ee5be50..326563d6 100644
--- a/lib/ur/basis.urs
+++ b/lib/ur/basis.urs
@@ -1047,6 +1047,15 @@ val curl : ctext
val ctel : ctext
val ccolor : ctext
+val cnumber : cformTag ([Source = source float, Value = float, Min = float, Max = float, Step = float, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs) []
+val crange : cformTag ([Source = source float, Value = float, Min = float, Max = float, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs) []
+val cdate : cformTag ([Source = source string, Value = string, Min = string, Max = string, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs) []
+val cdatetime : cformTag ([Source = source string, Value = string, Min = string, Max = string, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs) []
+val cdatetime_local : cformTag ([Source = source string, Value = string, Min = string, Max = string, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs) []
+val cmonth : cformTag ([Source = source string, Value = string, Min = string, Max = string, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs) []
+val cweek : cformTag ([Source = source string, Value = string, Min = string, Max = string, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs) []
+val ctime : cformTag ([Source = source string, Value = string, Min = string, Max = string, Size = int, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs) []
+
val button : cformTag ([Value = string] ++ boxAttrs) []
val ccheckbox : cformTag ([Value = bool, Size = int, Source = source bool, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs) []
diff --git a/src/monoize.sml b/src/monoize.sml
index 63ae0b31..0829abc9 100644
--- a/src/monoize.sml
+++ b/src/monoize.sml
@@ -3757,6 +3757,15 @@ fun monoExp (env, st, fm) (all as (e, loc)) =
| "ctel" => cinput ("tel", "tel")
| "ccolor" => cinput ("color", "color")
+ | "cnumber" => cinput ("number", "number")
+ | "crange" => cinput ("range", "range")
+ | "cdate" => cinput ("date", "date")
+ | "cdatetime" => cinput ("datetime", "datetime")
+ | "cdatetime_local" => cinput ("datetime-local", "datetime_local")
+ | "cmonth" => cinput ("month", "month")
+ | "cweek" => cinput ("week", "week")
+ | "ctime" => cinput ("time", "time")
+
| "ccheckbox" => cinput ("checkbox", "chk")
| "cselect" =>
(case List.find (fn ("Source", _, _) => true | _ => false) attrs of
diff --git a/src/urweb.grm b/src/urweb.grm
index 5b568a8c..995d1329 100644
--- a/src/urweb.grm
+++ b/src/urweb.grm
@@ -223,6 +223,7 @@ fun tagIn bt =
"table" => "tabl"
| "url" => "url_"
| "datetime-local" => "datetime_local"
+ | "cdatetime-local" => "cdatetime_local"
| _ => bt
datatype prop_kind = Delete | Update
diff --git a/tests/html5_cforms.ur b/tests/html5_cforms.ur
index a62dbf23..be07d07e 100644
--- a/tests/html5_cforms.ur
+++ b/tests/html5_cforms.ur
@@ -9,6 +9,15 @@ fun main () : transaction page =
d <- source "";
e <- source "";
f <- source "";
+ g <- source 1.0;
+ h <- source 1.0;
+ i <- source "#CCCCCC";
+ j <- source "2014/11/16";
+ k <- source "2014/11/16 12:30:45";
+ l <- source "2014/11/16 12:30:45";
+ m <- source "2014/11";
+ n <- source "2014-W7";
+ o <- source "12:30:45";
return <xml><body>
<ctextbox source={a}/>
@@ -17,6 +26,15 @@ fun main () : transaction page =
<curl source={d}/>
<ctel source={e}/>
<csearch source={f}/>
+ <cnumber source={g} min={-10.0} max={10.0} step={0.5}/>
+ <crange source={h} min={-10.0} max={10.0}/>
+ <ccolor source={i}/>
+ <cdate source={j}/>
+ <cdatetime source={k}/>
+ <cdatetime-local source={l}/>
+ <cmonth source={m}/>
+ <cweek source={n}/>
+ <ctime source={o}/>
<hr/>
@@ -25,5 +43,14 @@ fun main () : transaction page =
{dn c};
{dn d};
{dn e};
- {dn f}
+ {dn f};
+ {dn g};
+ {dn h};
+ {dn i};
+ {dn j};
+ {dn k};
+ {dn l};
+ {dn m};
+ {dn n};
+ {dn o}
</body></xml>