changeset 2077:3cd2bd4b1de0

More simple textual HTML5 input types
author Adam Chlipala <adam@chlipala.net>
date Sun, 16 Nov 2014 14:16:11 -0500
parents 855d7746a084
children 6d126af2e1cb
files lib/ur/basis.urs src/monoize.sml src/urweb.grm tests/html5_forms.ur
diffstat 4 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lib/ur/basis.urs	Sun Nov 16 14:06:24 2014 -0500
+++ b/lib/ur/basis.urs	Sun Nov 16 14:16:11 2014 -0500
@@ -956,12 +956,21 @@
 val textbox : formTag string [] ([Value = string, Size = int, Placeholder = string, Source = source string, Onchange = transaction unit,
                                   Ontext = transaction unit] ++ boxAttrs ++ inputAttrs)
 val password : formTag string [] ([Value = string, Size = int, Placeholder = string, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs)
-val email : formTag string [] ([Value = string, Size = int, Placeholder = string, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs)
 val textarea : formTag string [] ([Rows = int, Cols = int, Onchange = transaction unit,
                                    Ontext = transaction unit] ++ boxAttrs ++ inputAttrs)
 
 val checkbox : formTag bool [] ([Checked = bool, Onchange = transaction unit] ++ boxAttrs)
 
+(* HTML5 widgets galore! *)
+
+type textWidget = formTag string [] ([Value = string, Size = int, Placeholder = string, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs)
+
+val email : textWidget
+val search : textWidget
+val url_ : textWidget
+val tel : textWidget
+
+
 type file
 val fileName : file -> option string
 val fileMimeType : file -> string
--- a/src/monoize.sml	Sun Nov 16 14:06:24 2014 -0500
+++ b/src/monoize.sml	Sun Nov 16 14:16:11 2014 -0500
@@ -3664,6 +3664,9 @@
                                    raise Fail "No name passed to textbox tag"))
                       | "password" => input "password"
                       | "email" => input "email"
+                      | "search" => input "search"
+                      | "url_" => input "url"
+                      | "tel" => input "tel"
                       | "textarea" =>
 			(case targs of
                              [_, (L.CName name, _)] =>
--- a/src/urweb.grm	Sun Nov 16 14:06:24 2014 -0500
+++ b/src/urweb.grm	Sun Nov 16 14:16:11 2014 -0500
@@ -221,6 +221,7 @@
 fun tagIn bt =
     case bt of
         "table" => "tabl"
+      | "url" => "url_"
       | _ => bt
 
 datatype prop_kind = Delete | Update
--- a/tests/html5_forms.ur	Sun Nov 16 14:06:24 2014 -0500
+++ b/tests/html5_forms.ur	Sun Nov 16 14:16:11 2014 -0500
@@ -2,6 +2,10 @@
   A: {[r.A]}<br/>
   B: {[r.B]}<br/>
   C: {[r.C]}<br/>
+  D: {[r.D]}<br/>
+  E: {[r.E]}<br/>
+  F: {[r.F]}<br/>
+  G: {[r.G]}<br/>
 </body></xml>
 
 fun main () =
@@ -10,6 +14,10 @@
         <textbox{#A} required placeholder="bobby"/>
         <textbox{#B} placeholder="soggy" autofocus/>
         <checkbox{#C}/>
+        <email{#D}/>
+        <url{#E}/>
+        <tel{#F}/>
+        <search{#G}/>
 
         <submit action={handler}/>
       </form>