// ------------------------------------------------------------------------------------------- // avia timeline // ------------------------------------------------------------------------------------------- (function($) { "use strict"; $(window).on('load', function (e) { if ($.aviaslider) { $('.avia-timeline-container').avia_sc_timeline(); } }); $.fn.avia_sc_timeline = function (options) { return this.each(function () { var container = this, timeline_id = '#' + $(this).attr('id'), timeline = $(timeline_id), methods; methods = { // make sure all milestones have the same height in horizontal timelines matchheights: function(){ //date this.setminheight( $(timeline_id + ' .av-milestone-placement-top .av-milestone-date'), true ); //content this.setminheight( $(timeline_id + ' .av-milestone-placement-bottom .av-milestone-content-wrap'), true ); //contentbox this.setminheight( $(timeline_id + ' .av-milestone-placement-bottom.avia-timeline-boxshadow .av-milestone-contentbox'), false ); this.setminheight( $(timeline_id + ' .av-milestone-placement-top.avia-timeline-boxshadow .av-milestone-contentbox'), false ); //alternate this.setminheight( $(timeline_id + ' .avia-timeline-horizontal.av-milestone-placement-alternate li >:first-child'), true ); }, setminheight: function( els, setnav ) { if(els.length < 2) return; var elsheights = new array(); els.css('min-height','0').each(function(i) { var current = $(this); var currentheight = current.outerheight(true); elsheights.push(currentheight); }); var largest = math.max.apply(null, elsheights); els.css('min-height', largest); //set nav position if (setnav) { var $firstelement = els.first(), $parent = $firstelement.closest('.avia-timeline-container'), $pos = $firstelement.height(); $parent.find('.av-timeline-nav').css('top',$pos); } }, createcarousel : function(e){ var self = this, slider = $(timeline_id + '.avia-slideshow-carousel'), slides_num = 3, slides_num_small = 1; if (timeline.attr('avia-data-slides')) { slides_num = parseint(timeline.attr('avia-data-slides')); } if (slides_num >= 2) { slides_num_small = 2; } var slideroptions = { carousel : 'yes', keep_pading : true, carouselslidestoshow : slides_num, carouselslidestoscroll : 3, carouselresponsive : [ { breakpoint: 989, settings: { carouselslidestoshow: slides_num_small, carouselslidestoscroll: slides_num_small, } }, { breakpoint: 767, settings: { carouselslidestoshow: 1, carouselslidestoscroll: 1, } } ], } slider.aviaslider(slideroptions); slider.on('_kickoff',function(){ self.matchheights(); }); $(window).on( 'resize', function() { self.matchheights(); }); }, layouthelpers : function(e){ $(timeline_id + ' .avia-timeline-vertical li').each(function(index, element){ var $length = $(this).parents('ul').find('li').length; var $icon_wrap = $(this).find('.av-milestone-icon-wrap'); var $icon_wrap_height = $icon_wrap.outerheight(true); var $icon_wrap_height_half = parseint($icon_wrap_height/2); if (index === ($length - 1)) { $icon_wrap.css({ 'height' : $icon_wrap_height_half, }); } else { $icon_wrap.css({ 'height' : $icon_wrap_height, }); } }); }, fireanimations : function(e) { if ( $(timeline_id + ' > ul').hasclass('avia-timeline-vertical') ) { var milestone = timeline.find('.av-milestone'); timeline.on('avia_start_animation', function() { milestone.each(function(i) { var element = $(this); settimeout(function(){ element.addclass('avia_start_animation') }, (i * 350)); }); }); } } }; methods.createcarousel(); methods.layouthelpers(); methods.fireanimations(); methods.matchheights(); }); } })(jquery);