1// Function returns a random number between 1 and n 2function rand(n){return(Math.floor(Math.random()*n+1));} 3 4jQuery(document).ready(function($){ 5 6 // Disable HTML title attribute for slider images 7 $('.promo_slider img').removeAttr('title'); 8 9 // Get all instances of promo_slider on the page 10 var sliders = $('.promo_slider_wrapper'); 11 12 // Cycle through each slider 13 $.each(sliders, function(){ 14 15 // Define current slider 16 var currentSlider = $(this); 17 var thisSlider = $('.promo_slider', currentSlider); 18 19 // Get all panels 20 var panels = $('.panel', thisSlider); 21 22 // Get total count of panels 23 var panelCount = panels.length; 24 25 // Set number for first panel 26 var initialPanel; 27 if( promoslider_options.startOn == 'first' ) { 28 initialPanel = 1; 29 } else { 30 initialPanel = rand(panelCount); 31 } 32 if( currentSlider.hasClass('random') ) initialPanel = rand(panelCount); 33 if( currentSlider.hasClass('first') ) initialPanel = 1; 34 35 // Should we pause the slider on mouseover? 36 var pauseOnMouseover = currentSlider.hasClass('pause'); 37 38 // Assign variable for setInterval 39 var sliderInterval; 40 41 // Set time delay 42 var timeDelay = promoslider_options.timeDelay; 43 if( $('.promo_slider_time_delay', thisSlider).html() ){ 44 timeDelay = $('.promo_slider_time_delay', thisSlider).html(); 45 } 46 47 // Set auto advance variable 48 var autoAdvance = promoslider_options.autoAdvance; 49 if( thisSlider.hasClass('auto_advance') ) autoAdvance = true; 50 if( thisSlider.hasClass('no_auto_advance') ) autoAdvance = false; 51 if( panelCount < 2 ) autoAdvance = false; 52 53 // Set navigation option 54 var navOption = promoslider_options.nav_option; 55 if( currentSlider.hasClass('default_nav') ) navOption = 'default'; 56 else if( currentSlider.hasClass('fancy_nav') ) navOption = 'fancy'; 57 else if( currentSlider.hasClass('links_nav') ) navOption = 'links'; 58 else if( currentSlider.hasClass('thumb_nav') ) navOption = 'thumb'; 59 else if( currentSlider.hasClass('tabbed_nav') ) navOption = 'tabbed'; 60 else navOption = false; 61 62 // Hide all panels 63 panels.hide(); 64 65 // Show initial panel and add class 'current' to active panel 66 $('.panel-' + initialPanel, currentSlider).show().addClass('current'); 67 68 if(panelCount > 1 && (navOption == 'default' || navOption == 'fancy' || navOption == 'thumb' || navOption == 'tabbed' ) ){ 69 70 var navHTML; 71 72 if( 'tabbed' != navOption ) { 73 $('.promo_slider_nav').not('.tabbed_ps_nav').show(); 74 } 75 $('.promo_slider_thumb_nav').show(); 76 77 if(navOption == 'tabbed'){ 78 // Generate HTML for navigation 79 navHTML = ''; 80 $.each(panels, function(index, object){ 81 // Set panel title 82 var panelTitle = $('.panel-'+(index+1)+' span.panel-title', currentSlider).html(); 83 var newSpan = '<span class="'+(index+1)+'" title="'+panelTitle+'">'+panelTitle+'</span>'; 84 navHTML = navHTML + newSpan; 85 }); 86 87 // Insert HTML into nav 88 $('.slider_selections', currentSlider).html(navHTML); 89 } 90 91 if(navOption == 'fancy' || navOption == 'default'){ 92 // Generate HTML for navigation 93 navHTML = ''; 94 $.each(panels, function(index, object){ 95 // Set panel title 96 panelTitle = $('.panel-'+(index+1)+' span.panel-title', currentSlider).html(); 97 newSpan = '<span class="'+(index+1)+'" title="'+panelTitle+'">'+(index+1)+'</span>'; 98 if( (index + 1) != panelCount){newSpan = newSpan + '<b class="promo_slider_sep"> | </b>';} 99 navHTML = navHTML + newSpan; 100 }); 101 102 // Insert HTML into nav 103 $('.slider_selections', currentSlider).html(navHTML); 104 } 105 106 // Set click functions for each span in the slider nav 107 var slideNav = $('.slider_selections span', currentSlider); 108 $.each(slideNav, function(index, object){ 109 $(object).click(function(){ 110 clearInterval(sliderInterval); 111 if( !$(object).hasClass('current') ) progress($(object).attr('class'), currentSlider, panelCount); 112 if(autoAdvance) sliderInterval = setInterval(function(){progress('forward', currentSlider, panelCount);}, (timeDelay * 1000)); 113 }); 114 }); 115 116 // Set active span class to 'current' 117 $('.slider_selections span[class=' + initialPanel + ']', currentSlider).addClass('current'); 118 119 } 120 121 // Create click functions for navigational elements 122 $('.move_forward', currentSlider).click(function(){ 123 clearInterval(sliderInterval); 124 progress('forward', currentSlider, panelCount); 125 if(autoAdvance) sliderInterval = setInterval(function(){progress('forward', currentSlider, panelCount);}, (timeDelay * 1000)); 126 });
127 $('.move_backward', currentSlider).click(function(){ 128 clearInterval(sliderInterval); 129 progress('backward', currentSlider, panelCount); 130 if(autoAdvance) sliderInterval = setInterval(function(){progress('forward', currentSlider, panelCount);}, (timeDelay * 1000)); 131 }); 132 133 134 if( autoAdvance ){ 135 136 // Begin auto advancement of slides 137 sliderInterval = setInterval(function(){progress('forward', currentSlider, panelCount);}, (timeDelay * 1000)); 138 139 if( pauseOnMouseover ){ 140 141 // Pause slide advancement on mouseover 142 $(thisSlider).mouseover(function(){ 143 clearInterval(sliderInterval); 144 }); 145 146 // Continue slide advancement on mouseout 147 $(thisSlider).mouseout(function(){ 148 sliderInterval = setInterval(function(){progress('forward', currentSlider, panelCount);}, (timeDelay * 1000)); 149 }); 150 151 } 152 153 } 154 155 }); 156 157 // Progress to selected panel 158 function progress(value, currentSlider, panelCount){ 159 160 // Find number of current panel 161 var currentValue = $('div.promo_slider > .panel', currentSlider).index($('div.panel.current', currentSlider)) + 1; 162 163 var panels = $('.panel', currentSlider); 164 var current = $('.panel.current', currentSlider); 165 166 panels.stop( true, true ); 167 168 // Set value of new panel 169 var panelNum; 170 if( value == 'forward' ){
171 panelNum = current.is( panels.last() ) ? 1: currentValue + 1; 172 } else if(value == 'backward'){ 173 panelNum = current.is( panels.first() ) ? panels.length: currentValue - 1; 174 } else{ 175 panelNum = value; 176 } 177 178 // Assign variables for ease of use 179 var next = $('.panel-' + panelNum, currentSlider); 180 var currentSpan = $('.slider_selections span.current', currentSlider); 181 var newSpan = $('.slider_selections span.' + panelNum, currentSlider); 182 183 // Add / Remove classes 184 current.removeClass('current'); 185 next.addClass('current'); 186 currentSpan.removeClass('current'); 187 newSpan.addClass('current'); 188 189 // Fade in / out 190 next.hide().css({ 'z-index':1 }); 191 current.css({ 'z-index':0 }); 192 193 next.fadeIn( 1200, 'swing', function() { 194 current.hide(); 195 } ); 196 197 } 198 199});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.