Code improvement
Cosmetic (comments, names, formatting)
This commit is contained in:
@@ -1,20 +1,31 @@
|
||||
note
|
||||
description: "Summary description for {WSF_AUTOCOMPLETION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_AUTOCOMPLETION
|
||||
|
||||
feature -- Access
|
||||
feature -- Query
|
||||
|
||||
autocompletion (input: STRING_32): JSON_ARRAY
|
||||
autocompletion (input: READABLE_STRING_GENERAL): JSON_ARRAY
|
||||
-- JSON array of suggestions that fit the specific input
|
||||
deferred
|
||||
end
|
||||
|
||||
template: detachable STRING_32
|
||||
feature -- Access
|
||||
|
||||
template: detachable READABLE_STRING_32
|
||||
-- Customizable 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
|
||||
|
||||
@@ -8,7 +8,6 @@ class
|
||||
WSF_SIMPLE_AUTOCOMPLETION
|
||||
|
||||
inherit
|
||||
|
||||
WSF_AUTOCOMPLETION
|
||||
|
||||
create
|
||||
@@ -16,24 +15,33 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (l: ITERABLE [STRING_32])
|
||||
-- Initialize
|
||||
make (a_list: ITERABLE [READABLE_STRING_32])
|
||||
-- Initialize with collection `a_list'.
|
||||
do
|
||||
list := l
|
||||
list := a_list
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
list: ITERABLE [READABLE_STRING_32]
|
||||
-- List containing suggestions
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
autocompletion (input: STRING_32): JSON_ARRAY
|
||||
-- Implementation
|
||||
autocompletion (a_input: READABLE_STRING_GENERAL): JSON_ARRAY
|
||||
-- <Precursor>
|
||||
local
|
||||
o: WSF_JSON_OBJECT
|
||||
l_lowered_input: READABLE_STRING_GENERAL
|
||||
l_lowered_item: READABLE_STRING_GENERAL
|
||||
do
|
||||
create Result.make_array
|
||||
across
|
||||
l_lowered_input := a_input.as_lower
|
||||
across
|
||||
list as c
|
||||
loop
|
||||
if c.item.as_lower.has_substring (input.as_lower) then
|
||||
l_lowered_item := c.item.as_lower
|
||||
if l_lowered_item.has_substring (l_lowered_input) then
|
||||
create o.make
|
||||
o.put_string (c.item, "value")
|
||||
Result.add (o)
|
||||
@@ -41,7 +49,14 @@ feature -- Implementation
|
||||
end
|
||||
end
|
||||
|
||||
list: ITERABLE [STRING_32]
|
||||
-- List containing suggestions
|
||||
|
||||
;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,13 +10,13 @@ deferred class
|
||||
feature --Event handling
|
||||
|
||||
set_on_update_agent (f: PROCEDURE [ANY, TUPLE])
|
||||
--Set update listener
|
||||
-- Set update listener
|
||||
do
|
||||
on_update_agent := f
|
||||
end
|
||||
|
||||
update
|
||||
--Trigger update listener
|
||||
-- Trigger update listener
|
||||
do
|
||||
if attached on_update_agent as a then
|
||||
a.call (Void)
|
||||
@@ -76,4 +76,14 @@ feature -- Properties
|
||||
|
||||
on_update_agent: detachable PROCEDURE [ANY, TUPLE]
|
||||
|
||||
;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
|
||||
|
||||
@@ -6,12 +6,21 @@ note
|
||||
deferred class
|
||||
WSF_ENTITY
|
||||
|
||||
|
||||
feature -- Access
|
||||
|
||||
item alias "[]"(a_field: READABLE_STRING_GENERAL): detachable ANY
|
||||
item alias "[]" (a_field: READABLE_STRING_GENERAL): detachable ANY
|
||||
-- Value for field item `a_field'.
|
||||
deferred
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
@@ -25,13 +25,14 @@ feature -- Render
|
||||
-- Return the rendered column cell for a specific entity (row)
|
||||
do
|
||||
if attached e.item (field_name) as data then
|
||||
Result := data.out
|
||||
--| FIXME: .out may not be the best rendering for objects...
|
||||
Result := data.out
|
||||
else
|
||||
Result := "[VOID]"
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
feature -- Access
|
||||
|
||||
header: STRING_32
|
||||
|
||||
@@ -41,4 +42,14 @@ feature -- Properties
|
||||
|
||||
field_name: STRING_32
|
||||
|
||||
;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
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {WSF_PAGABLE}."
|
||||
author: ""
|
||||
description: "Summary description for {WSF_PAGABLE_DATASOURCE}."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -8,7 +7,6 @@ deferred class
|
||||
WSF_PAGABLE_DATASOURCE [G -> WSF_ENTITY]
|
||||
|
||||
inherit
|
||||
|
||||
WSF_DATASOURCE [G]
|
||||
redefine
|
||||
state,
|
||||
@@ -16,16 +14,16 @@ inherit
|
||||
update
|
||||
end
|
||||
|
||||
feature --Event handling
|
||||
feature -- Event handling
|
||||
|
||||
set_on_update_page_agent (f: PROCEDURE [ANY, TUPLE])
|
||||
--Set paging update listener
|
||||
-- Set paging update listener
|
||||
do
|
||||
on_update_page_agent := f
|
||||
end
|
||||
|
||||
update
|
||||
--Trigger update listeners
|
||||
-- Trigger update listeners
|
||||
do
|
||||
Precursor
|
||||
if attached on_update_page_agent as a then
|
||||
@@ -81,4 +79,14 @@ feature -- Properties
|
||||
|
||||
on_update_page_agent: detachable PROCEDURE [ANY, TUPLE]
|
||||
|
||||
;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
|
||||
|
||||
@@ -48,16 +48,19 @@ 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)
|
||||
-- Handle goto/next/prev events
|
||||
do
|
||||
if Current.control_name.same_string (cname[1]) then
|
||||
if control_name.same_string_general (cname.first) then
|
||||
if event.same_string ("next") then
|
||||
datasource.set_page (datasource.page + 1)
|
||||
elseif event.same_string ("prev") then
|
||||
datasource.set_page (datasource.page - 1)
|
||||
elseif event.same_string ("goto") then
|
||||
if attached {STRING_32}event_parameter as p and then attached p.to_integer as i then
|
||||
if
|
||||
attached {READABLE_STRING_GENERAL} event_parameter as p and then
|
||||
attached p.to_integer as i
|
||||
then
|
||||
datasource.set_page (i)
|
||||
end
|
||||
end
|
||||
@@ -96,4 +99,14 @@ feature -- Properties
|
||||
|
||||
datasource: WSF_PAGABLE_DATASOURCE [G]
|
||||
|
||||
;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
|
||||
|
||||
@@ -20,7 +20,7 @@ inherit
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make ( a_datasource: WSF_DATASOURCE [G])
|
||||
make (a_datasource: WSF_DATASOURCE [G])
|
||||
local
|
||||
p: WSF_PAGINATION_CONTROL [G]
|
||||
do
|
||||
@@ -28,7 +28,7 @@ feature {NONE} -- Initialization
|
||||
datasource := a_datasource
|
||||
datasource.set_on_update_agent (agent update)
|
||||
if attached {WSF_PAGABLE_DATASOURCE [G]} a_datasource as ds then
|
||||
create p.make ( ds)
|
||||
create p.make (ds)
|
||||
add_control (p)
|
||||
pagination_control := p
|
||||
end
|
||||
@@ -61,41 +61,52 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
feature -- Rendering
|
||||
|
||||
render_item (item: G): STRING_32
|
||||
--Render item
|
||||
-- Render item
|
||||
deferred
|
||||
end
|
||||
|
||||
render_body: STRING_32
|
||||
--Render Body
|
||||
-- Render Body
|
||||
do
|
||||
Result := ""
|
||||
create Result.make_empty
|
||||
across
|
||||
datasource.data as entity
|
||||
datasource.data as ic
|
||||
loop
|
||||
Result.append (render_item (entity.item))
|
||||
Result.append (render_item (ic.item))
|
||||
end
|
||||
end
|
||||
|
||||
render: STRING_32
|
||||
--Render repeater inclusive paging if paging is available
|
||||
-- Render repeater inclusive paging if paging is available
|
||||
local
|
||||
content: STRING_32
|
||||
do
|
||||
content := render_tag_with_tagname ("div", render_body, "", "repeater_content")
|
||||
Result := ""
|
||||
create Result.make_empty
|
||||
across
|
||||
controls as c
|
||||
controls as ic
|
||||
loop
|
||||
Result := c.item.render + Result
|
||||
-- CHECK: Prepend ? or Append?
|
||||
Result.prepend (ic.item.render)
|
||||
end
|
||||
-- Fix generator name since the user will extend this class to define item_render
|
||||
Result := render_tag_with_generator_name ("WSF_REPEATER_CONTROL", content + Result, "")
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
feature -- Access
|
||||
|
||||
datasource: WSF_DATASOURCE [G]
|
||||
|
||||
pagination_control: detachable WSF_PAGINATION_CONTROL [G]
|
||||
|
||||
;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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -5,7 +5,7 @@ note
|
||||
panels can be added to this control.
|
||||
See http://getbootstrap.com/components/#navbar
|
||||
]"
|
||||
author: ""
|
||||
EIS: "name=Bootstrap navbar", "protocol=URI", "src=http://getbootstrap.com/components/#navbar"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -27,10 +27,10 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
--Initialize
|
||||
-- Initialize
|
||||
do
|
||||
make_multi_control
|
||||
active_set := false
|
||||
active_set := False
|
||||
add_class ("navbar navbar-inverse navbar-fixed-top")
|
||||
create nav.make_with_tag_name ("ul")
|
||||
create nav_right.make_with_tag_name ("ul")
|
||||
@@ -40,13 +40,13 @@ feature {NONE} -- Initialization
|
||||
nav_right.add_class ("nav navbar-nav navbar-right")
|
||||
end
|
||||
|
||||
make_with_brand (b: STRING_32)
|
||||
-- Initialize with specified brand string
|
||||
make_with_brand (a_brand: READABLE_STRING_32)
|
||||
-- Initialize with specified `a_brand' string.
|
||||
do
|
||||
make
|
||||
brand := b
|
||||
brand := a_brand
|
||||
ensure
|
||||
brand_set: brand = b
|
||||
brand_set: brand = a_brand
|
||||
end
|
||||
|
||||
feature -- Rendering
|
||||
@@ -59,8 +59,8 @@ feature -- Rendering
|
||||
temp := render_tag_with_tagname ("span", "", "", "icon-bar")
|
||||
temp.multiply (3)
|
||||
temp := render_tag_with_tagname ("button", temp, "data-target=%".navbar-collapse%" data-toggle=%"collapse%" type=%"button%"", "navbar-toggle")
|
||||
if attached brand as b then
|
||||
temp.append (render_tag_with_tagname ("a", b, "href=%"#%"", "navbar-brand"))
|
||||
if attached brand as l_brand then
|
||||
temp.append (render_tag_with_tagname ("a", l_brand, "href=%"#%"", "navbar-brand"))
|
||||
end
|
||||
temp := render_tag_with_tagname ("div", temp, "", "navbar-header")
|
||||
nav_string := nav.render
|
||||
@@ -89,36 +89,36 @@ feature -- Change
|
||||
active_set_set: active_set
|
||||
end
|
||||
|
||||
add_list_element_right (l: WSF_STATELESS_CONTROL)
|
||||
add_list_element_right (a_control: WSF_STATELESS_CONTROL)
|
||||
-- Add element in li tag to right aligned part of navbar
|
||||
local
|
||||
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
do
|
||||
create li.make_with_tag_name ("li")
|
||||
li.add_control (l)
|
||||
li.add_control (a_control)
|
||||
add_element_right (li)
|
||||
end
|
||||
|
||||
add_list_element (l: WSF_STATELESS_CONTROL)
|
||||
add_list_element (a_control: WSF_STATELESS_CONTROL)
|
||||
-- Add element in li tag to main nav
|
||||
local
|
||||
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
do
|
||||
create li.make_with_tag_name ("li")
|
||||
li.add_control (l)
|
||||
li.add_control (a_control)
|
||||
add_element (li)
|
||||
end
|
||||
|
||||
add_element_right (c: WSF_STATELESS_CONTROL)
|
||||
add_element_right (a_control: WSF_STATELESS_CONTROL)
|
||||
-- Add element to right aligned part of navbar
|
||||
do
|
||||
nav_right.add_control (c)
|
||||
nav_right.add_control (a_control)
|
||||
end
|
||||
|
||||
add_element (c: WSF_STATELESS_CONTROL)
|
||||
add_element (a_control: WSF_STATELESS_CONTROL)
|
||||
-- Add element to main nav
|
||||
do
|
||||
nav.add_control (c)
|
||||
nav.add_control (a_control)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
@@ -134,7 +134,7 @@ feature -- Properties
|
||||
active_set: BOOLEAN
|
||||
-- This flag is set once a tab has been set as active tab
|
||||
|
||||
brand: detachable STRING_32
|
||||
brand: detachable READABLE_STRING_32
|
||||
-- Optional brand of the navbar
|
||||
|
||||
nav: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
@@ -143,4 +143,14 @@ feature -- Properties
|
||||
nav_right: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
-- Right nav
|
||||
|
||||
;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
|
||||
|
||||
@@ -59,9 +59,12 @@ feature -- State handling
|
||||
|
||||
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)
|
||||
do
|
||||
if cname [1].same_string (control_name) and event.same_string ("progress_fetch") then
|
||||
if
|
||||
cname.first.same_string (control_name) and
|
||||
event.same_string ("progress_fetch")
|
||||
then
|
||||
state_changes.put_integer (progress_value, "progress")
|
||||
end
|
||||
end
|
||||
@@ -73,6 +76,7 @@ feature -- Rendering
|
||||
p: STRING_32
|
||||
do
|
||||
p := progress_value.out
|
||||
-- FIXME: string 32 truncated to string 8 !!!
|
||||
Result := render_tag_with_tagname ("div", "", "role=%"progressbar%" aria-valuenow=%"" + p + "%" aria-valuemin=%"0%" aria-valuemax=%"100%" style=%"width: " + p + "%%;%"", "progress-bar")
|
||||
Result := render_tag (Result, "")
|
||||
end
|
||||
@@ -82,7 +86,7 @@ feature -- Change
|
||||
set_progress (p: INTEGER)
|
||||
-- Set current progress value to specified value. Must be between 0 and 100. Must only be called when no progresssource has been set to this progress control
|
||||
require
|
||||
no_progress_source: not (attached progress_source)
|
||||
no_progress_source: progress_source = Void
|
||||
valid_input_value: p >= 0 and p <= 100
|
||||
do
|
||||
progress := p
|
||||
@@ -116,4 +120,14 @@ feature -- Properties
|
||||
invariant
|
||||
progress_in_range: progress >= 0 and progress <= 100
|
||||
|
||||
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
|
||||
|
||||
@@ -47,7 +47,7 @@ feature -- State handling
|
||||
|
||||
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)
|
||||
-- Just implementation, nothing special to do here
|
||||
do
|
||||
end
|
||||
@@ -67,18 +67,21 @@ feature -- Rendering
|
||||
|
||||
feature -- Change
|
||||
|
||||
add_image_with_caption (src, alt, caption: STRING_32)
|
||||
add_image_with_caption (src, alt, a_caption: STRING_32)
|
||||
-- Add a new image to the slider with specified url, alternative text and caption
|
||||
local
|
||||
caption_control: detachable WSF_STATELESS_CONTROL
|
||||
caption_control: detachable WSF_BASIC_CONTROL
|
||||
do
|
||||
if attached caption as c and then not c.is_empty then
|
||||
caption_control := create {WSF_BASIC_CONTROL}.make_with_body ("p", "", c)
|
||||
if
|
||||
a_caption /= Void and then
|
||||
not a_caption.is_empty
|
||||
then
|
||||
create caption_control.make_with_body ("p", "", a_caption)
|
||||
end
|
||||
add_image_with_caption_control (src, alt, caption_control)
|
||||
end
|
||||
|
||||
add_image_with_caption_control (src, alt: STRING_32; caption: detachable WSF_STATELESS_CONTROL)
|
||||
add_image_with_caption_control (src, alt: STRING_32; a_caption: detachable WSF_STATELESS_CONTROL)
|
||||
-- Add a new image to the slider, with specified url, alternative text and caption element
|
||||
do
|
||||
add_control (create {WSF_BASIC_CONTROL}.make_with_body_class ("img", "src=%"" + src + "%" alt=%"" + alt + "%"", "", ""), Void)
|
||||
@@ -90,17 +93,17 @@ feature -- Change
|
||||
add_image_with_caption (src, alt, "")
|
||||
end
|
||||
|
||||
add_control (c: WSF_STATELESS_CONTROL; caption: detachable WSF_STATELESS_CONTROL)
|
||||
add_control (a_control: WSF_STATELESS_CONTROL; a_caption: detachable WSF_STATELESS_CONTROL)
|
||||
-- Add a new control to the slider
|
||||
local
|
||||
cl: STRING_32
|
||||
item: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
do
|
||||
create item.make ()
|
||||
create item.make
|
||||
item.add_class ("item")
|
||||
item.add_control (c)
|
||||
if attached caption as capt then
|
||||
item.add_control (capt)
|
||||
item.add_control (a_control)
|
||||
if a_caption /= Void then
|
||||
item.add_control (a_caption)
|
||||
end
|
||||
cl := ""
|
||||
if slide_wrapper.controls.count = 0 then
|
||||
@@ -119,4 +122,14 @@ feature -- Properties
|
||||
slide_wrapper: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
-- List of the single slides
|
||||
|
||||
;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
|
||||
|
||||
@@ -2,10 +2,12 @@ note
|
||||
description: "[
|
||||
Validator implementation which make sure that the input has
|
||||
the format of an valid email address. This is just a very
|
||||
basic implementation that tests if the given input contains
|
||||
a '@'.
|
||||
basic implementation that tests if the given input contains a '@'.
|
||||
|
||||
This is a simple checker, it does not handle all the cases.
|
||||
]"
|
||||
author: ""
|
||||
EIS: "name=Application Techniques for Checking and Transformation of Names RFC3696", "protocol=URI", "src=http://tools.ietf.org/html/rfc3696#section-3"
|
||||
EIS: "name=Email address (wikipedia)", "protocol=URI", "src=http://en.wikipedia.org/wiki/Email_address"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -30,4 +32,14 @@ feature {NONE} -- Initialization
|
||||
make_regexp_validator ("^.*@.*$", e)
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
@@ -32,12 +32,9 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
is_valid (input: detachable WSF_FILE_DEFINITION): BOOLEAN
|
||||
is_valid (a_input: detachable WSF_FILE_DEFINITION): BOOLEAN
|
||||
do
|
||||
Result := True
|
||||
if attached input as a_input then
|
||||
Result := a_input.size < max
|
||||
end
|
||||
Result := a_input /= Void implies a_input.size < max
|
||||
end
|
||||
|
||||
feature -- State
|
||||
@@ -48,9 +45,19 @@ feature -- State
|
||||
Result.put_integer (max, "max")
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
feature -- Access
|
||||
|
||||
max: INTEGER
|
||||
-- The maximal allowed value
|
||||
|
||||
;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
|
||||
|
||||
@@ -24,7 +24,7 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (m: INTEGER; e: STRING_32)
|
||||
-- Initialize with specified maximum and error message which will be displayed on validation failure
|
||||
-- Initialize with specified minimum `m' and error message `e' which will be displayed on validation failure.
|
||||
do
|
||||
make_validator (e)
|
||||
max := m
|
||||
@@ -32,9 +32,9 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
is_valid (input: G): BOOLEAN
|
||||
is_valid (a_input: G): BOOLEAN
|
||||
do
|
||||
Result := input.count < max or input.count = max
|
||||
Result := a_input.count < max or a_input.count = max
|
||||
end
|
||||
|
||||
feature -- State
|
||||
@@ -50,4 +50,14 @@ feature -- Properties
|
||||
max: INTEGER
|
||||
-- The maximal allowed value
|
||||
|
||||
;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,7 @@ deferred class
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (e: STRING_32)
|
||||
-- Initialize with specified error message to be displayed on validation failure
|
||||
-- Initialize with specified error message `e' to be displayed on validation failure.
|
||||
do
|
||||
error := e
|
||||
ensure
|
||||
@@ -27,9 +27,10 @@ feature -- Access
|
||||
create Result.make
|
||||
Result.put_string (generator, "name")
|
||||
Result.put_string (error, "error")
|
||||
-- FIXME: is that correct to always send error message??
|
||||
end
|
||||
|
||||
is_valid (input: G): BOOLEAN
|
||||
is_valid (a_input: G): BOOLEAN
|
||||
-- Perform validation on given input and tell whether validation was successful or not
|
||||
deferred
|
||||
end
|
||||
@@ -37,6 +38,16 @@ feature -- Access
|
||||
feature -- Properties
|
||||
|
||||
error: STRING_32
|
||||
-- The error message if validation fails
|
||||
-- The error message if validation fails.
|
||||
|
||||
;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
|
||||
|
||||
@@ -25,32 +25,32 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (tag: STRING_32)
|
||||
make (a_tag: STRING_32)
|
||||
-- Initialize
|
||||
require
|
||||
tag_not_empty: not tag.is_empty
|
||||
tag_not_empty: not a_tag.is_empty
|
||||
do
|
||||
make_with_body_class (tag, "", "", "")
|
||||
make_with_body_class (a_tag, "", "", "")
|
||||
end
|
||||
|
||||
make_with_body (tag, attr, b: STRING_32)
|
||||
-- Initialize with specific attributes and body
|
||||
make_with_body (a_tag, a_attribs, a_body: STRING_32)
|
||||
-- Initialize with tag `a_tag', specific attributes `a_attribs' and body `a_body'.
|
||||
require
|
||||
tag_not_empty: not tag.is_empty
|
||||
tag_not_empty: not a_tag.is_empty
|
||||
do
|
||||
make_stateless_control (tag)
|
||||
attributes := attr
|
||||
body := b
|
||||
make_stateless_control (a_tag)
|
||||
attributes := a_attribs
|
||||
body := a_body
|
||||
end
|
||||
|
||||
make_with_body_class (tag, attr, c, b: STRING_32)
|
||||
-- Initialize with specific class, attributes and body
|
||||
make_with_body_class (a_tag, a_attribs, a_css_class, a_body: STRING_32)
|
||||
-- Initialize with tag `a_tag' specific class `a_css_class', attributes `a_attribs' and body `a_body'.
|
||||
require
|
||||
tag_not_empty: not tag.is_empty
|
||||
tag_not_empty: not a_tag.is_empty
|
||||
do
|
||||
make_with_body (tag, attr, b)
|
||||
if not c.is_empty then
|
||||
css_classes.extend (c)
|
||||
make_with_body (a_tag, a_attribs, a_body)
|
||||
if not a_css_class.is_empty then
|
||||
css_classes.extend (a_css_class)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -80,4 +80,14 @@ feature -- Access
|
||||
body: STRING_32
|
||||
-- Body of this control
|
||||
|
||||
;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
|
||||
|
||||
@@ -62,12 +62,13 @@ feature --Event handling
|
||||
click_event_set: click_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)
|
||||
-- Called if the button is clicked.
|
||||
require else
|
||||
cname_has_element: cname.count > 0
|
||||
do
|
||||
if Current.control_name.same_string (cname [1]) and attached click_event as cevent then
|
||||
if
|
||||
control_name.same_string_general (cname.first) and
|
||||
attached click_event as cevent
|
||||
then
|
||||
cevent.call (Void)
|
||||
end
|
||||
end
|
||||
@@ -84,7 +85,7 @@ feature -- Rendering
|
||||
attr.append (a)
|
||||
end
|
||||
if disabled then
|
||||
attr.append ("disabled=%"disabled%" ")
|
||||
attr.append (" disabled=%"disabled%" ")
|
||||
end
|
||||
Result := render_tag (text, attr)
|
||||
end
|
||||
@@ -109,6 +110,8 @@ feature -- Change
|
||||
if disabled /= b then
|
||||
disabled := b
|
||||
state_changes.replace_with_boolean (disabled, "disabled")
|
||||
else
|
||||
check (b = False) implies state_changes.has_key ("disabled") end
|
||||
end
|
||||
ensure
|
||||
disabled_set: disabled = b
|
||||
@@ -125,4 +128,14 @@ feature -- Properties
|
||||
click_event: detachable PROCEDURE [ANY, TUPLE]
|
||||
-- Event that is executed when button is clicked
|
||||
|
||||
;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
|
||||
|
||||
@@ -11,7 +11,6 @@ deferred class
|
||||
WSF_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_STATELESS_CONTROL
|
||||
rename
|
||||
make as make_stateless_control
|
||||
@@ -110,14 +109,14 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
states.put (state_changes, control_name)
|
||||
end
|
||||
if actions.count > 0 then
|
||||
if not attached states.item ("actions") then
|
||||
if states.item ("actions") = Void then
|
||||
states.put (create {JSON_ARRAY}.make_array, "actions")
|
||||
end
|
||||
if attached {JSON_ARRAY} states.item ("actions") as action_list then
|
||||
across
|
||||
actions.array_representation as action
|
||||
actions.array_representation as ic
|
||||
loop
|
||||
action_list.add (action.item)
|
||||
action_list.add (ic.item)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -127,42 +126,43 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
-- Returns the current state of the Control as JSON. This state will be transfered to the client.
|
||||
deferred
|
||||
ensure
|
||||
controls_not_defined: not (attached Result.item ("controls"))
|
||||
controls_not_defined: Result.item ("controls") = Void
|
||||
end
|
||||
|
||||
state_changes: WSF_JSON_OBJECT
|
||||
|
||||
feature -- Rendering
|
||||
|
||||
render_tag (body: STRING_32; attrs: detachable STRING_32): STRING_32
|
||||
render_tag (body: READABLE_STRING_32; attrs: detachable READABLE_STRING_32): STRING_32
|
||||
-- Render this control with the specified body and attributes
|
||||
do
|
||||
Result := render_tag_with_generator_name (js_class, body, attrs)
|
||||
end
|
||||
|
||||
render_tag_with_generator_name (a_generator, body: STRING_32; attrs: detachable STRING_32): STRING_32
|
||||
render_tag_with_generator_name (a_generator, body: READABLE_STRING_32; attrs: detachable READABLE_STRING_32): STRING_32
|
||||
-- Render this control with the specified generator name, body and attributes
|
||||
local
|
||||
css_classes_string: STRING_32
|
||||
l_css_classes_string: STRING_32
|
||||
l_attributes: STRING_32
|
||||
do
|
||||
css_classes_string := ""
|
||||
create l_css_classes_string.make_empty
|
||||
across
|
||||
css_classes as c
|
||||
css_classes as ic
|
||||
loop
|
||||
css_classes_string := css_classes_string + " " + c.item
|
||||
l_css_classes_string.append_character (' ')
|
||||
l_css_classes_string.append (ic.item)
|
||||
end
|
||||
l_attributes := " data-name=%"" + control_name + "%" data-type=%"" + a_generator + "%" "
|
||||
if attached attrs as a then
|
||||
l_attributes := l_attributes + a
|
||||
if attached attrs as l_attrs then
|
||||
l_attributes.append (l_attrs)
|
||||
end
|
||||
if isolate then
|
||||
l_attributes.append (" data-isolation=%"1%"")
|
||||
end
|
||||
Result := render_tag_with_tagname (tag_name, body, l_attributes, css_classes_string)
|
||||
Result := render_tag_with_tagname (tag_name, body, l_attributes, l_css_classes_string)
|
||||
end
|
||||
|
||||
js_class: STRING_32
|
||||
js_class: READABLE_STRING_32
|
||||
-- The js_class is the name of the corresponding javascript class for this control. If this query is not redefined, it just
|
||||
-- returns the name of the Eiffel class. In case of customized controls, either the according javascript functionality has to
|
||||
-- be written in a coffeescript class of the same name or this query has to bee redefined and has to return the name of the
|
||||
@@ -173,8 +173,11 @@ feature -- Rendering
|
||||
|
||||
feature -- Event handling
|
||||
|
||||
handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
-- Method called if any callback received. In this method the callback can be routed to the event handler
|
||||
handle_callback (cname: LIST [READABLE_STRING_GENERAL]; event: READABLE_STRING_GENERAL; event_parameter: detachable ANY)
|
||||
-- Method called if any callback received.
|
||||
-- In this method the callback can be routed to the event handler.
|
||||
require
|
||||
cname_is_not_empty: not cname.is_empty
|
||||
deferred
|
||||
end
|
||||
|
||||
@@ -219,4 +222,14 @@ feature -- Properties
|
||||
-- Used to avoid name conflicts since the children stateful controls of stateless controls are appended to the parent
|
||||
-- control state and therefore could have the same name (Stateless multi controls do not add a hierarchy level)
|
||||
|
||||
;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
|
||||
|
||||
@@ -148,7 +148,7 @@ feature
|
||||
end
|
||||
|
||||
remove_control_by_id (id: INTEGER)
|
||||
--Add removes to pending removes list
|
||||
-- Add removes to pending removes list
|
||||
do
|
||||
pending_removes.extend (id)
|
||||
end
|
||||
@@ -176,7 +176,7 @@ feature
|
||||
Result := "WSF_DYNAMIC_MULTI_CONTROL"
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Access
|
||||
|
||||
items: JSON_ARRAY
|
||||
-- Holds the current items in this control
|
||||
@@ -193,4 +193,14 @@ feature
|
||||
invariant
|
||||
all_items_exist: items.count = controls.count
|
||||
|
||||
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
|
||||
|
||||
@@ -29,33 +29,36 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_without_border (a_label: detachable STRING_32; c: WSF_VALUE_CONTROL [G])
|
||||
-- Initialize form element control with a specific label (or 'Void' for no label) and value control
|
||||
make_without_border (a_label: detachable STRING_32; a_control: WSF_VALUE_CONTROL [G])
|
||||
-- Initialize Current form element control with a specific label
|
||||
-- (or 'Void' for no label) and value control `a_control'.
|
||||
do
|
||||
make_with_validators (a_label, False, c, create {ARRAYED_LIST [WSF_VALIDATOR [G]]}.make (0))
|
||||
make_with_validators (a_label, False, a_control, create {ARRAYED_LIST [WSF_VALIDATOR [G]]}.make (0))
|
||||
end
|
||||
|
||||
make (a_label: detachable STRING_32; c: WSF_VALUE_CONTROL [G])
|
||||
-- Initialize form element control with a specific label (or 'Void' for no label) and value control
|
||||
make (a_label: detachable STRING_32; a_control: WSF_VALUE_CONTROL [G])
|
||||
-- Initialize Current form element control with a specific label
|
||||
-- (or 'Void' for no label) and value control `a_control'.
|
||||
do
|
||||
make_with_validators (a_label, True, c, create {ARRAYED_LIST [WSF_VALIDATOR [G]]}.make (0))
|
||||
make_with_validators (a_label, True, a_control, create {ARRAYED_LIST [WSF_VALIDATOR [G]]}.make (0))
|
||||
end
|
||||
|
||||
make_with_validators (a_label: detachable STRING_32; show_border: BOOLEAN; c: WSF_VALUE_CONTROL [G]; v: LIST [WSF_VALIDATOR [G]])
|
||||
-- Initialize form element control with a specific label (or 'Void' for no label), value control and list of validators
|
||||
make_with_validators (a_label: detachable STRING_32; show_border: BOOLEAN; a_control: WSF_VALUE_CONTROL [G]; a_validators: LIST [WSF_VALIDATOR [G]])
|
||||
-- Initialize Current form element control with a specific label (or 'Void' for no label),
|
||||
-- value control `a_control' and list of validators `a_validators'
|
||||
do
|
||||
make_control ("div")
|
||||
add_class ("form-group")
|
||||
if show_border then
|
||||
if not attached {WSF_VALUE_CONTROL [LIST [ANY]]} c then
|
||||
c.add_class ("form-control")
|
||||
if attached {WSF_VALUE_CONTROL [LIST [ANY]]} a_control then
|
||||
a_control.add_class ("form-control-static")
|
||||
else
|
||||
c.add_class ("form-control-static")
|
||||
a_control.add_class ("form-control")
|
||||
end
|
||||
end
|
||||
label_width := 2
|
||||
value_control := c
|
||||
validators := v
|
||||
value_control := a_control
|
||||
validators := a_validators
|
||||
label := a_label
|
||||
error := ""
|
||||
end
|
||||
@@ -94,7 +97,10 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
-- Pass new_states to subcontrols
|
||||
do
|
||||
Precursor (new_states)
|
||||
if attached {JSON_OBJECT} new_states.item ("controls") as ct and then attached {JSON_OBJECT} ct.item (value_control.control_name) as value_state then
|
||||
if
|
||||
attached {JSON_OBJECT} new_states.item ("controls") as ct and then
|
||||
attached {JSON_OBJECT} ct.item (value_control.control_name) as value_state
|
||||
then
|
||||
value_control.load_state (value_state)
|
||||
end
|
||||
end
|
||||
@@ -154,13 +160,11 @@ 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)
|
||||
-- Pass callback to subcontrols
|
||||
require else
|
||||
cname_not_empty: cname.count > 0
|
||||
do
|
||||
if cname [1].same_string (control_name) then
|
||||
cname.go_i_th (1)
|
||||
if cname.first.same_string (control_name) then
|
||||
cname.start
|
||||
cname.remove
|
||||
if cname.is_empty then
|
||||
if event.same_string ("validate") then
|
||||
@@ -179,9 +183,9 @@ feature -- Implementation
|
||||
local
|
||||
body: STRING_32
|
||||
do
|
||||
body := ""
|
||||
if attached label as l and then not l.is_empty then
|
||||
body.append ("<label class=%"col-lg-" + label_width.out + " control-label%" for=%"" + value_control.control_name + "%">" + l + "</label>")
|
||||
create body.make_empty
|
||||
if attached label as l_label and then not l_label.is_empty then
|
||||
body.append ("<label class=%"col-lg-" + label_width.out + " control-label%" for=%"" + value_control.control_name + "%">" + l_label + "</label>")
|
||||
body.append ("<div class=%"col-lg-" + (12 - label_width).out + "%">")
|
||||
else
|
||||
body.append ("<div class=%"col-lg-12%">")
|
||||
@@ -252,4 +256,14 @@ feature -- Properties
|
||||
label_width: INTEGER
|
||||
-- The bootstrap column span of the label of this form element control
|
||||
|
||||
;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
|
||||
|
||||
@@ -53,7 +53,7 @@ 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)
|
||||
-- By default, this does nothing
|
||||
do
|
||||
end
|
||||
@@ -90,4 +90,14 @@ feature -- Properties
|
||||
html: STRING_32
|
||||
-- The HTML value of this HTML control
|
||||
|
||||
;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
|
||||
|
||||
@@ -18,7 +18,7 @@ inherit
|
||||
create
|
||||
make
|
||||
|
||||
feature
|
||||
feature -- Change
|
||||
|
||||
put_string (value: detachable READABLE_STRING_GENERAL; key: JSON_STRING)
|
||||
-- Assuming there is no item of key `key',
|
||||
@@ -160,4 +160,14 @@ feature
|
||||
replace (l_value, key)
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
@@ -11,7 +11,6 @@ class
|
||||
WSF_MULTI_CONTROL [G -> WSF_STATELESS_CONTROL]
|
||||
|
||||
inherit
|
||||
|
||||
WSF_CONTROL
|
||||
rename
|
||||
make as make_control
|
||||
@@ -32,15 +31,15 @@ feature {NONE} -- Initialization
|
||||
make_with_tag_name ("div")
|
||||
end
|
||||
|
||||
make_with_tag_name (t: STRING_32)
|
||||
-- Initialize with specified tag
|
||||
make_with_tag_name (a_tag: STRING_32)
|
||||
-- Initialize with specified tag `a_tag'.
|
||||
require
|
||||
t_not_empty: not t.is_empty
|
||||
a_tag_not_empty: not a_tag.is_empty
|
||||
do
|
||||
make_control (t)
|
||||
controls := create {ARRAYED_LIST [G]}.make (5);
|
||||
ensure
|
||||
tag_name_set:tag_name.same_string (t)
|
||||
make_control (a_tag)
|
||||
create {ARRAYED_LIST [G]} controls.make (5)
|
||||
ensure
|
||||
tag_name_set: tag_name.same_string (a_tag)
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
@@ -127,11 +126,11 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
-- If the subcontrol is a stateless multicontrol x. We add the state changes of subcontrols of x directly to sub_states. (Stateless multi controls do not add a hierarchy level)
|
||||
do
|
||||
across
|
||||
controls as c
|
||||
controls as ic
|
||||
loop
|
||||
if attached {WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]} c.item as cont then
|
||||
if attached {WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]} ic.item as cont then
|
||||
cont.read_subcontrol_state_changes (sub_states)
|
||||
elseif attached {WSF_CONTROL} c.item as cont then
|
||||
elseif attached {WSF_CONTROL} ic.item as cont then
|
||||
cont.read_state_changes (sub_states)
|
||||
end
|
||||
end
|
||||
@@ -145,19 +144,19 @@ 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)
|
||||
-- Pass callback to subcontrols
|
||||
do
|
||||
if equal (cname [1], control_name) then
|
||||
cname.go_i_th (1)
|
||||
if cname.first.same_string (control_name) then
|
||||
cname.start
|
||||
cname.remove
|
||||
if not cname.is_empty then
|
||||
across
|
||||
controls as c
|
||||
controls as ic
|
||||
until
|
||||
cname.is_empty
|
||||
loop
|
||||
if attached {WSF_CONTROL} c.item as cont then
|
||||
if attached {WSF_CONTROL} ic.item as cont then
|
||||
cont.handle_callback (cname, event, event_parameter)
|
||||
end
|
||||
end
|
||||
@@ -183,11 +182,11 @@ feature -- Rendering
|
||||
|
||||
feature
|
||||
|
||||
add_control (c: G)
|
||||
-- Add a control to this multi control
|
||||
add_control (a_control: G)
|
||||
-- Add a control `a_control' to this multi control.
|
||||
do
|
||||
controls.extend (c)
|
||||
if attached {WSF_CONTROL} c as d then
|
||||
controls.extend (a_control)
|
||||
if attached {WSF_CONTROL} a_control as d then
|
||||
d.control_id := controls.count
|
||||
end
|
||||
end
|
||||
@@ -197,4 +196,14 @@ feature -- Properties
|
||||
controls: ARRAYED_LIST [G]
|
||||
-- List of current controls in this multi control
|
||||
|
||||
;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 @@ deferred class
|
||||
WSF_PAGE_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_CONTROL
|
||||
rename
|
||||
make as make_control
|
||||
@@ -121,12 +120,26 @@ feature -- Implementation
|
||||
|
||||
render: STRING_32
|
||||
-- Render the HTML page
|
||||
local
|
||||
ajax: BOOLEAN
|
||||
do
|
||||
ajax := attached get_parameter ("ajax")
|
||||
create Result.make_empty
|
||||
if not ajax then
|
||||
if attached get_parameter ("ajax") as p_ajax then
|
||||
Result.append ("<div data-name=%"" + control_name + "%" data-type=%"WSF_PAGE_CONTROL%">")
|
||||
Result.append (control.render)
|
||||
if attached additional_javascripts as l_additional_javascripts then
|
||||
across
|
||||
l_additional_javascripts as ic
|
||||
loop
|
||||
Result.append ("<script src=%"")
|
||||
Result.append (base_path)
|
||||
Result.append (ic.item)
|
||||
Result.append ("%"></script>")
|
||||
end
|
||||
end
|
||||
Result.append ("<script type=%"text/javascript%">$(function() {var page= new WSF_PAGE_CONTROL(")
|
||||
Result.append (full_state.representation)
|
||||
Result.append (");page.initialize();});</script>")
|
||||
Result.append ("</div>")
|
||||
else
|
||||
Result.append ("<html><head>")
|
||||
Result.append ("<link href=%"")
|
||||
Result.append (base_path)
|
||||
@@ -142,13 +155,13 @@ feature -- Implementation
|
||||
Result.append ("<script src=%"")
|
||||
Result.append (base_path)
|
||||
Result.append ("assets/widget.js%"></script>")
|
||||
if attached additional_javascripts as ajs then
|
||||
if attached additional_javascripts as l_additional_javascripts then
|
||||
across
|
||||
ajs as js
|
||||
l_additional_javascripts as ic
|
||||
loop
|
||||
Result.append ("<script src=%"")
|
||||
Result.append (base_path)
|
||||
Result.append (js.item)
|
||||
Result.append (ic.item)
|
||||
Result.append ("%"></script>")
|
||||
end
|
||||
end
|
||||
@@ -156,23 +169,6 @@ feature -- Implementation
|
||||
Result.append (full_state.representation)
|
||||
Result.append (");page.initialize();});</script>")
|
||||
Result.append ("</body></html>")
|
||||
else
|
||||
Result.append ("<div data-name=%"" + control_name + "%" data-type=%"WSF_PAGE_CONTROL%">")
|
||||
Result.append (control.render)
|
||||
if attached additional_javascripts as ajs then
|
||||
across
|
||||
ajs as js
|
||||
loop
|
||||
Result.append ("<script src=%"")
|
||||
Result.append (base_path)
|
||||
Result.append (js.item)
|
||||
Result.append ("%"></script>")
|
||||
end
|
||||
end
|
||||
Result.append ("<script type=%"text/javascript%">$(function() {var page= new WSF_PAGE_CONTROL(")
|
||||
Result.append (full_state.representation)
|
||||
Result.append (");page.initialize();});</script>")
|
||||
Result.append ("</div>")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -183,34 +179,31 @@ feature -- Implementation
|
||||
control.read_state_changes (states)
|
||||
end
|
||||
|
||||
get_parameter (key: STRING_32): detachable STRING_32
|
||||
get_parameter (key: READABLE_STRING_GENERAL): detachable STRING_32
|
||||
-- Read query parameter as string
|
||||
local
|
||||
value: detachable WSF_VALUE
|
||||
do
|
||||
Result := VOID
|
||||
value := request.query_parameter (key)
|
||||
if attached value and then value.is_string then
|
||||
Result := value.as_string.value
|
||||
if
|
||||
attached {WSF_STRING} request.query_parameter (key) as l_value
|
||||
then
|
||||
Result := l_value.value
|
||||
end
|
||||
end
|
||||
|
||||
add_javascript (path: STRING_32)
|
||||
local
|
||||
ajs: attached like additional_javascripts
|
||||
l_additional_javascripts: like additional_javascripts
|
||||
do
|
||||
if attached additional_javascripts as aajs then
|
||||
ajs := aajs
|
||||
else
|
||||
create ajs.make (1)
|
||||
l_additional_javascripts := additional_javascripts
|
||||
if l_additional_javascripts = Void then
|
||||
create l_additional_javascripts.make (1)
|
||||
additional_javascripts := l_additional_javascripts
|
||||
end
|
||||
ajs.extend (path)
|
||||
additional_javascripts := ajs
|
||||
l_additional_javascripts.extend (path)
|
||||
end
|
||||
|
||||
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)
|
||||
-- Forward callback to control
|
||||
do
|
||||
control.handle_callback (cname, event, event_parameter)
|
||||
@@ -230,7 +223,10 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
set_state (sp: JSON_OBJECT)
|
||||
-- Set state
|
||||
do
|
||||
if attached {JSON_OBJECT} sp.item ("controls") as ct and then attached {JSON_OBJECT} ct.item (control.control_name) as value_state then
|
||||
if
|
||||
attached {JSON_OBJECT} sp.item ("controls") as ct and then
|
||||
attached {JSON_OBJECT} ct.item (control.control_name) as value_state
|
||||
then
|
||||
control.load_state (value_state)
|
||||
end
|
||||
end
|
||||
@@ -246,7 +242,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
Result.put (state, "state")
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Access
|
||||
|
||||
control_name: STRING_32
|
||||
-- Name of this page
|
||||
@@ -262,4 +258,14 @@ feature {NONE} -- Root control
|
||||
additional_javascripts: detachable ARRAYED_LIST [STRING_32]
|
||||
-- List containing the additional javascipt files
|
||||
|
||||
;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
|
||||
|
||||
@@ -27,43 +27,43 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- Change
|
||||
|
||||
add_class (c: STRING_32)
|
||||
add_class (a_css_class: STRING_32)
|
||||
-- Add a css class to this control
|
||||
require
|
||||
c_not_empty: not c.is_empty
|
||||
a_css_class_not_empty: not a_css_class.is_empty
|
||||
do
|
||||
css_classes.force (c)
|
||||
css_classes.force (a_css_class)
|
||||
ensure
|
||||
class_added: css_classes.has (c)
|
||||
class_added: css_classes.has (a_css_class)
|
||||
end
|
||||
|
||||
remove_class (c: STRING_32)
|
||||
remove_class (a_css_class: STRING_32)
|
||||
-- Remove a css class from this control
|
||||
require
|
||||
c_not_empty: not c.is_empty
|
||||
c_not_empty: not a_css_class.is_empty
|
||||
do
|
||||
css_classes.start
|
||||
css_classes.prune_all (c)
|
||||
css_classes.prune_all (a_css_class)
|
||||
ensure
|
||||
c_removed: not css_classes.has (c)
|
||||
c_removed: not css_classes.has (a_css_class)
|
||||
end
|
||||
|
||||
append_attribute (a: STRING_32)
|
||||
append_attribute (att: READABLE_STRING_32)
|
||||
-- Adds the specified attribute to the attribute string of this control
|
||||
require
|
||||
a_not_empty: not a.is_empty
|
||||
att_not_empty: not att.is_empty
|
||||
do
|
||||
if attached attributes as attr then
|
||||
attr.append (" ")
|
||||
attr.append (a)
|
||||
attr.append_character (' ')
|
||||
attr.append (att)
|
||||
else
|
||||
attributes := a
|
||||
create attributes.make_from_string (att)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Rendering
|
||||
|
||||
render_tag (body: STRING_32; attrs: detachable STRING_32): STRING_32
|
||||
render_tag (a_body: READABLE_STRING_32; attrs: detachable READABLE_STRING_32): STRING_32
|
||||
-- Generate HTML of this control with the specified body and attributes
|
||||
local
|
||||
css_classes_string: STRING_32
|
||||
@@ -74,10 +74,10 @@ feature -- Rendering
|
||||
loop
|
||||
css_classes_string.append (" " + c.item)
|
||||
end
|
||||
Result := render_tag_with_tagname (tag_name, body, attrs, css_classes_string)
|
||||
Result := render_tag_with_tagname (tag_name, a_body, attrs, css_classes_string)
|
||||
end
|
||||
|
||||
render_tag_with_tagname (tag, body: STRING_32; attrs: detachable STRING_32; css_classes_string: STRING_32): STRING_32
|
||||
render_tag_with_tagname (tag, a_body: READABLE_STRING_32; attrs: detachable READABLE_STRING_32; css_classes_string: READABLE_STRING_32): STRING_32
|
||||
-- Generate HTML of the specified tag with specified body, attributes and css classes
|
||||
local
|
||||
l_attributes: STRING_32
|
||||
@@ -92,16 +92,33 @@ feature -- Rendering
|
||||
l_attributes.append (css_classes_string)
|
||||
l_attributes.append_character ('%"')
|
||||
end
|
||||
Result := "<" + tag + " " + l_attributes
|
||||
create Result.make_empty
|
||||
Result.append_character ('<')
|
||||
Result.append (tag)
|
||||
Result.append_character (' ')
|
||||
Result.append (l_attributes)
|
||||
-- Check if we have to render a body. For some elements, this is not the case (like textareas) or only if the body is not empty.
|
||||
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") and not tag.same_string ("div") then
|
||||
Result.append (" />")
|
||||
if
|
||||
a_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") and
|
||||
not tag.same_string ("div")
|
||||
then
|
||||
-- Note: it should be ok to close for textarea, span, ... and so on.
|
||||
|
||||
Result.append ("/>")
|
||||
else
|
||||
Result.append (" >" + body + "</" + tag + ">")
|
||||
Result.append (" >")
|
||||
Result.append (a_body)
|
||||
Result.append ("</")
|
||||
Result.append (tag)
|
||||
Result.append (">")
|
||||
end
|
||||
end
|
||||
|
||||
render_tag_with_body (body: STRING_32): STRING_32
|
||||
render_tag_with_body (body: READABLE_STRING_32): STRING_32
|
||||
-- Generate HTML of this control with the specified body
|
||||
do
|
||||
Result := render_tag (body, attributes)
|
||||
@@ -126,4 +143,14 @@ feature -- Properties
|
||||
invariant
|
||||
tag_name_not_empty: not tag_name.is_empty
|
||||
|
||||
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
|
||||
|
||||
@@ -3,7 +3,6 @@ note
|
||||
Mutli controls are used as containers for multiple controls, for
|
||||
example a form is a multi control.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -11,7 +10,6 @@ class
|
||||
WSF_STATELESS_MULTI_CONTROL [G -> WSF_STATELESS_CONTROL]
|
||||
|
||||
inherit
|
||||
|
||||
WSF_MULTI_CONTROL [G]
|
||||
rename
|
||||
make as make_multi_control
|
||||
@@ -34,7 +32,7 @@ feature {NONE} -- Initialization
|
||||
make_with_tag_name ("")
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Change
|
||||
|
||||
set_control_id (d: INTEGER)
|
||||
-- Set id of this control and update subcontrol prefixes
|
||||
@@ -56,17 +54,22 @@ feature
|
||||
|
||||
set_subcontrol_prefixes
|
||||
-- Update subcontrol prefixes
|
||||
local
|
||||
s: STRING_32
|
||||
do
|
||||
across
|
||||
controls as e
|
||||
controls as ic
|
||||
loop
|
||||
if attached {WSF_CONTROL} e.item as el then
|
||||
el.control_name_prefix := control_name_prefix + control_id.out + "_"
|
||||
if attached {WSF_CONTROL} ic.item as l_control then
|
||||
create s.make_from_string (control_name_prefix)
|
||||
s.append_integer (control_id)
|
||||
s.append_character ('_')
|
||||
l_control.set_control_name_prefix (s)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Change
|
||||
|
||||
add_control (c: G)
|
||||
-- Add a control to this multi control
|
||||
@@ -80,7 +83,7 @@ feature
|
||||
control_added: controls.has (c)
|
||||
end
|
||||
|
||||
render_tag (body: STRING_32; attrs: detachable STRING_32): STRING_32
|
||||
render_tag (body: READABLE_STRING_32; attrs: detachable READABLE_STRING_32): STRING_32
|
||||
-- Generate HTML of this control with the specified body and attributes
|
||||
local
|
||||
css_classes_string: STRING_32
|
||||
@@ -96,7 +99,7 @@ feature
|
||||
|
||||
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)
|
||||
-- Pass callback to subcontrols
|
||||
do
|
||||
across
|
||||
@@ -110,4 +113,14 @@ feature -- Event handling
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
@@ -11,7 +11,6 @@ deferred class
|
||||
WSF_VALUE_CONTROL [G]
|
||||
|
||||
inherit
|
||||
|
||||
WSF_CONTROL
|
||||
|
||||
feature -- Access
|
||||
@@ -22,7 +21,18 @@ feature -- Access
|
||||
end
|
||||
|
||||
set_value (v: G)
|
||||
-- Set `value' to `v'.
|
||||
deferred
|
||||
end
|
||||
|
||||
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
draft/library/wsf_js_widget/license.lic
Normal file
10
draft/library/wsf_js_widget/license.lic
Normal file
@@ -0,0 +1,10 @@
|
||||
${NOTE_KEYWORD}
|
||||
copyright: "2011-${YEAR}, 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
|
||||
]"
|
||||
@@ -30,9 +30,22 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
-- tt
|
||||
-- local
|
||||
-- lst: ARRAYED_LIST [READABLE_STRING_GENERAL]
|
||||
-- do
|
||||
-- create lst.make (3)
|
||||
-- lst.compare_objects
|
||||
-- lst.extend ({STRING_32} "abc")
|
||||
-- if lst.has ("abc") then
|
||||
-- print ("found%N")
|
||||
-- end
|
||||
-- end
|
||||
|
||||
initialize
|
||||
-- Initialize current service.
|
||||
do
|
||||
-- tt
|
||||
initialize_router
|
||||
initialize_filter
|
||||
Precursor
|
||||
|
||||
@@ -18,7 +18,17 @@ inherit
|
||||
create
|
||||
make_news
|
||||
|
||||
feature --States
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_news
|
||||
do
|
||||
page := 1
|
||||
page_size := 8
|
||||
query := "eiffel"
|
||||
end
|
||||
|
||||
feature -- States
|
||||
|
||||
state: WSF_JSON_OBJECT
|
||||
-- Return state which contains the current html and if there is an event handle attached
|
||||
@@ -35,14 +45,7 @@ feature --States
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
make_news
|
||||
do
|
||||
page := 1
|
||||
page_size := 8
|
||||
query := "eiffel"
|
||||
end
|
||||
feature -- Access
|
||||
|
||||
data: ITERABLE [GOOGLE_NEWS]
|
||||
local
|
||||
|
||||
@@ -32,7 +32,7 @@ feature
|
||||
Precursor
|
||||
create form.make
|
||||
--Number 1
|
||||
create textbox1.make ({STRING_32}"1")
|
||||
create textbox1.make ({STRING_32} "1")
|
||||
create n1_container.make ({STRING_32}"Number1", textbox1)
|
||||
n1_container.add_validator (create {WSF_DECIMAL_VALIDATOR}.make ({STRING_32}"Invalid Number"))
|
||||
n1_container.add_validator (create {OWN_VALIDATOR}.make_own)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {IMAGE_SLIDER_PAGE}."
|
||||
description: "Summary description for {SLIDER_PAGE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
Reference in New Issue
Block a user