Fixed slider

This commit is contained in:
Severin Münger
2013-09-27 18:13:55 +02:00
parent 113df6efe1
commit c6d59d3366
8 changed files with 91 additions and 55 deletions

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,63 @@ 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_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
local
item: WSF_MULTI_CONTROL[WSF_STATELESS_CONTROL]
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)
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 + "%"", ""))
item.add_control (create {WSF_BASIC_CONTROL}.make_with_body_class ("img", "src=%"" + src + "%" alt=%"" + alt + "%"", "", ""))
if attached caption as c then
item.add_control (c)
end
slide_wrapper.add_control (item)
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)
add_image_with_caption (src, alt, "")
end
add_control(c:WSF_STATELESS_CONTROL)
do
end
add_control (c: WSF_STATELESS_CONTROL)
-- Add a new control to the slider
local
cl: STRING
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
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