jQuery(document).ready(function($){ /***************** PARALLAX FUNCTION ******************/ var $window = $(window); var windowHeight = $window.height(); $window.resize(function () { windowHeight = $window.height(); }); $.fn.parallax = function(xpos, speedFactor, outerHeight) { var $this = $(this); var getHeight; var firstTop; var paddingTop = 0; //get the starting position of each element to have parallax applied to it $this.each(function(){ firstTop = $this.offset().top; }); $window.resize(function () { $this.each(function(){ firstTop = $this.offset().top; }); }); $window.load(function(){ $this.each(function(){ firstTop = $this.offset().top; }); }); getHeight = function(jqo) { return jqo.outerHeight(true); }; // setup defaults if arguments aren't specified if (arguments.length < 1 || xpos === null) xpos = "50%"; if (arguments.length < 2 || speedFactor === null) speedFactor = 0.1; if (arguments.length < 3 || outerHeight === null) outerHeight = true; // function to be called whenever the window is scrolled or resized function update(){ var pos = $window.scrollTop(); $this.each(function(){ var $element = $(this); var top = $element.offset().top; var height = getHeight($element); // Check if totally above or totally below viewport if (top + height < pos || top > pos + windowHeight) { return; } $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px"); }); } $window.bind('scroll', update).resize(update); update(); }; $.fn.countTo = function (options) { options = options || {}; return $(this).each(function () { // set options for current element var settings = $.extend({}, $.fn.countTo.defaults, { from: $(this).data('from'), to: $(this).data('to'), speed: $(this).data('speed'), refreshInterval: $(this).data('refresh-interval'), decimals: $(this).data('decimals') }, options); // how many times to update the value, and how much to increment the value on each update var loops = Math.ceil(settings.speed / settings.refreshInterval), increment = (settings.to - settings.from) / loops; // references & variables that will change with each update var self = this, $self = $(this), loopCount = 0, value = settings.from, data = $self.data('countTo') || {}; $self.data('countTo', data); // if an existing interval can be found, clear it first if (data.interval) { clearInterval(data.interval); } data.interval = setInterval(updateTimer, settings.refreshInterval); // initialize the element with the starting value render(value); function updateTimer() { value += increment; loopCount++; render(value); if (typeof(settings.onUpdate) == 'function') { settings.onUpdate.call(self, value); } if (loopCount >= loops) { // remove the interval $self.removeData('countTo'); clearInterval(data.interval); value = settings.to; if (typeof(settings.onComplete) == 'function') { settings.onComplete.call(self, value); } } } function render(value) { var formattedValue = settings.formatter.call(self, value, settings); $self.html(formattedValue); } }); }; $.fn.countTo.defaults = { from: 0, // the number the element should start at to: 0, // the number the element should end at speed: 1000, // how long it should take to count between the target numbers refreshInterval: 100, // how often the element should be updated decimals: 0, // the number of decimal places to show formatter: formatter, // handler for formatting the value before rendering onUpdate: null, // callback method for every time the element is updated onComplete: null // callback method for when the element finishes updating }; function formatter(value, settings) { return value.toFixed(settings.decimals); } /***************** BAR GRAPH ******************/ $('.thmlv-short-progress-bar').each(function(i){ $(this).appear(function(){ var percent = $(this).find('span').attr('data-width'); var $endNum = parseInt($(this).find('strong i').text()); var $that = $(this); $(this).find('span').animate({ 'width' : percent + '%' },1600, 'easeOutCirc',function(){ }); $(this).find('strong').animate({ 'opacity' : 1 },1350); $(this).find('strong i').countTo({ from: 0, to: $endNum, speed: 1100, refreshInterval: 30, onComplete: function(){ } }); ////100% progress bar if(percent == '100'){ $that.find('strong').addClass('full'); } }); }); /***************** CIRCULAR GRAPH ******************/ $(".knob").knob(); $('.knob').each(function(){ $(this).appear(function(){ var currId = $(this).attr("id"); currId = "#" + currId; if($(currId).val() == 0) { $({value: 0}).animate({value: $(currId).attr("rel")}, { duration: 900, easing:'swing', step: function() { $(currId).val(Math.ceil(this.value)).trigger('change'); } }) } }); }); /***************** COLUMNS ANIMATION ******************/ $('.thmlv-short-col.has-animation').each(function() { $(this).appear(function() { if($(this).attr('data-animation') == 'fade-in-from-left'){ $(this).delay($(this).attr('data-delay')).animate({ 'opacity' : 1, 'left' : '0px' },800,'easeOutSine'); } else if($(this).attr('data-animation') == 'fade-in-from-right'){ $(this).delay($(this).attr('data-delay')).animate({ 'opacity' : 1, 'right' : '0px' },800,'easeOutSine'); } else if($(this).attr('data-animation') == 'fade-in-from-bottom'){ $(this).delay($(this).attr('data-delay')).animate({ 'opacity' : 1, 'bottom' : '0px' },800,'easeOutSine'); } else if($(this).attr('data-animation') == 'fade-in') { $(this).delay($(this).attr('data-delay')).animate({ 'opacity' : 1 },800,'easeOutSine'); } else if($(this).attr('data-animation') == 'grow-in') { var $that = $(this); setTimeout(function(){ $that.transition({ scale: 1, 'opacity':1 },900,'cubic-bezier(0.15, 0.84, 0.35, 1.25)'); },$that.attr('data-delay')); } },{accX: 0, accY: -105},'easeInCubic'); }); /***************** FULL WIDTH SECTION ******************/ $('.thmlv-short-full-width-section.parallax_section').each(function(){ var $id = $(this).attr('id'); $('#'+$id + ".parallax_section").parallax("50%", 0.2); }); $('.thmlv-short-full-width-section').each(function(){ var $fwsHeight = $(this).outerHeight(true); //make sure it's empty and also not being used as a small dvider if($(this).find('.container *').length == 0 && $.trim( $(this).find('.container').text() ).length == 0 && $fwsHeight > 40){ $(this).addClass('bg-only'); $(this).css({'height': $fwsHeight, 'padding-top': '0px', 'padding-bottom': '0px'}); $(this).attr('data-image-height',$fwsHeight); } }); function fullwidthImgOnlySizing(){ $('.thmlv-short-full-width-section.bg-only').each(function(){ var $initialHeight = $(this).attr('data-image-height'); if( window.innerWidth < 1000 && window.innerWidth > 690 ) { $(this).css('height', $initialHeight - $initialHeight*.60); } else if( window.innerWidth <= 690 ) { $(this).css('height', $initialHeight - $initialHeight*.78); } else if( window.innerWidth < 1300 && window.innerWidth >= 1000 ) { $(this).css('height', $initialHeight - $initialHeight*.33); } else { $(this).css('height', $initialHeight); } }); } fullwidthImgOnlySizing(); /***************** IMAGES ANIMATION ******************/ $('img.img-with-animation').each(function() { $(this).appear(function() { if($(this).attr('data-animation') == 'fade-in-from-left'){ $(this).delay($(this).attr('data-delay')).animate({ 'opacity' : 1, 'left' : '0px' },800,'easeOutSine'); } else if($(this).attr('data-animation') == 'fade-in-from-right'){ $(this).delay($(this).attr('data-delay')).animate({ 'opacity' : 1, 'right' : '0px' },800,'easeOutSine'); } else if($(this).attr('data-animation') == 'fade-in-from-bottom'){ $(this).delay($(this).attr('data-delay')).animate({ 'opacity' : 1, 'bottom' : '0px' },800,'easeOutSine'); } else if($(this).attr('data-animation') == 'fade-in') { $(this).delay($(this).attr('data-delay')).animate({ 'opacity' : 1 },800,'easeOutSine'); } else if($(this).attr('data-animation') == 'grow-in') { var $that = $(this); setTimeout(function(){ $that.transition({ scale: 1, 'opacity':1 },900,'cubic-bezier(0.15, 0.84, 0.35, 1.25)'); },$that.attr('data-delay')); } },{accX: 0, accY: -105},'easeInCubic'); }); /***************** FULL WIDTH ******************/ function fullWidthSections(){ var $shortWindowWidth = ($(window).width() <= parseInt($('#thmlv-main').css('max-width'))) ? parseInt($('#thmlv-main').css('max-width')) : $(window).width(); $justOutOfSight = Math.ceil( (($shortWindowWidth - parseInt($('#thmlv-main').css('max-width'))) / 2) ) //alert($justOutOfSight); $('.thmlv-short-full-width-section').each(function(){ $(this).css({ 'margin-left': - $justOutOfSight, 'padding-left': $justOutOfSight, 'padding-right': $justOutOfSight, 'visibility': 'visible' }); }); }; fullWidthSections(); /***************** MILESTONE COUNTER ******************/ if(!$('body').hasClass('mobile')) { $('.thmlv-short-milestone').each(function() { //symbol if($(this).has('[data-symbol]')) { if($(this).attr('data-symbol-pos') == 'before') { $(this).find('.thmlv-short-number').prepend($(this).attr('data-symbol')); } else { $(this).find('.thmlv-short-number').append($(this).attr('data-symbol')); } } //animation $(this).appear(function() { var $endNum = parseInt($(this).find('.thmlv-short-number span').text()); $(this).find('.thmlv-short-number span').countTo({ from: 0, to: $endNum, speed: 1500, refreshInterval: 20 }); },{accX: 0, accY: 0}); }); } /***************** TABBED ******************/ $('.thmlv-short-tabbed > ul li a').click(function(){ var $id = $(this).attr('href'); if(!$(this).hasClass('thmlv-short-active-tab') && !$(this).hasClass('thmlv-short-loading')){ $(this).parents('ul').find('a').removeClass('thmlv-short-active-tab'); $(this).addClass('thmlv-short-active-tab'); $(this).parents('.thmlv-short-tabbed').find('> div:not(.thmlv-short-clear)').css({'visibility':'hidden','position':'absolute','opacity':'0','left':'-9999px','display':'none'}); $(this).parents('.thmlv-short-tabbed').find('> div'+$id).css({'visibility':'visible', 'position' : 'relative','left':'0','display':'block'}).stop().animate({'opacity':1}); if($(this).parents('.thmlv-short-tabbed').find('> div'+$id + ' .iframe-embed').length > 0) responsiveVideoIframes(); } return false; }); $('.thmlv-short-tabbed').each(function(){ if($(this).find('.thmlv-short-testimonial_slider').length == 0 && $(this).find('iframe').length == 0){ $(this).find('> ul li:first-child a').click(); } if($(this).find('.thmlv-short-testimonial_slider').length == 1 || $(this).find('iframe').length > 0 ){ var $that = $(this); $(this).find('.thmlv-short-tab').show().css({'opacity':0,'height':'1px'}); $(this).find('> ul li a').addClass('thmlv-short-loading'); setTimeout(function(){ $that.find('.thmlv-short-tab').hide().css({'opacity':1,'height':'auto'}); $that.find('> ul li a').removeClass('thmlv-short-loading'); $that.find('> ul li:first-child a').click(); },900); } }); /***************** Testimonial Slider ******************/ $('.thmlv-short-testimonial_slider').animate({'opacity':'1'},800); //testimonial slider controls $('body').on('click','.thmlv-short-testimonial_slider .thmlv-short-controls li', function(){ if($(this).find('span').hasClass('thmlv-short-active')) return false; var $index = $(this).index(); var currentHeight = $(this).parents('.thmlv-short-testimonial_slider').find('.thmlv-short-slides blockquote').eq($index).height(); $(this).parents('.thmlv-short-testimonial_slider').find('li').html(''); $(this).html(''); $(this).parents('.thmlv-short-testimonial_slider').find('.thmlv-short-slides blockquote').stop().css({'opacity':'0', 'left':'-25px', 'z-index': '1'}); $(this).parents('.thmlv-short-testimonial_slider').find('.thmlv-short-slides blockquote').eq($index).stop(true,true).animate({'opacity':'1','left':'0'},550,'easeOutCubic').css('z-index','20'); $(this).parents('.thmlv-short-testimonial_slider').find('.thmlv-short-slides').stop(true,true).animate({'height' : currentHeight + 20 + 'px' },450,'easeOutCubic'); }); var $tallestQuote; //create controls $('.thmlv-short-testimonial_slider').each(function(){ $(this).append('