K&L Slide Show Script Web Developer's Manual.

K&L Slide Show is a client side script which provides the highly configurable slide show presentation without affecting the accessibility of content in legacy browsers and those without required javascript functionality.

The script imposes no restrictions on content of slides nor it's presentation within a slide.

Creation of Slide Show Content

K&L Slide Show script .

Following is the basic template for the slide show content. It consists of a block element representing the slide show and any number of child block elements representing individual slides.

<div klslideshow="Slide show options">
    <div klslide="Slide options">
         Slide content
    </div>
    <div klslide="Slide options">
        Slide content
    </div>
    <div klslide="Slide options">
        Slide content
    </div>
</div>
The content of slides can be comprized of any HTML elements valid within a block element. K&L Slide Show script does not impose any restrictions on styling of individual slides and slide show container.

It should be noted that any child of slide show container that does not have the klslide attribute is deleted during slide show initialization

Slide Show controls

K&L Slide Show script provides two ways for controling the slide show flow. First way, sufficient for most applications, is to include control elements within the web page and allow the script to automaticaly handle the flow of events.

K&L Slide Show script supports the following conrol elements:

Start Auto Play Button
Starts automatic advancement of slides. The slides are advanced using the delay specified for either entire slide show or individual slides. When the button is pressed the slide show automatically advances to the next slide.
Stop Auto Play Button
Stops automatic advancement of slides.
Next Slide Button
Advances slide show to the next slide.
Previous Slide Button
Moves slide show back one slide.
Last Slide Button
Moves slide show to the last slide
First Slide Button
Moves to the first slide of the slide show
Slide Number Indicator
This control has no action. It used to display the current slide number and overall number of slides. This control can be represented by a text element such as paragraph, span or div. As the user advances through the slide show, the K&L Slide Show script automatically updates the current slide number shown in the slide counter control
Go To Slide Selector
This control should be represented by a select element in either the drop-down or list forms. During script initialization it is automatically populated with the slide titles. The script can be set up to use header elements for slide titles, or text provided as part of the slide options string. During the slide show presentation, the slide selector is updated to show the currently displayed slide title. It can also be used to jump to any slide within the slide show.

Each control element must have a unique ID which is passed to the script using slide show options string.

Slide Show Options

K&L Slide Show script is configured using an options string that is used as a value of the klslideshow attribute. The options string uses CSS-like format of semi-colon separated property=value pairs. Following is the list of the slide show options:

class-name
Class name applied to the slide show container element. Normally, the size of this element would be limited to that of the slide and its position would be set to relative so that slides can be absolutely positioned within the container.
slide-titles
Header element used to generate the slide show table of content (TOC). For exapmle if set to h3, the slides will be searched for the first <h3> element and its content will be used as the slide title in the "Go To Slide" Selector control.
control-start
Id of the control element that is used to start slide show (Start Button)
control-stop
Id of the control element that is user to stop slide show (Stop Button)
control-toc
Id of the select element that is populated with slide show TOC ("Go To Slide" Selector)
control-counter
Id of the control element that is used to display current slide number and total number of slides (Slide Number Indicator)
control-next
Id of the control element that is used to advance to the next slide (Next Slide Button)
control-previous
Id of the control element that is used to go back to the previous slide (Previous Slide Button)
control-home
Id of the control element that is used to go to the first slide (First Slide Button)
control-end
Id of the control element that is used to go to the last slide (Last Slide Button)
start
Slide show start mode. When set to "manual", the slide show awaits for input to advance; when set to "auto" the slides are automatically advanced using slide delays
delay
Default slide delay in auto mode in the following format [Integer Number]s|ms. For example delay:5s will set the default delay between slides to five seconds; delay:500ms will set the default delay to half a second.
loop
Slide show looping mode - either "true" or "false". When the looping mode is set to true, the slide show loops in the "auto" mode and allows to jump to the first slide from the last by clicking "Next Slide" button and to last slide from first by clicking "Previous Slide" button, when in "manual" mode

Following is an example of an option string for a slide show that has no input controls and is used to continiously loop a set of images:

<div id="SimpleSS" klslideshow="class-name:simpless;start:auto;loop:true;delay:3s">
 <!-- Slide Show content -->
 </div>
 

In the following example the options string defines a slide show with complete set of input controls. The HTML code for the controls is also provided.

<div id="CompleteSS" klslideshow="class-name:completess;
                                  slide-titles:h3; 
                                  control-start:ssStart; 
                                  control-stop:ssStop; 
                                  start:manual; 
                                  loop:false; 
                                  control-next:ssNext; 
                                  control-previous: ssPrev; 
                                  control-home: ssFirst; 
                                  control-end: ssLast; 
                                  control-toc:ssTOC; 
                                  control-counter: ssCounter; 
                                  delay: 10s">
<!-- Slide Show content -->
</div>
<div id="ssctrls">
    <button id="ssFirst">Start</button>
    <button id="ssPrev">Previous</button>
    <button id="ssStart">Go</button>
    <button id="ssStop">Stop</button>
    <button id="ssNext">Next</button>
    <button id="ssLast">End</button>
    <br />Slide: <span id="ssCounter">Counter</span><br />
    Go To Slide: <select id="ssTOC"><option>Slide Show TOC</option></select>
</div>

Slide Options

Besides the slide show options, the K&L Slide Show script provides individual slide options that allow to further customize individual slides and their behaviour. The slide options are specified as a value of klslide attribute of a slide element. The following are the slide options:

class-name
Class name applied to slide element. Normally the slide position would be set to absolute and its size would be restricted.
title
Slide title. This value overrides the slide-titles setting of the klslideshow.
delay
Slide delay in auto mode. This value has the same format as the slide show delay and overides the delay setting of the klslideshow.

Following is an example of slide options:

<div klslide="class-name: slide; title: Slide 5; delay: 12s">
<!-- Slide Content -->
</div>

Slide Show Initialization

The file containing the K&L Slide Show script is added to the web page using script element:

<script type="text/javascript" src="scriptsFolder/klslideshow.js" ></script>

The slide show initialization is done by calling klSlideShow.init() function from the body onload event handler:

<body onload="klSlideShow.init();">

Programming Interface

K&L Slide Show programming interface allows to control the slide show advancement via javascript. It allows to utilize the script for applications where additional processing is required between slide advances and/or such advancement is conditional.

The slide show object is accessed through the slide show container element. The script adds the klss property to it during slide show initialization:

<div id="slideShow" klslideshow="class-name:klss;start:manual;loop:false">
 <!-- Slide Show content -->
 </div>
 <script type="text/javascript">
 klSlideShowObject = document.getElementById('slideShow').klss
 </script>
 

In order to navigate through the slide show, scripts can use the currentSlide property that stores the index of currently displayed slide and goToSlide function, that takes the destination slide index as an argument.

//Go to the next slide
klSlideShowObject.goToSlide(klSlideShowObject.currentSlide+1);
//Go to the previous slide
klSlideShowObject.goToSlide(klSlideShowObject.currentSlide-1);
//Go to the first slide
klSlideShowObject.goToSlide(0);
//Go to the last slide
klSlideShowObject.goToSlide(klSlideShowObject.slides.length-1);