diff --git a/draft/application/cms/src/kernel/form/with_html_attribute.e b/draft/application/cms/src/kernel/form/with_html_attribute.e new file mode 100644 index 00000000..37490bd6 --- /dev/null +++ b/draft/application/cms/src/kernel/form/with_html_attribute.e @@ -0,0 +1,81 @@ +note + description: "Summary description for {WITH_HTML_ATTRIBUTE}." + date: "$Date$" + revision: "$Revision$" + +deferred class + WITH_HTML_ATTRIBUTE + +feature -- Status report + + html_attributes: detachable HASH_TABLE [detachable READABLE_STRING_8, STRING_8] + +feature -- Change + + reset_html_attributes + do + html_attributes := Void + end + + add_html_attribute (a_name: READABLE_STRING_8; a_value: detachable READABLE_STRING_8) + require + is_valid_attribute_name: is_valid_attribute_name (a_name) + is_valid_attribute_value: is_valid_attribute_value (a_value) + local + lst: like html_attributes + do + lst := html_attributes + if lst = Void then + create lst.make (1) + lst.compare_objects + html_attributes := lst + end + lst.force (a_value, a_name) + end + + remove_html_attribute (a_name: READABLE_STRING_8) + require + is_valid_attribute_name: is_valid_attribute_name (a_name) + local + lst: like html_attributes + do + lst := html_attributes + if lst /= Void then + lst.remove (a_name) + end + end + +feature -- Query + + is_valid_attribute_name (s: detachable READABLE_STRING_8): BOOLEAN + do + Result := s /= Void implies (not s.is_empty) + -- To complete + end + + is_valid_attribute_value (s: detachable READABLE_STRING_8): BOOLEAN + do + Result := s /= Void implies (not s.has ('%"')) + -- To complete + end + +feature -- Conversion + + append_html_attributes_to (a_target: STRING) + do + if attached html_attributes as attribs then + across + attribs as c + loop + a_target.append (" " + c.key) + if attached c.item as v then + a_target.append_character ('=') + a_target.append_character ('%"') + a_target.append (v) + a_target.append_character ('%"') + end + end + end + end + +end diff --git a/draft/application/cms/src/widgets/cms_widget_table_item.e b/draft/application/cms/src/widgets/cms_widget_table_item.e index 3e71ab45..db223de8 100644 --- a/draft/application/cms/src/widgets/cms_widget_table_item.e +++ b/draft/application/cms/src/widgets/cms_widget_table_item.e @@ -10,6 +10,8 @@ class inherit CMS_WIDGET + WITH_HTML_ATTRIBUTE + WITH_CSS_CLASS WITH_CSS_STYLE