var obj = { 'header_height': '', 'window_height': '', 'window_width': '', 'window_top':'', 'sidebar_sticky':160, sticky_sidebar:function () { var window_top = jQuery(window).scrollTop(); obj.window_top = jQuery(window).scrollTop(); var footer_top = jQuery('.section-cta').offset().top; // var footer_top = jQuery('.quote').offset().top; var div_height = jQuery(".sidebar-sticky").height(); if (window_top + div_height < Math.round(footer_top) - 160)flag = true; if (window_top + div_height > Math.round(footer_top) - 160) { jQuery('.sidebar-sticky').addClass('stick-to-bottom'); flag = false; } else if(window_top > obj.sidebar_sticky){ if (!flag)return; jQuery('.sidebar-sticky').removeClass('stick-to-bottom'); jQuery('.sidebar-sticky').addClass('stick'); } else { jQuery('.sidebar-sticky').removeClass('stick'); } }, init:function(){ obj.window_height = jQuery(window).height(); obj.window_width = jQuery(window).width(); if(jQuery(".sidebar-sticky").length > 0){ obj.sidebar_sticky = jQuery(".sidebar-sticky").offset().top - 130; } if(obj.window_width > 991)jQuery("#sidebar").css("height", jQuery("#main-content").height()); jQuery(window).resize(function () { obj.window_width = jQuery(window).width(); obj.window_height = jQuery(window).height(); if(obj.window_width > 991){ // jQuery("#sidebar").css("height", jQuery("#main-content").height()); }else{ jQuery('.sidebar-sticky').removeClass('stick'); jQuery('.sidebar-sticky').removeClass('stick-to-bottom'); // jQuery("#sidebar").css("height", 'auto'); } }); var contentHeight = jQuery(".blog-content-wrap").height(); var blogSidebar = jQuery(".sidebar-inner-content").height(); jQuery(window).scroll(function () { if(obj.window_width > 991 && contentHeight > blogSidebar){ obj.sticky_sidebar(); } }); var half_height = obj.window_height / 2; var sticky_element = jQuery('.stikcy-share-icon').height() / 3; // console.info(half_height + 'elh'+ sticky_element); console.info('ss:'+half_height); jQuery('.stikcy-share-icon').css({'top': parseInt(half_height) +'px'}); } } jQuery(document).ready(function(){ obj.init(); jQuery('#lp-blog-tabs a').on('click', function (e) { e.preventDefault() // jQuery(this).tab('show') }) // jQuery("#commentform").validate({ // // submitHandler: function(form) { // jQuery(form).submit(); // }, // rules: { // author: { // required: true // }, // comment: { // required: true // }, // email: { // required: true, // email: true, // } // } // // }); // jQuery('.comment-tooltip').tooltip(); /** * Main menu Toggle * */ /** * Hide Main menu on document click * */ jQuery(document).click(function (e) { var target = e.target; if(jQuery('.hamburger').hasClass('open')){ if(jQuery(target).parents('.lp-dropdown__box').length == 0 && !jQuery(target).hasClass('lp-dropdown__box')){ jQuery('.hamburger').toggleClass('open'); jQuery('.hamburger').next().slideUp(function(){ jQuery('html,body').removeClass('noscroll'); jQuery('.lp-menu__item_dropdown').removeClass('open'); jQuery('.lp-menu__item_dropdown').find('.lp-menu__submenu').slideUp(); }); } } jQuery('[data-toggle="tooltip"]').tooltip(); }); }); /* --------------------------- Funnel auto focus on zip code field fixed!. --------------------------- */ jQuery(document).ready(function () { // underscore.js throttle implementation function throttle(func, wait, options) { var context, args, result; var timeout = null; var previous = 0; if (!options) options = {}; var later = function () { previous = options.leading === false ? 0 : Date.now(); timeout = null; result = func.apply(context, args); if (!timeout) context = args = null; }; return function () { var now = Date.now(); if (!previous && options.leading === false) previous = now; var remaining = wait - (now - previous); context = this; args = arguments; if (remaining <= 0 || remaining > wait) { if (timeout) { clearTimeout(timeout); timeout = null; } previous = now; result = func.apply(context, args); if (!timeout) context = args = null; } else if (!timeout && options.trailing !== false) { timeout = setTimeout(later, remaining); } return result; }; }; var $window = jQuery(window); var scrolltriggerMargin = 50; var $blogiframe = jQuery('#custom-pop-iframe'); var blogscrollHandler = function () { window.$ = jQuery; var $this = $(this), windowTop = $this.scrollTop(), windowBottom = $this.height() + windowTop; if($blogiframe.get(0)){ var iframe = $blogiframe.get(0), iframeTop = $blogiframe.offset().top, iframeBottom = $blogiframe.height() + iframeTop; if (iframeTop <= windowBottom + scrolltriggerMargin && iframeBottom >= windowTop - scrolltriggerMargin) { iframe.contentWindow.jQuery('#enteryourzipcode').show(); } } } jQuery(document).on('lpIfarmeReady', function (){ $window.on('scroll', throttle(blogscrollHandler, 250)); blogscrollHandler(); var scrollHandlerFirstCall = true; window.addEventListener('message', function (e) { blogscrollHandler(); scrollHandlerFirstCall = false; }); }); });