Added wsf_html documentation in the doc/workbook.

Also improved the structure of `wsf_html` library.
Added a few widgets.
This commit is contained in:
2017-02-14 19:37:03 +01:00
parent b93cb17f7c
commit 5dc9d82df7
43 changed files with 401 additions and 33 deletions

View File

@@ -0,0 +1,20 @@
note
description: "Summary description for {WSF_FORM_BUTTON_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_FORM_BUTTON_INPUT
inherit
WSF_FORM_INPUT
create
make
feature -- Access
input_type: STRING = "button"
end

View File

@@ -0,0 +1,23 @@
note
description: "Summary description for {WSF_FORM_CHECKBOX_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_FORM_CHECKBOX_INPUT
inherit
WSF_FORM_SELECTABLE_INPUT
create
make,
make_with_value
feature -- Access
input_type: STRING = "checkbox"
invariant
end

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_FIELD_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_FIELD_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_FIELD_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

@@ -0,0 +1,46 @@
note
description: "Summary description for {WSF_FORM_FILE_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_FORM_FILE_INPUT
inherit
WSF_FORM_INPUT
redefine
specific_input_attributes_string
end
create
make
feature -- Access
input_type: STRING = "file"
accepted_types: detachable READABLE_STRING_8
-- Types of files that the server accepts
feature -- Change
set_accepted_types (v: like accepted_types)
do
accepted_types := v
end
feature {NONE} -- Implementation
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
if attached accepted_types as l_accepted_types then
Result := " accept=%"" + l_accepted_types + "%""
end
end
invariant
end

View File

@@ -0,0 +1,37 @@
note
description: "Summary description for {WSF_FORM_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_FORM_HIDDEN_INPUT
inherit
WSF_FORM_INPUT
redefine
input_type,
append_item_to_html
end
create
make,
make_with_text
feature -- Access
input_type: STRING
once
Result := "hidden"
end
feature -- Conversion
append_item_to_html (a_theme: WSF_THEME; a_html: STRING_8)
do
a_html.append ("<div style=%"display:none%">")
Precursor (a_theme, a_html)
a_html.append ("</div>")
end
end

View File

@@ -0,0 +1,61 @@
note
description: "Summary description for {WSF_FORM_IMAGE_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_FORM_IMAGE_INPUT
inherit
WSF_FORM_INPUT
redefine
specific_input_attributes_string
end
WSF_FORM_WITH_ALTERNATIVE_ACTIONS
create
make
feature -- Access
input_type: STRING = "image"
src: detachable READABLE_STRING_8
-- Specifies the URL of the image to use as a submit button
alt: detachable READABLE_STRING_8
-- Alternate text for an image.
feature -- Change
set_src (v: like src)
do
src := v
end
set_alt (v: like alt)
do
alt := v
end
feature {NONE} -- Implementation
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
create Result.make_empty
if attached src as l_src then
Result.append (" src=%"" + l_src + "%"")
end
if attached alt as l_alt then
Result.append (" alt=%"" + l_alt + "%"")
end
append_submit_image_input_attributes_to (Result)
end
invariant
end

View File

@@ -0,0 +1,41 @@
note
description: "[
Represent an input type Month
Example:
<input id="expiry" name="expiry" type="month" required>
]"
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_FIELD_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,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_FIELD_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,27 @@
note
description: "Summary description for {WSF_FORM_PASSWORD_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_FORM_PASSWORD_INPUT
inherit
WSF_FORM_INPUT
redefine
input_type
end
create
make,
make_with_text
feature -- Access
input_type: STRING
once
Result := "password"
end
end

View File

@@ -0,0 +1,23 @@
note
description: "Summary description for {WSF_FORM_RADIO_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_FORM_RADIO_INPUT
inherit
WSF_FORM_SELECTABLE_INPUT
create
make,
make_with_value
feature -- Access
input_type: STRING = "radio"
invariant
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_FIELD_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,20 @@
note
description: "Summary description for {WSF_FORM_RESET_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_FORM_RESET_INPUT
inherit
WSF_FORM_INPUT
create
make
feature -- Access
input_type: STRING = "reset"
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

@@ -0,0 +1,122 @@
note
description: "Summary description for {WSF_FORM_SELECTABLE_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_FORM_SELECTABLE_INPUT
inherit
WSF_FORM_INPUT
rename
default_value as value,
make_with_text as make_with_value
redefine
set_value,
specific_input_attributes_string,
append_child_to_html
end
WSF_FORM_SELECTABLE_ITEM
rename
is_selected as checked,
set_is_selected as set_checked
end
feature -- Access
checked: BOOLEAN
-- Current <input> element should be preselected when the page loads
title: detachable READABLE_STRING_32
raw_title: detachable READABLE_STRING_8
feature -- Status report
is_same_value (v: READABLE_STRING_32): BOOLEAN
do
Result := attached value as l_value and then v.same_string (l_value)
end
feature -- Change
set_title (t: detachable READABLE_STRING_32)
do
title := t
end
set_raw_title (t: detachable READABLE_STRING_8)
do
raw_title := t
end
set_checked (b: like checked)
do
checked := b
end
set_checked_by_value (v: detachable WSF_VALUE)
do
if attached {WSF_STRING} v as s then
if value /= Void then
set_checked (is_same_value (s.value))
else
set_checked (s.value.same_string ("on") or s.value.same_string ("true") or s.value.same_string ("yes") or s.value.same_string ("enabled"))
end
else
set_checked (False)
end
end
set_value (v: detachable WSF_VALUE)
-- Set value `v' if applicable to Current
local
l_found: BOOLEAN
do
if attached {ITERABLE [WSF_VALUE]} v as lst then
across
lst as c
until
l_found
loop
if attached {WSF_STRING} c.item as s and then is_same_value (s.value) then
set_checked_by_value (c.item)
l_found := True
end
end
if not l_found then
set_checked (False)
end
else
set_checked_by_value (v)
Precursor (v)
end
end
feature {NONE} -- Implementation
append_child_to_html (a_theme: WSF_THEME; a_html: STRING_8)
-- Specific child element if any.
--| To redefine if needed
do
if attached raw_title as t then
a_html.append (t)
elseif attached title as t then
a_html.append (a_theme.html_encoded (t))
end
end
specific_input_attributes_string: detachable STRING_8
-- Specific input attributes if any.
-- To redefine if needed
do
if checked then
Result := "checked=%"checked%""
end
end
invariant
end

View File

@@ -0,0 +1,35 @@
note
description: "Summary description for {WSF_FORM_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_FORM_SUBMIT_INPUT
inherit
WSF_FORM_INPUT
redefine
specific_input_attributes_string
end
WSF_FORM_WITH_ALTERNATIVE_ACTIONS
create
make,
make_with_text
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,21 @@
note
description: "Summary description for {WSF_FORM_TEXT_INPUT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_FORM_TEXT_INPUT
inherit
WSF_FORM_INPUT
create
make,
make_with_text
feature -- Access
input_type: STRING = "text"
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_FIELD_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_FIELD_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