Hi!

I have ported one more Bootstrap3 [1] example to the Ur/Web. This time, it was
much easier job to do, but still I had to patch the compiler to make it work.

First thing I need was HTML5 attributes 'required' and 'autofocus' for input
fields. Those changes are located in basis.urs and are rather straightforward.

The second thing is the <input type='email'/>. My intuition says me that adding
custom input types was not designed to be regular operation, but building recent
HTML5 pages may require doing it. Quick search [2] shows that there are 'url'
'tel', 'search', 'number', 'range', 'date', etc. I included the monoize.sml
change to support just the [email] for ordinary [formTags].  Is it possible to
prepare a procedure of doing the same thing for [cformTags] (references to
javaScript confuse me)?

For now, the patch makes it possible run the example, the demo is working

    http://hit.msk.ru/B3_Login/main

Regards,
Sergey


[1] - http://getbootstrap.com/examples/signin/
[2] - http://html5doctor.com/html5-forms-input-types/

PS
patch doesn't do anything with 'placeholder' attribute. it turns out
it was already added.
# HG changeset patch
# User Sergey Mironov <[email protected]>
# Date 1413108216 0
#      Sun Oct 12 10:03:36 2014 +0000
# Node ID 41e03aeb714d2519ba8aa0dcdac08d94c5abaf31
# Parent  a240354c2433a537c97208b2afff2b88799b21e8
HTML5 input attributes: placeholder, required, autofocus; email input type (without cformTag equivalent)

diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs
--- a/lib/ur/basis.urs
+++ b/lib/ur/basis.urs
@@ -954,14 +954,19 @@
                   -> [[Form] ~ ctx] =>
                         nm :: Name -> unit
                         -> tag attrs ([Form] ++ ctx) inner [] [nm = ty]
+
+con inputAttrs = [Required = string, Autofocus = string]
+
+
 val hidden : formTag string [] [Data = data_attr, Id = string, Value = string]
 val textbox : formTag string [] ([Value = string, Size = int, Placeholder = string, Source = source string, Onchange = transaction unit,
-                                  Ontext = transaction unit] ++ boxAttrs)
-val password : formTag string [] ([Value = string, Size = int, Placeholder = string, Onchange = transaction unit] ++ boxAttrs)
+                                  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)
+                                   Ontext = transaction unit] ++ boxAttrs ++ inputAttrs)
 
-val checkbox : formTag bool [] ([Checked = bool, Onchange = transaction unit] ++ boxAttrs)
+val checkbox : formTag bool [] ([Checked = bool, Onchange = transaction unit, Value = string] ++ boxAttrs)
 
 type file
 val fileName : file -> option string
@@ -1018,18 +1023,18 @@
                         unit -> tag attrs ([Body] ++ ctx) ([Body] ++ inner) [] []
 
 val ctextbox : cformTag ([Value = string, Size = int, Source = source string, Placeholder = string, Onchange = transaction unit,
-                          Ontext = transaction unit] ++ boxAttrs) []
+                          Ontext = transaction unit] ++ boxAttrs ++ inputAttrs) []
 val cpassword : cformTag ([Value = string, Size = int, Source = source string, Placeholder = string, Onchange = transaction unit,
-                          Ontext = transaction unit] ++ boxAttrs) []
+                          Ontext = transaction unit] ++ boxAttrs ++ inputAttrs) []
 val button : cformTag ([Value = string] ++ boxAttrs) []
 
-val ccheckbox : cformTag ([Value = bool, Size = int, Source = source bool, Onchange = transaction unit] ++ boxAttrs) []
+val ccheckbox : cformTag ([Value = bool, Size = int, Source = source bool, Onchange = transaction unit] ++ boxAttrs ++ inputAttrs) []
 
 val cselect : cformTag ([Source = source string, Onchange = transaction unit] ++ boxAttrs) [Cselect]
 val coption : unit -> tag [Value = string, Selected = bool] [Cselect, Body] [] [] []
 
 val ctextarea : cformTag ([Value = string, Rows = int, Cols = int, Source = source string, Onchange = transaction unit,
-                           Ontext = transaction unit] ++ boxAttrs) []
+                           Ontext = transaction unit] ++ boxAttrs ++ inputAttrs) []
 
 (*** Tables *)
 
diff --git a/src/monoize.sml b/src/monoize.sml
--- a/src/monoize.sml
+++ b/src/monoize.sml
@@ -3665,6 +3665,7 @@
                            | _ => (Print.prefaces "Targs" (map (fn t => ("T", CorePrint.p_con env t)) targs);
                                    raise Fail "No name passed to textbox tag"))
                       | "password" => input "password"
+                      | "email" => input "email"
                       | "textarea" =>
 			(case targs of
                              [_, (L.CName name, _)] =>
_______________________________________________
Ur mailing list
[email protected]
http://www.impredicative.com/cgi-bin/mailman/listinfo/ur

Reply via email to