Initial import HTML5 support for attributes and input types.

Attributes
- Added support for new HTML5 attributes.
missing support for : form, list, and multiple attributes.

Input types: added the all the new input types.

Added test cases, still in progress.
This commit is contained in:
jvelilla
2015-05-21 12:32:08 -03:00
parent a7c8d40b3e
commit 28e51cc314
23 changed files with 1149 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
note
description: "[
Represent an input type color
Example
<input id="color" name="color" type="color">
]"
date: "$Date$"
revision: "$Revision$"
EIS: "name=color", "src=https://html.spec.whatwg.org/multipage/forms.html#color-state-(type=color)"
class
WSF_FORM_COLOR_INPUT
inherit
WSF_FORM_INPUT
create
make,
make_with_text
feature -- Access
input_type: STRING = "color"
end

View File

@@ -0,0 +1,39 @@
note
description: "[
Example:
<name="startdate" min="2012-01-01" max="2013-01-01" type="date">
]"
date: "$Date$"
revision: "$Revision$"
EIS: "name=date", "src=https://html.spec.whatwg.org/multipage/forms.html#date-state-(type=date)"
class
WSF_FORM_DATE_INPUT
inherit
WSF_FORM_INPUT
redefine
specific_input_attributes_string
end
WSF_FORM_WITH_NUMERIC_ATTRIBUTE
create
make,
make_with_text
feature -- Access
input_type: STRING = "date"
feature {NONE} -- Conversion
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
create Result.make_empty
append_numeric_input_attributes_to (Result)
end
end

View File

@@ -0,0 +1,42 @@
note
description: "[
Represent an input type datetime
Example
<input id="entry-day-time" name="entry-day-time" type="datetime">
]"
author: ""
date: "$Date$"
revision: "$Revision$"
EIS: "name=datetime", "src=https://html.spec.whatwg.org/multipage/forms.html#date-and-time-state-(type=datetime)"
class
WSF_FORM_DATETIME_INPUT
inherit
WSF_FORM_INPUT
redefine
specific_input_attributes_string
end
WSF_FORM_WITH_NUMERIC_ATTRIBUTE
create
make,
make_with_text
feature -- Access
input_type: STRING = "datetime"
feature {NONE} -- Conversion
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
create Result.make_empty
append_numeric_input_attributes_to (Result)
end
end

View File

@@ -0,0 +1,41 @@
note
description: "[
Represent an input type datetime-local
Example:
<input id="arrival-time" name="arrival-time " type="datetime-local">
]"
date: "$Date$"
revision: "$Revision$"
EIS: "name=datetime-local", "src=https://html.spec.whatwg.org/multipage/forms.html#local-date-and-time-state-(type=datetime-local)"
class
WSF_FORM_DATETIME_LOCAL_INPUT
inherit
WSF_FORM_INPUT
redefine
specific_input_attributes_string
end
WSF_FORM_WITH_NUMERIC_ATTRIBUTE
create
make,
make_with_text
feature -- Access
input_type: STRING = "datetime-local"
feature {NONE} -- Conversion
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
-- TODO find a way to validte differnet types of
-- values to (min, max and step).
create Result.make_empty
append_numeric_input_attributes_to (Result)
end
end

View File

@@ -0,0 +1,26 @@
note
description: "[
Represent the intput type email
Example:
<input type="email" name="email" required>
]"
date: "$Date$"
revision: "$Revision$"
EIS: "name=email", "src=https://html.spec.whatwg.org/multipage/forms.html#e-mail-state-(type=email)"
class
WSF_FORM_EMAIL_INPUT
inherit
WSF_FORM_INPUT
create
make,
make_with_text
feature -- Access
input_type: STRING = "email"
end

View File

@@ -12,6 +12,8 @@ inherit
redefine
specific_input_attributes_string
end
WSF_FORM_WITH_ATLERNATIVE_ACTIONS
create
make
@@ -51,6 +53,7 @@ feature {NONE} -- Implementation
if attached alt as l_alt then
Result.append (" alt=%"" + l_alt + "%"")
end
append_submit_image_input_attributes_to (Result)
end
invariant

View File

@@ -10,6 +10,8 @@ deferred class
inherit
WSF_FORM_FIELD
WSF_FORM_INPUT_WITH_HTML5
feature {NONE} -- Initialization
make (a_name: like name)
@@ -86,6 +88,7 @@ feature -- Conversion
append_css_class_to (a_html, Void)
append_css_id_to (a_html)
append_css_style_to (a_html)
append_html5_input_attributes_to (a_theme, a_html)
if is_readonly then
a_html.append (" readonly=%"readonly%"")
@@ -131,6 +134,7 @@ feature {NONE} -- Implementation
-- Specific input attributes if any.
--| To redefine if needed
do
-- TODO: should we consider to use theme?
end
end

View File

@@ -0,0 +1,174 @@
note
description: "Represent the improvement HTML5 brings to web forms"
date: "$Date$"
revision: "$Revision$"
EIS: "name=HTML5 forms", "src=https://html.spec.whatwg.org/multipage/forms.html#forms"
deferred class
WSF_FORM_INPUT_WITH_HTML5
feature -- Access
placeholder: detachable READABLE_STRING_32
-- short hint intended to aid the user with data entry when the control has no value.
-- EIS:"name=placeholder", "src=https://html.spec.whatwg.org/multipage/forms.html#attr-input-placeholder
autofocus: BOOLEAN
-- moves the input focus to a particular input field.
autocomplete: BOOLEAN
-- helps users complete forms based on earlier input.
-- The default state is set to on.
-- call set_autocomplete to turn it off.
required: BOOLEAN
-- The browser requires the user to enter data into that field before submitting the form.
pattern: detachable READABLE_STRING_32
-- specifies a JavaScript regular expression for the fields value to be checked against.
-- pattern makes it easy for us to implement specific validation for product codes, invoice numbers, and so on.
--! This pattern is not validated, at the moment.
feature -- Change element
set_placeholder (a_placeholder: READABLE_STRING_32)
-- Set `placeholder' with `a_placeholder'.
do
placeholder := a_placeholder
ensure
placeholder_set: attached placeholder as l_placeholder implies l_placeholder = a_placeholder
end
set_autofocus
-- Set autofocus in True.
do
autofocus := True
ensure
autofocus_true: autofocus
end
unset_autofocus
-- Set autofocus in False
do
autofocus := False
ensure
autofocus_false: not autofocus
end
turn_off_autocomplete
-- Turn off the autocompelte. The default behavior is on.
do
autocomplete := True
ensure
autocomplete_true: autocomplete
end
turn_on_autocomplete
-- Set autocomplete in False, Set default behavior.
do
autocomplete := False
ensure
autocomplete_false: not autocomplete
end
set_required
-- Set required to True.
do
required := True
ensure
required_true: required
end
unset_required
-- Set rquired to False.
do
required := False
ensure
required_flase: not required
end
set_pattern (a_pattern: READABLE_STRING_32)
-- Set `pattern' with `a_pattern'.
-- Example:[0-9][A-Z]{3}
-- Check HTML5 patterns site.
note
EIS: "name=HTML5 Patterns", "src=http://html5pattern.com/"
do
pattern := a_pattern
ensure
pattern_set: attached pattern as l_pattern implies l_pattern = a_pattern
end
-- list: detachable READABLE_STRING_32
-- The list attribute enables the user to associate a list of options with a particular field.
-- The value of the list attribute must be the same as the ID of a datalist element that resides in the same document.
-- The datalist element is new in HTML5 and represents a predefined list of options for form controls.
--
-- Example
--
-- <label>Your favorite fruit:
-- <datalist id="fruits">
-- <option value="Blackberry">Blackberry</option>
-- <option value="Blackcurrant">Blackcurrant</option>
-- <option value="Blueberry">Blueberry</option>
-- <!-- … -->
-- </datalist>
-- If other, please specify:
-- <input type="text" name="fruit" list="fruits">
-- </label>
-- multiple: BOOLEAN
--We can take our lists and datalists one step further by applying the Boolean attribute multiple to allow more than one value to be entered from the datalist.
-- Here is an example.
--<label>Your favorite fruit:
--<datalist id="fruits">
-- <select name="fruits">
-- <option value="Blackberry">Blackberry</option>
-- <option value="Blackcurrant">Blackcurrant</option>
-- <option value="Blueberry">Blueberry</option>
-- <!-- … -->
-- </select>
--If other, please specify:
--</datalist>
-- <input type="text" name="fruit" list="fruits" multiple>
--</label>
feature -- Conversion
append_html5_input_attributes_to (a_theme: WSF_THEME; a_target: STRING)
-- Append html5 attributes to target `a_target'.
--!Note: Several new HTML5 form attributes are Boolean attributes.
--This just means theyre set if theyre present and not set if theyre absent. They can be written several ways in HTML5.
--autofocus
--autofocus=""
--autofocus="autofocus"
--However, if you are writing XHTML5, you have to use the autofocus="autofocus" style.
do
if attached placeholder as l_placeholder then
a_target.append (" placeholder=%"")
a_target.append (l_placeholder)
a_target.append_character ('%"')
end
--TODO check how we can add xhtml5 support
-- if a_theme.has_xhtml5_support then
-- ....
if autofocus then
a_target.append (" autofocus")
end
if autocomplete then
a_target.append (" autocomplete=%"")
a_target.append ("off")
a_target.append_character ('%"')
end
if required then
a_target.append (" required")
end
if attached pattern as l_pattern then
a_target.append (" pattern=%"")
a_target.append (l_pattern)
a_target.append_character ('%"')
end
end
end

View File

@@ -0,0 +1,37 @@
note
description: "Summary description for {WSF_FORM_MONTH_INPUT}."
date: "$Date$"
revision: "$Revision$"
EIS: "name=month", "src=https://html.spec.whatwg.org/multipage/forms.html#month-state-(type=month)"
class
WSF_FORM_MONTH_INPUT
inherit
WSF_FORM_INPUT
redefine
specific_input_attributes_string
end
WSF_FORM_WITH_NUMERIC_ATTRIBUTE
create
make,
make_with_text
feature -- Access
input_type: STRING = "month"
feature {NONE} -- Conversion
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
create Result.make_empty
append_numeric_input_attributes_to (Result)
end
end

View File

@@ -0,0 +1,23 @@
note
description: "[
Represent the intput type search
Example
<input type="search" name="Search">
]"
date: "$Date$"
revision: "$Revision$"
EIS: "name=search", "src=https://html.spec.whatwg.org/multipage/forms.html#text-(type=text)-state-and-search-state-(type=search)"
class
WSF_FORM_SEARCH_INPUT
inherit
WSF_FORM_INPUT
create
make,
make_with_text
feature -- Access
input_type: STRING = "search"
end

View File

@@ -9,7 +9,11 @@ class
inherit
WSF_FORM_INPUT
redefine
specific_input_attributes_string
end
WSF_FORM_WITH_ATLERNATIVE_ACTIONS
create
make,
make_with_text
@@ -18,4 +22,14 @@ feature -- Access
input_type: STRING = "submit"
feature {NONE} -- Conversion
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
create Result.make_empty
append_submit_image_input_attributes_to (Result)
end
end

View File

@@ -0,0 +1,24 @@
note
description: "[
Represent an input type tel
Example
<input type="tel" name="tel" id="tel" required>
]"
date: "$Date$"
revision: "$Revision$"
EIS: "name=tel", "src=https://html.spec.whatwg.org/multipage/forms.html#telephone-state-(type=tel)"
class
WSF_FORM_TEL_INPUT
inherit
WSF_FORM_INPUT
create
make,
make_with_text
feature -- Access
input_type: STRING = "tel"
end

View File

@@ -0,0 +1,36 @@
note
description: "Summary description for {WSF_FORM_TIME_INPUT}."
date: "$Date$"
revision: "$Revision$"
EIS: "name=time", "src=https://html.spec.whatwg.org/multipage/forms.html#time-state-(type=time)"
class
WSF_FORM_TIME_INPUT
inherit
WSF_FORM_INPUT
redefine
specific_input_attributes_string
end
WSF_FORM_WITH_NUMERIC_ATTRIBUTE
create
make,
make_with_text
feature -- Access
input_type: STRING = "time"
feature {NONE} -- Conversion
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
create Result.make_empty
append_numeric_input_attributes_to (Result)
end
end

View File

@@ -0,0 +1,24 @@
note
description: "[
Represent the input type url
Example
<input type="url" name="url" required>
]"
date: "$Date$"
revision: "$Revision$"
EIS: "name=url", "src=https://html.spec.whatwg.org/multipage/forms.html#url-state-(type=url)"
class
WSF_FORM_URL_INPUT
inherit
WSF_FORM_INPUT
create
make,
make_with_text
feature -- Access
input_type: STRING = "url"
end

View File

@@ -0,0 +1,43 @@
note
description: "[
Represent an input type week
Example
<input id="vacation" name="vacation" type="week">
]"
date: "$Date$"
revision: "$Revision$"
EIS: "name=week", "src=https://html.spec.whatwg.org/multipage/forms.html#week-state-(type=week)"
class
WSF_FORM_WEEK_INPUT
inherit
WSF_FORM_INPUT
redefine
specific_input_attributes_string
end
WSF_FORM_WITH_NUMERIC_ATTRIBUTE
create
make,
make_with_text
feature -- Access
input_type: STRING = "week"
feature {NONE} -- Conversion
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
create Result.make_empty
append_numeric_input_attributes_to (Result)
end
end

View File

@@ -0,0 +1,136 @@
note
description: "[
Represent alternative actions for forms
The formaction, formenctype, formmethod, and formtarget attributes.
]"
date: "$Date$"
revision: "$Revision$"
class
WSF_FORM_WITH_ATLERNATIVE_ACTIONS
feature -- Access
formnovalidate: BOOLEAN
-- indicate that the form shouldnt be validated when submitted.
-- it's only applicable to input type=submit or image.
formaction: detachable READABLE_STRING_32
-- formaction specifies the file or application that will submit the form.
-- It has the same effect as the action attribute on the form element and
-- can only be used with a submit or image button (type="submit" or type="image").
-- When the form is submitted, the browser first checks for a formaction attribute;
-- if that isnt present, it proceeds to look for an action attribute on the form.
formenctype: detachable READABLE_STRING_32
-- formenctype details how the form data is encoded with the POST method type.
-- It has the same effect as the enctype attribute on the form element and
-- can only be used with a submit or image button (type="submit" or type="image").
-- The default value if not included is application/x-www-formurlencoded.
--! At the moment the value is not validated.
formmethod: detachable READABLE_STRING_32
-- formmethod specifies which HTTP method (GET, POST, PUT, DELETE) will be used to submit the form data.
-- It has the same effect as the method attribute on the form element and can only be used with a
-- submit or image button (type="submit" or type="image").
--!At the moment the value is not validated.
formtarget: detachable READABLE_STRING_32
-- formtarget specifies the target window for the form results.
-- It has the same effect as the target attribute on the form element and can only be used with a submit or image button (type="submit" or type="image").
feature -- Element Change
set_formnovalidate
-- Set formnovalidate to True.
do
formnovalidate := True
ensure
formnovalidate_true: formnovalidate
end
unset_formnovalidate
-- Set formnovalidate to False.
do
formnovalidate := False
ensure
formnovalidate_false: not formnovalidate
end
set_formaction (a_action: READABLE_STRING_32)
-- Set `formaction' with `a_action'.
-- Example:<input type="submit" value="Submit" formaction="/users">
do
formaction := a_action
ensure
formaction_set: attached formaction as l_action implies l_action = a_action
end
set_formenctype (a_enctype: READABLE_STRING_32)
-- Set `formenctype' with `a_enctype'.
-- Example: <input type="submit" value="Submit" formenctype="application/x-www-form-urlencoded">
do
formenctype := a_enctype
ensure
formenctype_set: attached formenctype as l_enctype implies l_enctype = a_enctype
end
set_formmethod (a_method: READABLE_STRING_32)
-- Set `formmethod' with `a_method'.
-- Example: <input type="submit" value="Submit" formmethod="POST">
--! require is_valid_method: [PUT, POST, DELETE, GET, ...]
do
formmethod := a_method
ensure
formmethod_set: attached formmethod as l_method implies l_method = a_method
end
set_formtarget (a_target: READABLE_STRING_32)
-- Set `formtarget' with `a_target'.
-- Example: <input type="submit" value="Submit" formtarget="_self">
do
formtarget := a_target
ensure
formtarget_set: attached formtarget as l_target implies l_target = a_target
end
feature {NONE} -- Conversion
append_submit_image_input_attributes_to (a_target: STRING_8)
-- Append specific input attributes for submit/image to a_target,
do
--formnovalidate
if formnovalidate then
a_target.append (" formnovalidate")
end
--formaction
if attached formaction as l_formaction then
a_target.append (" formaction=%"")
a_target.append (l_formaction)
a_target.append_character ('%"')
end
--formenctype
if attached formenctype as l_enctype then
a_target.append (" formenctype=%"")
a_target.append (l_enctype)
a_target.append_character ('%"')
end
-- formmethod
if attached formmethod as l_method then
a_target.append (" formmethod=%"")
a_target.append (l_method)
a_target.append_character ('%"')
end
-- formmethod
if attached formtarget as l_target then
a_target.append (" formtarget=%"")
a_target.append (l_target)
a_target.append_character ('%"')
end
end
end

View File

@@ -0,0 +1,101 @@
note
description: "[
Represent attributes applicable to input type type=[number, range, date]
The attributes: min, max, step.
]"
date: "$Date$"
revision: "$Revision$"
class
WSF_FORM_WITH_NUMERIC_ATTRIBUTE
feature -- Access
min: detachable READABLE_STRING_32
-- Represent the minimun value the field will accept
max: detachable READABLE_STRING_32
-- Represent the maximun value the field will accept.
step: detachable READABLE_STRING_32
-- step is the increment that the value should adjust up or down, with the default step value being 1.
feature -- Element Change
set_min (a_val: INTEGER)
-- Set `min' with `a_val'.
do
set_min_string (a_val.out)
ensure
min_set: attached min as l_min implies l_min.same_string (a_val.out)
end
set_max (a_val: INTEGER)
-- Set `max' with `a_val'.
do
set_max_string(a_val.out)
ensure
max_set: attached max as l_max implies l_max.same_string (a_val.out)
end
set_step (a_val: REAL)
-- Set `step' with `a_val'.
do
set_step_string (a_val.out)
ensure
step_set: attached step as l_step implies l_step.same_string (a_val.out)
end
set_min_string (a_val: READABLE_STRING_32)
-- Set `min' with `a_val'.
do
min := a_val
ensure
min_set: attached min as l_min implies l_min = a_val
end
set_max_string (a_val: READABLE_STRING_32)
-- Set `max' with `a_val'.
do
max := a_val
ensure
max_set: attached max as l_max implies l_max = a_val
end
set_step_string (a_val: READABLE_STRING_32)
-- Set `step' with `a_val'.
do
step := a_val
ensure
step_set: attached step as l_step implies l_step = a_val
end
feature {NONE} -- Conversion
append_numeric_input_attributes_to (a_target: STRING)
-- append numeric attributes to a_target, if any.
do
--min
if attached min as l_min then
a_target.append (" min=%"")
a_target.append (l_min)
a_target.append_character ('%"')
end
--max
if attached max as l_max then
a_target.append (" max=%"")
a_target.append (l_max)
a_target.append_character ('%"')
end
--step
if attached step as l_step then
a_target.append (" step=%"")
a_target.append (l_step)
a_target.append_character ('%"')
end
end
end

View File

@@ -0,0 +1,107 @@
note
description : "test application root class"
date : "$Date$"
revision : "$Revision$"
class
APPLICATION
inherit
ARGUMENTS
create
make
feature {NONE} -- Initialization
make
-- Run application.
local
l_text_input: WSF_FORM_TEXT_INPUT
l_theme: WSF_NULL_THEME
l_input_type: WSF_FORM_SUBMIT_INPUT
l_search_type: WSF_FORM_SEARCH_INPUT
l_email_type: WSF_FORM_EMAIL_INPUT
l_number_type: WSF_FORM_NUMBER_INPUT
do
create l_theme.make
-- Basic example
create l_text_input.make_with_text ("fullname", "some text example")
print (l_text_input.to_html (l_theme))
io.put_new_line
-- Placeholder
create l_text_input.make ("fullname")
l_text_input.set_placeholder ("John Doe")
print (l_text_input.to_html (l_theme))
io.put_new_line
-- autofocus
create l_text_input.make ("fullname")
l_text_input.set_autofocus
print (l_text_input.to_html (l_theme))
io.put_new_line
-- autocomplete
create l_text_input.make ("fullname")
l_text_input.turn_off_autocomplete
print (l_text_input.to_html (l_theme))
io.put_new_line
-- required
create l_text_input.make ("fullname")
l_text_input.set_required
print (l_text_input.to_html (l_theme))
io.put_new_line
-- pattern
create l_text_input.make ("product")
l_text_input.set_pattern ("[0-9][A-Z]{3}")
print (l_text_input.to_html (l_theme))
io.put_new_line
-- basic submit
create l_input_type.make ("Submit")
print (l_input_type.to_html (l_theme))
io.put_new_line
-- basic submit with formnovalidate
create l_input_type.make ("Submit")
l_input_type.set_formnovalidate
print (l_input_type.to_html (l_theme))
io.put_new_line
-- input search
create l_search_type.make ("Search")
print (l_search_type.to_html (l_theme))
io.put_new_line
-- input email
create l_email_type.make ("Email")
print (l_email_type.to_html (l_theme))
io.put_new_line
-- input number
create l_number_type.make ("Price")
l_number_type.set_min (1)
l_number_type.set_max (10)
l_number_type.set_step (0.5)
print (l_number_type.to_html (l_theme))
end
end

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="test" uuid="F428CCD3-FF90-4E80-8C60-BFF17F72F0FA">
<target name="test">
<root class="APPLICATION" feature="make"/>
<option warning="true">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<setting name="console_application" value="true"/>
<precompile name="base_pre" location="$ISE_PRECOMP\base-safe.ecf"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
<library name="wsf_html" location="..\..\..\library\server\wsf_html\wsf_html-safe.ecf" readonly="false"/>
<cluster name="test" location=".\" recursive="true">
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
</cluster>
</target>
</system>

View File

@@ -0,0 +1,118 @@
note
description: "[
Eiffel tests that can be executed by testing tool.
]"
author: "EiffelStudio test wizard"
date: "$Date$"
revision: "$Revision$"
testing: "type/manual"
class
WSF_FORM_INPUT_HTML5_TEST_SET
inherit
EQA_TEST_SET
feature -- Test routines
test_placeholder
-- <input type="text" name="fullname" placeholder="John Doe">
local
l_text_input: WSF_FORM_TEXT_INPUT
l_theme: WSF_NULL_THEME
l_placeholder: STRING
do
l_placeholder := "<div><input type=%"text%" name=%"fullname%" placeholder=%"John Doe%"/></div>"
create l_theme.make
create l_text_input.make ("fullname")
l_text_input.set_placeholder ("John Doe")
assert ("expected input with placeholder",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_placeholder) )
end
test_autofocus
-- <input type="text" name="fullname" autofocus>
local
l_text_input: WSF_FORM_TEXT_INPUT
l_theme: WSF_NULL_THEME
l_autofocus: STRING
do
l_autofocus := "<div><input type=%"text%" name=%"fullname%" autofocus/></div>"
create l_theme.make
create l_text_input.make ("fullname")
l_text_input.set_autofocus
assert ("expected input with autofocus",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_autofocus) )
l_text_input.unset_autofocus
l_autofocus := "<div><input type=%"text%" name=%"fullname%"/></div>"
assert ("expected input without autofocus",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_autofocus) )
end
test_autocomplete
-- <input type="text" name="fullname" autocomplete="off">
local
l_text_input: WSF_FORM_TEXT_INPUT
l_theme: WSF_NULL_THEME
l_autocomplete: STRING
do
l_autocomplete := "<div><input type=%"text%" name=%"fullname%" autocomplete=%"off%"/></div>"
create l_theme.make
create l_text_input.make ("fullname")
l_text_input.turn_off_autocomplete
assert ("expected input with autocomplete in off",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_autocomplete) )
l_text_input.turn_on_autocomplete
l_autocomplete := "<div><input type=%"text%" name=%"fullname%"/></div>"
assert ("expected input without autocomplete",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_autocomplete) )
end
test_required
-- <input type="text" name="fullname" required>
local
l_text_input: WSF_FORM_TEXT_INPUT
l_theme: WSF_NULL_THEME
l_required: STRING
do
l_required := "<div><input type=%"text%" name=%"fullname%" required/></div>"
create l_theme.make
create l_text_input.make ("fullname")
l_text_input.set_required
assert ("expected input with required",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_required) )
l_text_input.unset_required
l_required := "<div><input type=%"text%" name=%"fullname%"/></div>"
assert ("expected input without required",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_required) )
end
test_pattern
-- <input type="text" name="product" pattern="[0-9][A-Z]{3}"/>
local
l_text_input: WSF_FORM_TEXT_INPUT
l_theme: WSF_NULL_THEME
l_pattern: STRING
do
l_pattern := "<div><input type=%"text%" name=%"product%" pattern=%"[0-9][A-Z]{3}%"/></div>"
create l_theme.make
create l_text_input.make ("product")
l_text_input.set_pattern ("[0-9][A-Z]{3}")
assert ("expected input with pattern",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_pattern) )
end
end

View File

@@ -0,0 +1,40 @@
note
description: "[
Represent the input type number.
Example:
<input type="number" min="5" max="18" step="0.5" value="9" name="shoe-size">
]"
date: "$Date$"
revision: "$Revision$"
EIS: "name= Number", "src=https://html.spec.whatwg.org/multipage/forms.html#number-state-(type=number)"
class
WSF_FORM_NUMBER_INPUT
inherit
WSF_FORM_INPUT
redefine
specific_input_attributes_string
end
WSF_FORM_WITH_NUMERIC_ATTRIBUTE
create
make,
make_with_text
feature -- Access
input_type: STRING = "number"
feature {NONE} -- Conversion
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
create Result.make_empty
append_numeric_input_attributes_to (Result)
end
end

View File

@@ -0,0 +1,40 @@
note
description: "[
Represent an input type range
Example
<input type="range" min=0 max=100 step=20 value=50>
]"
date: "$Date$"
revision: "$Revision$"
class
WSF_FORM_RANGE_INPUT
inherit
WSF_FORM_INPUT
redefine
specific_input_attributes_string
end
WSF_FORM_WITH_NUMERIC_ATTRIBUTE
create
make,
make_with_text
feature -- Access
input_type: STRING = "range"
feature {NONE} -- Conversion
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
create Result.make_empty
append_numeric_input_attributes_to (Result)
end
end

View File

@@ -0,0 +1,31 @@
note
description: " Null theme for void-safety and test purpose."
date: "$Date$"
revision: "$Revision$"
class
WSF_NULL_THEME
inherit
WSF_THEME
create
make
feature {NONE} -- Initialization
make
do
end
feature -- Core
site_url: STRING = ""
base_url: detachable READABLE_STRING_8
-- Base url if any.
do
end
end