1// ------------------------------------------------------------------------------------------- 2// Avia Timeline 3// ------------------------------------------------------------------------------------------- 4 5 6(function($) 7{ 8 "use strict"; 9 10 $(window).on('load', function (e) 11 { 12 if( $.AviaSlider ) 13 { 14 $('.avia-timeline-container').avia_sc_timeline(); 15 } 16 }); 17 18 19 $.fn.avia_sc_timeline = function (options) 20 { 21 return this.each( function () 22 { 23 var container = this, 24 timeline_id = '#' + $(this).attr('id'), 25 timeline = $(timeline_id), 26 methods; 27 28 methods = 29 { 30 // make sure all milestones have the same height in horizontal timelines 31 matchHeights: function() 32 { 33 //date 34 this.setMinHeight( $(timeline_id + ' .av-milestone-placement-top .av-milestone-date'), true ); 35 36 //content 37 this.setMinHeight( $(timeline_id + ' .av-milestone-placement-bottom .av-milestone-content-wrap'), true ); 38 39 //contentbox 40 this.setMinHeight( $(timeline_id + ' .av-milestone-placement-bottom.avia-timeline-boxshadow .av-milestone-contentbox'), false ); 41 this.setMinHeight( $(timeline_id + ' .av-milestone-placement-top.avia-timeline-boxshadow .av-milestone-contentbox'), false ); 42 43 //alternate 44 this.setMinHeight( $(timeline_id + ' .avia-timeline-horizontal.av-milestone-placement-alternate li >:first-child'), true ); 45 }, 46 47 setMinHeight: function( els, setNav ) 48 { 49 if(els.length < 2) 50 { 51 return; 52 } 53 54 var elsHeights = new Array(); 55 els.css('min-height','0').each( function(i) 56 { 57 var current = $(this); 58 var currentHeight = current.outerHeight(true); 59 elsHeights.push(currentHeight); 60 }); 61 62 var largest = Math.max.apply( null, elsHeights ); 63 els.css('min-height', largest); 64 65 //set nav position 66 if( setNav ) 67 { 68 var $firstElement = els.first(), 69 $parent = $firstElement.closest('.avia-timeline-container'), 70 $pos = $firstElement.height(); 71 72 $parent.find('.av-timeline-nav').css( 'top', $pos ); 73 } 74 75 }, 76 77 createCarousel: function(e) 78 { 79 var self = this, 80 slider = $(timeline_id + '.avia-slideshow-carousel'), 81 slides_num = 3, 82 slides_num_small = 1; 83 84 if( timeline.attr('avia-data-slides')) 85 { 86 slides_num = parseInt(timeline.attr('avia-data-slides')); 87 } 88 89 if( slides_num >= 2 ) 90 { 91 slides_num_small = 2; 92 } 93 94 var sliderOptions = { 95 carousel: 'yes', 96 keep_padding: true, 97 carouselSlidesToShow: slides_num, 98 carouselSlidesToScroll: 3, 99 carouselResponsive: [ 100 { 101 breakpoint: 989, 102 settings: { 103 carouselSlidesToShow: slides_num_small, 104 carouselSlidesToScroll: slides_num_small 105 } 106 }, 107 { 108 breakpoint: 767, 109 settings: { 110 carouselSlidesToShow: 1, 111 carouselSlidesToScroll: 1 112 } 113 } 114 ] 115 }; 116 117 slider.aviaSlider( sliderOptions ); 118 119 slider.on('_kickOff',function() 120 { 121 self.matchHeights(); 122 }); 123 124 $(window).on( 'resize', function() 125 { 126 self.matchHeights(); 127 }); 128 129 }, 130 131 layoutHelpers: function(e) 132 { 133 $(timeline_id + ' .avia-timeline-vertical li').each( function(index, element) 134 { 135 var $length = $(this).parents('ul').find('li').length; 136 var $icon_wrap = $(this).find('.av-milestone-icon-wrap'); 137 var $icon_wrap_height = $icon_wrap.outerHeight(true); 138 var $icon_wrap_height_half = parseInt( $icon_wrap_height / 2 ); 139 140 if( index === ( $length - 1 ) ) 141 { 142 $icon_wrap.css({ 143 'height': $icon_wrap_height_half 144 }); 145 } 146 else 147 { 148 $icon_wrap.css({ 149 'height': $icon_wrap_height 150 }); 151 } 152 }); 153 }, 154 155 fireAnimations: function(e) 156 { 157 if( $(timeline_id + ' > ul').hasClass('avia-timeline-vertical') ) 158 { 159 var milestone = timeline.find('.av-milestone'); 160 161 timeline.on('avia_start_animation', function() 162 { 163 milestone.each(function(i) 164 { 165 var element = $(this); 166 setTimeout( function(){ element.addClass('avia_start_animation'); }, ( i * 350 ) ); 167 }); 168 }); 169 } 170 } 171 }; 172 173 methods.createCarousel(); 174 methods.layoutHelpers(); 175 methods.fireAnimations(); 176 methods.matchHeights(); 177 }); 178 }; 179 180})(jQuery); 181
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.