Merge branch 'widget_slider' into widget

Conflicts:
	draft/library/wsf_js_widget/kernel/webcontrol/wsf_control.e
	examples/widgetapp/base_page.e
This commit is contained in:
severin
2013-10-29 15:39:32 +01:00
17 changed files with 161 additions and 87 deletions

View File

View File

@@ -19,13 +19,16 @@ inherit
feature {NONE} -- Initialization
make_repeater (n: STRING; a_datasource: WSF_DATASOURCE [G])
local
p: WSF_PAGINATION_CONTROL [G]
do
make_multi_control (n)
datasource := a_datasource
datasource.set_on_update_agent (agent update)
if attached {WSF_PAGABLE_DATASOURCE [G]} a_datasource as ds then
create pagination_control.make_paging (n + "_paging", ds)
add_control (pagination_control)
create p.make_paging (n + "_paging", ds)
add_control (p)
pagination_control := p
end
end
@@ -53,7 +56,6 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
Result.put (datasource.state, "datasource")
end
feature -- Rendering
render_item (item: G): STRING

View File

@@ -23,9 +23,12 @@ feature {NONE} -- Initialization
--Initialize
do
make_multi_control (n)
active_set := false
add_class ("navbar navbar-inverse navbar-fixed-top")
create nav.make_with_tag_name (control_name + "_nav", "ul")
create nav_right.make_with_tag_name (control_name + "_nav_right", "ul")
nav.add_class ("nav navbar-nav")
nav_right.add_class ("nav navbar-nav navbar-right")
end
make_navbar_with_brand (n, b: STRING)
@@ -43,16 +46,15 @@ feature -- Rendering
nav_string: STRING
do
temp := render_tag_with_tagname ("span", "", "", "icon-bar")
temp.append (render_tag_with_tagname ("span", "", "", "icon-bar"))
temp.append (render_tag_with_tagname ("span", "", "", "icon-bar"))
temp.multiply (3)
temp := render_tag_with_tagname ("button", temp, "", "navbar-toggle")
if attached brand as b then
temp.append (render_tag_with_tagname ("a", b, "href=%"#%"", "navbar-brand"))
end
temp := render_tag_with_tagname ("div", temp, "", "navbar-header")
nav_string := nav.render
if attached nav_right as n then
nav_string.append (n.render)
if nav_right.controls.count > 0 then
nav_string.append (nav_right.render)
end
temp.append (render_tag_with_tagname ("div", nav_string, "", "navbar-collapse"))
Result := render_tag_with_tagname ("div", temp, "", "container")
@@ -61,46 +63,70 @@ feature -- Rendering
feature -- Change
add_list_element_right (c: WSF_STATELESS_CONTROL)
set_active (tab: INTEGER)
-- Sets the given tab as current active tab
require
tab >= 1 and tab <= tab_count and not active_set
do
if tab <= nav.controls.count then
nav.controls.i_th (tab).add_class ("active")
else
nav_right.controls.i_th (tab - nav.controls.count).add_class ("active")
end
active_set := true
end
add_dropdown (l: WSF_STATELESS_CONTROL; d: WSF_STATELESS_CONTROL)
-- Add dropdown menu (in li tag with class dropdown) to navbar
local
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
do
create li.make_with_tag_name (control_name + "_link" + nav.controls.count.out, "li")
li.add_class ("dropdown")
li.add_control (l)
li.add_control (d)
add_element (li)
end
add_dropdown_right (l: WSF_STATELESS_CONTROL; d: WSF_STATELESS_CONTROL)
-- Add dropdown menu (in li tag with class dropdown) to right aligned part of navbar
local
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
do
create li.make_with_tag_name (control_name + "_link" + nav.controls.count.out, "li")
li.add_class ("dropdown")
li.add_control (l)
li.add_control (d)
add_element_right (li)
end
add_list_element_right (l: WSF_STATELESS_CONTROL)
-- Add element in li tag to right aligned part of navbar
local
name: STRING
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
do
name := control_name + "_rightlink";
if attached nav_right as right then
name := name + right.controls.count.out
else
name := name + "0"
end
name := name + nav_right.controls.count.out
create li.make_with_tag_name (name, "li")
li.add_control (c)
li.add_control (l)
add_element_right (li)
end
add_list_element (c: WSF_STATELESS_CONTROL)
add_list_element (l: 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 (control_name + "_link" + nav.controls.count.out, "li")
li.add_control (c)
li.add_control (l)
add_element (li)
end
add_element_right (c: WSF_STATELESS_CONTROL)
-- Add element to right aligned part of navbar
local
right: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
do
if attached nav_right as r then
right := r
else
create right.make_with_tag_name (control_name + "_rightnav", "ul")
right.add_class ("nav navbar-nav navbar-right")
nav_right := right
end
right.add_control (c)
nav_right.add_control (c)
end
add_element (c: WSF_STATELESS_CONTROL)
@@ -109,15 +135,26 @@ feature -- Change
nav.add_control (c)
end
feature -- Access
tab_count: INTEGER
-- Current sum of the number of items in left and right navbar
do
Result := nav.controls.count + nav_right.controls.count
end
feature -- Properties
active_set: BOOLEAN
-- This flag is set once a tab has been set as active tab
brand: detachable STRING
-- Optional brand of the navbar
nav: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
-- Middle nav
nav_right: detachable WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
nav_right: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
-- Right nav
end

View File

@@ -21,9 +21,9 @@ feature {NONE} -- Initialization
do
make_control (n, "div")
add_class ("carousel slide")
create list.make_with_tag_name (control_name+"_links", "ol")
create list.make_with_tag_name (control_name + "_links", "ol")
list.add_class ("carousel-indicators")
create slide_wrapper.make_multi_control (control_name+"_wrapper")
create slide_wrapper.make_multi_control (control_name + "_wrapper")
slide_wrapper.add_class ("carousel-inner")
end
@@ -53,45 +53,62 @@ feature -- Rendering
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"))
temp.append (render_tag_with_tagname ("a", "<span class=%"icon-prev%"></span>", "href=%"#" + control_name + "%" data-slide=%"prev%"", "left carousel-control"))
temp.append (render_tag_with_tagname ("a", "<span class=%"icon-next%"></span>", "href=%"#" + control_name + "%" data-slide=%"next%"", "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
add_image_with_caption (src, alt, caption: STRING)
local
item: WSF_MULTI_CONTROL[WSF_STATELESS_CONTROL]
caption_control: detachable 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)
if attached caption as c and then not c.is_empty then
caption_control := create {WSF_BASIC_CONTROL}.make_with_body ("p", "", c)
end
slide_wrapper.add_control (item)
add_image_with_caption_control (src, alt, caption_control)
end
add_image_with_caption_control (src, alt: STRING; 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)
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)
add_image_with_caption (src, alt, "")
end
add_control(c:WSF_STATELESS_CONTROL)
do
end
add_control (c: WSF_STATELESS_CONTROL; caption: detachable WSF_STATELESS_CONTROL)
-- Add a new control to the slider
local
cl: STRING
item: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
do
create item.make_multi_control (control_name + "_item" + slide_wrapper.controls.count.out)
item.add_class ("item")
item.add_control (c)
if attached caption as capt then
item.add_control (capt)
end
cl := ""
if slide_wrapper.controls.count = 0 then
cl := "active"
item.add_class (cl)
end
slide_wrapper.add_control (item)
list.add_control (create {WSF_BASIC_CONTROL}.make_with_body_class ("li", "data-target=%"#" + control_name + "%" data-slide-to=%"" + list.controls.count.out + "%"", cl, ""));
end
feature -- Properties
list: WSF_MULTI_CONTROL[WSF_STATELESS_CONTROL]
list: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
-- List of slider links
slide_wrapper: WSF_MULTI_CONTROL[WSF_STATELESS_CONTROL]
slide_wrapper: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
-- List of the single slides
end

View File

@@ -15,14 +15,14 @@ inherit
end
create
make_control, make_with_body
make_control, make_with_body, make_with_body_class
feature {NONE} -- Initialization
make_control (t: STRING)
-- Initialize
do
make_with_body (t, "", "")
make_with_body_class (t, "", "", "")
end
make_with_body (t, attr, b: STRING)
@@ -33,6 +33,15 @@ feature {NONE} -- Initialization
body := b
end
make_with_body_class (t, attr, c, b: STRING)
-- Initialize with specific attributes and body
do
make_with_body (t, attr, b)
if not c.is_empty then
css_classes.extend (c)
end
end
feature -- Rendering
render: STRING

View File

@@ -14,11 +14,6 @@ inherit
render_tag
end
feature
control_name: STRING
feature {NONE} -- Initialization
make_control (n, a_tag_name: STRING)
@@ -37,10 +32,10 @@ feature {NONE} -- Initialization
feature -- Actions
start_modal(url:STRING; title:STRING)
--Start a modal window containg an other or the same page
start_modal (url: STRING; title: STRING)
--Start a modal window containg an other or the same page
local
modal:WSF_JSON_OBJECT
modal: WSF_JSON_OBJECT
do
create modal.make
modal.put_string ("start_modal", "type")
@@ -49,10 +44,10 @@ feature -- Actions
actions.add (modal)
end
start_modal_big(url:STRING; title:STRING)
--Start a modal window containg an other or the same page
start_modal_big (url: STRING; title: STRING)
--Start a modal window containg an other or the same page
local
modal:WSF_JSON_OBJECT
modal: WSF_JSON_OBJECT
do
create modal.make
modal.put_string ("start_modal_big", "type")
@@ -61,10 +56,10 @@ feature -- Actions
actions.add (modal)
end
show_alert(mesage:STRING)
--Start a modal window containg an other or the same page
show_alert (mesage: STRING)
--Start a modal window containg an other or the same page
local
modal:WSF_JSON_OBJECT
modal: WSF_JSON_OBJECT
do
create modal.make
modal.put_string ("show_alert", "type")
@@ -72,7 +67,7 @@ feature -- Actions
actions.add (modal)
end
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
load_state (new_states: JSON_OBJECT)
-- Select state stored with `control_name` as key
@@ -102,9 +97,9 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
end
if actions.count > 0 then
if not attached states.item ("actions") then
states.put (create {JSON_ARRAY}.make_array,"actions")
states.put (create {JSON_ARRAY}.make_array, "actions")
end
if attached {JSON_ARRAY}states.item ("actions") as action_list then
if attached {JSON_ARRAY} states.item ("actions") as action_list then
across
actions.array_representation as action
loop
@@ -150,17 +145,18 @@ feature -- Rendering
Result := render_tag_with_tagname (tag_name, body, l_attributes, css_classes_string)
end
feature -- EVENT HANDLING
feature -- Event handling
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
-- Method called if any callback received. In this method you can route the callback to the event handler
deferred
end
feature -- Change
set_isolation (p: BOOLEAN)
do
isolate := true
isolate := p
end
feature -- Properties
@@ -168,4 +164,7 @@ feature -- Properties
isolate: BOOLEAN
actions: JSON_ARRAY
control_name: STRING
end

View File

@@ -120,19 +120,17 @@ feature -- Rendering
across
controls as c
loop
Result := c.item.render + Result
Result := Result + c.item.render
end
Result := render_tag (Result, "")
end
feature -- Change
add_control (c: detachable G)
add_control (c: G)
-- Add a control to this multi control
do
if attached c as d then
controls.put_front (d)
end
controls.extend (c)
end
feature -- Properties

View File

@@ -27,7 +27,7 @@ feature -- Access
-- List of classes (appear in the "class" attribute)
attributes: detachable STRING
-- Attributes string
-- Attributes string (without classes)
feature -- Change

View File

@@ -129,7 +129,7 @@ feature -- Execution
slider_demo (request: WSF_REQUEST; response: WSF_RESPONSE)
local
page: IMAGE_SLIDER_PAGE
page: SLIDER_PAGE
do
-- To send a response we need to setup, the status code and
-- the response headers.

View File

@@ -18,7 +18,6 @@ feature
initialize_controls
local
navbar: WSF_NAVBAR_CONTROL
btn: WSF_BUTTON_CONTROL
do
create control.make_multi_control ("container")
@@ -27,7 +26,8 @@ feature
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 (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/slider%"", "Slider"))
navbar.add_list_element_right (create {WSF_BASIC_CONTROL}.make_with_body ("a", "href=%"/about%"", "About"))
create btn.make_button ("scode", "Show Code")
btn.set_click_event (agent show_code)
btn.set_isolation (true)
@@ -47,4 +47,6 @@ feature
control: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
navbar: WSF_NAVBAR_CONTROL
end

View File

@@ -10,9 +10,9 @@ class
inherit
BASE_PAGE
redefine
initialize_controls
end
redefine
initialize_controls
end
create
make
@@ -22,16 +22,16 @@ feature
initialize_controls
do
Precursor
control.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)
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)
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)
control.add_control (grid)
navbar.set_active (2)
end
change_query

View File

@@ -5,7 +5,7 @@ note
revision: "$Revision$"
class
IMAGE_SLIDER_PAGE
SLIDER_PAGE
inherit
@@ -20,12 +20,20 @@ create
feature -- Implementation
initialize_controls
local
form: WSF_FORM_CONTROL
do
Precursor
create slider.make_slider ("myslider")
create form.make_form_control ("sliderform")
form.add_control (create {WSF_FORM_ELEMENT_CONTROL[STRING]}.make_form_element ("Input", create {WSF_INPUT_CONTROL}.make_input ("sliderformtext", "Test")))
slider.add_control (form, Void)
slider.add_image ("http://www.placesmustseen.com/wp-content/uploads/2013/01/paris-eiffel-tower.jpg", "Eiffel Tower")
slider.add_image ("http://24.media.tumblr.com/0fcec9a7dde5b405a46b6fcda1ffad0c/tumblr_mtagkyYVIT1st5lhmo1_1280.jpg", "car")
slider.add_image ("http://25.media.tumblr.com/d9e791508eb9a532aa7f258fa4e0fedc/tumblr_mtag5zve3g1st5lhmo1_1280.jpg", "landscape")
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", " Image Slider Demo"))
control.add_control (slider)
navbar.set_active (4)
end
process

View File

@@ -31,6 +31,7 @@ feature
control.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h2", "", "Results"))
create repeater.make_repeater ("myrepeater", datasource)
control.add_control (repeater)
navbar.set_active (3)
end
change_query

View File

@@ -85,6 +85,7 @@ feature
source.set_control (progress)
progress.set_isolation (true)
control.add_control (progress)
navbar.set_active (1)
end
handle_click

0
tools/build_archive.sh Executable file → Normal file
View File

0
tools/ise_wizard/install_ise_wizard.sh Executable file → Normal file
View File

0
tools/ise_wizard/install_ise_wizard_custom.sh Executable file → Normal file
View File