Merge branch 'widget' of github.com:souvarin/EWF into widget

Conflicts:
	library/server/wsf_html/webcontrol/wsf_control.e
This commit is contained in:
YNH Webdev
2013-09-05 17:20:40 +02:00
6 changed files with 93 additions and 7 deletions

View File

@@ -59,7 +59,7 @@ feature
render: STRING
do
Result := render_tag ( text, "")
Result := render_tag (text, "")
end
set_text (t: STRING)

View File

@@ -0,0 +1,83 @@
note
description: "Summary description for {WSF_CHECKBOX_CONTROL}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_CHECKBOX_CONTROL
inherit
WSF_VALUE_CONTROL[BOOLEAN]
create
make_checkbox
feature {NONE}
make_checkbox (n: STRING; l: STRING)
do
make (n, "input")
label := l
end
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
set_state (new_state: JSON_OBJECT)
-- Restore text from json
do
if attached {JSON_BOOLEAN} new_state.item (create {JSON_STRING}.make_json ("checked")) as new_checked then
checked := new_checked.item
end
end
state: JSON_OBJECT
-- Return state which contains the current text and if there is an event handle attached
do
create Result.make
Result.put (create {JSON_BOOLEAN}.make_boolean (checked), create {JSON_STRING}.make_json ("checked"))
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), create {JSON_STRING}.make_json ("callback_change"))
end
feature --EVENT HANDLING
set_change_event (e: attached like change_event)
-- Set text change event handle
do
change_event := e
end
handle_callback (cname: STRING; event: STRING)
do
if Current.control_name.is_equal (cname) and attached change_event as cevent then
if event.is_equal ("change") then
cevent.call ([])
end
end
end
feature -- Implementation
render: STRING
local
attributes: STRING
do
attributes := "type=%"checkbox%""
if checked then
attributes := attributes + " checked"
end
Result := render_tag ("", attributes)
end
value: BOOLEAN
do
Result := checked
end
feature
label: STRING
checked: BOOLEAN
change_event: detachable PROCEDURE [ANY, TUPLE []]
end

View File

@@ -91,7 +91,8 @@ feature
if not css_classes_string.is_empty then
css_classes_string := " class=%"" + css_classes_string + "%""
end
Result := "<" + tag_name + " data-name=%"" + control_name + "%" data-type=%"" + generator + "%" " + attributes + css_classes_string
Result := "<" + tag_name + " id=%"" + control_name + "%" data-name=%"" + control_name + "%" data-type=%"" + generator + "%" " + attributes + css_classes_string
if body.is_empty and not tag_name.is_equal("textarea") then
Result := Result + " />"
else

View File

@@ -10,6 +10,9 @@ class
inherit
WSF_CONTROL
redefine
read_state_changes
end
create
make_form_element, make_form_element_with_validators

View File

@@ -9,8 +9,6 @@ class
inherit
WSF_CONTROL
WSF_VALUE_CONTROL [STRING]
create
@@ -63,7 +61,7 @@ feature -- Implementation
render: STRING
do
Result := render_tag ("", "value=%"" + text + "%"")
Result := render_tag ("", "type=%"text%" value=%"" + text + "%"")
end
set_text (t: STRING)

View File

@@ -22,13 +22,14 @@ feature {NONE}
make_textarea (n, t: STRING)
do
make_text (n, t)
tag_name := "textarea"
tag_name := "textarea"
end
feature
render: STRING
do
Result :=render_tag(text,"")
Result := render_tag (text, "")
end
end