Added comments to autocompletion, input, navbar, progressbar, validator, webcontrol. Some more little changes.
This commit is contained in:
@@ -12,46 +12,52 @@ inherit
|
||||
WSF_STATELESS_CONTROL
|
||||
|
||||
create
|
||||
make_control,
|
||||
make_with_body
|
||||
make_control, make_with_body
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_control (t: STRING)
|
||||
-- Initialize
|
||||
do
|
||||
make_with_body (t, "", "")
|
||||
end
|
||||
|
||||
make_with_body (t,attr,a_content: STRING)
|
||||
make_with_body (t, attr, b: STRING)
|
||||
-- Initialize with specific attributes and body
|
||||
do
|
||||
make (t)
|
||||
attributes := attr
|
||||
content := a_content
|
||||
body := b
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
feature -- Access
|
||||
|
||||
attributes: STRING
|
||||
-- Attributes string of this control
|
||||
|
||||
content: STRING
|
||||
body: STRING
|
||||
-- Body of this control
|
||||
|
||||
feature -- Rendering
|
||||
|
||||
render: STRING
|
||||
-- HTML representation of this control
|
||||
do
|
||||
Result := render_tag (content, attributes)
|
||||
Result := render_tag (body, attributes)
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
set_attributes (a: STRING)
|
||||
-- Set the attributes string of this control
|
||||
do
|
||||
attributes := a
|
||||
end
|
||||
|
||||
set_content (c: STRING)
|
||||
set_body (b: STRING)
|
||||
-- Set the body of this control
|
||||
do
|
||||
content := c
|
||||
body := b
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -14,9 +14,10 @@ inherit
|
||||
create
|
||||
make_button
|
||||
|
||||
feature {NONE}
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_button (n: STRING; t: STRING)
|
||||
-- Initialize with specified control name and text
|
||||
do
|
||||
make_control (n, "button")
|
||||
add_class ("btn")
|
||||
@@ -24,7 +25,7 @@ feature {NONE}
|
||||
text := t
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore text from json
|
||||
@@ -42,7 +43,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
Result.put (create {JSON_BOOLEAN}.make_boolean (attached click_event), "callback_click")
|
||||
end
|
||||
|
||||
feature --EVENT HANDLING
|
||||
feature --Event handling
|
||||
|
||||
set_click_event (e: attached like click_event)
|
||||
-- Set button click event handle
|
||||
@@ -57,14 +58,18 @@ feature --EVENT HANDLING
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Rendering
|
||||
|
||||
render: STRING
|
||||
-- HTML representation of this control
|
||||
do
|
||||
Result := render_tag (text, "")
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_text (t: STRING)
|
||||
-- Set text of that button
|
||||
do
|
||||
if not t.same_string (text) then
|
||||
text := t
|
||||
@@ -72,10 +77,12 @@ feature
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Properties
|
||||
|
||||
text: STRING
|
||||
-- The text currently displayed on this button
|
||||
|
||||
click_event: detachable PROCEDURE [ANY, TUPLE]
|
||||
-- Event that is executed when button is clicked
|
||||
|
||||
end
|
||||
|
||||
@@ -18,9 +18,10 @@ feature
|
||||
|
||||
control_name: STRING
|
||||
|
||||
feature {NONE}
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_control (n, a_tag_name: STRING)
|
||||
-- Initialize with specified control name and tag
|
||||
do
|
||||
make (a_tag_name)
|
||||
control_name := n
|
||||
@@ -68,11 +69,13 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
feature -- Rendering
|
||||
|
||||
render_tag (body, attrs: STRING): STRING
|
||||
-- Render this control with the specified body and attributes
|
||||
do
|
||||
Result := render_tag_with_generator_name (generator, body, attrs)
|
||||
end
|
||||
|
||||
render_tag_with_generator_name (a_generator, body, attrs: STRING): STRING
|
||||
-- Render this control with the specified generator name, body and attributes
|
||||
local
|
||||
css_classes_string: STRING
|
||||
l_attributes: STRING
|
||||
|
||||
@@ -16,9 +16,10 @@ inherit
|
||||
create
|
||||
make_form_control
|
||||
|
||||
feature {NONE}
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_form_control (n: STRING)
|
||||
-- Initialize
|
||||
do
|
||||
make_multi_control (n)
|
||||
tag_name := "form"
|
||||
@@ -27,6 +28,7 @@ feature {NONE}
|
||||
feature -- Validation
|
||||
|
||||
validate
|
||||
-- Perform form validation
|
||||
do
|
||||
is_valid := True
|
||||
across
|
||||
@@ -44,5 +46,6 @@ feature -- Validation
|
||||
end
|
||||
|
||||
is_valid: BOOLEAN
|
||||
-- Tells whether the last validation was valid
|
||||
|
||||
end
|
||||
|
||||
@@ -21,14 +21,16 @@ inherit
|
||||
create
|
||||
make_form_element, make_form_element_with_validators
|
||||
|
||||
feature {NONE}
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_form_element (a_label: STRING; c: WSF_VALUE_CONTROL [G])
|
||||
-- Initialize form element control with a specific label and value control
|
||||
do
|
||||
make_form_element_with_validators (a_label, c, create {ARRAYED_LIST [WSF_VALIDATOR [G]]}.make (0))
|
||||
end
|
||||
|
||||
make_form_element_with_validators (a_label: STRING; c: WSF_VALUE_CONTROL [G]; v: LIST [WSF_VALIDATOR [G]])
|
||||
-- Initialize form element control with a specific label, value control and list of validators
|
||||
do
|
||||
make_control (c.control_name + "_container", "div")
|
||||
add_class ("form-group")
|
||||
@@ -44,7 +46,7 @@ feature {NONE}
|
||||
error := ""
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
load_state (new_states: JSON_OBJECT)
|
||||
-- Pass new_states to subcontrols
|
||||
@@ -54,6 +56,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
end
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Set new state
|
||||
do
|
||||
value_control.set_state (new_state)
|
||||
end
|
||||
@@ -73,7 +76,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
end
|
||||
|
||||
state: JSON_OBJECT
|
||||
--Read state
|
||||
-- Read state
|
||||
local
|
||||
validator_description: JSON_ARRAY
|
||||
do
|
||||
@@ -88,7 +91,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
Result.put (validator_description, "validators")
|
||||
end
|
||||
|
||||
feature --EVENT HANDLING
|
||||
feature -- Event handling
|
||||
|
||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
||||
-- Pass callback to subcontrols
|
||||
@@ -102,9 +105,10 @@ feature --EVENT HANDLING
|
||||
end
|
||||
end
|
||||
|
||||
feature --Implementation
|
||||
feature -- Implementation
|
||||
|
||||
render: STRING
|
||||
-- HTML Respresentation of this form element control
|
||||
local
|
||||
body: STRING
|
||||
do
|
||||
@@ -121,17 +125,20 @@ feature --Implementation
|
||||
feature -- Validation
|
||||
|
||||
add_validator (v: WSF_VALIDATOR [G])
|
||||
-- Add an additional validator that will check the input of the value control of this form element control on validation
|
||||
do
|
||||
validators.extend (v)
|
||||
end
|
||||
|
||||
set_error (e: STRING)
|
||||
-- Set the error message that will be displayed upon failure of client side validation
|
||||
do
|
||||
error := e
|
||||
state_changes.replace (create {JSON_STRING}.make_json (e), "error")
|
||||
end
|
||||
|
||||
validate
|
||||
-- Perform validation
|
||||
local
|
||||
current_value: G
|
||||
do
|
||||
@@ -153,15 +160,20 @@ feature -- Validation
|
||||
end
|
||||
|
||||
is_valid: BOOLEAN
|
||||
-- Tells whether the last validation was successful or not
|
||||
|
||||
feature
|
||||
feature -- Properties
|
||||
|
||||
value_control: WSF_VALUE_CONTROL [G]
|
||||
-- The value control associated with this form element control
|
||||
|
||||
validators: LIST [WSF_VALIDATOR [G]]
|
||||
-- The validators which check the input when validaton is performed
|
||||
|
||||
label: STRING
|
||||
-- The label of this form element control
|
||||
|
||||
error: STRING
|
||||
-- The error message that is displayed when client side validation fails
|
||||
|
||||
end
|
||||
|
||||
@@ -14,15 +14,16 @@ inherit
|
||||
create
|
||||
make_html
|
||||
|
||||
feature {NONE}
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_html (n, t, v: STRING)
|
||||
-- Initialize
|
||||
do
|
||||
make_control (n, t)
|
||||
html := v
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore html from json
|
||||
@@ -39,7 +40,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
Result.put (create {JSON_STRING}.make_json (html), "html")
|
||||
end
|
||||
|
||||
feature --EVENT HANDLING
|
||||
feature --Event handling
|
||||
|
||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
||||
do
|
||||
@@ -48,6 +49,7 @@ feature --EVENT HANDLING
|
||||
feature -- Implementation
|
||||
|
||||
render: STRING
|
||||
-- HTML representation of this html control
|
||||
do
|
||||
Result := render_tag (html, "")
|
||||
end
|
||||
@@ -65,7 +67,7 @@ feature -- Implementation
|
||||
Result := html
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Properties
|
||||
|
||||
html: STRING
|
||||
|
||||
|
||||
@@ -22,17 +22,19 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_multi_control (n: STRING)
|
||||
-- Initialize with specified control name and default tag "div"
|
||||
do
|
||||
make_with_tag_name (n, "div")
|
||||
end
|
||||
|
||||
make_with_tag_name (n, t: STRING)
|
||||
-- Initialize with specified control name and tag
|
||||
do
|
||||
make_control (n, t)
|
||||
controls := create {LINKED_LIST [G]}.make;
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
load_state (new_states: JSON_OBJECT)
|
||||
-- Pass new_states to subcontrols
|
||||
@@ -84,7 +86,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
create Result.make
|
||||
end
|
||||
|
||||
feature -- EVENT HANDLING
|
||||
feature -- Event handling
|
||||
|
||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
||||
-- Pass callback to subcontrols
|
||||
@@ -101,9 +103,10 @@ feature -- EVENT HANDLING
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Rendering
|
||||
|
||||
render: STRING
|
||||
-- HTML representation of this multi control
|
||||
do
|
||||
Result := ""
|
||||
across
|
||||
@@ -114,13 +117,19 @@ feature
|
||||
Result := render_tag (Result, "")
|
||||
end
|
||||
|
||||
add_control (c: detachable G)
|
||||
feature -- Change
|
||||
|
||||
add_control (c: detachable G)
|
||||
-- Add a control to this multi control
|
||||
do
|
||||
if attached c as d then
|
||||
controls.put_front (d)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
controls: LINKED_LIST [G]
|
||||
-- List of current controls in this multi control
|
||||
|
||||
end
|
||||
|
||||
@@ -10,6 +10,7 @@ deferred class
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Initialize
|
||||
do
|
||||
request := req
|
||||
response := res
|
||||
@@ -19,10 +20,12 @@ feature {NONE} -- Initialization
|
||||
feature -- Access
|
||||
|
||||
request: WSF_REQUEST
|
||||
-- The request
|
||||
|
||||
response: WSF_RESPONSE
|
||||
-- The response
|
||||
|
||||
feature
|
||||
feature -- Specific implementation
|
||||
|
||||
initialize_controls
|
||||
-- Initalize all the controls, all the event handles must be set in this function.
|
||||
@@ -36,7 +39,7 @@ feature
|
||||
deferred
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Implementation
|
||||
|
||||
execute
|
||||
-- Entry Point: If request is a callback, restore control states and execute handle then return new state json.
|
||||
@@ -108,8 +111,9 @@ feature
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE}
|
||||
feature {NONE} -- Root control
|
||||
|
||||
control: WSF_CONTROL
|
||||
-- The root control of this page
|
||||
|
||||
end
|
||||
|
||||
@@ -7,9 +7,10 @@ note
|
||||
deferred class
|
||||
WSF_STATELESS_CONTROL
|
||||
|
||||
feature {NONE}
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_tag_name: STRING)
|
||||
-- Initialize with specified tag
|
||||
do
|
||||
tag_name := a_tag_name
|
||||
create css_classes.make (0)
|
||||
@@ -20,19 +21,25 @@ feature {NONE}
|
||||
feature -- Access
|
||||
|
||||
tag_name: STRING
|
||||
-- The tag name
|
||||
|
||||
css_classes: ARRAYED_LIST [STRING]
|
||||
-- List of classes (appear in the "class" attribute)
|
||||
|
||||
--TODO: Maybe improve
|
||||
-- TODO: Maybe improve
|
||||
|
||||
feature -- Change
|
||||
|
||||
add_class (c: STRING)
|
||||
-- Add a css class to this control
|
||||
do
|
||||
css_classes.force (c)
|
||||
end
|
||||
|
||||
feature -- Rendering
|
||||
|
||||
render_tag (body, attrs: STRING): STRING
|
||||
-- Generate HTML of this control with the specified body and attributes
|
||||
local
|
||||
css_classes_string: STRING
|
||||
do
|
||||
@@ -46,6 +53,7 @@ feature -- Change
|
||||
end
|
||||
|
||||
render_tag_with_tagname (tag, body, attrs, css_classes_string: STRING): STRING
|
||||
-- Generate HTML of the specified tag with specified body, attributes and css classes
|
||||
local
|
||||
l_attributes: STRING
|
||||
do
|
||||
@@ -56,13 +64,7 @@ feature -- Change
|
||||
l_attributes.append_character ('%"')
|
||||
end
|
||||
Result := "<" + tag + " " + l_attributes
|
||||
if
|
||||
body.is_empty and
|
||||
not tag.same_string ("textarea") and
|
||||
not tag.same_string ("span") and
|
||||
not tag.same_string ("button") and
|
||||
not tag.same_string ("ul")
|
||||
then
|
||||
if body.is_empty and not tag.same_string ("textarea") and not tag.same_string ("span") and not tag.same_string ("button") and not tag.same_string ("ul") then
|
||||
Result.append (" />")
|
||||
else
|
||||
Result.append (" >" + body + "</" + tag + ">")
|
||||
|
||||
@@ -5,7 +5,7 @@ note
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_STATELESS_MULTI_CONTROL [G -> WSF_STATELESS_CONTROL]
|
||||
WSF_STATELESS_MULTI_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
@@ -17,19 +17,22 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_multi_control
|
||||
-- Initialize with default tag "div"
|
||||
do
|
||||
make_with_tag_name ("div")
|
||||
end
|
||||
|
||||
make_with_tag_name (t: STRING)
|
||||
-- Initialize with specified tag
|
||||
do
|
||||
make (t)
|
||||
controls := create {LINKED_LIST [G]}.make;
|
||||
controls := create {LINKED_LIST [WSF_STATELESS_CONTROL]}.make;
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Rendering
|
||||
|
||||
render: STRING
|
||||
-- HTML representation of this stateless multi control
|
||||
do
|
||||
Result := ""
|
||||
across
|
||||
@@ -40,11 +43,17 @@ feature
|
||||
Result := render_tag (Result, "")
|
||||
end
|
||||
|
||||
add_control (c: G)
|
||||
feature -- Change
|
||||
|
||||
add_control (c: WSF_STATELESS_CONTROL)
|
||||
-- Add control to this stateless multi control
|
||||
do
|
||||
controls.put_front (c)
|
||||
end
|
||||
|
||||
controls: LINKED_LIST [G]
|
||||
feature -- Properties
|
||||
|
||||
controls: LINKED_LIST [WSF_STATELESS_CONTROL]
|
||||
-- List of controls
|
||||
|
||||
end
|
||||
|
||||
@@ -11,9 +11,10 @@ inherit
|
||||
|
||||
WSF_CONTROL
|
||||
|
||||
feature
|
||||
feature -- Access
|
||||
|
||||
value: G
|
||||
-- The current value of this control
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user