Viewing 2 replies - 1 through 2 (of 2 total)
  • Any way to avoid this?

    Thread Starter freerange

    (@freerange)

    Replace the slideshow.js file with this one – it adds 2 lines

    if(!document.getElementById("content-slideshow"))
    		return;		//Bail if we don't have a slideshow

    This causes it to bail gracefully if there is no slideshow on the page

    // Tutorial by https://ooyes.net/
    
    $slideshow = {
    	context: false,
    	tabs: false,
    	timeout: 8000,
    	fx: 'fade',
    	slideSpeed: 900,
    	tabSpeed: 900,   
    
        init: function() {
    	if(!document.getElementById("content-slideshow"))
    		return;		//Bail if we don't have a slideshow
            this.context = jQuery('#content-slideshow');
            this.tabs = jQuery('ul.slideshow-nav li', this.context);
            this.tabs.remove();
            this.startSlideshow();
        },
    
        startSlideshow: function() {
    
            jQuery('div.content_slideshow > ul', $slideshow.context).cycle({
                fx: $slideshow.fx,
                pager: jQuery('ul.slideshow-nav', $slideshow.context),
                pagerAnchorBuilder: $slideshow.startTabs,
                before: $slideshow.Tabactive,
    	    timeout: $slideshow.timeout,
                speed: $slideshow.slideSpeed,
                fastOnEvent: $slideshow.tabSpeed,
                pauseOnPagerHover: true,
                pause: true
            });
        },
    
        startTabs: function(i, slide) {
            return $slideshow.tabs.eq(i);
        },
    
        Tabactive: function(currentSlide, nextSlide) {
            var activeTab = jQuery('a[href="#' + nextSlide.id + '"]', $slideshow.context);
            if(activeTab.length) {
                $slideshow.tabs.removeClass('on');
                activeTab.parent().addClass('on');
            }
        }
    };
    
    jQuery(document).ready(function($) {
        $slideshow.init();
    });
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘JS error when no slider on page’ is closed to new replies.