3
\$\begingroup\$

I have this all figured out now thanks to the help of a mod. Here's the working code:

     <script>
    jQuery(document).ready(function() {
    var queryString = location.search;
    var regEx = new RegExp("slide[0-9]");
    var match = queryString.search(regEx);

    if (match === -1) {
        return;
    }
    else {
        var slideNumber = queryString.substring(match + 5); 
        var slide = jQuery('li#slide' + slideNumber);
        var slides = jQuery('li[id^=slide]').not(slide);        

        if (slide.length) {
        slides.addClass('hideMe');
        stopSlideShow();    
        slide.addClass('lonelySlide').show();
        slide.css('opacity', '1');  
        }  
    }

    function stopSlideShow() {
        jQuery('.flexslider').flexslider({
            slideshow: false
        });        

        jQuery('ol.flex-control-nav.flex-control-paging, a.flex-prev, a.flex-next').hide();
    }
});
</script>

Basically I needed to set variables to remove my DRY code and then create a function for stopping the slider and hiding the slider direction navs and paging dots. If someone uses a slide number in the query string that doesn't exist, the slideshow will return itself. If the slide number does exist then it will return the slide requested, stop the slideshow and remove the slide navs and paging dots. This code was causing a funky fade in issue when it was originally presented to me, so i pulled the stopSlideShow() function out of show() and ran it before show() runs to get rid of the fade in effect. If anyone else has additional suggestions for the code, that would be great!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.