1(function($){ 2 'use strict'; 3 $(document).ready(function(){ 4 5 var carousel_container = $('.carousel-container'); 6 7 function carousel_init(){ 8 carousel_container.each(function(){ 9 var carousel = $(this); 10 var carousel_holder = carousel.children('.carousel-item-holder'); 11 var carousel_item = carousel.find('.carousel-item'); 12 13 carousel_item.css('float', 'left'); 14 15 var child_size; 16 if( carousel_item.filter(':first').hasClass('three') ){ 17 carousel_holder.attr('data-num', 4); 18 child_size = carousel.parents('.row').width() / 4; 19 }else if( carousel_item.filter(':first').hasClass('four') ){ 20 carousel_holder.attr('data-num', 3); 21 child_size = carousel.parents('.row').width() / 3; 22 }else if( carousel_item.filter(':first').hasClass('six') ){ 23 carousel_holder.attr('data-num', 2); 24 child_size = carousel.parents('.row').width() / 2; 25 } 26 27 if( $(window).width() <= '767' ){ 28 carousel_holder.attr('data-num', 1); 29 child_size = carousel_item.width() + 15; //carousel.parents('.row').width(); 30 } 31 32 child_size += 9; 33 34 carousel_item.width( child_size - 25 ); 35 36 carousel_holder.attr('data-width', child_size); 37 carousel_holder.attr('data-max', carousel_item.length); 38 carousel_holder.width( carousel_item.length * child_size ); 39 40 var cur_index = parseInt(carousel_holder.attr('data-index')); 41 carousel_holder.css({ 'margin-left': -(cur_index * child_size + 12.5) }); 42 }); 43 } 44 45 // bind the navigation 46 var carousel_nav = carousel_container.children('.carousel-navigation'); 47 carousel_nav.children('.carousel-prev').click(function(){ 48 var carousel_holder = $(this).parent('.carousel-navigation').siblings('.carousel-item-holder'); 49 var cur_index = parseInt(carousel_holder.attr('data-index')); 50 51 if( cur_index > 0 ){ cur_index--; } 52 53 carousel_holder.attr('data-index', cur_index); 54 carousel_holder.animate({ 'margin-left': -(cur_index * parseInt(carousel_holder.attr('data-width')) + 12.5) }); 55 }); 56 carousel_nav.children('.carousel-next').click(function(){ 57 var carousel_holder = $(this).parent('.carousel-navigation').siblings('.carousel-item-holder'); 58 var cur_index = parseInt(carousel_holder.attr('data-index')); 59 60 if( cur_index + parseInt(carousel_holder.attr('data-num')) < parseInt(carousel_holder.attr('data-max')) ){ 61 cur_index++; 62 } 63 64 carousel_holder.attr('data-index', cur_index); 65 carousel_holder.animate({ 'margin-left': -(cur_index * parseInt(carousel_holder.attr('data-width')) + 12.5) }); 66 }); 67 68 carousel_init(); 69 70 //Auto animate 71 //var infiniteLoop = setInterval(function(){ 72 // carousel_nav.children('.carousel-next').trigger('click'); 73 //}, 1000); 74 75 $(window).resize(function(){ 76 carousel_init(); 77 }); 78 }); 79 80})(jQuery);
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.