ckridgway@53: /** ckridgway@53: * jQuery bxSlider v3.0 ckridgway@53: * http://bxslider.com ckridgway@53: * ckridgway@53: * Copyright 2011, Steven Wanderski ckridgway@53: * http://bxcreative.com ckridgway@53: * ckridgway@53: * Free to use and abuse under the MIT license. ckridgway@53: * http://www.opensource.org/licenses/mit-license.php ckridgway@53: * ckridgway@53: */ ckridgway@53: ckridgway@53: ckridgway@53: (function($){ ckridgway@53: ckridgway@53: $.fn.bxSlider = function(options){ ckridgway@53: ckridgway@53: var defaults = { ckridgway@53: mode: 'horizontal', // 'horizontal', 'vertical', 'fade' ckridgway@53: infiniteLoop: true, // true, false - display first slide after last ckridgway@53: hideControlOnEnd: false, // true, false - if true, will hide 'next' control on last slide and 'prev' control on first ckridgway@53: controls: true, // true, false - previous and next controls ckridgway@53: speed: 500, // integer - in ms, duration of time slide transitions will occupy ckridgway@53: easing: 'swing', // used with jquery.easing.1.3.js - see http://gsgd.co.uk/sandbox/jquery/easing/ for available options ckridgway@53: pager: false, // true / false - display a pager ckridgway@53: pagerSelector: null, // jQuery selector - element to contain the pager. ex: '#pager' ckridgway@53: pagerType: 'full', // 'full', 'short' - if 'full' pager displays 1,2,3... if 'short' pager displays 1 / 4 ckridgway@53: pagerLocation: 'bottom', // 'bottom', 'top' - location of pager ckridgway@53: pagerShortSeparator: '/', // string - ex: 'of' pager would display 1 of 4 ckridgway@53: pagerActiveClass: 'pager-active', // string - classname attached to the active pager link ckridgway@53: nextText: 'next', // string - text displayed for 'next' control ckridgway@53: nextImage: '', // string - filepath of image used for 'next' control. ex: 'images/next.jpg' ckridgway@53: nextSelector: null, // jQuery selector - element to contain the next control. ex: '#next' ckridgway@53: prevText: 'prev', // string - text displayed for 'previous' control ckridgway@53: prevImage: '', // string - filepath of image used for 'previous' control. ex: 'images/prev.jpg' ckridgway@53: prevSelector: null, // jQuery selector - element to contain the previous control. ex: '#next' ckridgway@53: captions: false, // true, false - display image captions (reads the image 'title' tag) ckridgway@53: captionsSelector: null, // jQuery selector - element to contain the captions. ex: '#captions' ckridgway@53: auto: false, // true, false - make slideshow change automatically ckridgway@53: autoDirection: 'next', // 'next', 'prev' - direction in which auto show will traverse ckridgway@53: autoControls: false, // true, false - show 'start' and 'stop' controls for auto show ckridgway@53: autoControlsSelector: null, // jQuery selector - element to contain the auto controls. ex: '#auto-controls' ckridgway@53: autoStart: true, // true, false - if false show will wait for 'start' control to activate ckridgway@53: autoHover: false, // true, false - if true show will pause on mouseover ckridgway@53: autoDelay: 0, // integer - in ms, the amount of time before starting the auto show ckridgway@53: pause: 3000, // integer - in ms, the duration between each slide transition ckridgway@53: startText: 'start', // string - text displayed for 'start' control ckridgway@53: startImage: '', // string - filepath of image used for 'start' control. ex: 'images/start.jpg' ckridgway@53: stopText: 'stop', // string - text displayed for 'stop' control ckridgway@53: stopImage: '', // string - filepath of image used for 'stop' control. ex: 'images/stop.jpg' ckridgway@53: ticker: false, // true, false - continuous motion ticker mode (think news ticker) ckridgway@53: // note: autoControls, autoControlsSelector, and autoHover apply to ticker! ckridgway@53: tickerSpeed: 5000, // float - use value between 1 and 5000 to determine ticker speed - the smaller the value the faster the ticker speed ckridgway@53: tickerDirection: 'next', // 'next', 'prev' - direction in which ticker show will traverse ckridgway@53: tickerHover: false, // true, false - if true ticker will pause on mouseover ckridgway@53: wrapperClass: 'bx-wrapper', // string - classname attached to the slider wraper ckridgway@53: startingSlide: 0, // integer - show will start on specified slide. note: slides are zero based! ckridgway@53: displaySlideQty: 1, // integer - number of slides to display at once ckridgway@53: moveSlideQty: 1, // integer - number of slides to move at once ckridgway@53: randomStart: false, // true, false - if true show will start on a random slide ckridgway@53: onBeforeSlide: function(){}, // function(currentSlideNumber, totalSlideQty, currentSlideHtmlObject) - advanced use only! see the tutorial here: http://bxslider.com/custom-pager ckridgway@53: onAfterSlide: function(){}, // function(currentSlideNumber, totalSlideQty, currentSlideHtmlObject) - advanced use only! see the tutorial here: http://bxslider.com/custom-pager ckridgway@53: onLastSlide: function(){}, // function(currentSlideNumber, totalSlideQty, currentSlideHtmlObject) - advanced use only! see the tutorial here: http://bxslider.com/custom-pager ckridgway@53: onFirstSlide: function(){}, // function(currentSlideNumber, totalSlideQty, currentSlideHtmlObject) - advanced use only! see the tutorial here: http://bxslider.com/custom-pager ckridgway@53: onNextSlide: function(){}, // function(currentSlideNumber, totalSlideQty, currentSlideHtmlObject) - advanced use only! see the tutorial here: http://bxslider.com/custom-pager ckridgway@53: onPrevSlide: function(){}, // function(currentSlideNumber, totalSlideQty, currentSlideHtmlObject) - advanced use only! see the tutorial here: http://bxslider.com/custom-pager ckridgway@53: buildPager: null // function(slideIndex, slideHtmlObject){ return string; } - advanced use only! see the tutorial here: http://bxslider.com/custom-pager ckridgway@53: } ckridgway@53: ckridgway@53: var options = $.extend(defaults, options); ckridgway@53: ckridgway@53: // cache the base element ckridgway@53: var base = this; ckridgway@53: // initialize (and localize) all variables ckridgway@53: var $parent = ''; ckridgway@53: var $origElement = ''; ckridgway@53: var $children = ''; ckridgway@53: var $outerWrapper = ''; ckridgway@53: var $firstChild = ''; ckridgway@53: var childrenWidth = ''; ckridgway@53: var childrenOuterWidth = ''; ckridgway@53: var wrapperWidth = ''; ckridgway@53: var wrapperHeight = ''; ckridgway@53: var $pager = ''; ckridgway@53: var interval = ''; ckridgway@53: var $autoControls = ''; ckridgway@53: var $stopHtml = ''; ckridgway@53: var $startContent = ''; ckridgway@53: var $stopContent = ''; ckridgway@53: var autoPlaying = true; ckridgway@53: var loaded = false; ckridgway@53: var childrenMaxWidth = 0; ckridgway@53: var childrenMaxHeight = 0; ckridgway@53: var currentSlide = 0; ckridgway@53: var origLeft = 0; ckridgway@53: var origTop = 0; ckridgway@53: var origShowWidth = 0; ckridgway@53: var origShowHeight = 0; ckridgway@53: var tickerLeft = 0; ckridgway@53: var tickerTop = 0; ckridgway@53: var isWorking = false; ckridgway@53: ckridgway@53: var firstSlide = 0; ckridgway@53: var lastSlide = $children.length - 1; ckridgway@53: ckridgway@53: ckridgway@53: // PUBLIC FUNCTIONS ckridgway@53: ckridgway@53: /** ckridgway@53: * Go to specified slide ckridgway@53: */ ckridgway@53: this.goToSlide = function(number, stopAuto){ ckridgway@53: if(!isWorking){ ckridgway@53: isWorking = true; ckridgway@53: // set current slide to argument ckridgway@53: currentSlide = number; ckridgway@53: options.onBeforeSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: // check if stopAuto argument is supplied ckridgway@53: if(typeof(stopAuto) == 'undefined'){ ckridgway@53: var stopAuto = true; ckridgway@53: } ckridgway@53: if(stopAuto){ ckridgway@53: // if show is auto playing, stop it ckridgway@53: if(options.auto){ ckridgway@53: base.stopShow(true); ckridgway@53: } ckridgway@53: } ckridgway@53: slide = number; ckridgway@53: // check for first slide callback ckridgway@53: if(slide == firstSlide){ ckridgway@53: options.onFirstSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: } ckridgway@53: // check for last slide callback ckridgway@53: if(slide == lastSlide){ ckridgway@53: options.onLastSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: } ckridgway@53: // horizontal ckridgway@53: if(options.mode == 'horizontal'){ ckridgway@53: $parent.animate({'left': '-'+getSlidePosition(slide, 'left')+'px'}, options.speed, options.easing, function(){ ckridgway@53: isWorking = false; ckridgway@53: // perform the callback function ckridgway@53: options.onAfterSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: }); ckridgway@53: // vertical ckridgway@53: }else if(options.mode == 'vertical'){ ckridgway@53: $parent.animate({'top': '-'+getSlidePosition(slide, 'top')+'px'}, options.speed, options.easing, function(){ ckridgway@53: isWorking = false; ckridgway@53: // perform the callback function ckridgway@53: options.onAfterSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: }); ckridgway@53: // fade ckridgway@53: }else if(options.mode == 'fade'){ ckridgway@53: setChildrenFade(); ckridgway@53: } ckridgway@53: // check to remove controls on last/first slide ckridgway@53: checkEndControls(); ckridgway@53: // accomodate multi slides ckridgway@53: if(options.moveSlideQty > 1){ ckridgway@53: number = Math.floor(number / options.moveSlideQty); ckridgway@53: } ckridgway@53: // make the current slide active ckridgway@53: makeSlideActive(number); ckridgway@53: // display the caption ckridgway@53: showCaptions(); ckridgway@53: } ckridgway@53: } ckridgway@53: ckridgway@53: /** ckridgway@53: * Go to next slide ckridgway@53: */ ckridgway@53: this.goToNextSlide = function(stopAuto){ ckridgway@53: // check if stopAuto argument is supplied ckridgway@53: if(typeof(stopAuto) == 'undefined'){ ckridgway@53: var stopAuto = true; ckridgway@53: } ckridgway@53: if(stopAuto){ ckridgway@53: // if show is auto playing, stop it ckridgway@53: if(options.auto){ ckridgway@53: base.stopShow(true); ckridgway@53: } ckridgway@53: } ckridgway@53: // makes slideshow finite ckridgway@53: if(!options.infiniteLoop){ ckridgway@53: if(!isWorking){ ckridgway@53: var slideLoop = false; ckridgway@53: // make current slide the old value plus moveSlideQty ckridgway@53: currentSlide = (currentSlide + (options.moveSlideQty)); ckridgway@53: // if current slide has looped on itself ckridgway@53: if(currentSlide <= lastSlide){ ckridgway@53: checkEndControls(); ckridgway@53: // next slide callback ckridgway@53: options.onNextSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: // move to appropriate slide ckridgway@53: base.goToSlide(currentSlide); ckridgway@53: }else{ ckridgway@53: currentSlide -= options.moveSlideQty; ckridgway@53: } ckridgway@53: } // end if(!isWorking) ckridgway@53: }else{ ckridgway@53: if(!isWorking){ ckridgway@53: isWorking = true; ckridgway@53: var slideLoop = false; ckridgway@53: // make current slide the old value plus moveSlideQty ckridgway@53: currentSlide = (currentSlide + options.moveSlideQty); ckridgway@53: // if current slide has looped on itself ckridgway@53: if(currentSlide > lastSlide){ ckridgway@53: currentSlide = currentSlide % $children.length; ckridgway@53: slideLoop = true; ckridgway@53: } ckridgway@53: // next slide callback ckridgway@53: options.onNextSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: // slide before callback ckridgway@53: options.onBeforeSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: if(options.mode == 'horizontal'){ ckridgway@53: // get the new 'left' property for $parent ckridgway@53: var parentLeft = (options.moveSlideQty * childrenOuterWidth); ckridgway@53: // animate to the new 'left' ckridgway@53: $parent.animate({'left': '-='+parentLeft+'px'}, options.speed, options.easing, function(){ ckridgway@53: isWorking = false; ckridgway@53: // if its time to loop, reset the $parent ckridgway@53: if(slideLoop){ ckridgway@53: $parent.css('left', '-'+getSlidePosition(currentSlide, 'left')+'px'); ckridgway@53: } ckridgway@53: // perform the callback function ckridgway@53: options.onAfterSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: }); ckridgway@53: }else if(options.mode == 'vertical'){ ckridgway@53: // get the new 'left' property for $parent ckridgway@53: var parentTop = (options.moveSlideQty * childrenMaxHeight); ckridgway@53: // animate to the new 'left' ckridgway@53: $parent.animate({'top': '-='+parentTop+'px'}, options.speed, options.easing, function(){ ckridgway@53: isWorking = false; ckridgway@53: // if its time to loop, reset the $parent ckridgway@53: if(slideLoop){ ckridgway@53: $parent.css('top', '-'+getSlidePosition(currentSlide, 'top')+'px'); ckridgway@53: } ckridgway@53: // perform the callback function ckridgway@53: options.onAfterSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: }); ckridgway@53: }else if(options.mode == 'fade'){ ckridgway@53: setChildrenFade(); ckridgway@53: } ckridgway@53: // make the current slide active ckridgway@53: if(options.moveSlideQty > 1){ ckridgway@53: makeSlideActive(Math.ceil(currentSlide / options.moveSlideQty)); ckridgway@53: }else{ ckridgway@53: makeSlideActive(currentSlide); ckridgway@53: } ckridgway@53: // display the caption ckridgway@53: showCaptions(); ckridgway@53: } // end if(!isWorking) ckridgway@53: ckridgway@53: } ckridgway@53: } // end function ckridgway@53: ckridgway@53: /** ckridgway@53: * Go to previous slide ckridgway@53: */ ckridgway@53: this.goToPreviousSlide = function(stopAuto){ ckridgway@53: // check if stopAuto argument is supplied ckridgway@53: if(typeof(stopAuto) == 'undefined'){ ckridgway@53: var stopAuto = true; ckridgway@53: } ckridgway@53: if(stopAuto){ ckridgway@53: // if show is auto playing, stop it ckridgway@53: if(options.auto){ ckridgway@53: base.stopShow(true); ckridgway@53: } ckridgway@53: } ckridgway@53: // makes slideshow finite ckridgway@53: if(!options.infiniteLoop){ ckridgway@53: if(!isWorking){ ckridgway@53: var slideLoop = false; ckridgway@53: // make current slide the old value plus moveSlideQty ckridgway@53: currentSlide = currentSlide - options.moveSlideQty; ckridgway@53: // if current slide has looped on itself ckridgway@53: if(currentSlide < 0){ ckridgway@53: currentSlide = 0; ckridgway@53: // if specified, hide the control on the last slide ckridgway@53: if(options.hideControlOnEnd){ ckridgway@53: $('.bx-prev', $outerWrapper).hide(); ckridgway@53: } ckridgway@53: } ckridgway@53: checkEndControls(); ckridgway@53: // next slide callback ckridgway@53: options.onPrevSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: // move to appropriate slide ckridgway@53: base.goToSlide(currentSlide); ckridgway@53: } ckridgway@53: }else{ ckridgway@53: if(!isWorking){ ckridgway@53: isWorking = true; ckridgway@53: var slideLoop = false; ckridgway@53: // make current slide the old value plus moveSlideQty ckridgway@53: currentSlide = (currentSlide - (options.moveSlideQty)); ckridgway@53: // if current slide has looped on itself ckridgway@53: if(currentSlide < 0){ ckridgway@53: negativeOffset = (currentSlide % $children.length); ckridgway@53: if(negativeOffset == 0){ ckridgway@53: currentSlide = 0; ckridgway@53: }else{ ckridgway@53: currentSlide = ($children.length) + negativeOffset; ckridgway@53: } ckridgway@53: slideLoop = true; ckridgway@53: } ckridgway@53: // next slide callback ckridgway@53: options.onPrevSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: // slide before callback ckridgway@53: options.onBeforeSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: if(options.mode == 'horizontal'){ ckridgway@53: // get the new 'left' property for $parent ckridgway@53: var parentLeft = (options.moveSlideQty * childrenOuterWidth); ckridgway@53: // animate to the new 'left' ckridgway@53: $parent.animate({'left': '+='+parentLeft+'px'}, options.speed, options.easing, function(){ ckridgway@53: isWorking = false; ckridgway@53: // if its time to loop, reset the $parent ckridgway@53: if(slideLoop){ ckridgway@53: $parent.css('left', '-'+getSlidePosition(currentSlide, 'left')+'px'); ckridgway@53: } ckridgway@53: // perform the callback function ckridgway@53: options.onAfterSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: }); ckridgway@53: }else if(options.mode == 'vertical'){ ckridgway@53: // get the new 'left' property for $parent ckridgway@53: var parentTop = (options.moveSlideQty * childrenMaxHeight); ckridgway@53: // animate to the new 'left' ckridgway@53: $parent.animate({'top': '+='+parentTop+'px'}, options.speed, options.easing, function(){ ckridgway@53: isWorking = false; ckridgway@53: // if its time to loop, reset the $parent ckridgway@53: if(slideLoop){ ckridgway@53: $parent.css('top', '-'+getSlidePosition(currentSlide, 'top')+'px'); ckridgway@53: } ckridgway@53: // perform the callback function ckridgway@53: options.onAfterSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: }); ckridgway@53: }else if(options.mode == 'fade'){ ckridgway@53: setChildrenFade(); ckridgway@53: } ckridgway@53: // make the current slide active ckridgway@53: if(options.moveSlideQty > 1){ ckridgway@53: makeSlideActive(Math.ceil(currentSlide / options.moveSlideQty)); ckridgway@53: }else{ ckridgway@53: makeSlideActive(currentSlide); ckridgway@53: } ckridgway@53: // display the caption ckridgway@53: showCaptions(); ckridgway@53: } // end if(!isWorking) ckridgway@53: } ckridgway@53: } // end function ckridgway@53: ckridgway@53: /** ckridgway@53: * Go to first slide ckridgway@53: */ ckridgway@53: this.goToFirstSlide = function(stopAuto){ ckridgway@53: // check if stopAuto argument is supplied ckridgway@53: if(typeof(stopAuto) == 'undefined'){ ckridgway@53: var stopAuto = true; ckridgway@53: } ckridgway@53: base.goToSlide(firstSlide, stopAuto); ckridgway@53: } ckridgway@53: ckridgway@53: /** ckridgway@53: * Go to last slide ckridgway@53: */ ckridgway@53: this.goToLastSlide = function(){ ckridgway@53: // check if stopAuto argument is supplied ckridgway@53: if(typeof(stopAuto) == 'undefined'){ ckridgway@53: var stopAuto = true; ckridgway@53: } ckridgway@53: base.goToSlide(lastSlide, stopAuto); ckridgway@53: } ckridgway@53: ckridgway@53: /** ckridgway@53: * Get the current slide ckridgway@53: */ ckridgway@53: this.getCurrentSlide = function(){ ckridgway@53: return currentSlide; ckridgway@53: } ckridgway@53: ckridgway@53: /** ckridgway@53: * Get the total slide count ckridgway@53: */ ckridgway@53: this.getSlideCount = function(){ ckridgway@53: return $children.length; ckridgway@53: } ckridgway@53: ckridgway@53: /** ckridgway@53: * Stop the slideshow ckridgway@53: */ ckridgway@53: this.stopShow = function(changeText){ ckridgway@53: clearInterval(interval); ckridgway@53: // check if changeText argument is supplied ckridgway@53: if(typeof(changeText) == 'undefined'){ ckridgway@53: var changeText = true; ckridgway@53: } ckridgway@53: if(changeText && options.autoControls){ ckridgway@53: $autoControls.html($startContent).removeClass('stop').addClass('start'); ckridgway@53: autoPlaying = false; ckridgway@53: } ckridgway@53: } ckridgway@53: ckridgway@53: /** ckridgway@53: * Start the slideshow ckridgway@53: */ ckridgway@53: this.startShow = function(changeText){ ckridgway@53: // check if changeText argument is supplied ckridgway@53: if(typeof(changeText) == 'undefined'){ ckridgway@53: var changeText = true; ckridgway@53: } ckridgway@53: setAutoInterval(); ckridgway@53: if(changeText && options.autoControls){ ckridgway@53: $autoControls.html($stopContent).removeClass('start').addClass('stop'); ckridgway@53: autoPlaying = true; ckridgway@53: } ckridgway@53: } ckridgway@53: ckridgway@53: /** ckridgway@53: * Stops the ticker ckridgway@53: */ ckridgway@53: this.stopTicker = function(changeText){ ckridgway@53: $parent.stop(); ckridgway@53: // check if changeText argument is supplied ckridgway@53: if(typeof(changeText) == 'undefined'){ ckridgway@53: var changeText = true; ckridgway@53: } ckridgway@53: if(changeText && options.ticker){ ckridgway@53: $autoControls.html($startContent).removeClass('stop').addClass('start'); ckridgway@53: autoPlaying = false; ckridgway@53: } ckridgway@53: } ckridgway@53: ckridgway@53: /** ckridgway@53: * Starts the ticker ckridgway@53: */ ckridgway@53: this.startTicker = function(changeText){ ckridgway@53: if(options.mode == 'horizontal'){ ckridgway@53: if(options.tickerDirection == 'next'){ ckridgway@53: // get the 'left' property where the ticker stopped ckridgway@53: var stoppedLeft = parseInt($parent.css('left')); ckridgway@53: // calculate the remaining distance the show must travel until the loop ckridgway@53: var remainingDistance = (origShowWidth + stoppedLeft) + $children.eq(0).width(); ckridgway@53: }else if(options.tickerDirection == 'prev'){ ckridgway@53: // get the 'left' property where the ticker stopped ckridgway@53: var stoppedLeft = -parseInt($parent.css('left')); ckridgway@53: // calculate the remaining distance the show must travel until the loop ckridgway@53: var remainingDistance = (stoppedLeft) - $children.eq(0).width(); ckridgway@53: } ckridgway@53: // calculate the speed ratio to seamlessly finish the loop ckridgway@53: var finishingSpeed = (remainingDistance * options.tickerSpeed) / origShowWidth; ckridgway@53: // call the show ckridgway@53: moveTheShow(tickerLeft, remainingDistance, finishingSpeed); ckridgway@53: }else if(options.mode == 'vertical'){ ckridgway@53: if(options.tickerDirection == 'next'){ ckridgway@53: // get the 'top' property where the ticker stopped ckridgway@53: var stoppedTop = parseInt($parent.css('top')); ckridgway@53: // calculate the remaining distance the show must travel until the loop ckridgway@53: var remainingDistance = (origShowHeight + stoppedTop) + $children.eq(0).height(); ckridgway@53: }else if(options.tickerDirection == 'prev'){ ckridgway@53: // get the 'left' property where the ticker stopped ckridgway@53: var stoppedTop = -parseInt($parent.css('top')); ckridgway@53: // calculate the remaining distance the show must travel until the loop ckridgway@53: var remainingDistance = (stoppedTop) - $children.eq(0).height(); ckridgway@53: } ckridgway@53: // calculate the speed ratio to seamlessly finish the loop ckridgway@53: var finishingSpeed = (remainingDistance * options.tickerSpeed) / origShowHeight; ckridgway@53: // call the show ckridgway@53: moveTheShow(tickerTop, remainingDistance, finishingSpeed); ckridgway@53: // check if changeText argument is supplied ckridgway@53: if(typeof(changeText) == 'undefined'){ ckridgway@53: var changeText = true; ckridgway@53: } ckridgway@53: if(changeText && options.ticker){ ckridgway@53: $autoControls.html($stopContent).removeClass('start').addClass('stop'); ckridgway@53: autoPlaying = true; ckridgway@53: } ckridgway@53: } ckridgway@53: } ckridgway@53: ckridgway@53: /** ckridgway@53: * Initialize a new slideshow ckridgway@53: */ ckridgway@53: this.initShow = function(){ ckridgway@53: ckridgway@53: // reinitialize all variables ckridgway@53: // base = this; ckridgway@53: $parent = $(this); ckridgway@53: $origElement = $parent.clone(); ckridgway@53: $children = $parent.children(); ckridgway@53: $outerWrapper = ''; ckridgway@53: $firstChild = $parent.children(':first'); ckridgway@53: childrenWidth = $firstChild.width(); ckridgway@53: childrenMaxWidth = 0; ckridgway@53: childrenOuterWidth = $firstChild.outerWidth(); ckridgway@53: childrenMaxHeight = 0; ckridgway@53: wrapperWidth = getWrapperWidth(); ckridgway@53: wrapperHeight = getWrapperHeight(); ckridgway@53: isWorking = false; ckridgway@53: $pager = ''; ckridgway@53: currentSlide = 0; ckridgway@53: origLeft = 0; ckridgway@53: origTop = 0; ckridgway@53: interval = ''; ckridgway@53: $autoControls = ''; ckridgway@53: $stopHtml = ''; ckridgway@53: $startContent = ''; ckridgway@53: $stopContent = ''; ckridgway@53: autoPlaying = true; ckridgway@53: loaded = false; ckridgway@53: origShowWidth = 0; ckridgway@53: origShowHeight = 0; ckridgway@53: tickerLeft = 0; ckridgway@53: tickerTop = 0; ckridgway@53: ckridgway@53: firstSlide = 0; ckridgway@53: lastSlide = $children.length - 1; ckridgway@53: ckridgway@53: // get the largest child's height and width ckridgway@53: $children.each(function(index) { ckridgway@53: if($(this).outerHeight() > childrenMaxHeight){ ckridgway@53: childrenMaxHeight = $(this).outerHeight(); ckridgway@53: } ckridgway@53: if($(this).outerWidth() > childrenMaxWidth){ ckridgway@53: childrenMaxWidth = $(this).outerWidth(); ckridgway@53: } ckridgway@53: }); ckridgway@53: ckridgway@53: // get random slide number ckridgway@53: if(options.randomStart){ ckridgway@53: var randomNumber = Math.floor(Math.random() * $children.length); ckridgway@53: currentSlide = randomNumber; ckridgway@53: origLeft = childrenOuterWidth * (options.moveSlideQty + randomNumber); ckridgway@53: origTop = childrenMaxHeight * (options.moveSlideQty + randomNumber); ckridgway@53: // start show at specific slide ckridgway@53: }else{ ckridgway@53: currentSlide = options.startingSlide; ckridgway@53: origLeft = childrenOuterWidth * (options.moveSlideQty + options.startingSlide); ckridgway@53: origTop = childrenMaxHeight * (options.moveSlideQty + options.startingSlide); ckridgway@53: } ckridgway@53: ckridgway@53: // set initial css ckridgway@53: initCss(); ckridgway@53: ckridgway@53: // check to show pager ckridgway@53: if(options.pager && !options.ticker){ ckridgway@53: if(options.pagerType == 'full'){ ckridgway@53: showPager('full'); ckridgway@53: }else if(options.pagerType == 'short'){ ckridgway@53: showPager('short'); ckridgway@53: } ckridgway@53: } ckridgway@53: ckridgway@53: // check to show controls ckridgway@53: if(options.controls && !options.ticker){ ckridgway@53: setControlsVars(); ckridgway@53: } ckridgway@53: ckridgway@53: // check if auto ckridgway@53: if(options.auto || options.ticker){ ckridgway@53: // check if auto controls are displayed ckridgway@53: if(options.autoControls){ ckridgway@53: setAutoControlsVars(); ckridgway@53: } ckridgway@53: // check if show should auto start ckridgway@53: if(options.autoStart){ ckridgway@53: // check if autostart should delay ckridgway@53: setTimeout(function(){ ckridgway@53: base.startShow(true); ckridgway@53: }, options.autoDelay); ckridgway@53: }else{ ckridgway@53: base.stopShow(true); ckridgway@53: } ckridgway@53: // check if show should pause on hover ckridgway@53: if(options.autoHover && !options.ticker){ ckridgway@53: setAutoHover(); ckridgway@53: } ckridgway@53: } ckridgway@53: // make the starting slide active ckridgway@53: if(options.moveSlideQty > 1){ ckridgway@53: makeSlideActive(Math.ceil(currentSlide / options.moveSlideQty)); ckridgway@53: }else{ ckridgway@53: makeSlideActive(currentSlide); ckridgway@53: } ckridgway@53: // check for finite show and if controls should be hidden ckridgway@53: checkEndControls(); ckridgway@53: // show captions ckridgway@53: if(options.captions){ ckridgway@53: showCaptions(); ckridgway@53: } ckridgway@53: // perform the callback function ckridgway@53: options.onAfterSlide(currentSlide, $children.length, $children.eq(currentSlide)); ckridgway@53: } ckridgway@53: ckridgway@53: /** ckridgway@53: * Destroy the current slideshow ckridgway@53: */ ckridgway@53: this.destroyShow = function(){ ckridgway@53: // stop the auto show ckridgway@53: clearInterval(interval); ckridgway@53: // remove any controls / pagers that have been appended ckridgway@53: $('.bx-next, .bx-prev, .bx-pager, .bx-auto', $outerWrapper).remove(); ckridgway@53: // unwrap all bx-wrappers ckridgway@53: $parent.unwrap().unwrap().removeAttr('style'); ckridgway@53: // remove any styles that were appended ckridgway@53: $parent.children().removeAttr('style').not('.pager').remove(); ckridgway@53: // remove any childrent that were appended ckridgway@53: $children.removeClass('pager'); ckridgway@53: ckridgway@53: } ckridgway@53: ckridgway@53: /** ckridgway@53: * Reload the current slideshow ckridgway@53: */ ckridgway@53: this.reloadShow = function(){ ckridgway@53: base.destroyShow(); ckridgway@53: base.initShow(); ckridgway@53: } ckridgway@53: ckridgway@53: // PRIVATE FUNCTIONS ckridgway@53: ckridgway@53: /** ckridgway@53: * Creates all neccessary styling for the slideshow ckridgway@53: */ ckridgway@53: function initCss(){ ckridgway@53: // layout the children ckridgway@53: setChildrenLayout(options.startingSlide); ckridgway@53: // CSS for horizontal mode ckridgway@53: if(options.mode == 'horizontal'){ ckridgway@53: // wrap the