SlideShow Class

Jan 7, 2003

*****************************************************************

SlideShow javascript class by Peter Bailey - Copyright (c) 2003
Contact: me@peterbailey.net
Website: http://www.peterbailey.net/slideshow/

Main Features:
- OO design means low namespace consumption and allows for
multiple SlideShow instances per page
- Auto-creation of SELECT navigation widget
- Can preload images (but doesn't have to)
- Toggle start/end looping
- Slideshow data can be used between shows

Compatibility:
- Tested on IE6 and Mozilla 1.1
- DOM compliant browsers only

Note: This document was created with a tab-spacing of four (4)

******************************************************************/

function SlideShow( imgId, capId, stsId, root, data, pre, loop )
{
this.img = document.images[imgId];
this.cap = ( capId != '' );
this.sts = ( stsId != '' );
this.root = root;
this.slide = 0;
this.data = window[data];
this.pre = pre;
this.loop = loop;

if ( this.cap ) this.capObj = document.getElementById( capId );
if ( this.sts ) this.stsObj = document.getElementById( stsId );
if ( this.pre ) this.preload();
else this.imgsDone = true;

this.img.src = "/images/blank.gif";
if ( this.capObj ) this.capObj.firstChild.nodeValue = "Loading";
this.go(1);
}

SlideShow.prototype.preload = function()
{
var o = this;
this.img.setAttribute( "alt", "Preloading Images...Please Wait" );
this.imgs = new Array();
for ( var i = 0, l = this.data.length; i < l; i++ )
{
this.imgs[i] = new Image();
this.imgs[i].src = this.root + this.data[i][0];
}
this.imgs[--i].onload = function ()
{
o.img.setAttribute( "alt", o.data[o.slide][1] );
o.imgsDone = true;
}
}

SlideShow.prototype.next = function()
{
this.go('next');
}

SlideShow.prototype.prev = function()
{
this.go('prev');
}

SlideShow.prototype.go = function( v )
{
switch ( v )
{
case 'prev':
case 'back':
this.slide--; break;
case 'next':
case 'foward':
this.slide++; break;
default:
this.slide = v - 1;
}
if ( this.slide == -1 ) // Loop from beginning to end
this.slide = ( this.loop ) ? parseInt( this.data.length - 1 ) : 0;
if ( this.slide == this.data.length ) // Loop from end to beginning
this.slide = ( this.loop ) ? 0 : this.slide = this.data.length - 1;

this.img.src = ( this.pre ) ? this.imgs[this.slide].src : this.root + this.data[this.slide][0];
if (this.imgsDone) this.img.setAttribute( "alt", this.data[this.slide][1] );
if (this.cap) this.capObj.firstChild.nodeValue = this.data[this.slide][1];
if (this.sts) this.stsObj.firstChild.nodeValue = "Slide " + ( this.slide + 1 ) + " of " + this.data.length;
if (this.sel) this.sel.selectedIndex = this.slide;
}

SlideShow.prototype.makeSelect = function( containerId, useCaps )
{
var ssObj = this;
var s = document.createElement( "select" );
this.sel = document.getElementById( containerId ).appendChild( s );
if ( document.all )
this.sel.attachEvent( "onchange", function () { changeHandler( event.srcElement, ssObj ) } );
else
this.sel.addEventListener( "change", function ( e ) { changeHandler( e.target, ssObj ) }, false );
this.addOptions( useCaps );

function changeHandler( sel, ss )
{
ss.go( parseInt( sel.options[sel.selectedIndex].value ) + 1 );
}
}

SlideShow.prototype.addOptions = function( useCaps )
{
var o;
for ( var i = 0, len = this.data.length; i < len; i++ )
{
o = document.createElement( "option" );
t = document.createTextNode( ( useCaps ) ? this.data[i][1] : "Picture " + ( i + 1 ) );
o.setAttribute( "value", i );
o.appendChild( t );
this.sel.appendChild( o );
}
}

View 1 Replies


ADVERTISEMENT

JQuery :: Create A Slideshow With Thumbnails The User Scroll Through And Use To Navigate The Slideshow?

Aug 18, 2010

So Im trying to create a slideshow with thumbnails the user can scroll through and use to navigate the slideshow. I'm a big fan of cycle so I wanted to use that as my main slideshow component and was planning on using jcarousel for the pager. So far it works great in Firefox, Chrome, and Safari, yet in IE the thumbnails are not loading. I'm guessing it has something to do with how the images in the pager are generated and then jcarousel just isnt proccessing that in IE but I 'm not sure. I feel like I'm very close to getting this slideshow to work, yet I need to figure out why it is failing in IE.

[Code]...

View 2 Replies View Related

Jquery :: Simple Prototype Slideshow And A More Comprehensive Slideshow On Website?

Nov 25, 2009

I am using a simple prototype slideshow and a more comprehensive jquery slideshow on my website.When these are used on the same webpage on my website there appears to be a collision: (For example)Code:element.attachEvent is not a function[Break on this error] element.attachEvent("on" + actualEventName, responder); How can I avoid the conflict without reverting to a new slideshow?

View 1 Replies View Related

JQuery :: Add Text Slideshow To Image Slideshow?

Jun 1, 2011

i have a small image slideshow i want add a text slideshow to image slideshow. how is it?

my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>

[Code]....

View 7 Replies View Related

JQuery :: Select Class Which Is In The Same Class Of Class, On Which Clicked?

Jun 3, 2010

My code: [URL]... When I click on UpraviÅĨ in class edit I need add some HTML code to begin and to end of class entry how to I can select class entry in the same class post on which I clicked?

View 1 Replies View Related

JQuery :: Assigning A Click To A Class Selector - Once Clicked The Class Is Removed - Does This Work

May 5, 2011

I have a huge blob of code but the main part I am focusing on is this

$('.billboard_click').click(function () {
//this remove class
$(".billboard_click").removeClass("billboard_click");
});

1. Execute a click event when the div with the class 'billboard_click' is clicked

2. Once clicked, remove the class from that very div to avoid another click from happening

3. Execute a series of events such as animations, etc

4. add the class back to the clicker div

The code does not seem to work as expected but I am wondering if I am having issues elsewhere at this point and wonder if this actually is known to work

View 7 Replies View Related

Accessing Class Member Using This Inside An Anonymous Function Call In A Class Method?

Mar 28, 2010

I'm using jquery to make it easy for AJAX calls.

So I create a class: function cMap(mapID){//vars and stuff}

I go and prototype a function: cMap.prototype.loadMap = function(){ //jquery AJAX call }

Now in the jquery $.ajax({...}); call, I use an anonymous function on the "success:" call: success: function(data){ this.member = data; }

My problem is that inside this anonymous function call I'm trying to call a class member of my cMap class to store the data in from the AJAX call, but it's out of scope. So the JS console in FF/Chrome throws errors about bad value/doesn't exist.

How can I access this class member from inside an anonymous function? Or at least what's a good way to go about doing all this?

View 2 Replies View Related

JQuery :: Firebug Shows The Updated Class Of An Element But Live() Function Takes The Old Class?

Jul 2, 2009

I am new to this discussion but hope you would post reply for my query and encourage me to keep in touch with this discussion. Well here is my problem. I have made an edit in place form in which we can add and remove the elements. I have used jquery.jeditable.mini.js and jquery.duplicate-remove.js plugins for edit in place and add and remove action. I have live() function to access the dynamically ganerated elements like this. $(".addressDiv span").live("mouseover", function(){
clickable function here...

[Code]...

View 1 Replies View Related

If A Person Selects A Friday Class But Not A Saturday Class The Total Cost Field Will Automatically Enter $99?

Sep 27, 2011

CONDITIONS:If a person selects a Friday Class but not a Saturday Class the Total Cost Field will automatically enter $99.If a person selects a Saturday Class but not a Friday Class the Total Cost Field will automatically enter $99 as well.If a person selects both a Friday & Saturday Class the Total Cost field will automatically be $159.I found the following code and so far only have it changing when a Friday class is entered. I have no idea where to go from here

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

[code].....

View 10 Replies View Related

JQuery :: Class To Be Added Only If DIV Does Not Have Class Named 'Disabled'

Dec 29, 2011

I am adding a CSS class to a DIV as follows:$div.addClass("Hover");But I would like the class to be added only if the DIV does not have a class named "Disabled".

View 2 Replies View Related

JQuery :: Add Class / Remove Class With Live() And/or Livequery()?

Dec 22, 2010

I have this filter in a results table that also reflect in a ui datepicker day styling (ex:available unavailable) . Everything fine till i change month or year in datepicker . Maybe i have to use live() or livequery() but can see the way .This is the code:

$("#filterSelect").change(function(){
var filtro=$("#filterSelect").val();
$("#filter-box2").val(filtro);

[code]....

View 1 Replies View Related

JQuery :: Selector Speed - Class Only Versus Tag With Class

Mar 9, 2011

I'm trying to figure out which selector is faster (assuming that the class 'foo' only appears on input tags)...

$('.foo');
or
$('input.foo');

From what I've seen online, it seems that people recommend $('input.foo'), but in some limited testing it appears that $('.foo') is much faster in both FF and Chrome. In IE, both methods seem to produce similar results. Here is a fiddle with a simple example...

[URL]

Have browsers started implementing native ways to find all elements with a given class name? Would that explain why $('.foo') seems to be faster?

View 1 Replies View Related

JQuery :: Select Items With One Class, But Not Second Class?

Nov 25, 2010

<input type="text" class="class1">
<input type="text" class="class3">
<input type="text" class="class2">
<input type="text" class="class2 class1">
<input type="text" class="class1 class3">
<input type="text" class="class1">

Given the above, how would I select those that HAVE class1, but NOT class2, don't care about class3

So what I want are the items on lines 1,5 & 6 How could the below be modified to achieve what I want, or do I need something completely different?

View 1 Replies View Related

JQuery :: Usage Of .class.class Selector?

Dec 24, 2011

[URL] The above webpage lists the selector .class.class without an example. I can't find this usage in jQuery document either. I made the following example, but it doesn't work. Could anybody let me know who to use the .class.class selector?

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

[code]....

View 3 Replies View Related

Override Onmouseover In A Class, Now I Can't Get My Class Attributes.

Sep 15, 2006

I'm currently working with Javascript to build some "dynamic" tabs. Basicly, the tab "onmouseover" and "onmouseout" event have been overriden to change the tab's css class.

Here's the class:

function HtmlTab(id)
{
this.id = id;
this.tab = document.getElementById(id);
this.cssover = "over";
this.cssout = "out";

this.tab.onmouseover = function()
{

this.className = this.cssover; // NOT WORKING
}
this.tab.onmouseout = function()
{
this.className = "gen";
}
}
My problem is, I cannot access my HtmlTab class attributes from the this.tab.onmouseover function.

Anyone knows a way to fix this?

View 4 Replies View Related

JQuery :: Turn On An 'inactive-state' CSS Class For A Group Of Divs, Then Reset One Div To The 'active-state' Class?

Feb 2, 2011

I am attempting to make a menu that has a background image that changeswhen you rollover or click a menuitem. I've got the hover effect working fine with CSS, but am trying to implement the click event via jquery with the following:

CSS:
div.SustainResourcesMenuTabs
{ background-image: url('/images/departments/commdev/sustainability/menu_tab.jpg');
}[code]....

My process is to reset the entire menu to the inactive state, then switch on the active state for the item that was clicked. Eventually, the item that was clicked will display its corresponding body section as well. I've tried using the CSS pseudo-class "active", but since the entire div is the link, that is unavailable. I've also tried multiple variations of addClass/removeClass, toggleClass, and setAttribute/removeAttributebut nothing hasworked so far.

View 2 Replies View Related

Jquery: Class / Fade - Menu Link "active" Class Not Working

Dec 5, 2009

I have a script that fades links on load and im trying to get this to work on everything but the menu link that has the "active" class

Code:
<div id="menu">
<ul><li id="Home"><a title="Home" href="/" style="opacity: 0.6;">Home</a></li>
<li class="active" id="projects"><a title="projects" href="/projects/" style="opacity: 0.6;">projects</a></li>
<li class="last" id="Contact"><a title="Contact" href="/contact" style="opacity: 0.6;">Contact</a></li>
</ul>
</div>
[Code]...

View 4 Replies View Related

JQuery :: Css Class As Variable - Change The Css Class Of Li Element From Name Hidden To Variable FilterVal

May 26, 2010

I just donīt know the right syntax for this:

I want to change the css class of the li element from the name hidden to the variable filterVal, but i donīt know the right syntax.

View 1 Replies View Related

JQuery :: Add A Class Then Do Something To The Class?

Mar 19, 2009

I want to add a class to an element when you hover over (so it can be targeted with the next bit) it then do something to that element (animate, fade etc) then the class is removed ready to be applied to another similar element.But it all needs to happen on the initial hover (apart from the class being removed obviously)This is what I have so far that is adding and removing the class...

Code JavaScript:
$(document).ready(function () {
$("p#jtest a").mouseover(function () {[code].....

View 6 Replies View Related

JQuery :: Click Swap Image Gallery - Turn Off The "hover" Class And The "show" Class Of The Others When You Click One?

Mar 23, 2011

This is what I'm trying to do: I want a simple image container to swap the image inside it by clicking the nav buttons on the right like 1, 2, 3.Here's my code:

HTML
Code HTML4Strict:
<div id="item1">
<div class="img-container shadow" style="background-image:url(images/gallery/tcg1.jpg)">[code].....

My jQuery code is not right. I want it to turn off the "hover" class and the "show" class of the others when you click one. I think I need some kind of if..else? how to write it? I have a bg image set on the container div so there's an initial image to view.I also need multiple of these on the same page!

View 1 Replies View Related

IE8 Slideshow All Other Browsers?

Mar 22, 2011

I have an Issue with a Javascript slideshow. If you see link below it is obvious :)[URL]... I only get the Issue in Internet Explorer 8

View 4 Replies View Related

Slideshow Fade In And Out?

Jan 27, 2011

currently making a website for a friend and he's after a image slide show that fades in and out of the images. He wants it javascript based as he does not want flash on it. However my knowledge of javascript at the moment is very poor but this is what I've come up with so far.

I managed to get a slideshow working fine without the fade. Then I got a fade working for IE with this code:

var slideShowSpeed = 5000;
var crossFadeDuration = 5;
var Pic = new Array();
Pic[0] = 'images/SD_Banner.jpg'

[Code].....

However, even though this works for Mozilla and Chrome, IE does not like this at all...

Is there anyway of somehow doing some kind of IF statemement depending on which browser is open to determine which code shoud be used?

View 8 Replies View Related

Dhtml Slideshow

Jan 13, 2005

I've got a good cross browser dhtml fade in script that shows random images from an array when the window loads. It works perfectly for that.

I'd like to alter the code to show when the window loads the 'entire slideshow' over and over in a loop. I'm very new to JavaScript and could use a bit of help or advice on how to implement this. My coding knowledge is very basic. Code:

View 8 Replies View Related

Can't Get Slideshow To Loop

Jun 28, 2010

When I had 4 images it seemed to loop..When I added images it stopped.

Code:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="horizon photography.css" rel="stylesheet" type="text/css" />

[Code]....

I do not know if this is dated script or if you know of a simpler script that does the same thing. I just liked the fact that it was not flash and liked the fade transitions.....

View 5 Replies View Related

How To End A Slideshow Loop

Jun 12, 2011

I have a basic 3 image slideshow banner for a website, but it loops and I'd like it to stop on the last banner image instead of start over. Here is the code I have, but I don't know what to do to stop the slideshow once the last image is displayed:

<div id="mySlider">
<div id="slider">
<!-- start slideshow -->
<div id="slideshow">

[Code]....

I need to add to the code above to get the slideshow to stop on the last banner image?

View 2 Replies View Related

Adding A ULR To A JS Slideshow

Dec 7, 2011

I'm trying to add a URL to a slideshow.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved