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..e825f842 --- /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_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 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..c7a25fe9 --- /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_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 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..b3317a24 --- /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_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 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_field_with_numeric_attribute.e b/library/server/wsf_html/form/wsf_form_field_with_numeric_attribute.e new file mode 100644 index 00000000..7745ce06 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_field_with_numeric_attribute.e @@ -0,0 +1,125 @@ +note + description: "[ + Represent attributes applicable to input type type=[number, range, date] + The attributes: min, max, step. + ]" + date: "$Date$" + revision: "$Revision$" + EIS: "name=numeric attributes", "src=https://html.spec.whatwg.org/multipage/forms.html#common-input-element-attributes" + +class + WSF_FORM_FIELD_WITH_NUMERIC_ATTRIBUTE + +inherit + + SHARED_HTML_ENCODER + + +feature -- Access + + min: detachable READABLE_STRING_8 + -- minimun value accepted by Current field. + + max: detachable READABLE_STRING_8 + -- maximun value accepted by Current field. + + 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 + + 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_GENERAL) + -- Set `min' with `a_val'. + require + is_valid_number: a_val.is_integer + do + 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.same_string_general (a_val) + end + + set_max_string (a_val: READABLE_STRING_GENERAL) + -- Set `max' with `a_val'. + require + is_valid_number: a_val.is_integer + do + 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.same_string_general (a_val) + end + + set_step_string (a_val: READABLE_STRING_GENERAL) + -- Set `step' with `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.same_string_general (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/library/server/wsf_html/form/wsf_form_image_input.e b/library/server/wsf_html/form/wsf_form_image_input.e index 60022600..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,6 +12,8 @@ inherit redefine specific_input_attributes_string end + WSF_FORM_WITH_ALTERNATIVE_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..604b2086 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_input_with_html5.e @@ -0,0 +1,181 @@ +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 + +inherit + + SHARED_HTML_ENCODER + +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 + + enable_autofocus + -- Set autofocus in True. + do + autofocus := True + ensure + autofocus_true: autofocus + end + + disable_autofocus + -- Set autofocus in False + do + autofocus := False + ensure + autofocus_false: not autofocus + end + + disable_autocomplete + -- Turn off the autocomplete. The default behavior is on. + do + autocomplete := True + ensure + autocomplete_true: autocomplete + end + + enable_autocomplete + -- Set autocomplete in False, Set default behavior. + do + autocomplete := False + ensure + autocomplete_false: not autocomplete + end + + enable_required + -- Set required to True. + do + required := True + ensure + required_true: required + end + + disable_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 + + + -- 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. + -- 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 (html_encoder.encoded_string (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 ( html_encoder.encoded_string (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..3fe9b0f9 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_month_input.e @@ -0,0 +1,41 @@ +note + 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)" + +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 diff --git a/library/server/wsf_html/form/wsf_form_number_input.e b/library/server/wsf_html/form/wsf_form_number_input.e new file mode 100644 index 00000000..648fd4b7 --- /dev/null +++ b/library/server/wsf_html/form/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_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 diff --git a/library/server/wsf_html/form/wsf_form_range_input.e b/library/server/wsf_html/form/wsf_form_range_input.e new file mode 100644 index 00000000..806d4751 --- /dev/null +++ b/library/server/wsf_html/form/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_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 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..dd4af67b 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_ALTERNATIVE_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..dfbf507b --- /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_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 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..00778c84 --- /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_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 + + diff --git a/library/server/wsf_html/form/wsf_form_with_alternative_actions.e b/library/server/wsf_html/form/wsf_form_with_alternative_actions.e new file mode 100644 index 00000000..fc5183b4 --- /dev/null +++ b/library/server/wsf_html/form/wsf_form_with_alternative_actions.e @@ -0,0 +1,137 @@ +note + description: "[ + Represent alternative actions for forms + 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_ALTERNATIVE_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/tests/server/wsf_html/application.e b/tests/server/wsf_html/application.e new file mode 100644 index 00000000..e01ae5d5 --- /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.enable_autofocus + print (l_text_input.to_html (l_theme)) + + io.put_new_line + + -- autocomplete + create l_text_input.make ("fullname") + 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.enable_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..cb9944f8 --- /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.enable_autofocus + + assert ("expected input with autofocus",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_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) ) + + 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.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.enable_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.enable_required + + assert ("expected input with required",l_text_input.to_html (l_theme).is_case_insensitive_equal_general (l_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) ) + + 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_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