Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery(document).ready(function(){
- var play_div_slideshow_tid;
- jQuery('.div_slideshow_container').each(function() {
- jQuery(this).prepend('<div class="play_div_slideshow"><a href="javascript: void(0);" class="play_div_slideshow_link">Play Slideshow</a></div><div class="div_slideshow_nav"><a href="javascript: void(0);" class="div_slideshow_previous div_slideshow_nav_button" data-direction="-1"><img src="' + imagedir + 'nav_button_prev.png" width="35" height="35" alt="Prev" /></a> <span class="div_slideshow_start"></span> of <span class="div_slideshow_end"></span> <a href="javascript: void(0);" class="div_slideshow_next div_slideshow_nav_button" data-direction="1"><img src="' + imagedir + 'nav_button_next.png" width="35" height="35" alt="Next" /></a></div>');
- jQuery(this).children('.div_slide').each(function(index, Element) {
- if (index != 0) {
- jQuery(this).hide();
- }
- });
- jQuery(this).find('.div_slideshow_start').text('1');
- jQuery(this).find('.div_slideshow_end').text(jQuery(this).children('div.div_slide').length);
- });
- jQuery('.div_slideshow_previous').mouseenter(function() {
- jQuery(this).children('img').attr('src', imagedir + 'nav_button_prev_active.png');
- });
- jQuery('.div_slideshow_previous').mouseleave(function() {
- jQuery(this).children('img').attr('src', imagedir + 'nav_button_prev.png');
- });
- jQuery('.div_slideshow_next').mouseenter(function() {
- jQuery(this).children('img').attr('src', imagedir + 'nav_button_next_active.png');
- });
- jQuery('.div_slideshow_next').mouseleave(function() {
- jQuery(this).children('img').attr('src', imagedir + 'nav_button_next.png');
- });
- jQuery('.div_slideshow_nav_button').click(function() {
- var currentslide = parseInt(jQuery(this).parents('div.div_slideshow_container').find('span.div_slideshow_start').text()) -1,
- navdirection = parseInt(jQuery(this).attr('data-direction')), newslide = currentslide + navdirection,
- lastindex = jQuery(this).parents('div.div_slideshow_container').children('div.div_slide').length - 1;
- //alert('currentslide = ' + currentslide + ' and newslide = ' + newslide + ' and lastindex = ' + lastindex);
- //alert('image directory is ' + imagedir);
- if (newslide > lastindex) {
- newslide = 0;
- } else if (newslide < 0) {
- newslide = lastindex;
- }
- jQuery(this).parents('div.div_slideshow_container').find('span.div_slideshow_start').text(newslide + 1);
- jQuery(this).parents('div.div_slideshow_container').children('div.div_slide').eq(currentslide).hide("slide", { direction: "left" }, 500, function() {
- jQuery(this).parents('div.div_slideshow_container').children('div.div_slide').eq(newslide).show("slide", { direction: "right" }, 500);
- });
- });
- jQuery('.play_div_slideshow_link').click(function() {
- if (jQuery(this).text() == 'Play Slideshow') {
- jQuery(this).text('Stop Slideshow');
- var theobject = jQuery(this), currentslide, newslide, lastindex;
- play_div_slideshow_tid = setInterval(function(thisobject = theobject) {
- currentslide = parseInt(thisobject.parents('div.div_slideshow_container').find('span.div_slideshow_start').text()) -1,
- newslide = currentslide + 1,
- lastindex = thisobject.parents('div.div_slideshow_container').children('div.div_slide').length - 1;
- if (newslide > lastindex) {
- newslide = 0;
- } else if (newslide < 0) {
- newslide = lastindex;
- }
- thisobject.parents('div.div_slideshow_container').find('span.div_slideshow_start').text(newslide + 1);
- thisobject.parents('div.div_slideshow_container').children('div.div_slide').eq(currentslide).hide("slide", { direction: "left" }, 500, function() {
- thisobject.parents('div.div_slideshow_container').children('div.div_slide').eq(newslide).show("slide", { direction: "right" }, 500);
- });
- }, 3000);
- } else {
- jQuery(this).text('Play Slideshow');
- clearInterval(play_div_slideshow_tid);
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement