Deutschland United States United Kingdom
ContentLion - Open Source CMS

Blame image_slide.js

Details | Last modification | View Log

Rev Author Line
1 Stefan Wienströer
$(document).ready(function() {    
Stefan Wienströer
 
Stefan Wienströer
  // execute the slideShow, set 4 seconds (4000) for each image
Stefan Wienströer
  slideShow(4000);
Stefan Wienströer
 
Stefan Wienströer
});
Stefan Wienströer
 
Stefan Wienströer
function slideShow(speed) {
Stefan Wienströer
 
Stefan Wienströer
  // append an 'li' item to the 'ul' list for displaying the caption
Stefan Wienströer
  $('ul.slideshow').append('<li id="slideshow-caption" class="caption"><div class="slideshow-caption-container"><p></p></div></li>');
Stefan Wienströer
 
Stefan Wienströer
  // set the opacity of all images to 0
Stefan Wienströer
  $('ul.slideshow li').css({opacity: 0.0});
Stefan Wienströer
 
Stefan Wienströer
  // get the first image and display it
Stefan Wienströer
  $('ul.slideshow li:first').css({opacity: 1.0}).addClass('show');
Stefan Wienströer
 
Stefan Wienströer
  // get the caption of the first image from the 'rel' attribute and display it
Stefan Wienströer
  $('#slideshow-caption p').html($('ul.slideshow li.show').find('img').attr('alt'));
Stefan Wienströer
 
Stefan Wienströer
  // display the caption
Stefan Wienströer
  if($('ul.slideshow li.show').find('img').attr('alt').length == 0)
Stefan Wienströer
  {
Stefan Wienströer
        $('#slideshow-caption').css({opacity: 0.0, bottom:0});
Stefan Wienströer
  }
Stefan Wienströer
  else
Stefan Wienströer
  {
Stefan Wienströer
        $('#slideshow-caption').css({opacity: 0.6, bottom:0});
Stefan Wienströer
  }
Stefan Wienströer
 
Stefan Wienströer
  // call the gallery function to run the slideshow  
Stefan Wienströer
  var timer = setInterval('gallery()',speed);
Stefan Wienströer
 
Stefan Wienströer
  // pause the slideshow on mouse over
Stefan Wienströer
  $('ul.slideshow').hover(
Stefan Wienströer
    function () {
Stefan Wienströer
      clearInterval(timer);
Stefan Wienströer
    },  
Stefan Wienströer
    function () {
Stefan Wienströer
      timer = setInterval('gallery()',speed);    
Stefan Wienströer
    }
Stefan Wienströer
  );  
Stefan Wienströer
}
Stefan Wienströer
 
Stefan Wienströer
function gallery() {
Stefan Wienströer
 
Stefan Wienströer
  //if no images have the show class, grab the first image
Stefan Wienströer
  var current = ($('ul.slideshow li.show')?  $('ul.slideshow li.show') : $('#ul.slideshow li:first'));
Stefan Wienströer
 
Stefan Wienströer
  // trying to avoid speed issue
Stefan Wienströer
  if(current.queue('fx').length == 0) {
Stefan Wienströer
 
Stefan Wienströer
    // get the next image, if it reached the end of the slideshow, rotate it back to the first image
Stefan Wienströer
    var next = ((current.next().length) ? ((current.next().attr('id') == 'slideshow-caption')? $('ul.slideshow li:first') :current.next()) : $('ul.slideshow li:first'));
Stefan Wienströer
 
Stefan Wienströer
    // get the next image caption
Stefan Wienströer
    var desc = next.find('img').attr('alt');  
Stefan Wienströer
 
Stefan Wienströer
    // set the fade in effect for the next image, show class has higher z-index
Stefan Wienströer
    next.css({opacity: 0.0}).addClass('show').animate({opacity: 1.0}, 1000);
Stefan Wienströer
 
Stefan Wienströer
    // hide the caption first, and then set and display the caption
Stefan Wienströer
    $('#slideshow-caption').slideToggle(300, function () {
Stefan Wienströer
      $('#slideshow-caption p').html(desc);
Stefan Wienströer
      $('#slideshow-caption').slideToggle(500);
Stefan Wienströer
    });  
Stefan Wienströer
 
Stefan Wienströer
    // hide the current image
Stefan Wienströer
    current.animate({opacity: 0.0}, 1000).removeClass('show');
Stefan Wienströer
 
Stefan Wienströer
  }
Stefan Wienströer
}