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

This commit is contained in:
YNH Webdev
2013-09-24 15:20:43 +02:00
48 changed files with 204 additions and 123 deletions

View File

@@ -9,30 +9,29 @@ class
inherit
WSF_STATELESS_MULTI_CONTROL
WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
redefine
render
end
create
make_navbar,
make_navbar_with_brand
make_navbar, make_navbar_with_brand
feature {NONE} -- Initialization
make_navbar
make_navbar (n: STRING)
--Initialize
do
make_multi_control
make_multi_control (n)
add_class ("navbar navbar-inverse navbar-fixed-top")
create nav.make_with_tag_name ("ul")
create nav.make_with_tag_name (control_name + "_nav", "ul")
nav.add_class ("nav navbar-nav")
end
make_navbar_with_brand (b: STRING)
make_navbar_with_brand (n, b: STRING)
-- Initialize with specified brand string
do
make_navbar
make_navbar (n)
brand := b
end
@@ -65,10 +64,16 @@ feature -- Change
add_list_element_right (c: WSF_STATELESS_CONTROL)
-- Add element in li tag to right aligned part of navbar
local
right: WSF_STATELESS_MULTI_CONTROL
li: WSF_STATELESS_MULTI_CONTROL
name: STRING
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
do
create li.make_with_tag_name ("li")
name := control_name + "_rightlink";
if attached nav_right as right then
name := name + right.controls.count.out
else
name := name + "0"
end
create li.make_with_tag_name (name, "li")
li.add_control (c)
add_element_right (li)
end
@@ -76,9 +81,9 @@ feature -- Change
add_list_element (c: WSF_STATELESS_CONTROL)
-- Add element in li tag to main nav
local
li: WSF_STATELESS_MULTI_CONTROL
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
do
create li.make_with_tag_name ("li")
create li.make_with_tag_name (control_name + "_link" + nav.controls.count.out, "li")
li.add_control (c)
add_element (li)
end
@@ -86,12 +91,12 @@ feature -- Change
add_element_right (c: WSF_STATELESS_CONTROL)
-- Add element to right aligned part of navbar
local
right: WSF_STATELESS_MULTI_CONTROL
right: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
do
if attached nav_right as r then
right := r
else
create right.make_with_tag_name ("ul")
create right.make_with_tag_name (control_name + "_rightnav", "ul")
right.add_class ("nav navbar-nav navbar-right")
nav_right := right
end
@@ -109,10 +114,10 @@ feature -- Properties
brand: detachable STRING
-- Optional brand of the navbar
nav: WSF_STATELESS_MULTI_CONTROL
nav: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
-- Middle nav
nav_right: detachable WSF_STATELESS_MULTI_CONTROL
nav_right: detachable WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
-- Right nav
end

View File

@@ -0,0 +1,97 @@
note
description: "Summary description for {WSF_IMAGE_SLIDER_CONTROL}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_SLIDER_CONTROL
inherit
WSF_CONTROL
create
make_slider
feature {NONE} -- Initialization
make_slider (n: STRING)
-- Initialize with specified name
do
make_control (n, "div")
add_class ("carousel slide")
create list.make_with_tag_name (control_name+"_links", "ol")
list.add_class ("carousel-indicators")
create slide_wrapper.make_multi_control (control_name+"_wrapper")
slide_wrapper.add_class ("carousel-inner")
end
feature -- State handling
set_state (new_state: JSON_OBJECT)
do
end
state: JSON_OBJECT
do
create Result.make
end
feature -- Callback
handle_callback (cname, event: STRING; event_parameter: detachable STRING)
do
-- Do nothing here
end
feature -- Rendering
render: STRING
local
temp: STRING
do
temp := list.render
temp.append (slide_wrapper.render)
temp.append (render_tag_with_tagname ("a", "<span class=%"icon-prev%"></span>", "href=%"#" + control_name + "%" data-slide=%"next%"", "left carousel-control"))
temp.append (render_tag_with_tagname ("a", "<span class=%"icon-next%"></span>", "href=%"#" + control_name + "%" data-slide=%"prev%"", "right carousel-control"))
Result := render_tag (temp, "")
end
feature -- Change
add_image_with_caption (src, alt: STRING; caption: detachable WSF_STATELESS_CONTROL)
-- Add a new image to the slider, with specified url, alternative text and caption element
local
item: WSF_MULTI_CONTROL[WSF_STATELESS_CONTROL]
do
list.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("li", "data-target=%"#" + control_name + "%" data-slide-to=%"" + list.controls.count.out + "%"", ""));
create item.make_multi_control (control_name+"_item"+slide_wrapper.controls.count.out)
item.add_class ("item")
item.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("img", "src=%"" + src + "%" alt=%"" + alt + "%"", ""))
if attached caption as c then
item.add_control (c)
end
slide_wrapper.add_control (item)
end
add_image (src, alt: STRING)
-- Add a new image to the slider, with specified url and alternative text
do
add_image_with_caption (src, alt, Void)
end
add_control(c:WSF_STATELESS_CONTROL)
do
end
feature -- Properties
list: WSF_MULTI_CONTROL[WSF_STATELESS_CONTROL]
-- List of slider links
slide_wrapper: WSF_MULTI_CONTROL[WSF_STATELESS_CONTROL]
-- List of the single slides
end

View File

@@ -145,7 +145,7 @@ feature -- Implementation
end
end
feature -- EVENT HANDLING
feature -- Event handling
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
-- Forward callback to control
@@ -153,7 +153,7 @@ feature -- EVENT HANDLING
control.handle_callback (cname, event, event_parameter)
end
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
state: JSON_OBJECT
do

View File

@@ -10,18 +10,12 @@
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="standard">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="encoder" location="..\..\text\encoder\encoder-safe.ecf"/>
<library name="http" location="..\..\network\protocol\http\http-safe.ecf"/>
<library name="encoder" location="..\..\..\library\text\encoder\encoder-safe.ecf"/>
<library name="http" location="..\..\..\library\network\protocol\http\http-safe.ecf"/>
<library name="json" location="..\..\..\contrib\library\text\parser\json\library\json-safe.ecf"/>
<library name="pcre" location="$ISE_EIFFEL\unstable\library\text\regexp\pcre\pcre-safe.ecf"/>
<library name="uri_template" location="..\..\text\parser\uri_template\uri_template-safe.ecf"/>
<library name="wsf" location="..\wsf\wsf-safe.ecf"/>
<cluster name="webcontrol" location=".\webcontrol\"/>
<cluster name="validator" location=".\validator\"/>
<cluster name="input" location=".\input\"/>
<cluster name="grid" location=".\grid\"/>
<cluster name="autocompletion" location=".\autocompletion\"/>
<cluster name="navbar" location=".\navbar\"/>
<cluster name="progressbar" location=".\progressbar\"/>
<library name="uri_template" location="..\..\..\library\text\parser\uri_template\uri_template-safe.ecf"/>
<library name="wsf" location="..\..\..\library\server\wsf\wsf-safe.ecf"/>
<cluster name="kernel" location=".\kernel\" recursive="true"/>
</target>
</system>

View File

@@ -10,18 +10,12 @@
<option warning="true" full_class_checking="true" void_safety="none" syntax="standard">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="encoder" location="..\..\text\encoder\encoder.ecf"/>
<library name="http" location="..\..\network\protocol\http\http-safe.ecf"/>
<library name="encoder" location="..\..\..\library\text\encoder\encoder.ecf"/>
<library name="http" location="..\..\..\library\network\protocol\http\http.ecf"/>
<library name="json" location="..\..\..\contrib\library\text\parser\json\library\json.ecf"/>
<library name="pcre" location="$ISE_EIFFEL\unstable\library\text\regexp\pcre\pcre.ecf"/>
<library name="uri_template" location="..\..\text\parser\uri_template\uri_template.ecf"/>
<library name="wsf" location="..\wsf\wsf.ecf"/>
<cluster name="webcontrol" location=".\webcontrol\"/>
<cluster name="validator" location=".\validator\"/>
<cluster name="input" location=".\input\"/>
<cluster name="grid" location=".\grid\"/>
<cluster name="autocompletion" location=".\autocompletion\"/>
<cluster name="navbar" location=".\navbar\"/>
<cluster name="progressbar" location=".\progressbar\"/>
<library name="uri_template" location="..\..\..\library\text\parser\uri_template\uri_template.ecf"/>
<library name="wsf" location="..\..\..\library\server\wsf\wsf.ecf"/>
<cluster name="kernel" location=".\kernel\" recursive="true"/>
</target>
</system>

View File

@@ -57,7 +57,6 @@ feature -- Router and Filter
create {WSF_LOGGING_FILTER} f
f.set_next (l_filter)
l_filter := f
filter := l_filter
end
@@ -78,10 +77,10 @@ feature -- Router and Filter
setup_router
do
-- router.map (create {WSF_URI_MAPPING}.make ("/hello", create {WSF_AGENT_URI_HANDLER}.make (agent execute_hello)))
map_agent_uri ("/", agent execute_hello, Void)
map_agent_uri ("/grid", agent grid_demo, Void)
map_agent_uri ("/repeater", agent repeater_demo, Void)
map_agent_uri ("/slider", agent slider_demo, Void)
-- NOTE: you could put all those files in a specific folder, and use WSF_FILE_SYSTEM_HANDLER with "/"
-- this way, it handles the caching and so on
@@ -102,7 +101,7 @@ feature -- Helper: mapping
feature -- Execution
execute_hello (request: WSF_REQUEST; response: WSF_RESPONSE)
execute_hello (request: WSF_REQUEST; response: WSF_RESPONSE)
local
page: SAMPLE_PAGE
do
@@ -132,6 +131,16 @@ feature -- Execution
page.execute
end
slider_demo (request: WSF_REQUEST; response: WSF_RESPONSE)
local
page: IMAGE_SLIDER_PAGE
do
-- To send a response we need to setup, the status code and
-- the response headers.
create page.make (request, response)
page.execute
end
load_file (name: STRING; request: WSF_REQUEST; response: WSF_RESPONSE)
local
f: WSF_FILE_RESPONSE

View File

@@ -10,6 +10,9 @@ deferred class
inherit
WSF_PAGE_CONTROL
redefine
control
end
feature
@@ -17,21 +20,21 @@ feature
local
navbar: WSF_NAVBAR_CONTROL
do
create container.make_multi_control ("container")
container.add_class ("container")
create navbar.make_navbar_with_brand ("Example")
create control.make_multi_control ("container")
control.add_class ("container")
create navbar.make_navbar_with_brand ("navbar1", "Example")
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/%"", "Home"))
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/grid%"", "Grid"))
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/repeater%"", "Repeater"))
navbar.add_list_element (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/slider%"", "Image Slider"))
navbar.add_list_element_right (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"#%"", "About"))
if not attached get_parameter ("ajax") then
container.add_control (navbar)
control.add_control (navbar)
end
control := container
end
feature
container: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
control: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
end

View File

@@ -22,17 +22,16 @@ feature
initialize_controls
do
Precursor
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h1","","Grid Demo"))
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h1","","Grid Demo"))
create datasource.make_news
create search_query.make_autocomplete ("query", create {GOOGLE_AUTOCOMPLETION}.make)
search_query.add_class ("form-control")
search_query.set_change_event (agent change_query)
container.add_control (search_query)
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h2","","Results"))
control.add_control (search_query)
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h2","","Results"))
create grid.make_grid ("mygrid", <<create {WSF_GRID_COLUMN}.make ("Title", "title"),
create {WSF_GRID_COLUMN}.make ("Content", "content")>>, datasource)
container.add_control (grid)
control := container
control.add_control (grid)
end
change_query

View File

@@ -0,0 +1,39 @@
note
description: "Summary description for {IMAGE_SLIDER_PAGE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
IMAGE_SLIDER_PAGE
inherit
BASE_PAGE
redefine
initialize_controls
end
create
make
feature -- Implementation
initialize_controls
do
Precursor
create slider.make_slider ("myslider")
slider.add_image ("http://www.placesmustseen.com/wp-content/uploads/2013/01/paris-eiffel-tower.jpg", "Eiffel Tower")
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", " Image Slider Demo"))
control.add_control (slider)
end
process
do
end
feature -- Properties
slider: WSF_SLIDER_CONTROL
end

View File

@@ -8,6 +8,7 @@ class
REPEATER_PAGE
inherit
BASE_PAGE
redefine
initialize_controls
@@ -21,15 +22,15 @@ feature
initialize_controls
do
Precursor
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", ""," Repeater Demo"))
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", " Repeater Demo"))
create datasource.make_news
create search_query.make_autocomplete ("query", create {GOOGLE_AUTOCOMPLETION}.make)
search_query.add_class ("form-control")
search_query.set_change_event (agent change_query)
container.add_control (search_query)
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h2", "", "Results"))
control.add_control (search_query)
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h2", "", "Results"))
create repeater.make_repeater ("myrepeater", datasource)
container.add_control (repeater)
control.add_control (repeater)
end
change_query
@@ -50,4 +51,3 @@ feature
datasource: GOOGLE_NEWS_DATASOURCE
end

View File

@@ -77,15 +77,15 @@ feature
--Result
create result_html.make_html ("txtBox3", "p", "")
form.add_control (create {WSF_FORM_ELEMENT_CONTROL [STRING]}.make_form_element ("Result", result_html))
container.add_control (form)
control.add_control (form)
--Progress bar
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h4", "", "Autoincrementing progressbar"))
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h4", "", "Autoincrementing progressbar"))
create source.make
create progress.make_progress_with_source ("progress1", source)
source.set_control (progress)
progress.set_isolation (true)
container.add_control (progress)
control.add_control (progress)
end
handle_click2

View File

@@ -13,7 +13,7 @@
<library name="http" location="..\..\library\network\protocol\http\http-safe.ecf"/>
<library name="http_client" location="$ISE_LIBRARY\contrib\library\network\http_client\http_client-safe.ecf"/>
<library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf"/>
<library name="wsf_js_widget" location="..\..\library\server\wsf_js_widget\wsf_js_widget-safe.ecf" readonly="false"/>
<library name="wsf_js_widget" location="..\..\draft\library\wsf_js_widget\wsf_js_widget-safe.ecf" readonly="false"/>
</target>
<target name="widgetapp_nino" extends="common">
<root class="APPLICATION" feature="make_and_launch"/>

View File

@@ -1,59 +0,0 @@
note
description: "Summary description for {WSF_STATELESS_MULTI_CONTROL}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_STATELESS_MULTI_CONTROL
inherit
WSF_STATELESS_CONTROL
create
make_multi_control, make_with_tag_name
feature {NONE} -- Initialization
make_multi_control
-- Initialize with default tag "div"
do
make_with_tag_name ("div")
end
make_with_tag_name (t: STRING)
-- Initialize with specified tag
do
make (t)
controls := create {ARRAYED_LIST [WSF_STATELESS_CONTROL]}.make (5);
end
feature -- Rendering
render: STRING
-- HTML representation of this stateless multi control
do
Result := ""
across
controls as c
loop
Result := c.item.render + Result
end
Result := render_tag (Result, "")
end
feature -- Change
add_control (c: WSF_STATELESS_CONTROL)
-- Add control to this stateless multi control
do
controls.put_front (c)
end
feature -- Properties
controls: ARRAYED_LIST [WSF_STATELESS_CONTROL]
-- List of controls
end