Code improvement
Cosmetic (comments, names, formatting)
This commit is contained in:
@@ -35,7 +35,7 @@ feature {NONE} -- Initialization
|
||||
end
|
||||
end
|
||||
|
||||
make_with_agent (c: FUNCTION [ANY, TUPLE [STRING_32], JSON_ARRAY])
|
||||
make_with_agent (c: FUNCTION [ANY, TUPLE [READABLE_STRING_GENERAL], JSON_ARRAY])
|
||||
-- Initialize with autocompletion function
|
||||
do
|
||||
make_input ("")
|
||||
@@ -53,20 +53,34 @@ feature -- State
|
||||
|
||||
feature -- Callback
|
||||
|
||||
handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
handle_callback (cname: LIST [READABLE_STRING_GENERAL]; event: READABLE_STRING_GENERAL; event_parameter: detachable ANY)
|
||||
-- <Precursor>
|
||||
do
|
||||
Precursor {WSF_INPUT_CONTROL} (cname, event, event_parameter)
|
||||
if cname [1].same_string (control_name) and event.same_string ("autocomplete") then
|
||||
if
|
||||
cname.first.same_string (control_name) and
|
||||
event.same_string ("autocomplete")
|
||||
then
|
||||
state_changes.put (create_json_list.item ([text]), "suggestions")
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
create_json_list: FUNCTION [ANY, TUPLE [STRING_32], JSON_ARRAY]
|
||||
create_json_list: FUNCTION [ANY, TUPLE [READABLE_STRING_GENERAL], JSON_ARRAY]
|
||||
-- The function which is called to give a list of suggestions to a given user input
|
||||
|
||||
template: STRING_32
|
||||
template: READABLE_STRING_32
|
||||
-- The template
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
|
||||
@@ -10,7 +10,6 @@ class
|
||||
WSF_CHECKBOX_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_VALUE_CONTROL [BOOLEAN]
|
||||
rename
|
||||
make as make_value_control,
|
||||
@@ -23,14 +22,14 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (l, value: STRING_32)
|
||||
-- Initialize with specified label and value
|
||||
make (a_label, a_value: STRING_32)
|
||||
-- Initialize with specified label `a_label' and value `a_value'.
|
||||
require
|
||||
value_not_empty: not value.is_empty
|
||||
a_value_not_empty: not a_value.is_empty
|
||||
do
|
||||
make_value_control ("input")
|
||||
label := l
|
||||
checked_value := value
|
||||
label := a_label
|
||||
checked_value := a_value
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
@@ -60,12 +59,14 @@ feature --Event handling
|
||||
change_event := e
|
||||
end
|
||||
|
||||
handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
handle_callback (cname: LIST [READABLE_STRING_GENERAL]; event: READABLE_STRING_GENERAL; event_parameter: detachable ANY)
|
||||
do
|
||||
if Current.control_name.same_string (cname [1]) and attached change_event as cevent then
|
||||
if event.same_string ("change") then
|
||||
cevent.call (Void)
|
||||
end
|
||||
if
|
||||
control_name.same_string_general (cname.first) and
|
||||
attached change_event as cevent and then
|
||||
event.same_string ("change")
|
||||
then
|
||||
cevent.call (Void)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -102,4 +103,14 @@ feature -- Properties
|
||||
change_event: detachable PROCEDURE [ANY, TUPLE]
|
||||
-- Function to be executed on change
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
|
||||
@@ -41,11 +41,15 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
local
|
||||
id: detachable STRING_32
|
||||
do
|
||||
if attached {JSON_STRING} new_state.item ("file_name") as new_name and attached {JSON_STRING} new_state.item ("file_type") as new_type and attached {JSON_NUMBER} new_state.item ("file_size") as new_size then
|
||||
if
|
||||
attached {JSON_STRING} new_state.item ("file_name") as new_name and
|
||||
attached {JSON_STRING} new_state.item ("file_type") as new_type and
|
||||
attached {JSON_NUMBER} new_state.item ("file_size") as new_size
|
||||
then
|
||||
if attached {JSON_STRING} new_state.item ("file_id") as a_id then
|
||||
id := a_id.unescaped_string_32
|
||||
end
|
||||
create file.make (new_name.unescaped_string_32, new_type.unescaped_string_32, new_size.item.to_integer_32, id);
|
||||
create file.make (new_name.unescaped_string_32, new_type.unescaped_string_32, new_size.item.to_integer_32, id)
|
||||
end
|
||||
if attached {JSON_BOOLEAN} new_state.item ("disabled") as a_disabled then
|
||||
disabled := a_disabled.item
|
||||
@@ -73,14 +77,14 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
feature -- Event handling
|
||||
|
||||
handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
handle_callback (cname: LIST [READABLE_STRING_GENERAL]; event: READABLE_STRING_GENERAL; event_parameter: detachable ANY)
|
||||
local
|
||||
f_name: detachable STRING_32
|
||||
f_type: detachable STRING_32
|
||||
f_size: detachable INTEGER
|
||||
f_id: detachable STRING_32
|
||||
do
|
||||
if Current.control_name.same_string (cname [1]) then
|
||||
if control_name.same_string_general (cname.first) then
|
||||
if attached change_event as cevent and event.same_string ("change") then
|
||||
cevent.call (Void)
|
||||
elseif attached upload_done_event as udevent and event.same_string ("uploaddone") then
|
||||
@@ -214,4 +218,14 @@ feature -- Properties
|
||||
upload_function: detachable FUNCTION [ANY, TUPLE [ITERABLE [WSF_UPLOADED_FILE]], detachable STRING_32]
|
||||
-- Store uploaded file and return server side file id
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
|
||||
@@ -12,7 +12,6 @@ class
|
||||
WSF_INPUT_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_VALUE_CONTROL [STRING_32]
|
||||
rename
|
||||
make as make_value_control
|
||||
@@ -62,12 +61,14 @@ feature --Event handling
|
||||
change_event_set: change_event = e
|
||||
end
|
||||
|
||||
handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
handle_callback (cname: LIST [READABLE_STRING_GENERAL]; event: READABLE_STRING_GENERAL; event_parameter: detachable ANY)
|
||||
do
|
||||
if Current.control_name.same_string (cname [1]) and attached change_event as cevent then
|
||||
if event.same_string ("change") then
|
||||
cevent.call (Void)
|
||||
end
|
||||
if
|
||||
control_name.same_string_general (cname.first) and
|
||||
attached change_event as cevent and then
|
||||
event.same_string ("change")
|
||||
then
|
||||
cevent.call (Void)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -77,12 +78,17 @@ feature -- Rendering
|
||||
local
|
||||
attr: STRING_32
|
||||
do
|
||||
attr := "type=%"" + type + "%" value=%"" + text + "%" "
|
||||
if attached attributes as a then
|
||||
attr.append (a)
|
||||
create attr.make (25)
|
||||
attr.append ("type=%"")
|
||||
attr.append (type)
|
||||
attr.append ("%" value=%"")
|
||||
attr.append (text)
|
||||
attr.append ("%" ")
|
||||
if attached attributes as l_attributes then
|
||||
attr.append (l_attributes)
|
||||
end
|
||||
if disabled then
|
||||
attr.append ("disabled=%"disabled%" ")
|
||||
attr.append (" disabled=%"disabled%" ")
|
||||
end
|
||||
Result := render_tag ("", attr)
|
||||
end
|
||||
@@ -107,13 +113,15 @@ feature -- Change
|
||||
if disabled /= b then
|
||||
disabled := b
|
||||
state_changes.replace_with_boolean (disabled, "disabled")
|
||||
else
|
||||
check has_key_disabled: (b = False) or else state_changes.has_key ("disabled") end
|
||||
end
|
||||
ensure
|
||||
disabled_set: disabled = b
|
||||
state_changes_registered: old b /= b implies state_changes.has_key ("disabled")
|
||||
state_changes_registered: (old b) /= b implies state_changes.has_key ("disabled")
|
||||
end
|
||||
|
||||
set_type (t: STRING_32)
|
||||
set_type (t: READABLE_STRING_32)
|
||||
-- Set the type of this input control (HTML 'type' attribute)
|
||||
do
|
||||
type := t
|
||||
@@ -142,13 +150,23 @@ feature -- Properties
|
||||
disabled: BOOLEAN
|
||||
-- Defines if the input field is editable
|
||||
|
||||
text: STRING_32
|
||||
text: READABLE_STRING_32
|
||||
-- Text to be displayed
|
||||
|
||||
type: STRING_32
|
||||
type: READABLE_STRING_32
|
||||
-- Type of this input control
|
||||
|
||||
change_event: detachable PROCEDURE [ANY, TUPLE]
|
||||
-- Procedure to be execued on change
|
||||
|
||||
;note
|
||||
copyright: "2011-2014, Yassin Hassan, Severin Munger, Jocelyn Fiat, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user