From a5fa428e98d6097be75ea83b17a410933031bfca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Severin=20M=C3=BCnger?= Date: Tue, 24 Sep 2013 01:27:25 +0200 Subject: [PATCH] Added simple image slider widget --- .../image_slider/wsf_image_slider_control.e | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 library/server/wsf_js_widget/image_slider/wsf_image_slider_control.e diff --git a/library/server/wsf_js_widget/image_slider/wsf_image_slider_control.e b/library/server/wsf_js_widget/image_slider/wsf_image_slider_control.e new file mode 100644 index 00000000..f200e258 --- /dev/null +++ b/library/server/wsf_js_widget/image_slider/wsf_image_slider_control.e @@ -0,0 +1,93 @@ +note + description: "Summary description for {WSF_IMAGE_SLIDER_CONTROL}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_IMAGE_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 ("ol") + list.add_class ("carousel-indicators") + create slide_wrapper.make_multi_control + 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", "", "href=%"#" + control_name + "%" data-slide=%"next%"", "left carousel-control")) + temp.append (render_tag_with_tagname ("a", "", "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 + 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 + 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 + end + + add_image (src, alt: STRING) + -- Add a new image to the slider, with specified url and alternative text + local + item: WSF_MULTI_CONTROL[WSF_STATELESS_CONTROL] + do + add_image_with_caption (src, alt, Void) + 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 image slides + +end