From 28e51cc314aeedfee901336ca5a1715eff14d7c9 Mon Sep 17 00:00:00 2001 From: jvelilla Date: Thu, 21 May 2015 12:32:08 -0300 Subject: [PATCH 1/5] 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. --- .../wsf_html/form/wsf_form_color_input.e | 24 +++ .../wsf_html/form/wsf_form_date_input.e | 39 ++++ .../wsf_html/form/wsf_form_datetime_input.e | 42 +++++ .../form/wsf_form_datetime_local_input.e | 41 +++++ .../wsf_html/form/wsf_form_email_input.e | 26 +++ .../wsf_html/form/wsf_form_image_input.e | 3 + library/server/wsf_html/form/wsf_form_input.e | 4 + .../wsf_html/form/wsf_form_input_with_html5.e | 174 ++++++++++++++++++ .../wsf_html/form/wsf_form_month_input.e | 37 ++++ .../wsf_html/form/wsf_form_search_input.e | 23 +++ .../wsf_html/form/wsf_form_submit_input.e | 16 +- .../server/wsf_html/form/wsf_form_tel_input.e | 24 +++ .../wsf_html/form/wsf_form_time_input.e | 36 ++++ .../server/wsf_html/form/wsf_form_url_input.e | 24 +++ .../wsf_html/form/wsf_form_week_input.e | 43 +++++ .../form/wsf_form_with_atlernative_actions.e | 136 ++++++++++++++ .../form/wsf_form_with_numeric_attribute.e | 101 ++++++++++ tests/server/wsf_html/application.e | 107 +++++++++++ tests/server/wsf_html/test.ecf | 21 +++ .../wsf_html/wsf_form_input_html5_test_set.e | 118 ++++++++++++ tests/server/wsf_html/wsf_form_number_input.e | 40 ++++ tests/server/wsf_html/wsf_form_range_input.e | 40 ++++ tests/server/wsf_html/wsf_null_theme.e | 31 ++++ 23 files changed, 1149 insertions(+), 1 deletion(-) create mode 100644 library/server/wsf_html/form/wsf_form_color_input.e create mode 100644 library/server/wsf_html/form/wsf_form_date_input.e create mode 100644 library/server/wsf_html/form/wsf_form_datetime_input.e create mode 100644 library/server/wsf_html/form/wsf_form_datetime_local_input.e create mode 100644 library/server/wsf_html/form/wsf_form_email_input.e create mode 100644 library/server/wsf_html/form/wsf_form_input_with_html5.e create mode 100644 library/server/wsf_html/form/wsf_form_month_input.e create mode 100644 library/server/wsf_html/form/wsf_form_search_input.e create mode 100644 library/server/wsf_html/form/wsf_form_tel_input.e create mode 100644 library/server/wsf_html/form/wsf_form_time_input.e create mode 100644 library/server/wsf_html/form/wsf_form_url_input.e create mode 100644 library/server/wsf_html/form/wsf_form_week_input.e create mode 100644 library/server/wsf_html/form/wsf_form_with_atlernative_actions.e create mode 100644 library/server/wsf_html/form/wsf_form_with_numeric_attribute.e create mode 100644 tests/server/wsf_html/application.e create mode 100644 tests/server/wsf_html/test.ecf create mode 100644 tests/server/wsf_html/wsf_form_input_html5_test_set.e create mode 100644 tests/server/wsf_html/wsf_form_number_input.e create mode 100644 tests/server/wsf_html/wsf_form_range_input.e create mode 100644 tests/server/wsf_html/wsf_null_theme.e diff --git a/library/server/wsf_html/form/wsf_form_color_input.e b/library/server/wsf_html/form/wsf_form_color_input.e new file mode 100644 index 00000000..d8eaec3e --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_color_input.e @@ -0,0 +1,24 @@ +note + description: "[ + Represent an input type color + Example + + ]" + 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 + diff --git a/library/server/wsf_html/form/wsf_form_date_input.e b/library/server/wsf_html/form/wsf_form_date_input.e new file mode 100644 index 00000000..309721b5 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_date_input.e @@ -0,0 +1,39 @@ +note + description: "[ + Example: + + ]" + 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 diff --git a/library/server/wsf_html/form/wsf_form_datetime_input.e b/library/server/wsf_html/form/wsf_form_datetime_input.e new file mode 100644 index 00000000..5c7cf6e2 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_datetime_input.e @@ -0,0 +1,42 @@ +note + description: "[ + Represent an input type datetime + Example + + ]" + 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 diff --git a/library/server/wsf_html/form/wsf_form_datetime_local_input.e b/library/server/wsf_html/form/wsf_form_datetime_local_input.e new file mode 100644 index 00000000..a64d080a --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_datetime_local_input.e @@ -0,0 +1,41 @@ +note + description: "[ + Represent an input type datetime-local + Example: + + ]" + 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 diff --git a/library/server/wsf_html/form/wsf_form_email_input.e b/library/server/wsf_html/form/wsf_form_email_input.e new file mode 100644 index 00000000..36522097 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_email_input.e @@ -0,0 +1,26 @@ +note + description: "[ + Represent the intput type email + Example: + + ]" + 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 diff --git a/library/server/wsf_html/form/wsf_form_image_input.e b/library/server/wsf_html/form/wsf_form_image_input.e index 60022600..2fe880c2 100644 --- a/library/server/wsf_html/form/wsf_form_image_input.e +++ b/library/server/wsf_html/form/wsf_form_image_input.e @@ -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 diff --git a/library/server/wsf_html/form/wsf_form_input.e b/library/server/wsf_html/form/wsf_form_input.e index 494e8f9d..035c7410 100644 --- a/library/server/wsf_html/form/wsf_form_input.e +++ b/library/server/wsf_html/form/wsf_form_input.e @@ -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 diff --git a/library/server/wsf_html/form/wsf_form_input_with_html5.e b/library/server/wsf_html/form/wsf_form_input_with_html5.e new file mode 100644 index 00000000..05f1fa81 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_input_with_html5.e @@ -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 field’s 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 + -- + -- + + -- 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. + -- + +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 they’re set if they’re present and not set if they’re 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 diff --git a/library/server/wsf_html/form/wsf_form_month_input.e b/library/server/wsf_html/form/wsf_form_month_input.e new file mode 100644 index 00000000..8843ff23 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_month_input.e @@ -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 diff --git a/library/server/wsf_html/form/wsf_form_search_input.e b/library/server/wsf_html/form/wsf_form_search_input.e new file mode 100644 index 00000000..722184e8 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_search_input.e @@ -0,0 +1,23 @@ +note + description: "[ + Represent the intput type search + Example + + ]" + 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 diff --git a/library/server/wsf_html/form/wsf_form_submit_input.e b/library/server/wsf_html/form/wsf_form_submit_input.e index 32f0fab3..e289fd28 100644 --- a/library/server/wsf_html/form/wsf_form_submit_input.e +++ b/library/server/wsf_html/form/wsf_form_submit_input.e @@ -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 diff --git a/library/server/wsf_html/form/wsf_form_tel_input.e b/library/server/wsf_html/form/wsf_form_tel_input.e new file mode 100644 index 00000000..f0c81ac6 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_tel_input.e @@ -0,0 +1,24 @@ +note + description: "[ + Represent an input type tel + Example + + ]" + 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 diff --git a/library/server/wsf_html/form/wsf_form_time_input.e b/library/server/wsf_html/form/wsf_form_time_input.e new file mode 100644 index 00000000..260a82b8 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_time_input.e @@ -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 diff --git a/library/server/wsf_html/form/wsf_form_url_input.e b/library/server/wsf_html/form/wsf_form_url_input.e new file mode 100644 index 00000000..cd7f3440 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_url_input.e @@ -0,0 +1,24 @@ +note + description: "[ + Represent the input type url + Example + + ]" + 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 diff --git a/library/server/wsf_html/form/wsf_form_week_input.e b/library/server/wsf_html/form/wsf_form_week_input.e new file mode 100644 index 00000000..334827b4 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_week_input.e @@ -0,0 +1,43 @@ +note + description: "[ + Represent an input type week + Example + + + ]" + 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 + + diff --git a/library/server/wsf_html/form/wsf_form_with_atlernative_actions.e b/library/server/wsf_html/form/wsf_form_with_atlernative_actions.e new file mode 100644 index 00000000..69644aef --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_with_atlernative_actions.e @@ -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 shouldn’t 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 isn’t 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: + 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: + 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: + --! 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: + 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 diff --git a/library/server/wsf_html/form/wsf_form_with_numeric_attribute.e b/library/server/wsf_html/form/wsf_form_with_numeric_attribute.e new file mode 100644 index 00000000..62c70351 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_with_numeric_attribute.e @@ -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 diff --git a/tests/server/wsf_html/application.e b/tests/server/wsf_html/application.e new file mode 100644 index 00000000..2994585f --- /dev/null +++ b/tests/server/wsf_html/application.e @@ -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 diff --git a/tests/server/wsf_html/test.ecf b/tests/server/wsf_html/test.ecf new file mode 100644 index 00000000..acdcffcc --- /dev/null +++ b/tests/server/wsf_html/test.ecf @@ -0,0 +1,21 @@ + + + + + + + + + + + + + /EIFGENs$ + /CVS$ + /.svn$ + + + + diff --git a/tests/server/wsf_html/wsf_form_input_html5_test_set.e b/tests/server/wsf_html/wsf_form_input_html5_test_set.e new file mode 100644 index 00000000..fc07749a --- /dev/null +++ b/tests/server/wsf_html/wsf_form_input_html5_test_set.e @@ -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 + -- + local + l_text_input: WSF_FORM_TEXT_INPUT + l_theme: WSF_NULL_THEME + l_placeholder: STRING + do + l_placeholder := "
" + 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 + -- + local + l_text_input: WSF_FORM_TEXT_INPUT + l_theme: WSF_NULL_THEME + l_autofocus: STRING + do + l_autofocus := "
" + 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 := "
" + assert ("expected input without autofocus",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_autofocus) ) + + end + + + test_autocomplete + -- + local + l_text_input: WSF_FORM_TEXT_INPUT + l_theme: WSF_NULL_THEME + l_autocomplete: STRING + do + l_autocomplete := "
" + 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 := "
" + assert ("expected input without autocomplete",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_autocomplete) ) + + end + + test_required + -- + local + l_text_input: WSF_FORM_TEXT_INPUT + l_theme: WSF_NULL_THEME + l_required: STRING + do + l_required := "
" + 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 := "
" + assert ("expected input without required",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_required) ) + + end + + + test_pattern + -- + local + l_text_input: WSF_FORM_TEXT_INPUT + l_theme: WSF_NULL_THEME + l_pattern: STRING + do + l_pattern := "
" + 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 + + diff --git a/tests/server/wsf_html/wsf_form_number_input.e b/tests/server/wsf_html/wsf_form_number_input.e new file mode 100644 index 00000000..7a055761 --- /dev/null +++ b/tests/server/wsf_html/wsf_form_number_input.e @@ -0,0 +1,40 @@ +note + description: "[ + Represent the input type number. + Example: + + ]" + 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 diff --git a/tests/server/wsf_html/wsf_form_range_input.e b/tests/server/wsf_html/wsf_form_range_input.e new file mode 100644 index 00000000..5b61b9b7 --- /dev/null +++ b/tests/server/wsf_html/wsf_form_range_input.e @@ -0,0 +1,40 @@ +note + description: "[ + Represent an input type range + Example + + ]" + 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 diff --git a/tests/server/wsf_html/wsf_null_theme.e b/tests/server/wsf_html/wsf_null_theme.e new file mode 100644 index 00000000..7b35ef11 --- /dev/null +++ b/tests/server/wsf_html/wsf_null_theme.e @@ -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 From 94340c1c014a4f312535bbe4398f086ecce404ab Mon Sep 17 00:00:00 2001 From: jvelilla Date: Thu, 28 May 2015 09:19:21 -0300 Subject: [PATCH 2/5] Updated html5 classes based on review --- .../server/wsf_html/form/wsf_form_date_input.e | 2 +- .../wsf_html/form/wsf_form_datetime_input.e | 2 +- .../form/wsf_form_datetime_local_input.e | 2 +- ...e => wsf_form_field_with_numeric_attribute.e} | 13 +++++++------ .../server/wsf_html/form/wsf_form_image_input.e | 2 +- .../wsf_html/form/wsf_form_input_with_html5.e | 16 ++++++++-------- .../server/wsf_html/form/wsf_form_month_input.e | 2 +- .../wsf_html/form}/wsf_form_number_input.e | 2 +- .../server/wsf_html/form}/wsf_form_range_input.e | 2 +- .../server/wsf_html/form/wsf_form_submit_input.e | 2 +- .../server/wsf_html/form/wsf_form_time_input.e | 2 +- .../server/wsf_html/form/wsf_form_week_input.e | 2 +- ...ons.e => wsf_form_with_alternative_actions.e} | 5 +++-- tests/server/wsf_html/application.e | 6 +++--- .../wsf_html/wsf_form_input_html5_test_set.e | 12 ++++++------ 15 files changed, 37 insertions(+), 35 deletions(-) rename library/server/wsf_html/form/{wsf_form_with_numeric_attribute.e => wsf_form_field_with_numeric_attribute.e} (81%) rename {tests/server/wsf_html => library/server/wsf_html/form}/wsf_form_number_input.e (94%) rename {tests/server/wsf_html => library/server/wsf_html/form}/wsf_form_range_input.e (93%) rename library/server/wsf_html/form/{wsf_form_with_atlernative_actions.e => wsf_form_with_alternative_actions.e} (96%) diff --git a/library/server/wsf_html/form/wsf_form_date_input.e b/library/server/wsf_html/form/wsf_form_date_input.e index 309721b5..e825f842 100644 --- a/library/server/wsf_html/form/wsf_form_date_input.e +++ b/library/server/wsf_html/form/wsf_form_date_input.e @@ -16,7 +16,7 @@ inherit specific_input_attributes_string end - WSF_FORM_WITH_NUMERIC_ATTRIBUTE + WSF_FORM_FIELD_WITH_NUMERIC_ATTRIBUTE create make, diff --git a/library/server/wsf_html/form/wsf_form_datetime_input.e b/library/server/wsf_html/form/wsf_form_datetime_input.e index 5c7cf6e2..c7a25fe9 100644 --- a/library/server/wsf_html/form/wsf_form_datetime_input.e +++ b/library/server/wsf_html/form/wsf_form_datetime_input.e @@ -19,7 +19,7 @@ inherit specific_input_attributes_string end - WSF_FORM_WITH_NUMERIC_ATTRIBUTE + WSF_FORM_FIELD_WITH_NUMERIC_ATTRIBUTE create make, diff --git a/library/server/wsf_html/form/wsf_form_datetime_local_input.e b/library/server/wsf_html/form/wsf_form_datetime_local_input.e index a64d080a..b3317a24 100644 --- a/library/server/wsf_html/form/wsf_form_datetime_local_input.e +++ b/library/server/wsf_html/form/wsf_form_datetime_local_input.e @@ -16,7 +16,7 @@ inherit specific_input_attributes_string end - WSF_FORM_WITH_NUMERIC_ATTRIBUTE + WSF_FORM_FIELD_WITH_NUMERIC_ATTRIBUTE create make, diff --git a/library/server/wsf_html/form/wsf_form_with_numeric_attribute.e b/library/server/wsf_html/form/wsf_form_field_with_numeric_attribute.e similarity index 81% rename from library/server/wsf_html/form/wsf_form_with_numeric_attribute.e rename to library/server/wsf_html/form/wsf_form_field_with_numeric_attribute.e index 62c70351..f51cc6c3 100644 --- a/library/server/wsf_html/form/wsf_form_with_numeric_attribute.e +++ b/library/server/wsf_html/form/wsf_form_field_with_numeric_attribute.e @@ -5,17 +5,18 @@ note ]" date: "$Date$" revision: "$Revision$" + EIS: "name=numeric attributes", "src=https://html.spec.whatwg.org/multipage/forms.html#common-input-element-attributes" class - WSF_FORM_WITH_NUMERIC_ATTRIBUTE + WSF_FORM_FIELD_WITH_NUMERIC_ATTRIBUTE feature -- Access min: detachable READABLE_STRING_32 - -- Represent the minimun value the field will accept + -- minimun value accepted by Current field. max: detachable READABLE_STRING_32 - -- Represent the maximun value the field will accept. + -- maximun value accepted by Current field. step: detachable READABLE_STRING_32 -- step is the increment that the value should adjust up or down, with the default step value being 1. @@ -79,21 +80,21 @@ feature {NONE} -- Conversion --min if attached min as l_min then a_target.append (" min=%"") - a_target.append (l_min) + a_target.append ((create {HTML_ENCODER}).encoded_string (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 ((create {HTML_ENCODER}).encoded_string (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 ((create {HTML_ENCODER}).encoded_string (l_step)) a_target.append_character ('%"') end end diff --git a/library/server/wsf_html/form/wsf_form_image_input.e b/library/server/wsf_html/form/wsf_form_image_input.e index 2fe880c2..15315236 100644 --- a/library/server/wsf_html/form/wsf_form_image_input.e +++ b/library/server/wsf_html/form/wsf_form_image_input.e @@ -12,7 +12,7 @@ inherit redefine specific_input_attributes_string end - WSF_FORM_WITH_ATLERNATIVE_ACTIONS + WSF_FORM_WITH_ALTERNATIVE_ACTIONS create diff --git a/library/server/wsf_html/form/wsf_form_input_with_html5.e b/library/server/wsf_html/form/wsf_form_input_with_html5.e index 05f1fa81..d36f4e94 100644 --- a/library/server/wsf_html/form/wsf_form_input_with_html5.e +++ b/library/server/wsf_html/form/wsf_form_input_with_html5.e @@ -39,7 +39,7 @@ feature -- Change element placeholder_set: attached placeholder as l_placeholder implies l_placeholder = a_placeholder end - set_autofocus + enable_autofocus -- Set autofocus in True. do autofocus := True @@ -47,7 +47,7 @@ feature -- Change element autofocus_true: autofocus end - unset_autofocus + disable_autofocus -- Set autofocus in False do autofocus := False @@ -55,7 +55,7 @@ feature -- Change element autofocus_false: not autofocus end - turn_off_autocomplete + disable_autocomplete -- Turn off the autocompelte. The default behavior is on. do autocomplete := True @@ -63,7 +63,7 @@ feature -- Change element autocomplete_true: autocomplete end - turn_on_autocomplete + enable_autocomplete -- Set autocomplete in False, Set default behavior. do autocomplete := False @@ -71,7 +71,7 @@ feature -- Change element autocomplete_false: not autocomplete end - set_required + enable_required -- Set required to True. do required := True @@ -79,7 +79,7 @@ feature -- Change element required_true: required end - unset_required + disable_required -- Set rquired to False. do required := False @@ -147,7 +147,7 @@ feature -- Conversion do if attached placeholder as l_placeholder then a_target.append (" placeholder=%"") - a_target.append (l_placeholder) + a_target.append ((create {HTML_ENCODER}).encoded_string (l_placeholder)) a_target.append_character ('%"') end --TODO check how we can add xhtml5 support @@ -166,7 +166,7 @@ feature -- Conversion end if attached pattern as l_pattern then a_target.append (" pattern=%"") - a_target.append (l_pattern) + a_target.append ((create {HTML_ENCODER}).encoded_string (l_pattern)) a_target.append_character ('%"') end end diff --git a/library/server/wsf_html/form/wsf_form_month_input.e b/library/server/wsf_html/form/wsf_form_month_input.e index 8843ff23..85dc04d1 100644 --- a/library/server/wsf_html/form/wsf_form_month_input.e +++ b/library/server/wsf_html/form/wsf_form_month_input.e @@ -14,7 +14,7 @@ inherit specific_input_attributes_string end - WSF_FORM_WITH_NUMERIC_ATTRIBUTE + WSF_FORM_FIELD_WITH_NUMERIC_ATTRIBUTE create make, diff --git a/tests/server/wsf_html/wsf_form_number_input.e b/library/server/wsf_html/form/wsf_form_number_input.e similarity index 94% rename from tests/server/wsf_html/wsf_form_number_input.e rename to library/server/wsf_html/form/wsf_form_number_input.e index 7a055761..648fd4b7 100644 --- a/tests/server/wsf_html/wsf_form_number_input.e +++ b/library/server/wsf_html/form/wsf_form_number_input.e @@ -18,7 +18,7 @@ inherit specific_input_attributes_string end - WSF_FORM_WITH_NUMERIC_ATTRIBUTE + WSF_FORM_FIELD_WITH_NUMERIC_ATTRIBUTE create make, diff --git a/tests/server/wsf_html/wsf_form_range_input.e b/library/server/wsf_html/form/wsf_form_range_input.e similarity index 93% rename from tests/server/wsf_html/wsf_form_range_input.e rename to library/server/wsf_html/form/wsf_form_range_input.e index 5b61b9b7..806d4751 100644 --- a/tests/server/wsf_html/wsf_form_range_input.e +++ b/library/server/wsf_html/form/wsf_form_range_input.e @@ -17,7 +17,7 @@ inherit specific_input_attributes_string end - WSF_FORM_WITH_NUMERIC_ATTRIBUTE + WSF_FORM_FIELD_WITH_NUMERIC_ATTRIBUTE create make, diff --git a/library/server/wsf_html/form/wsf_form_submit_input.e b/library/server/wsf_html/form/wsf_form_submit_input.e index e289fd28..dd4af67b 100644 --- a/library/server/wsf_html/form/wsf_form_submit_input.e +++ b/library/server/wsf_html/form/wsf_form_submit_input.e @@ -12,7 +12,7 @@ inherit redefine specific_input_attributes_string end - WSF_FORM_WITH_ATLERNATIVE_ACTIONS + WSF_FORM_WITH_ALTERNATIVE_ACTIONS create make, diff --git a/library/server/wsf_html/form/wsf_form_time_input.e b/library/server/wsf_html/form/wsf_form_time_input.e index 260a82b8..dfbf507b 100644 --- a/library/server/wsf_html/form/wsf_form_time_input.e +++ b/library/server/wsf_html/form/wsf_form_time_input.e @@ -13,7 +13,7 @@ inherit specific_input_attributes_string end - WSF_FORM_WITH_NUMERIC_ATTRIBUTE + WSF_FORM_FIELD_WITH_NUMERIC_ATTRIBUTE create make, diff --git a/library/server/wsf_html/form/wsf_form_week_input.e b/library/server/wsf_html/form/wsf_form_week_input.e index 334827b4..00778c84 100644 --- a/library/server/wsf_html/form/wsf_form_week_input.e +++ b/library/server/wsf_html/form/wsf_form_week_input.e @@ -18,7 +18,7 @@ inherit specific_input_attributes_string end - WSF_FORM_WITH_NUMERIC_ATTRIBUTE + WSF_FORM_FIELD_WITH_NUMERIC_ATTRIBUTE create make, diff --git a/library/server/wsf_html/form/wsf_form_with_atlernative_actions.e b/library/server/wsf_html/form/wsf_form_with_alternative_actions.e similarity index 96% rename from library/server/wsf_html/form/wsf_form_with_atlernative_actions.e rename to library/server/wsf_html/form/wsf_form_with_alternative_actions.e index 69644aef..fc5183b4 100644 --- a/library/server/wsf_html/form/wsf_form_with_atlernative_actions.e +++ b/library/server/wsf_html/form/wsf_form_with_alternative_actions.e @@ -1,13 +1,14 @@ note description: "[ Represent alternative actions for forms - The formaction, formenctype, formmethod, and formtarget attributes. + The formaction, formenctype, formmethod, and formtarget attributes. ]" date: "$Date$" revision: "$Revision$" + EIS: "name=form submission", "src=https://html.spec.whatwg.org/multipage/forms.html#form-submission" class - WSF_FORM_WITH_ATLERNATIVE_ACTIONS + WSF_FORM_WITH_ALTERNATIVE_ACTIONS feature -- Access diff --git a/tests/server/wsf_html/application.e b/tests/server/wsf_html/application.e index 2994585f..e01ae5d5 100644 --- a/tests/server/wsf_html/application.e +++ b/tests/server/wsf_html/application.e @@ -44,21 +44,21 @@ feature {NONE} -- Initialization -- autofocus create l_text_input.make ("fullname") - l_text_input.set_autofocus + l_text_input.enable_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 + l_text_input.disable_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 + l_text_input.enable_required print (l_text_input.to_html (l_theme)) io.put_new_line diff --git a/tests/server/wsf_html/wsf_form_input_html5_test_set.e b/tests/server/wsf_html/wsf_form_input_html5_test_set.e index fc07749a..cb9944f8 100644 --- a/tests/server/wsf_html/wsf_form_input_html5_test_set.e +++ b/tests/server/wsf_html/wsf_form_input_html5_test_set.e @@ -43,11 +43,11 @@ feature -- Test routines create l_theme.make create l_text_input.make ("fullname") - l_text_input.set_autofocus + l_text_input.enable_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_text_input.disable_autofocus l_autofocus := "
" assert ("expected input without autofocus",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_autofocus) ) @@ -65,10 +65,10 @@ feature -- Test routines create l_theme.make create l_text_input.make ("fullname") - l_text_input.turn_off_autocomplete + l_text_input.disable_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_text_input.enable_autocomplete l_autocomplete := "
" assert ("expected input without autocomplete",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_autocomplete) ) @@ -85,11 +85,11 @@ feature -- Test routines create l_theme.make create l_text_input.make ("fullname") - l_text_input.set_required + l_text_input.enable_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_text_input.disable_required l_required := "
" assert ("expected input without required",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_required) ) From 857397e2269af31bd2709e2d0810a3c9c6fe0bce Mon Sep 17 00:00:00 2001 From: jvelilla Date: Thu, 28 May 2015 09:39:14 -0300 Subject: [PATCH 3/5] Updated code inherit from SHARED_HTML_ENCODER instead of creating new objects. --- .../form/wsf_form_field_with_numeric_attribute.e | 11 ++++++++--- .../server/wsf_html/form/wsf_form_input_with_html5.e | 8 ++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/library/server/wsf_html/form/wsf_form_field_with_numeric_attribute.e b/library/server/wsf_html/form/wsf_form_field_with_numeric_attribute.e index f51cc6c3..1bf122b5 100644 --- a/library/server/wsf_html/form/wsf_form_field_with_numeric_attribute.e +++ b/library/server/wsf_html/form/wsf_form_field_with_numeric_attribute.e @@ -10,6 +10,11 @@ note class WSF_FORM_FIELD_WITH_NUMERIC_ATTRIBUTE +inherit + + SHARED_HTML_ENCODER + + feature -- Access min: detachable READABLE_STRING_32 @@ -80,21 +85,21 @@ feature {NONE} -- Conversion --min if attached min as l_min then a_target.append (" min=%"") - a_target.append ((create {HTML_ENCODER}).encoded_string (l_min)) + a_target.append (html_encoder.encoded_string (l_min)) a_target.append_character ('%"') end --max if attached max as l_max then a_target.append (" max=%"") - a_target.append ((create {HTML_ENCODER}).encoded_string (l_max)) + a_target.append (html_encoder.encoded_string (l_max)) a_target.append_character ('%"') end --step if attached step as l_step then a_target.append (" step=%"") - a_target.append ((create {HTML_ENCODER}).encoded_string (l_step)) + a_target.append (html_encoder.encoded_string (l_step)) a_target.append_character ('%"') end end diff --git a/library/server/wsf_html/form/wsf_form_input_with_html5.e b/library/server/wsf_html/form/wsf_form_input_with_html5.e index d36f4e94..94e11fa2 100644 --- a/library/server/wsf_html/form/wsf_form_input_with_html5.e +++ b/library/server/wsf_html/form/wsf_form_input_with_html5.e @@ -7,6 +7,10 @@ deferred class WSF_FORM_INPUT_WITH_HTML5 +inherit + + SHARED_HTML_ENCODER + feature -- Access placeholder: detachable READABLE_STRING_32 @@ -147,7 +151,7 @@ feature -- Conversion do if attached placeholder as l_placeholder then a_target.append (" placeholder=%"") - a_target.append ((create {HTML_ENCODER}).encoded_string (l_placeholder)) + a_target.append (html_encoder.encoded_string (l_placeholder)) a_target.append_character ('%"') end --TODO check how we can add xhtml5 support @@ -166,7 +170,7 @@ feature -- Conversion end if attached pattern as l_pattern then a_target.append (" pattern=%"") - a_target.append ((create {HTML_ENCODER}).encoded_string (l_pattern)) + a_target.append ( html_encoder.encoded_string (l_pattern)) a_target.append_character ('%"') end end From 8c8dfdd4a32d46bd49eeb12571095848f7089529 Mon Sep 17 00:00:00 2001 From: jvelilla Date: Thu, 28 May 2015 10:04:13 -0300 Subject: [PATCH 4/5] Updated code based on review --- .../wsf_form_field_with_numeric_attribute.e | 50 +++++++++++++------ .../wsf_html/form/wsf_form_input_with_html5.e | 2 +- .../wsf_html/form/wsf_form_month_input.e | 6 ++- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/library/server/wsf_html/form/wsf_form_field_with_numeric_attribute.e b/library/server/wsf_html/form/wsf_form_field_with_numeric_attribute.e index 1bf122b5..7745ce06 100644 --- a/library/server/wsf_html/form/wsf_form_field_with_numeric_attribute.e +++ b/library/server/wsf_html/form/wsf_form_field_with_numeric_attribute.e @@ -17,13 +17,13 @@ inherit feature -- Access - min: detachable READABLE_STRING_32 + min: detachable READABLE_STRING_8 -- minimun value accepted by Current field. - max: detachable READABLE_STRING_32 + max: detachable READABLE_STRING_8 -- maximun value accepted by Current field. - step: detachable READABLE_STRING_32 + step: detachable READABLE_STRING_8 -- step is the increment that the value should adjust up or down, with the default step value being 1. feature -- Element Change @@ -52,28 +52,46 @@ feature -- Element Change 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_string (a_val: READABLE_STRING_GENERAL) -- Set `min' with `a_val'. + require + is_valid_number: a_val.is_integer do - min := a_val + if a_val.is_string_32 then + min := html_encoder.encoded_string (a_val.as_string_32) + elseif a_val.is_string_8 then + min := a_val.as_string_8 + end ensure - min_set: attached min as l_min implies l_min = a_val + min_set: attached min as l_min implies l_min.same_string_general (a_val) end - set_max_string (a_val: READABLE_STRING_32) + set_max_string (a_val: READABLE_STRING_GENERAL) -- Set `max' with `a_val'. + require + is_valid_number: a_val.is_integer do - max := a_val + if a_val.is_string_32 then + max := html_encoder.encoded_string (a_val.as_string_32) + elseif a_val.is_string_8 then + max := a_val.as_string_8 + end ensure - max_set: attached max as l_max implies l_max = a_val + max_set: attached max as l_max implies l_max.same_string_general (a_val) end - set_step_string (a_val: READABLE_STRING_32) + set_step_string (a_val: READABLE_STRING_GENERAL) -- Set `step' with `a_val'. - do - step := a_val + require + is_valid_sequence: a_val.is_number_sequence or else a_val.is_real_sequence + do + if a_val.is_string_32 then + step := html_encoder.encoded_string (a_val.as_string_32) + elseif a_val.is_string_8 then + step := a_val.as_string_8 + end ensure - step_set: attached step as l_step implies l_step = a_val + step_set: attached step as l_step implies l_step.same_string_general (a_val) end @@ -85,21 +103,21 @@ feature {NONE} -- Conversion --min if attached min as l_min then a_target.append (" min=%"") - a_target.append (html_encoder.encoded_string (l_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 (html_encoder.encoded_string (l_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 (html_encoder.encoded_string (l_step)) + a_target.append (l_step) a_target.append_character ('%"') end end diff --git a/library/server/wsf_html/form/wsf_form_input_with_html5.e b/library/server/wsf_html/form/wsf_form_input_with_html5.e index 94e11fa2..b9c38b7d 100644 --- a/library/server/wsf_html/form/wsf_form_input_with_html5.e +++ b/library/server/wsf_html/form/wsf_form_input_with_html5.e @@ -60,7 +60,7 @@ feature -- Change element end disable_autocomplete - -- Turn off the autocompelte. The default behavior is on. + -- Turn off the autocomplete. The default behavior is on. do autocomplete := True ensure diff --git a/library/server/wsf_html/form/wsf_form_month_input.e b/library/server/wsf_html/form/wsf_form_month_input.e index 85dc04d1..3fe9b0f9 100644 --- a/library/server/wsf_html/form/wsf_form_month_input.e +++ b/library/server/wsf_html/form/wsf_form_month_input.e @@ -1,5 +1,9 @@ note - description: "Summary description for {WSF_FORM_MONTH_INPUT}." + description: "[ + Represent an input type Month + Example: + + ]" date: "$Date$" revision: "$Revision$" EIS: "name=month", "src=https://html.spec.whatwg.org/multipage/forms.html#month-state-(type=month)" From e1b583a2b39e2d506454b164e5c88453bc7d63a6 Mon Sep 17 00:00:00 2001 From: jvelilla Date: Thu, 28 May 2015 10:07:40 -0300 Subject: [PATCH 5/5] Updated code based on comments --- library/server/wsf_html/form/wsf_form_input_with_html5.e | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/server/wsf_html/form/wsf_form_input_with_html5.e b/library/server/wsf_html/form/wsf_form_input_with_html5.e index b9c38b7d..604b2086 100644 --- a/library/server/wsf_html/form/wsf_form_input_with_html5.e +++ b/library/server/wsf_html/form/wsf_form_input_with_html5.e @@ -104,6 +104,9 @@ feature -- Change element end + -- The attribues `form',`list', and `multiple' are not supported yet. + -- For example the list attribute need datalist support. + -- 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.