Added more comments and assertions to all classes; clean up
This commit is contained in:
8
draft/library/wsf_js_widget/README.md
Normal file
8
draft/library/wsf_js_widget/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Eiffel Web Framework
|
||||
|
||||
|
||||
## Overview
|
||||
|
||||
## Dependencies
|
||||
|
||||
*
|
||||
@@ -29,10 +29,12 @@ feature {NONE} -- Initialization
|
||||
make_with_tag_name (title, "div")
|
||||
end
|
||||
|
||||
make_with_tag_name (title, t: STRING_32)
|
||||
make_with_tag_name (title, tag: STRING_32)
|
||||
-- Make a dropdown control with specified tag name (such as li) and menu title
|
||||
require
|
||||
tag_not_empty: not tag.is_empty
|
||||
do
|
||||
make_multi_control_with_tag_name (t)
|
||||
make_multi_control_with_tag_name (tag)
|
||||
add_class ("dropdown")
|
||||
create {WSF_BASIC_CONTROL} dropdown_toggle.make_with_body_class ("a", "data-toggle=%"dropdown%" href=%"#%" type=%"button%" id=%"" + control_name + "_toggle%"", "dropdown-toggle", title + " <strong class=%"caret%"></strong>")
|
||||
create dropdown_menu.make_with_tag_name ("ul")
|
||||
@@ -45,6 +47,7 @@ feature {NONE} -- Initialization
|
||||
feature -- Change
|
||||
|
||||
add_item (c: WSF_STATELESS_CONTROL)
|
||||
-- Wrap the specified control into a <li> tag and add it to the menu
|
||||
local
|
||||
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
do
|
||||
@@ -56,6 +59,7 @@ feature -- Change
|
||||
end
|
||||
|
||||
add_link_item (label, link: STRING_32)
|
||||
-- Add an item to the menu which redirects to the specified link
|
||||
local
|
||||
c: WSF_BASIC_CONTROL
|
||||
do
|
||||
@@ -64,6 +68,7 @@ feature -- Change
|
||||
end
|
||||
|
||||
add_divider
|
||||
-- Append a horizontal divider to the menu
|
||||
do
|
||||
dropdown_menu.add_control (create {WSF_BASIC_CONTROL}.make_with_body_class ("li", "role=%"menuitem%"", "divider", ""))
|
||||
end
|
||||
@@ -71,7 +76,9 @@ feature -- Change
|
||||
feature -- Properties
|
||||
|
||||
dropdown_toggle: WSF_STATELESS_CONTROL
|
||||
-- The dropdown toggle which causes the menu to pop up or dispose
|
||||
|
||||
dropdown_menu: WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
-- The dropdown menu which holds the single entries (controls and dividers)
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
note
|
||||
description: "Summary description for {WSF_AUTOCOMPLETE_CONTROL}."
|
||||
description: "[
|
||||
A control that can be used for autocompletion. A customizable
|
||||
template can be passed to this class in a WSF_AUTOCOMPLETION
|
||||
instance.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -23,18 +27,18 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (c: WSF_AUTOCOMPLETION)
|
||||
-- Initialize with specified name and autocompletion
|
||||
-- Initialize with specified autocompletion
|
||||
do
|
||||
make_with_agent ( agent c.autocompletion)
|
||||
make_with_agent (agent c.autocompletion)
|
||||
if attached c.template as t then
|
||||
template := t
|
||||
end
|
||||
end
|
||||
|
||||
make_with_agent (c: FUNCTION [ANY, TUPLE [STRING_32], JSON_ARRAY])
|
||||
-- Initialize with specified name and autocompletion function
|
||||
-- Initialize with autocompletion function
|
||||
do
|
||||
make_input ( "")
|
||||
make_input ("")
|
||||
create_json_list := c
|
||||
template := "{{=value}}"
|
||||
end
|
||||
@@ -49,10 +53,10 @@ feature -- State
|
||||
|
||||
feature -- Callback
|
||||
|
||||
handle_callback (cname: LIST[STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
do
|
||||
Precursor {WSF_INPUT_CONTROL} (cname, event, event_parameter)
|
||||
if cname[1].same_string (control_name) and event.same_string ("autocomplete") then
|
||||
if cname [1].same_string (control_name) and event.same_string ("autocomplete") then
|
||||
state_changes.put (create_json_list.item ([text]), "suggestions")
|
||||
end
|
||||
end
|
||||
@@ -60,7 +64,9 @@ feature -- Callback
|
||||
feature -- Properties
|
||||
|
||||
create_json_list: FUNCTION [ANY, TUPLE [STRING_32], JSON_ARRAY]
|
||||
-- The function which is called to give a list of suggestions to a given user input
|
||||
|
||||
template: STRING_32
|
||||
-- The template
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CHECKBOX_CONTROL}."
|
||||
description: "[
|
||||
Representation of an HTML checkbox.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -11,7 +13,9 @@ inherit
|
||||
|
||||
WSF_VALUE_CONTROL [BOOLEAN]
|
||||
rename
|
||||
make as make_value_control
|
||||
make as make_value_control,
|
||||
value as checked,
|
||||
set_value as set_checked
|
||||
end
|
||||
|
||||
create
|
||||
@@ -19,12 +23,14 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (l, c: STRING_32)
|
||||
-- Initialize with specified control name,
|
||||
make (l, value: STRING_32)
|
||||
-- Initialize with specified label and value
|
||||
require
|
||||
value_not_empty: not value.is_empty
|
||||
do
|
||||
make_value_control ("input")
|
||||
label := l
|
||||
checked_value := c
|
||||
checked_value := value
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
@@ -76,12 +82,8 @@ feature -- Implementation
|
||||
Result := render_tag_with_tagname ("div", render_tag_with_tagname ("label", render_tag ("", attrs) + " " + label, "", ""), "", "checkbox")
|
||||
end
|
||||
|
||||
value: BOOLEAN
|
||||
do
|
||||
Result := checked
|
||||
end
|
||||
|
||||
set_value (v: BOOLEAN)
|
||||
set_checked (v: BOOLEAN)
|
||||
-- Set if the checkbox is checked
|
||||
do
|
||||
checked := v
|
||||
end
|
||||
@@ -95,7 +97,7 @@ feature -- Properties
|
||||
-- The checked value of the checkbox control
|
||||
|
||||
checked_value: STRING_32
|
||||
-- String checked value
|
||||
-- The value of this checkbox
|
||||
|
||||
change_event: detachable PROCEDURE [ANY, TUPLE]
|
||||
-- Function to be executed on change
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CHECKBOX_LIST_CONTROL}."
|
||||
description: "[
|
||||
Representation of a list of HTML checkboxes.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -37,23 +39,26 @@ feature {NONE} -- Initializaton
|
||||
feature -- Implementation
|
||||
|
||||
value: LIST [STRING_32]
|
||||
-- Returns the values of all selected checkboxes in this list
|
||||
do
|
||||
create {ARRAYED_LIST [STRING_32]} Result.make (0)
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
if c.item.value then
|
||||
if c.item.checked then
|
||||
Result.extend (c.item.checked_value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_value (v: LIST [STRING_32])
|
||||
-- Sets the checked state of each of the checkboxes in this list according to whether the value
|
||||
-- of a checkbox occurs in the specified list or not
|
||||
do
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
c.item.set_value (v.has (c.item.checked_value))
|
||||
c.item.set_checked (v.has (c.item.checked_value))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CODEVIEW_CONTROL}."
|
||||
description:"[
|
||||
This class is only used because the code viewer has a specific
|
||||
mapping in javascript. The Eiffel class does not provide
|
||||
special functionality itself.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FILE_CONTROL}."
|
||||
description: "[
|
||||
A control that represents a file upload.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -20,11 +22,13 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize
|
||||
do
|
||||
make_value_control ("input")
|
||||
end
|
||||
|
||||
make_with_image_preview
|
||||
-- Initialize with image_preview set to true
|
||||
do
|
||||
make
|
||||
image_preview := True
|
||||
@@ -102,6 +106,7 @@ feature -- Event handling
|
||||
feature -- Upload
|
||||
|
||||
start_upload
|
||||
-- Add start upload command to action list which then executes the javascript function to start upload on client side
|
||||
local
|
||||
upload: WSF_JSON_OBJECT
|
||||
do
|
||||
@@ -137,39 +142,56 @@ feature -- Change
|
||||
-- Set text change event handle
|
||||
do
|
||||
change_event := e
|
||||
ensure
|
||||
change_event_set: change_event = e
|
||||
end
|
||||
|
||||
set_upload_done_event (e: attached like upload_done_event)
|
||||
-- Set text change event handle
|
||||
do
|
||||
upload_done_event := e
|
||||
ensure
|
||||
upload_done_event_set: upload_done_event = e
|
||||
end
|
||||
|
||||
set_upload_function (e: attached like upload_function)
|
||||
-- Set button click event handle
|
||||
do
|
||||
upload_function := e
|
||||
ensure
|
||||
upload_function_set: upload_function = e
|
||||
end
|
||||
|
||||
set_disabled (b: BOOLEAN)
|
||||
-- Set the disabled state of this file control
|
||||
do
|
||||
if disabled /= b then
|
||||
disabled := b
|
||||
state_changes.replace_with_boolean (disabled, "disabled")
|
||||
end
|
||||
ensure
|
||||
disabled_set: disabled = b
|
||||
state_changes_registered: old disabled /= disabled implies state_changes.has_key ("disabled")
|
||||
end
|
||||
|
||||
set_value (v: detachable WSF_FILE_DEFINITION)
|
||||
-- Set the file definition of this file control
|
||||
do
|
||||
file := v
|
||||
ensure then
|
||||
file_set: file = v
|
||||
end
|
||||
|
||||
set_image_preview (b: BOOLEAN)
|
||||
-- Set if the image should be previewed in the control
|
||||
do
|
||||
if image_preview /= b then
|
||||
image_preview := b
|
||||
state_changes.replace_with_boolean (image_preview, "image_preview")
|
||||
end
|
||||
ensure
|
||||
image_preview_set: image_preview = b
|
||||
state_changes_registered: old image_preview /= image_preview implies state_changes.has_key ("image_preview")
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FILE_DEFINITION}."
|
||||
description: "[
|
||||
A container to encapsulate file information which is used by
|
||||
WSF_FILE_CONTROL, such as name or type of the file.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -20,9 +23,10 @@ feature {NONE}
|
||||
id := a_id
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Change
|
||||
|
||||
set_id (a_id: detachable STRING_32)
|
||||
-- Set the id of this abstract file.
|
||||
do
|
||||
id := a_id
|
||||
end
|
||||
@@ -30,6 +34,7 @@ feature
|
||||
feature --Properties
|
||||
|
||||
is_uploaded: BOOLEAN
|
||||
-- Whether the file denoted by this abstract file has been uploaded.
|
||||
do
|
||||
Result := attached id
|
||||
end
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
note
|
||||
description: "Summary description for {WSF_TEXT_CONTROL}."
|
||||
description: "[
|
||||
The basic <input> HTML element is represented by this control.
|
||||
All controls that are used to gather some input from the user
|
||||
basically can inherit from this class.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -25,6 +29,8 @@ feature {NONE} -- Initialization
|
||||
make_value_control ("input")
|
||||
type := "text"
|
||||
text := v
|
||||
ensure
|
||||
text_set: text = v
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
@@ -52,6 +58,8 @@ feature --Event handling
|
||||
-- Set text change event handle
|
||||
do
|
||||
change_event := e
|
||||
ensure
|
||||
change_event_set: change_event = e
|
||||
end
|
||||
|
||||
handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
@@ -88,31 +96,45 @@ feature -- Change
|
||||
text := t
|
||||
state_changes.replace (create {JSON_STRING}.make_json (text), "text")
|
||||
end
|
||||
ensure
|
||||
text_same_string_as_t: text.same_string (t)
|
||||
state_changes_registered: old text /= text implies state_changes.has_key ("text")
|
||||
end
|
||||
|
||||
set_disabled (b: BOOLEAN)
|
||||
-- Set the disabled state of this control
|
||||
do
|
||||
if disabled /= b then
|
||||
disabled := b
|
||||
state_changes.replace_with_boolean (disabled, "disabled")
|
||||
end
|
||||
ensure
|
||||
disabled_set: disabled = b
|
||||
state_changes_registered: old b /= b implies state_changes.has_key ("disabled")
|
||||
end
|
||||
|
||||
set_type (t: STRING_32)
|
||||
-- Set the type of this input control (HTML 'type' attribute)
|
||||
do
|
||||
type := t
|
||||
ensure
|
||||
type_set: type = t
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
value: STRING_32
|
||||
-- The value of this input control
|
||||
do
|
||||
Result := text
|
||||
end
|
||||
|
||||
set_value (v: STRING_32)
|
||||
-- Set the value of this input control
|
||||
do
|
||||
text := v
|
||||
ensure then
|
||||
value_set: text = v
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {WSF_PASSWORD_CONTROL}."
|
||||
description: "[
|
||||
This control represents an HTML input control with the 'type'
|
||||
attribute set to 'password'.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
note
|
||||
description: "Summary description for {WSF_TEXT_CONTROL}."
|
||||
description: "[
|
||||
This control represents a textarea (the HTML 'textarea' tag).
|
||||
It basically just inherits the functionality of an input
|
||||
control.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
note
|
||||
description: "[
|
||||
WSF_NAVBAR_CONTROL encapsulates the navbar provided by bootstrap.
|
||||
Simple menu items as well as dropdown lists and panels can be added to this control
|
||||
http://getbootstrap.com/components/#navbar
|
||||
WSF_NAVBAR_CONTROL encapsulates the navbar provided by
|
||||
bootstrap. Simple menu items as well as dropdown lists and
|
||||
panels can be added to this control.
|
||||
See http://getbootstrap.com/components/#navbar
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
@@ -44,6 +45,8 @@ feature {NONE} -- Initialization
|
||||
do
|
||||
make
|
||||
brand := b
|
||||
ensure
|
||||
brand_set: brand = b
|
||||
end
|
||||
|
||||
feature -- Rendering
|
||||
@@ -72,7 +75,7 @@ feature -- Rendering
|
||||
feature -- Change
|
||||
|
||||
set_active (tab: INTEGER)
|
||||
-- Sets the given tab as current active tab
|
||||
-- Sets the given tab as current active tab. This procedure must not be called more than once.
|
||||
require
|
||||
tab >= 1 and tab <= tab_count and not active_set
|
||||
do
|
||||
@@ -82,6 +85,8 @@ feature -- Change
|
||||
nav_right.controls.i_th (tab - nav.controls.count).add_class ("active")
|
||||
end
|
||||
active_set := true
|
||||
ensure
|
||||
active_set_set: active_set
|
||||
end
|
||||
|
||||
add_list_element_right (l: WSF_STATELESS_CONTROL)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "[
|
||||
WSF_NAVLIST_CONTROL encapsulates the linked items provided by bootstrap.
|
||||
http://getbootstrap.com/components/#list-group-linked
|
||||
This class encapsulates the linked items provided by bootstrap.
|
||||
See http://getbootstrap.com/components/#list-group-linked
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
@@ -23,6 +23,7 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize
|
||||
do
|
||||
make_multi_control
|
||||
add_class ("list-group")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
note
|
||||
description: "[
|
||||
WSF_NAVLIST_ITEM_CONTROL represents a menu item in WSF_NAVLIST_CONTROL
|
||||
This class represents a menu item in WSF_NAVLIST_CONTROL.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
@@ -25,11 +25,14 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (link, t: STRING_32)
|
||||
-- Initialize with the given link and text
|
||||
do
|
||||
make_control ("a")
|
||||
text := t
|
||||
attributes := "href=%"" + link + "%"";
|
||||
add_class ("list-group-item")
|
||||
ensure
|
||||
text_set: text = t
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
@@ -53,7 +56,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
feature -- Change
|
||||
|
||||
set_active (a: BOOLEAN)
|
||||
-- Set text of that button
|
||||
-- Set whether this item should be displayed as active or not
|
||||
do
|
||||
if active /= a then
|
||||
active := a
|
||||
@@ -64,10 +67,14 @@ feature -- Change
|
||||
end
|
||||
state_changes.replace (create {JSON_BOOLEAN}.make_boolean (a), "active")
|
||||
end
|
||||
ensure
|
||||
active_set: active = a
|
||||
state_changes_registered: old active /= active implies state_changes.has_key ("active")
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
active: BOOLEAN
|
||||
-- The active state of this item
|
||||
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
note
|
||||
description: "[
|
||||
WSF_PROGRESS_CONTROL encapsulates the progress bar provided by bootstrap.
|
||||
The value of the progress bar can either be set directly using set_progress
|
||||
or it can be fetched from a progress source.
|
||||
WSF_PROGRESS_CONTROL encapsulates the progress bar provided by bootstrap.
|
||||
The value of the progress bar can either be set directly using set_progress
|
||||
or it can be fetched from a progress source.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
@@ -24,23 +24,27 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize with specified control name
|
||||
-- Initialize
|
||||
do
|
||||
make_control ("div")
|
||||
add_class ("progress")
|
||||
progress := 0
|
||||
end
|
||||
|
||||
make_with_source ( p: WSF_PROGRESS_SOURCE)
|
||||
-- Initialize with specified control name and progresssource
|
||||
make_with_source (p: WSF_PROGRESS_SOURCE)
|
||||
-- Initialize with specified progresssource
|
||||
do
|
||||
make
|
||||
progress_source := p
|
||||
ensure
|
||||
progress_source_set: progress_source = p
|
||||
end
|
||||
|
||||
feature -- State handling
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
require else
|
||||
progress_in_range: attached {JSON_NUMBER} new_state.item ("progress") as new_progress implies new_progress.item.to_integer >= 0 and new_progress.item.to_integer <= 100
|
||||
do
|
||||
if attached {JSON_NUMBER} new_state.item ("progress") as new_progress then
|
||||
progress := new_progress.item.to_integer
|
||||
@@ -55,9 +59,9 @@ feature -- State handling
|
||||
|
||||
feature -- Event handling
|
||||
|
||||
handle_callback (cname: LIST[STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
do
|
||||
if cname[1].same_string (control_name) and event.same_string ("progress_fetch") then
|
||||
if cname [1].same_string (control_name) and event.same_string ("progress_fetch") then
|
||||
state_changes.put_integer (progress_value, "progress")
|
||||
end
|
||||
end
|
||||
@@ -83,22 +87,33 @@ feature -- Change
|
||||
do
|
||||
progress := p
|
||||
state_changes.put_integer (progress, "progress")
|
||||
ensure
|
||||
progress_set: progress = p
|
||||
state_changes_registered: state_changes.has_key ("progress")
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
progress_value: INTEGER
|
||||
-- The progress value of this progress control
|
||||
do
|
||||
Result := progress
|
||||
if attached progress_source as ps then
|
||||
Result := ps.progress
|
||||
end
|
||||
ensure
|
||||
result_in_range: Result >= 0 and Result <= 100
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
progress_source: detachable WSF_PROGRESS_SOURCE
|
||||
-- The source which provides this progress control the progress value
|
||||
|
||||
progress: INTEGER
|
||||
-- The progress value of this progress control
|
||||
|
||||
invariant
|
||||
progress_in_range: progress >= 0 and progress <= 100
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {WSF_IMAGE_SLIDER_CONTROL}."
|
||||
description: "[
|
||||
Represents the bootstraps's 'carousel'.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -20,11 +22,11 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize with specified name
|
||||
-- Initialize
|
||||
do
|
||||
make_control ( "div")
|
||||
make_control ("div")
|
||||
add_class ("carousel slide")
|
||||
create list.make_with_tag_name ( "ol")
|
||||
create list.make_with_tag_name ("ol")
|
||||
list.add_class ("carousel-indicators")
|
||||
create slide_wrapper.make_with_tag_name ("div")
|
||||
slide_wrapper.add_class ("carousel-inner")
|
||||
@@ -33,19 +35,21 @@ feature {NONE} -- Initialization
|
||||
feature -- State handling
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Just implementation, nothing special to do here
|
||||
do
|
||||
end
|
||||
|
||||
state: WSF_JSON_OBJECT
|
||||
-- Just implementation, nothing special to do here
|
||||
do
|
||||
create Result.make
|
||||
end
|
||||
|
||||
feature -- Callback
|
||||
|
||||
handle_callback (cname: LIST[STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
-- Just implementation, nothing special to do here
|
||||
do
|
||||
-- Do nothing here
|
||||
end
|
||||
|
||||
feature -- Rendering
|
||||
@@ -64,6 +68,7 @@ feature -- Rendering
|
||||
feature -- Change
|
||||
|
||||
add_image_with_caption (src, alt, caption: STRING_32)
|
||||
-- Add a new image to the slider with specified url, alternative text and caption
|
||||
local
|
||||
caption_control: detachable WSF_STATELESS_CONTROL
|
||||
do
|
||||
|
||||
@@ -22,18 +22,25 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (h: like handler; e: STRING_32)
|
||||
-- Initialize with given validation function and error message
|
||||
do
|
||||
make_validator (e)
|
||||
handler := h
|
||||
ensure
|
||||
handler_set: handler = h
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Implementation
|
||||
|
||||
is_valid (input: G): BOOLEAN
|
||||
-- Tests if given input is valid
|
||||
do
|
||||
Result := handler.item ([input])
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
handler: FUNCTION [ANY, TUPLE [G], BOOLEAN]
|
||||
-- The function which is used to validate inputs
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
note
|
||||
description: "[
|
||||
Validator implementation which make sure that the input has a the format of an valid email address
|
||||
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 '@'.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
@@ -22,7 +25,7 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (e: STRING_32)
|
||||
-- Initialize with specified error message which will be displayed on validation failure
|
||||
-- Initialize with specified error message
|
||||
do
|
||||
make_regexp_validator ("^.*@.*$", e)
|
||||
end
|
||||
|
||||
@@ -29,6 +29,7 @@ feature {NONE} -- Initialization
|
||||
make_validator (e)
|
||||
regexp_string := r
|
||||
create regexp
|
||||
ensure regexp_string_set: regexp_string = r
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
@@ -39,7 +40,6 @@ feature -- Implementation
|
||||
if not regexp.is_compiled then
|
||||
regexp.compile (regexp_string)
|
||||
end
|
||||
|
||||
Result := (not input.is_empty) and regexp.matches (input)
|
||||
end
|
||||
|
||||
@@ -56,7 +56,9 @@ feature -- State
|
||||
feature -- Properties
|
||||
|
||||
regexp_string: STRING_32
|
||||
-- The regexp in string representation
|
||||
|
||||
regexp: REGULAR_EXPRESSION
|
||||
-- The regexp of this validator
|
||||
|
||||
end
|
||||
|
||||
@@ -15,6 +15,8 @@ feature {NONE} -- Initialization
|
||||
-- Initialize with specified error message to be displayed on validation failure
|
||||
do
|
||||
error := e
|
||||
ensure
|
||||
error_set: error = e
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
@@ -35,5 +37,6 @@ feature -- Access
|
||||
feature -- Properties
|
||||
|
||||
error: STRING_32
|
||||
-- The error message if validation fails
|
||||
|
||||
end
|
||||
|
||||
@@ -186,6 +186,18 @@ feature -- Change
|
||||
isolate := p
|
||||
end
|
||||
|
||||
set_control_name_prefix (p: STRING_32)
|
||||
-- Set the control name prefix
|
||||
do
|
||||
control_name_prefix := p
|
||||
end
|
||||
|
||||
set_control_id (d: INTEGER)
|
||||
-- Set the id of this control
|
||||
do
|
||||
control_id := d
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
isolate: BOOLEAN
|
||||
@@ -197,12 +209,6 @@ feature -- Properties
|
||||
control_id: INTEGER assign set_control_id
|
||||
-- The id of this control
|
||||
|
||||
set_control_id (d: INTEGER)
|
||||
-- Set the id of this control
|
||||
do
|
||||
control_id := d
|
||||
end
|
||||
|
||||
control_name: STRING_32
|
||||
-- The name of this control which is composed of the control name prefix and the id of the control
|
||||
do
|
||||
@@ -213,10 +219,4 @@ 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)
|
||||
|
||||
set_control_name_prefix (p: STRING_32)
|
||||
-- Set the control name prefix
|
||||
do
|
||||
control_name_prefix := p
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -194,8 +194,6 @@ feature
|
||||
|
||||
feature -- Properties
|
||||
|
||||
stateless: BOOLEAN
|
||||
|
||||
controls: ARRAYED_LIST [G]
|
||||
-- List of current controls in this multi control
|
||||
|
||||
|
||||
@@ -21,19 +21,10 @@ feature {NONE} -- Initialization
|
||||
do
|
||||
tag_name := a_tag_name
|
||||
create css_classes.make (0)
|
||||
ensure
|
||||
tag_name_set: tag_name = a_tag_name
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
tag_name: STRING_32
|
||||
-- The tag name
|
||||
|
||||
css_classes: ARRAYED_LIST [STRING_32]
|
||||
-- List of classes (appear in the "class" attribute)
|
||||
|
||||
attributes: detachable STRING_32
|
||||
-- Attributes string (without classes)
|
||||
|
||||
feature -- Change
|
||||
|
||||
add_class (c: STRING_32)
|
||||
@@ -121,6 +112,17 @@ feature -- Rendering
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
tag_name: STRING_32
|
||||
-- The tag name
|
||||
|
||||
css_classes: ARRAYED_LIST [STRING_32]
|
||||
-- List of classes (appear in the "class" attribute)
|
||||
|
||||
attributes: detachable STRING_32
|
||||
-- Attributes string (without classes)
|
||||
|
||||
invariant
|
||||
tag_name_not_empty: not tag_name.is_empty
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@ feature {NONE} -- Initialization
|
||||
-- Initialize
|
||||
do
|
||||
make_with_tag_name ("")
|
||||
stateless := True
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
@@ -53,17 +53,22 @@ feature {NONE} -- Initialization
|
||||
feature -- Implementation
|
||||
|
||||
value: STRING_32
|
||||
-- The current value
|
||||
do
|
||||
Result := input.value
|
||||
end
|
||||
|
||||
set_value (v: STRING_32)
|
||||
-- Set the current date (has to be in format dd-mm-yyyy)
|
||||
do
|
||||
input.set_value (v)
|
||||
ensure then
|
||||
value_set: input.value = v
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
input: WSF_INPUT_CONTROL
|
||||
-- The input control which is used to display the selected date
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user