Fixed slider
This commit is contained in:
@@ -25,6 +25,7 @@ feature {NONE} -- Initialization
|
|||||||
make_multi_control (n)
|
make_multi_control (n)
|
||||||
add_class ("navbar navbar-inverse navbar-fixed-top")
|
add_class ("navbar navbar-inverse navbar-fixed-top")
|
||||||
create nav.make_with_tag_name (control_name + "_nav", "ul")
|
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.add_class ("nav navbar-nav")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -43,16 +44,15 @@ feature -- Rendering
|
|||||||
nav_string: STRING
|
nav_string: STRING
|
||||||
do
|
do
|
||||||
temp := render_tag_with_tagname ("span", "", "", "icon-bar")
|
temp := render_tag_with_tagname ("span", "", "", "icon-bar")
|
||||||
temp.append (render_tag_with_tagname ("span", "", "", "icon-bar"))
|
temp.multiply (3)
|
||||||
temp.append (render_tag_with_tagname ("span", "", "", "icon-bar"))
|
|
||||||
temp := render_tag_with_tagname ("button", temp, "", "navbar-toggle")
|
temp := render_tag_with_tagname ("button", temp, "", "navbar-toggle")
|
||||||
if attached brand as b then
|
if attached brand as b then
|
||||||
temp.append (render_tag_with_tagname ("a", b, "href=%"#%"", "navbar-brand"))
|
temp.append (render_tag_with_tagname ("a", b, "href=%"#%"", "navbar-brand"))
|
||||||
end
|
end
|
||||||
temp := render_tag_with_tagname ("div", temp, "", "navbar-header")
|
temp := render_tag_with_tagname ("div", temp, "", "navbar-header")
|
||||||
nav_string := nav.render
|
nav_string := nav.render
|
||||||
if attached nav_right as n then
|
if nav_right.controls.count > 0 then
|
||||||
nav_string.append (n.render)
|
nav_string.append (nav_right.render)
|
||||||
end
|
end
|
||||||
temp.append (render_tag_with_tagname ("div", nav_string, "", "navbar-collapse"))
|
temp.append (render_tag_with_tagname ("div", nav_string, "", "navbar-collapse"))
|
||||||
Result := render_tag_with_tagname ("div", temp, "", "container")
|
Result := render_tag_with_tagname ("div", temp, "", "container")
|
||||||
@@ -61,6 +61,17 @@ feature -- Rendering
|
|||||||
|
|
||||||
feature -- Change
|
feature -- Change
|
||||||
|
|
||||||
|
set_active (tab: INTEGER)
|
||||||
|
require
|
||||||
|
tab >= 0 and tab < nav.controls.count + nav_right.controls.count
|
||||||
|
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
|
||||||
|
end
|
||||||
|
|
||||||
add_list_element_right (c: WSF_STATELESS_CONTROL)
|
add_list_element_right (c: WSF_STATELESS_CONTROL)
|
||||||
-- Add element in li tag to right aligned part of navbar
|
-- Add element in li tag to right aligned part of navbar
|
||||||
local
|
local
|
||||||
@@ -68,11 +79,7 @@ feature -- Change
|
|||||||
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
li: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||||
do
|
do
|
||||||
name := control_name + "_rightlink";
|
name := control_name + "_rightlink";
|
||||||
if attached nav_right as right then
|
name := name + nav_right.controls.count.out
|
||||||
name := name + right.controls.count.out
|
|
||||||
else
|
|
||||||
name := name + "0"
|
|
||||||
end
|
|
||||||
create li.make_with_tag_name (name, "li")
|
create li.make_with_tag_name (name, "li")
|
||||||
li.add_control (c)
|
li.add_control (c)
|
||||||
add_element_right (li)
|
add_element_right (li)
|
||||||
@@ -117,7 +124,7 @@ feature -- Properties
|
|||||||
nav: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
nav: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||||
-- Middle nav
|
-- Middle nav
|
||||||
|
|
||||||
nav_right: detachable WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
nav_right: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||||
-- Right nav
|
-- Right nav
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ feature {NONE} -- Initialization
|
|||||||
do
|
do
|
||||||
make_control (n, "div")
|
make_control (n, "div")
|
||||||
add_class ("carousel slide")
|
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")
|
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")
|
slide_wrapper.add_class ("carousel-inner")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -53,45 +53,63 @@ feature -- Rendering
|
|||||||
do
|
do
|
||||||
temp := list.render
|
temp := list.render
|
||||||
temp.append (slide_wrapper.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-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=%"prev%"", "right 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, "")
|
Result := render_tag (temp, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Change
|
feature -- Change
|
||||||
|
|
||||||
add_image_with_caption (src, alt: STRING; caption: detachable WSF_STATELESS_CONTROL)
|
add_image_with_caption (src, alt, caption: STRING)
|
||||||
|
local
|
||||||
|
caption_control: detachable WSF_STATELESS_CONTROL
|
||||||
|
do
|
||||||
|
if attached caption as c then
|
||||||
|
caption_control := create {WSF_BASIC_CONTROL}.make_with_body ("p", "", c)
|
||||||
|
end
|
||||||
|
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
|
-- Add a new image to the slider, with specified url, alternative text and caption element
|
||||||
local
|
local
|
||||||
item: WSF_MULTI_CONTROL[WSF_STATELESS_CONTROL]
|
item: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||||
do
|
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)
|
||||||
create item.make_multi_control (control_name+"_item"+slide_wrapper.controls.count.out)
|
|
||||||
item.add_class ("item")
|
item.add_class ("item")
|
||||||
item.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("img", "src=%"" + src + "%" alt=%"" + alt + "%"", ""))
|
item.add_control (create {WSF_BASIC_CONTROL}.make_with_body_class ("img", "src=%"" + src + "%" alt=%"" + alt + "%"", "", ""))
|
||||||
if attached caption as c then
|
if attached caption as c then
|
||||||
item.add_control (c)
|
item.add_control (c)
|
||||||
end
|
end
|
||||||
slide_wrapper.add_control (item)
|
add_control (item)
|
||||||
end
|
end
|
||||||
|
|
||||||
add_image (src, alt: STRING)
|
add_image (src, alt: STRING)
|
||||||
-- Add a new image to the slider, with specified url and alternative text
|
-- Add a new image to the slider, with specified url and alternative text
|
||||||
do
|
do
|
||||||
add_image_with_caption (src, alt, Void)
|
add_image_with_caption (src, alt, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
add_control(c:WSF_STATELESS_CONTROL)
|
add_control (c: WSF_STATELESS_CONTROL)
|
||||||
|
-- Add a new control to the slider
|
||||||
|
local
|
||||||
|
cl: STRING
|
||||||
do
|
do
|
||||||
|
cl := ""
|
||||||
|
if slide_wrapper.controls.count = 0 then
|
||||||
|
cl := "active"
|
||||||
|
c.add_class (cl)
|
||||||
|
end
|
||||||
|
slide_wrapper.add_control (c)
|
||||||
|
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
|
end
|
||||||
|
|
||||||
feature -- Properties
|
feature -- Properties
|
||||||
|
|
||||||
list: WSF_MULTI_CONTROL[WSF_STATELESS_CONTROL]
|
list: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||||
-- List of slider links
|
-- 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
|
-- List of the single slides
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ inherit
|
|||||||
end
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
make_control, make_with_body
|
make_control, make_with_body, make_with_body_class
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_control (t: STRING)
|
make_control (t: STRING)
|
||||||
-- Initialize
|
-- Initialize
|
||||||
do
|
do
|
||||||
make_with_body (t, "", "")
|
make_with_body_class (t, "", "", "")
|
||||||
end
|
end
|
||||||
|
|
||||||
make_with_body (t, attr, b: STRING)
|
make_with_body (t, attr, b: STRING)
|
||||||
@@ -33,6 +33,15 @@ feature {NONE} -- Initialization
|
|||||||
body := b
|
body := b
|
||||||
end
|
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
|
feature -- Rendering
|
||||||
|
|
||||||
render: STRING
|
render: STRING
|
||||||
|
|||||||
@@ -14,11 +14,6 @@ inherit
|
|||||||
render_tag
|
render_tag
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
feature
|
|
||||||
|
|
||||||
control_name: STRING
|
|
||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make_control (n, a_tag_name: STRING)
|
make_control (n, a_tag_name: STRING)
|
||||||
@@ -37,30 +32,30 @@ feature {NONE} -- Initialization
|
|||||||
|
|
||||||
feature -- Actions
|
feature -- Actions
|
||||||
|
|
||||||
start_modal(url:STRING; title:STRING)
|
start_modal (url: STRING; title: STRING)
|
||||||
--Start a modal window containg an other or the same page
|
--Start a modal window containg an other or the same page
|
||||||
local
|
local
|
||||||
modal:JSON_OBJECT
|
modal: JSON_OBJECT
|
||||||
do
|
do
|
||||||
create modal.make
|
create modal.make
|
||||||
modal.put (create {JSON_STRING}.make_json("start_modal"), "type")
|
modal.put (create {JSON_STRING}.make_json ("start_modal"), "type")
|
||||||
modal.put (create {JSON_STRING}.make_json(url), "url")
|
modal.put (create {JSON_STRING}.make_json (url), "url")
|
||||||
modal.put (create {JSON_STRING}.make_json(title), "title")
|
modal.put (create {JSON_STRING}.make_json (title), "title")
|
||||||
actions.add (modal)
|
actions.add (modal)
|
||||||
end
|
end
|
||||||
|
|
||||||
show_alert(mesage:STRING)
|
show_alert (mesage: STRING)
|
||||||
--Start a modal window containg an other or the same page
|
--Start a modal window containg an other or the same page
|
||||||
local
|
local
|
||||||
modal:JSON_OBJECT
|
modal: JSON_OBJECT
|
||||||
do
|
do
|
||||||
create modal.make
|
create modal.make
|
||||||
modal.put (create {JSON_STRING}.make_json("show_alert"), "type")
|
modal.put (create {JSON_STRING}.make_json ("show_alert"), "type")
|
||||||
modal.put (create {JSON_STRING}.make_json(mesage), "message")
|
modal.put (create {JSON_STRING}.make_json (mesage), "message")
|
||||||
actions.add (modal)
|
actions.add (modal)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||||
|
|
||||||
load_state (new_states: JSON_OBJECT)
|
load_state (new_states: JSON_OBJECT)
|
||||||
-- Select state stored with `control_name` as key
|
-- Select state stored with `control_name` as key
|
||||||
@@ -90,9 +85,9 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
|||||||
end
|
end
|
||||||
if actions.count > 0 then
|
if actions.count > 0 then
|
||||||
if not attached states.item ("actions") 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
|
end
|
||||||
if attached {JSON_ARRAY}states.item ("actions") as action_list then
|
if attached {JSON_ARRAY} states.item ("actions") as action_list then
|
||||||
across
|
across
|
||||||
actions.array_representation as action
|
actions.array_representation as action
|
||||||
loop
|
loop
|
||||||
@@ -138,17 +133,18 @@ feature -- Rendering
|
|||||||
Result := render_tag_with_tagname (tag_name, body, l_attributes, css_classes_string)
|
Result := render_tag_with_tagname (tag_name, body, l_attributes, css_classes_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- EVENT HANDLING
|
feature -- Event handling
|
||||||
|
|
||||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
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
|
-- Method called if any callback received. In this method you can route the callback to the event handler
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Change
|
feature -- Change
|
||||||
|
|
||||||
set_isolation (p: BOOLEAN)
|
set_isolation (p: BOOLEAN)
|
||||||
do
|
do
|
||||||
isolate := true
|
isolate := p
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Properties
|
feature -- Properties
|
||||||
@@ -156,4 +152,7 @@ feature -- Properties
|
|||||||
isolate: BOOLEAN
|
isolate: BOOLEAN
|
||||||
|
|
||||||
actions: JSON_ARRAY
|
actions: JSON_ARRAY
|
||||||
|
|
||||||
|
control_name: STRING
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ feature -- Access
|
|||||||
-- List of classes (appear in the "class" attribute)
|
-- List of classes (appear in the "class" attribute)
|
||||||
|
|
||||||
attributes: detachable STRING
|
attributes: detachable STRING
|
||||||
-- Attributes string
|
-- Attributes string (without classes)
|
||||||
|
|
||||||
feature -- Change
|
feature -- Change
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ inherit
|
|||||||
feature
|
feature
|
||||||
|
|
||||||
initialize_controls
|
initialize_controls
|
||||||
local
|
|
||||||
navbar: WSF_NAVBAR_CONTROL
|
|
||||||
do
|
do
|
||||||
create control.make_multi_control ("container")
|
create control.make_multi_control ("container")
|
||||||
control.add_class ("container")
|
control.add_class ("container")
|
||||||
@@ -37,4 +35,6 @@ feature
|
|||||||
|
|
||||||
control: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
control: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||||
|
|
||||||
|
navbar: WSF_NAVBAR_CONTROL
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ feature -- Implementation
|
|||||||
Precursor
|
Precursor
|
||||||
create slider.make_slider ("myslider")
|
create slider.make_slider ("myslider")
|
||||||
slider.add_image ("http://www.placesmustseen.com/wp-content/uploads/2013/01/paris-eiffel-tower.jpg", "Eiffel Tower")
|
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 (create {WSF_BASIC_CONTROL}.make_with_body ("h1", "", " Image Slider Demo"))
|
||||||
control.add_control (slider)
|
control.add_control (slider)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ feature
|
|||||||
source.set_control (progress)
|
source.set_control (progress)
|
||||||
progress.set_isolation (true)
|
progress.set_isolation (true)
|
||||||
control.add_control (progress)
|
control.add_control (progress)
|
||||||
|
navbar.set_active (1)
|
||||||
end
|
end
|
||||||
|
|
||||||
handle_click2
|
handle_click2
|
||||||
|
|||||||
Reference in New Issue
Block a user