1/* Index carousel slider 2 * @author Simon Pollard for Blue Fuse Systems 3 * @date May 2012 4 * @version 1.2 5 */ 6 7/* 8 * Initial start up function 9 */ 10 11// jQuery no conflict mode. 12var $j = jQuery.noConflict(); 13 14// Page load functionss 15$j(document).ready(function() { 16 17 // Check if we have a carousel on the page 18 if ($j(".carousel-content").length > 0){ 19 20 // Get each of the slides 21 kids = $j(".carousel-images").children(); 22 23 // Create an array to hold the id's of our slides 24 slides = new Array(); 25 26 kids.each(function(){ 27 // Add the id's of the slide divs to our array 28 slides.push($j(this).attr("id")); 29 }); 30 31 // We need to find out how many slides there are 32 total_slides = slides.length; 33 34 // Current slide is first array item 35 current_carousel = 1; 36 37 // Get all the carousel dots 38 kids = $j('#carousel .dots p').children(); 39 // And then loop through them all 40 kids.each(function(){ 41 // Add click functionality 42 $j(this).click(function(){ 43 dot_id = $j(this).attr('id'); 44 dot_id = dot_id.replace('slide_',''); 45 dot_id = dot_id.replace('_dot',''); 46 animate_slides(dot_id); 47 }); 48 // Stop the animation on mouse enter 49 $j(this).mouseenter(function() { 50 $j(".carousel-content").stopTime(); 51 }); 52 // And start it again on mouse leave 53 $j(this).mouseleave(function() { 54 carousel_timer(); 55 }); 56 }); 57 58 // Start carousel animation 59 carousel_timer(); 60 61 // Add functionality to stop timer when user is hovering over gallery 62 $j(".carousel-content").mouseenter(function() { 63 $j(".carousel-content").stopTime(); 64 }); 65 66 // Start timer again once they leave the gallery 67 $j(".carousel-content").mouseleave(function() { 68 carousel_timer(); 69 }); 70 71 // If using previous and next nav 72 if ($j(".carousel-content .prev").length > 0){ 73 $j(".carousel-content .prev").click(function(event){ 74 animate_slides('prev'); 75 }); 76 $j(".carousel-content .next").click(function(event){ 77 animate_slides('next'); 78 }); 79 } 80 81 } 82}); 83 84/** 85 * Basic timer on loop to call next slide function 86 * 87 */ 88function carousel_timer() { 89 // Make sure we remove any timers already set 90 $j(".carousel-content").stopTime(); 91 $j(".carousel-content").everyTime(6000, function() { 92 animate_slides(); 93 }); 94} 95 96/* 97 * Animates to next slide 98 * @requires var slide_direction 99 */ 100function animate_slides(next_carousel_id) { 101 102 // Make sure our value is a number 103 current_carousel=parseInt(current_carousel); 104 105 // Un-highlight the current dot 106 $j('#slide_'+current_carousel+'_dot').removeClass('selected'); 107 108 // If we are on the last item 109 if (current_carousel == total_slides){ 110 // Our next slide will be back to the first one 111 next_carousel = 1; 112 } else { 113 // Otherwise its the next in sequence 114 next_carousel = current_carousel+1; 115 } 116 117 // If we were passed a specific ID 118 if(next_carousel_id!=null && next_carousel_id!=undefined) { 119 120 // Check if we are passed next or prev first 121 if(next_carousel_id == 'next') { 122 // Do nothing 123 } else if (next_carousel_id == 'prev') { 124 if(current_carousel == 1) { 125 next_carousel = total_slides; 126 } else { 127 next_carousel = current_carousel-1; 128 } 129 } else { 130 // Make sure our value is a number 131 next_carousel_id = parseInt(next_carousel_id); 132 next_carousel = next_carousel_id; 133 next_carousel_id = null; 134 } 135 } 136 137 // Fade out the current slide 138 $j('.carousel').fadeOut(600); 139 140 // Now fade in the next slide 141 $j("#slide_"+next_carousel).fadeIn(600, function() { 142 // Highlight the correct dot
143 $j('#slide_'+next_carousel+'_dot').addClass('selected'); 144 current_carousel = next_carousel; 145 }); 146}
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.