How to stop rotation of banner on click of thumbnail.

How to stop rotation of banner on click of thumbnail.

I have an auto rotating banner that can be seen here http://www.meridianintegrations.com

I'd like for a user to be able to click on one of the thumbnails, switches to that respected rotation and stops.

In case someone wants to stop and read one of the rotations.

I cut out the javascript I assume would be the script in questions.

  1. (function($)
  2. {
  3. $.fn.et_switcher = function(options)
  4. {
  5. var defaults =
  6. {
  7.   slides: '>div',
  8.   activeClass: 'active',
  9.   linksNav: '',
  10.   findParent: true, //use parent elements in defining lengths
  11.   lengthElement: 'li', //parent element, used only if findParent is set to true
  12.   useArrows: false,
  13.   arrowLeft: 'prevlink',
  14.   arrowRight: 'nextlink',
  15.   auto: false,
  16.   autoSpeed: <?php echo(get_option($shortname.'_slider_autospeed')); ?>
  17. };

  18. var options = $.extend(defaults, options);

  19. return this.each(function()
  20. {
  21. var slidesContainer = jQuery(this);
  22. slidesContainer.find(options.slides).hide().end().find(options.slides).filter(':first').css('display','block');
  23.  
  24. if (options.linksNav != '') {
  25. var linkSwitcher = jQuery(options.linksNav);
  26. linkSwitcher.click(function(){
  27. var targetElement;

  28. if (options.findParent) targetElement = jQuery(this).parent();
  29. else targetElement = jQuery(this);
  30. if (targetElement.hasClass('active')) return false;
  31. jQuery('div.item .active').animate({marginTop: '0px'},500,function(){
  32. jQuery(this).removeClass('active');
  33. });
  34. jQuery(this).animate({marginTop: '-15px'},500,function(){
  35. jQuery(this).addClass('active');
  36. });
  37. var ordernum = targetElement.prevAll(options.lengthElement).length;
  38. slidesContainer.find(options.slides).filter(':visible').hide().end().end().find(options.slides).filter(':eq('+ordernum+')').stop().fadeIn(700);
  39. jQuery('div.#slides div.slide div.banner').css('top', '0px');
  40. slidesContainer.find(options.slides).filter(':visible').children('div').animate({top: '90px'}, 300);
  41. if (typeof interval != 'undefined') {
  42. clearInterval(interval);
  43. auto_rotate();
  44. };
  45. return false;
  46. });
  47. };
  48. jQuery('#'+options.arrowRight+', #'+options.arrowLeft).click(function(){
  49.  
  50. var slideActive = slidesContainer.find(options.slides).filter(":visible"),
  51. nextSlide = slideActive.next(),
  52. prevSlide = slideActive.prev();

  53. if (jQuery(this).attr("id") == options.arrowRight) {
  54. if (nextSlide.length) {
  55. var ordernum = nextSlide.prevAll().length;                        
  56. } else { var ordernum = 0; }
  57. };

  58. if (jQuery(this).attr("id") == options.arrowLeft) {
  59. if (prevSlide.length) {
  60. var ordernum = prevSlide.prevAll().length;                  
  61. } else { var ordernum = slidesContainer.find(options.slides).length-1; }
  62. };

  63. slidesContainer.find(options.slides).filter(':visible').hide().end().end().find(options.slides).filter(':eq('+ordernum+')').stop().fadeIn(700);

  64. if (typeof interval != 'undefined') {
  65. clearInterval(interval);
  66. auto_rotate();
  67. };

  68. return false;
  69. });   

  70. if (options.auto) {
  71. auto_rotate();
  72. };
  73. function auto_rotate(){
  74. interval = setInterval(function(){
  75. var slideActive = slidesContainer.find(options.slides).filter(":visible"),
  76. nextSlide = slideActive.next();
  77.  
  78. if (nextSlide.length) {
  79. var ordernum = nextSlide.prevAll().length;                        
  80. } else { var ordernum = 0; }
  81.  
  82. if (options.linksNav === '') 
  83. jQuery('#'+options.arrowRight).trigger("click");
  84. else
  85. linkSwitcher.filter(':eq('+ordernum+')').trigger("click");
  86. },options.autoSpeed);
  87. };
  88. });
  89. }
  90. })(jQuery);
  91. var $featuredArea = jQuery('#featured #slides');
  92. if ($featuredArea.length) {
  93. $featuredArea.et_switcher({
  94. linksNav: '#switcher div div.wrap',
  95. auto: <?php if (get_option($shortname.'_slider_auto') == 'on') print "true"; else print "false";  ?>,
  96. autoSpeed: <?php echo(get_option($shortname.'_slider_autospeed')); ?>,
  97. findParent: true,
  98. lengthElement: 'div'
  99. });
  100. };

  101. jQuery('div.#slides div.active div.banner').css('top', '90px');

    • Topic Participants

    • dru6