The KIDS Carousel is a simple, lightweight feature rotator plugin for jQuery.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis lacus sed enim rutrum fringilla. Maecenas euismod purus arcu, aliquam ultricies mauris. Phasellus scelerisque, urna sit amet tincidunt ornare, sem elit aliquam nibh, ut malesuada tellus sapien at lectus. Cras rhoncus porta urna, et malesuada neque vestibulum a. Nunc at orci eros. Mauris molestie, nisl ut elementum cursus, lorem enim scelerisque ligula, non rhoncus augue arcu id massa. Aliquam imperdiet odio sit amet metus condimentum ut aliquet lacus mattis. Donec nec facilisis nunc.
Phasellus dictum tempus purus non vulputate. Maecenas commodo luctus nulla, bibendum faucibus magna tristique nec. Curabitur metus quam, eleifend ut molestie id, pulvinar id erat. Mauris aliquet vestibulum rutrum. Maecenas ultricies, sapien ac porta congue, augue lorem imperdiet elit, ut sollicitudin est quam ut felis. Vivamus interdum urna eu turpis facilisis ultrices interdum mauris interdum. Vestibulum sed leo sed nisl vestibulum commodo ut a libero.
Integer leo augue, malesuada eget tincidunt at, cursus sit amet lacus. Phasellus ultrices ligula eu est convallis in condimentum tortor dictum. Nulla fermentum ipsum nec mi lobortis aliquam.
Phasellus id ante faucibus risus aliquam ornare ac in est. Integer et libero neque. Nunc dignissim ultricies quam, eget sodales nisi accumsan in. Aenean volutpat, nibh non egestas suscipit, dolor nisi lobortis enim, sit amet congue dolor nisi eget eros. Vestibulum imperdiet convallis molestie. Cras eu turpis sit amet metus fermentum mollis at ac libero. Nulla facilisi. Nulla facilisi.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis lacus sed enim rutrum fringilla. Maecenas euismod purus arcu, aliquam ultricies mauris. Phasellus scelerisque, urna sit amet tincidunt ornare, sem elit aliquam nibh, ut malesuada tellus sapien at lectus. Cras rhoncus porta urna, et malesuada neque vestibulum a. Nunc at orci eros. Mauris molestie, nisl ut elementum cursus, lorem enim scelerisque ligula, non rhoncus augue arcu id massa. Aliquam imperdiet odio sit amet metus condimentum ut aliquet lacus mattis. Donec nec facilisis nunc.
Phasellus dictum tempus purus non vulputate. Maecenas commodo luctus nulla, bibendum faucibus magna tristique nec. Curabitur metus quam, eleifend ut molestie id, pulvinar id erat. Mauris aliquet vestibulum rutrum. Maecenas ultricies, sapien ac porta congue, augue lorem imperdiet elit, ut sollicitudin est quam ut felis. Vivamus interdum urna eu turpis facilisis ultrices interdum mauris interdum. Vestibulum sed leo sed nisl vestibulum commodo ut a libero.
Integer leo augue, malesuada eget tincidunt at, cursus sit amet lacus. Phasellus ultrices ligula eu est convallis in condimentum tortor dictum. Nulla fermentum ipsum nec mi lobortis aliquam.
Phasellus id ante faucibus risus aliquam ornare ac in est. Integer et libero neque. Nunc dignissim ultricies quam, eget sodales nisi accumsan in. Aenean volutpat, nibh non egestas suscipit, dolor nisi lobortis enim, sit amet congue dolor nisi eget eros. Vestibulum imperdiet convallis molestie. Cras eu turpis sit amet metus fermentum mollis at ac libero. Nulla facilisi. Nulla facilisi.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam quis lacus sed enim rutrum fringilla. Maecenas euismod purus arcu, aliquam ultricies mauris. Phasellus scelerisque, urna sit amet tincidunt ornare, sem elit aliquam nibh, ut malesuada tellus sapien at lectus. Cras rhoncus porta urna, et malesuada neque vestibulum a. Nunc at orci eros. Mauris molestie, nisl ut elementum cursus, lorem enim scelerisque ligula, non rhoncus augue arcu id massa. Aliquam imperdiet odio sit amet metus condimentum ut aliquet lacus mattis. Donec nec facilisis nunc.
Phasellus dictum tempus purus non vulputate. Maecenas commodo luctus nulla, bibendum faucibus magna tristique nec. Curabitur metus quam, eleifend ut molestie id, pulvinar id erat. Mauris aliquet vestibulum rutrum. Maecenas ultricies, sapien ac porta congue, augue lorem imperdiet elit, ut sollicitudin est quam ut felis. Vivamus interdum urna eu turpis facilisis ultrices interdum mauris interdum. Vestibulum sed leo sed nisl vestibulum commodo ut a libero.
Integer leo augue, malesuada eget tincidunt at, cursus sit amet lacus. Phasellus ultrices ligula eu est convallis in condimentum tortor dictum. Nulla fermentum ipsum nec mi lobortis aliquam.
Phasellus id ante faucibus risus aliquam ornare ac in est. Integer et libero neque. Nunc dignissim ultricies quam, eget sodales nisi accumsan in. Aenean volutpat, nibh non egestas suscipit, dolor nisi lobortis enim, sit amet congue dolor nisi eget eros. Vestibulum imperdiet convallis molestie. Cras eu turpis sit amet metus fermentum mollis at ac libero. Nulla facilisi. Nulla facilisi.
Grab the script:
The PBS KIDS Carousel turns a set of div panels into a rotating carousel that can be used for features, images, or anything else on a webpage. It gracefully degrades if the user does not have javascript enabled. (Try it!) It sets its own height based on the tallest panel in your list. It also dynamically generates a navigation bar with the titles of your panels as links. The time delay between rotation is customizable. By default, it begins with a random panel from your list, but you can set it to always begin with the first panel.
The Carousel requires jQuery.
Some things that make kidsCarousel special:
There are some pretty outstanding alternatives out there if this doesn’t meet your needs.
I’m happy to add to this list if others have recommendations.
Include jQuery in the <head> section of your page:
<script type="text/javascript" src="http://ajax.googleapis.com/
ajax/libs/jquery/1.3.2/jquery.min.js"></script>
Include the kidsCarousel plugin after including jQuery in the <head> section of your page:
<script type="text/javascript" src="/includes/javascript/jquery.kidscarousel.js"></script>
If you’re working on the PBS KIDS site, that’s all you need. If you’re using this elsewhere, please grab the script and host it on your own site, changing the directory of the include accordingly.
All the Carousel script needs is an element with a series of divs inside it to serve as panels.
<div id="myCarousel">
<-- Panel 1 -->
<div>
<h4>Panel Title</h4>
<p>Panel contents. Can be anything.</p>
</div>
<-- Panel 2 -->
<div>
<h4>Panel Title</h4>
<p>Panel contents. Can be anything.</p>
</div>
<-- Panel 3 -->
<div>
<h4>Panel Title</h4>
<p>Panel contents. Can be anything.</p>
</div>
<-- Panel 4 -->
<div>
<h4>Panel Title</h4>
<p>Panel contents. Can be anything.</p>
</div>
</div>
The carousel needs to be initiated by running the kidsCarousel function. The simplest way is to put the following script after the other javascript includes in your <head>.
<script type="text/javascript">
$(document).ready(function() {
$('#myCarousel').kidsCarousel();
});
</script>
The $(document).ready function intializes the script once the DOM is ready to be manipulated. The $('') selector uses CSS-style selection to target the appropriate element. You should substitute this with the #id of your own element.
The Carousel does not have any essential CSS, but you will want to add some styling for the navigation bar at the very least. This is the CSS used in the demo:
/* Each div inside your carousel is given a panel class that can be used for styling */
#myCarousel .panel h4 { margin: 0 0 1em; }
/* Styling for navigation bar */
.kidsCarouselNavigation {
background: #333;
font-family: Verdana, Geneva, sans-serif;
font-size: 10px;
margin: 10px 0 0;
padding: 10px;
}
/* Styling for navigation bar links */
.kidsCarouselNavigation a {
color: #fff;
outline: none;
padding: 5px;
text-decoration: none;
}
/* Styling for the back and forward buttons */
.kidsCarouselNavigation .back { }
.kidsCarouselNavigation .forward { float: right !important; }
/* Styling for the navigation link that is currently displayed */
.kidsCarouselNavigation a.current { background: #666; }
There are a number of behaviors that can be customized. You can insert options by adding this to your initialization:
<script type="text/javascript">
$(document).ready(function() {
$('#myCarousel').kidsCarousel({
'delay' : 10000,
'randomStart' : false,
'relativeNavButtons' : ['Previous', 'Next']
});
});
</script>
Options may be added in any order, and only those that you wish to change from the defaults need be added.
These are the options available, with the default option listed in bold:
autoAdvance: true / false
Controls whether the carousel rotates automatically (advances one to the right).
delay: 7000
The length of the delay before automatically advancing. 1000 equals roughly one second.
navigation: true / false
Turns the panel navigation on or off.
panel: 'div' / 'any class or tag'
By default, the script looks for divs that are immediate children of the your carousel, but you can tell it to look for any element you want: list items, paragraphs, or what you will.
panelNav: true / false
Turns on or off the panel navigation that displays between the back and forward buttons.
panelNavType: 'title' / 'number' By default, the carousel gets a title from an element inside each panel to use as the panel navigation link. Set this option to 'number' if you would like to simply have the number of the panel used instead, as in demo #2. If you simply wish to turn off the panel navigation, use the panelNav option.
panelTitle: 'h4' / 'any tag type'
Inside the divs in my examples, there are h4 elements that serve as panel titles. These can be whatever elements you want, though, and you can specify what tag you want to be used here. Important note: Sometimes you may wish the title used in the panel navigation to be shorter than the title in the panel itself. Just add a title attribute to your element and the panel navigation will use the title attribute instead of the full text as its panel navigation text.
randomStart: true / false
By default, the carousel starts with a random panel so that the carousel does not always begin on the same item. You may turn it off with this option, after which it will always begin with the first panel.
relativeNav: true / false
Use this option to turn off the back / forward navigation.
relativeNavButtons: ['Back', 'Forward'] / ['text or html for back button', 'text or html for forward button']
By default, the text 'Back' and 'Forward' is used for the respective relative navigation, but you can make this anything else you want, even images as in demo #1 or, conceivably, any other HTML.
relativeNavCustomButtons: [null, null] / ['id, class, or tag for back button', 'id, class, or tag for forward button']
So maybe you don't want to use my panel navigation. That's fine. I understand. Really. So you can turn off my nav (panelNav: false) and tell the carousel to use your elements. Just put the id, class, or tag in quotes in this array, as such: ['#myBackButton', '#myForwardButton']
This documentation is a first draft. Please let me know how it can be improved, or if you have any questions.