var obj = { 'header_height': '', 'window_height': '', 'window_width': '', 'window_top':'', 'sidebar_sticky':286, set_menu_box_height:function () { obj.window_height = jQuery(window).height(); obj.header_height = jQuery('.header').height(); var rerquired_height = parseInt(obj.window_height - obj.header_height); if(rerquired_height < 700){ jQuery('.lp-dropdown__scroll').css('max-height' , rerquired_height - 65+'px'); jQuery('.lp-dropdown__box').css('height' , rerquired_height -15+'px'); }else{ jQuery('.lp-dropdown__scroll').css('max-height' , 600+'px'); jQuery('.lp-dropdown__box').css('height' , 681+'px'); } }, sticky_header:function(direction){ var _sticky_header = jQuery('.header'); if(jQuery('.hamburger').hasClass('open')){ jQuery('.hamburger').toggleClass('open'); jQuery('.hamburger').next().hide('fast',function(){ // jQuery('body').removeClass('noscroll'); jQuery('.lp-menu__item_dropdown').removeClass('open'); jQuery('.lp-menu__item_dropdown').find('.lp-menu__submenu').hide(); }); } if (direction == "down") { setTimeout(function () { _sticky_header.css({ 'position': 'fixed', 'background-color': '#fff' }); if(_sticky_header.hasClass('header_inner')){ jQuery('#main-content').css({'padding-top':90+'px'}); } _sticky_header.addClass('header_sticky'); _sticky_header.hide().slideDown('fast'); },200); } else { if(obj.window_width > 991 && !_sticky_header.hasClass('header_inner')){ _sticky_header.css({ 'position': 'absolute', 'background-color': 'transparent' }); }else{ _sticky_header.css({ 'position': 'relative', // 'background-color': 'transparent' }); } if(_sticky_header.hasClass('header_inner')){ jQuery('#main-content').css({'padding-top':0+'px'}); } _sticky_header.removeClass('header_sticky'); } }, sticky_sidebar:function () { var window_top = jQuery(window).scrollTop(); obj.window_top = jQuery(window).scrollTop(); //console.info('top:'+window_top); var footer_top = jQuery('.footer').offset().top; var div_height = jQuery(".sidebar-sticky").height(); if (window_top + div_height < Math.round(footer_top)- 30)flag = true; if (window_top + div_height > Math.round(footer_top) - 30) { 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'); } }, presize:function ($obj, w, h) { var nw = jQuery('body').find($obj).width(), nh = jQuery('body').find($obj).height(); if ((nw > w) && w > 0) { nw = w; nh = (w / jQuery('body').find($obj).width()) * jQuery('body').find($obj).height(); } if ((nh > h) && h > 0) { nh = h; nw = (h / jQuery('body').find($obj).height()) * jQuery('body').find($obj).width(); } xscale = jQuery('body').find($obj).width() / nw; yscale = jQuery('body').find($obj).height() / nh; jQuery('body').find($obj).css({'max-width':nw , 'max-height':nh}); }, sidebar_resize:function () { if(obj.window_width < 1200 && obj.window_width > 991){ // jQuery('.sidebar-sticky').css({'max-width':jQuery('#sidebar').width()-35+'px'}); }else if(obj.window_width < 991){ jQuery('.sidebar-sticky').css({'max-width':'auto'}); }else{ jQuery('.sidebar-sticky').css({'max-width':'325px'}); } }, init:function(){ if(jQuery('body').hasClass('single')){ // obj.sidebar_sticky = 786; } obj.set_menu_box_height(); // obj.sidebar_resize(); obj.window_width = jQuery(window).width(); if(jQuery(".sidebar-sticky").length > 0){ obj.sidebar_sticky = jQuery(".sidebar-sticky").offset().top - 90; } if(obj.window_width > 991)jQuery("#sidebar").css("height", jQuery("#main-content").height()); jQuery(window).resize(function () { obj.window_width = jQuery(window).width(); obj.set_menu_box_height(); // obj.sidebar_resize(); if(obj.window_width > 991){ jQuery("#sidebar").css("height", jQuery("#main-content").height()); }else{ jQuery('.sidebar-sticky').removeClass('stick'); jQuery("#sidebar").css("height", 'auto'); } }); jQuery(window).scroll(function () { if(obj.window_width > 991){ 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); jQuery('.stikcy-share-icon').css({'top': parseInt(half_height) +'px'}); } } jQuery(document).ready(function(){ obj.init(); setTimeout(function(){ obj.presize('.logo', 228 , 70); },100); jQuery("#commentform").validate({ submitHandler: function(form) { console.info('kashif'); jQuery(form).submit(); }, rules: { author: { required: true }, comment: { required: true }, email: { required: true, email: true, } } }); jQuery('.comment-tooltip').tooltip({ // html:true }); /** * Main menu Toggle * */ jQuery('.hamburger').click(function (e) { e.stopPropagation(); if(jQuery(this).hasClass('open')){ jQuery(this).toggleClass('open'); jQuery(this).next().slideUp(function(){ // jQuery('body').removeClass('noscroll'); jQuery('.lp-menu__item_dropdown').removeClass('open'); jQuery('.lp-menu__item_dropdown').find('.lp-menu__submenu').slideUp(); }); }else{ // jQuery('body').addClass('noscroll'); jQuery(this).toggleClass('open'); jQuery(this).next().slideDown(); } }); /** * Sub-Main menu Toggle * */ jQuery('.lp-menu__item_dropdown').on('click' , function(e){ e.preventDefault(); e.stopPropagation(); if(jQuery(this).hasClass('open')){ jQuery(this).toggleClass('open'); jQuery(this).find('.lp-menu__submenu').slideUp(); }else{ jQuery('.lp-menu__item_dropdown').removeClass('open'); jQuery('.lp-menu__item_dropdown').find('.lp-menu__submenu').slideUp(); jQuery(this).toggleClass('open'); jQuery(this).find('.lp-menu__submenu').slideDown(); } }); jQuery('.lp-menu__submenu-item').click(function (e) { e.stopPropagation(); }); /** * 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(); }); } } }); /** * Generate the SVG path * */ jQuery('img.lp-box__svg').each(function(){ var $img = jQuery(this); var imgID = $img.attr('id'); var imgClass = $img.attr('class'); var imgURL = $img.attr('src'); jQuery.get(imgURL, function(data) { // Get the SVG tag, ignore the rest var $svg = jQuery(data).find('svg'); // Add replaced image's ID to the new SVG if(typeof imgID !== 'undefined') { $svg = $svg.attr('id', imgID); } // Add replaced image's classes to the new SVG if(typeof imgClass !== 'undefined') { $svg = $svg.attr('class', imgClass+' replaced-svg'); } // Remove any invalid XML tags as per http://validator.w3.org $svg = $svg.removeAttr('xmlns:a'); // Replace image with new SVG $img.replaceWith($svg); }, 'xml'); // var title = $img.find('title').text("test title!"); }); setTimeout(function () { jQuery('.lp-box').each(function(){ jQuery(this).find('title').text(jQuery(this).find('.lp-box__title').text()); }); },1500); /** * Owl Carousel * */ var _owl = jQuery('.owl-carousel').owlCarousel({ items: 1, loop: false, autoHeight:true, pause: "true", touchDrag: false, mouseDrag: false, }); jQuery('.owl-slider__left').click(function (e) { e.preventDefault(); _owl.trigger('prev.owl.carousel'); }); jQuery('.owl-slider__right').click(function (e) { e.preventDefault(); _owl.trigger('next.owl.carousel'); }); /** * Sticky Header * */ /** * home page * */ if(lp_custom.sticky_menu_display != 'disable'){ jQuery('.lending-solution').waypoint(function (direction) { obj.sticky_header(direction); }); } /** * Inner pages * */ if(lp_custom.sticky_menu_display == 'all_pages') { jQuery('.width-md.dark' ).waypoint(function(direction){ obj.sticky_header(direction); }); jQuery('.blogs_single' ).waypoint(function(direction){ obj.sticky_header(direction); }); jQuery('.blogs').waypoint(function(direction){ obj.sticky_header(direction); }); } }); /** * Init mCustomScrollbar * */ jQuery(window).on("load",function(){ jQuery(".lp-dropdown__scroll").mCustomScrollbar({ scrollbarPosition:'outside', mouseWheel:{ scrollAmount: 200 }, scrollButtons:{ enable: false } }); });