function resizeText() {
jQuery('.lp-btn-responsive span').each(function() {
jQuery( this ).fontSizeAdapter({
fontMax: 42,
fontMin: 8
});
});
}
function presize($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).width(nw).height(nh);
}
/*
---------------------------
ADA Plugin position fixed!
---------------------------
*/
jQuery(document).ready(function () {
var $ = jQuery;
var tries = 5;
var left_align_iframe = function (){
var $iframe = jQuery('.userway_iframe');
var style = $iframe.attr('style');
if( tries && (!$iframe.length || style.indexOf('max-width: 360px !important;') < 0) ){
tries--;
setTimeout( left_align_iframe, 1000 );
}
$iframe.attr('style', style + '; max-width: 360px !important;max-height: 600px !important;position: fixed;top: auto !important;bottom: 45px;');
}
$(window).on('load', function(){
setTimeout( left_align_iframe , 1000);
});
});
jQuery(document).ready(function() {
jQuery(window).resize(function() {
jQuery('.lp-btn-responsive, .lp-btn-responsive span').addClass("lp-notransition");
if(this.resizeTO) clearTimeout(this.resizeTO);
this.resizeTO = setTimeout(function() {
jQuery(this).trigger('windowResize');
}, 800);
});
jQuery(window).on('windowResize', function() {
resizeText();
window_resize_handler();
jQuery('.lp-btn-responsive, .lp-btn-responsive span').removeClass("lp-notransition");
});
/*jQuery('p:not(.form-submit)').html(function(){
// separate the text by spaces
var text= jQuery(this).text().split(' ');
// drop the last word and store it in a variable
var last = text.pop();
// join the text back and if it has more than 1 word add the span tag
// to the last word
return text.join(" ") + (text.length > 0 ? ' '+last+'': last);
});*/
if(jQuery("#sidebar h3.banner-title,#sidebar .banner-content p, .category-blog .post .entry-content p, .single-post .post .entry-content p").length > 0){
jQuery("#sidebar h3.banner-title,#sidebar .banner-content p, .category-blog .post .entry-content p, .single-post .post .entry-content p").html(function(){
// trim space
// separate the text by spaces
var html= jQuery(this).html().split(' ');
// drop the last word and store it in a variable
var last = html.pop();
// join the text back and if it has more than 1 word add the span tag
// console.info(last);
// to the last word
return html.join(" ") + (html.length > 0 ? ' '+last+'': last);
});
}
// var trim = jQuery.trim(jQuery(".single-post .blog-banner__title").text());
jQuery.fn.lastWord = function() {
//var text = this.text().trim().split(" ");
var text = jQuery(this).html().trim().split(" ");
var last = text.pop();
this.html(text.join(" ") + (text.length > 0 ? " " + last + "" : last));
};
jQuery.fn.lastWordindex = function() {
var last_anchor = jQuery(this).find("a:last-child");
//console.log("----Start-----");
//console.log(last_anchor);
jQuery(this).find("a:last-child").remove();
var target_ele = jQuery(this).html();
//console.log(target_ele);
var raw_data = target_ele.split(" ");
var data_arr = [];
jQuery.each(raw_data, function( index, value ) {
if(value){
data_arr.push(value);
}
});
//console.log(data_arr);
var indexoftext = data_arr[data_arr.length-3];
data_arr[data_arr.length-2]=' '+data_arr[data_arr.length-2];
data_arr[data_arr.length-3]=' '+data_arr[data_arr.length-3];
var format_txt=data_arr.join(" ").replace(/\s+ /, ' ');
format_txt=format_txt.replace(' ...',' ...');
//console.log(format_txt);
jQuery(this).html(format_txt);
//console.log("----End-----");
/*var text = jQuery(this).html().split(" 0){
jQuery(".category-blog .post .entry-content p").lastWordindex();
}
if(jQuery(".single-post .blog-banner__title, .single-post .post .entry-content header.entry-header h2.entry-title").length > 0){
jQuery(".single-post .blog-banner__title, .single-post .post .entry-content header.entry-header h2.entry-title").lastWord();
}
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({
// html:true
});
resizeText();
setTimeout(function(){
presize('.header-logo' , 200 , 60);
},250);
// jQuery("#navigation-header").css('display','block');
jQuery(window).load(function(e){
jQuery("#mask").fadeOut(1100)
});
bind_dropdown_event();
navigation_handler();
window_resize_handler();
if (lp_custom.sticky_menu_display != "disable") {
if (lp_custom.sticky_menu_display == "all_pages") {
navigation_scroll();
} else if (lp_custom.sticky_menu_display == "home") {
if (lp_custom.is_home) {
navigation_scroll();
}
}
}
newsletter_handler();
var flexsliderOptions = {
manualControls: '.flex-manual .switch',
nextText: "Next",
prevText: "Prev",
startAt: 1,
slideshow: true,
direction: "horizontal",
animation: "slide"
};
// jQuery('#leadpop_footer').find('a').attr('title', jQuery('title').text());
// jQuery('#leadpop_footer').find('img').attr('alt', jQuery('title').text());
if(jQuery.isFunction('flexslider')){
jQuery('.testimonials-slider').flexslider(flexsliderOptions);
}
//back-to-top functions
jQuery('.back-to-top').on('click', function (event) {
event.preventDefault();
event.stopPropagation();
jQuery('html, body').animate({
scrollTop: 0,
easing: 'swing'
}, 750);
});
jQuery(window).on('scroll', function() {
if (jQuery(window).scrollTop() > 250) {
jQuery('.back-to-top').fadeIn();
}else {
jQuery('.back-to-top').fadeOut();
}
});
});
/*jQuery('.navbar-toggle').click(function(e){
e.stopPropagation();
if(jQuery(this).hasClass('slide-active')){
jQuery('body , html').removeClass('noscroll');
jQuery(this).removeClass('slide-active');
jQuery('.navbar-header').css({'margin-left': '0'});
jQuery('.navbar .navbar-collapse').css({'right':'-100%'});
/!*
$('.navbar .lp-nav__right , .inner-header__main .lp-nav__right').delay('2000').css({'opacity':'1','transition': 'all 2.5s'});
*!/
jQuery('.lp-navbar-toggle i').removeClass('fa-close');
jQuery('.lp-navbar-toggle i').addClass('fa-bars');
}else{
// outside_close_menu();
jQuery('body , html').addClass('noscroll');
/!* jQuery('.navbar').css({'opacity':'0','transition': 'all .1s'});*!/
var mrg = jQuery('.menu-container').width();
var mrg = mrg;
jQuery(this).addClass('slide-active');
jQuery('.navbar-header').css({'margin-left': '-'+mrg+'px'});
jQuery('.navbar .navbar-collapse').css({'right':'0'});
jQuery('.lp-navbar-toggle i').removeClass('fa-bars');
jQuery('.lp-navbar-toggle i').addClass('fa-close');
}
});*/
function animate_navigation(_this){
var navigationwrapper = '.navbar-header';
var slidewidth = '0';
var menu_dalta = '-50%';
if(_this.hasClass('slide-active')){
// remove it
_this.removeClass('slide-active');
jQuery('.navbar-toggle i').removeClass('fa-close');
jQuery('.navbar-toggle i').addClass('fa-bars');
}else{
_this.addClass('slide-active');
jQuery('.navbar-toggle i').removeClass('fa-bars');
jQuery('.navbar-toggle i').addClass('fa-close');
menu_dalta = '0';
slidewidth = '50%';
}
jQuery('.navbar-collapse').css({
right: menu_dalta
});
jQuery(navigationwrapper).css({
right: slidewidth
});
jQuery('body , html').toggleClass('noscroll');
}
function navigation_handler() {
// var toggler = '.navbar-toggle';
// jQuery("#navigation-header").on("click", toggler, function(e) {
// e.preventDefault();
//
// });
jQuery('.navbar-toggle').click(function (e) {
e.stopPropagation();
animate_navigation(jQuery(this));
});
}
jQuery(document).click(function(e) {
var target = e.target;
console.info(target);
if(jQuery(".navbar-toggle").hasClass('slide-active')) {
// Navbar is opened on mobile
if (jQuery(target).parents('.navbar-collapse').length > 0) { }
else{
jQuery('.navbar-header').css({'right': '0'});
jQuery('.navbar-collapse').css({'right': '-65%'});
jQuery('#navigation-header').find('.slide-active').removeClass('slide-active');
jQuery('body , html').removeClass('noscroll');
jQuery('.navbar-toggle i').removeClass('fa-close');
jQuery('.navbar-toggle i').addClass('fa-bars');
}
}
});
var w =jQuery(window).width();
//console.log(w);
function window_resize_handler() {
// if (jQuery(window).width() > 1199 && jQuery('.navbar-toggle').is(':hidden')) {
if (jQuery(window).width() > 1024 && jQuery('.navbar-toggle').is(':hidden')) {
jQuery('body').removeClass('mobile');
jQuery('.navbar-collapse').removeAttr('style');
} else {
jQuery('body').addClass('mobile');
jQuery('.navbar-collapse').css('min-height', jQuery(window).height());
}
}
function bind_dropdown_event() {
// if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
if (jQuery(window).width() <= 1199) {
jQuery('.dropdown-menu').hide();
jQuery(".menu-container .dropdown").click(function() {
if(jQuery(this).hasClass('open')){
_this = jQuery(this);
jQuery(this).find('.dropdown-menu').stop().slideUp(300 , function(){
_this.toggleClass('open');
});
}else{
jQuery('.dropdown-menu').slideUp('fast');
jQuery('.menu-container .dropdown').delay(1500).removeClass('open');
jQuery(this).toggleClass('open');
jQuery(this).find('.dropdown-menu').stop().slideDown();
}
});
}else{
jQuery(".menu-container .dropdown").hover(
function() {
jQuery('.dropdown-menu', this).stop(true, true).slideDown("fast");
jQuery(this).toggleClass('open');
},
function() {
jQuery('.dropdown-menu', this).stop(true, true).slideUp("fast");
jQuery(this).toggleClass('open');
}
);
}
}
var menuTrigger = false;
var menuTriggerOld = false;
function navigation_scroll() {
jQuery(window).on('scroll', function() {
var scrollTop = jQuery(this).scrollTop();
var _top = 200;
if (lp_custom.sticky_menu_position != undefined) {
_top = lp_custom.sticky_menu_position;
}
if (scrollTop >= _top) {
menuTrigger = true;
} else {
menuTrigger = false;
}
if (menuTrigger != menuTriggerOld) {
if (menuTrigger) {
stickMenu();
} else {
unstickMenu();
}
menuTriggerOld = menuTrigger;
}
});
}
function stickMenu() {
jQuery('#navigation-header').addClass('no-transition');
jQuery('#navigation-header').css('top', -(jQuery('#navigation-header').height() +
10));
jQuery('#navigation-header').addClass('fixmenu-clone');
setTimeout(function() {
jQuery('#navigation-header').css('top', 0);
jQuery('#navigation-header').removeClass('no-transition');
}, 30);
if (jQuery('.navbar-collapse').not('.collapsed').length) {
jQuery('.navbar-collapse').not('.collapsed').closest('#navigation-header').find(
'.navigation-toggle').trigger('click');
}
}
function unstickMenu() {
jQuery('#navigation-header').addClass('no-transition');
jQuery('#navigation-header').removeClass('fixmenu-clone');
jQuery('#navigation-header').css('top', '');
setTimeout(function() {
jQuery('#navigation-header').removeClass('no-transition');
}, 30);
if (jQuery('.navbar-collapse').not('.collapsed').length) {
setTimeout(function() {
jQuery('.navbar-collapse').not('.collapsed').closest(
'#navigation-header').find('.navigation-toggle').trigger('click');
}, 100);
}
}
function newsletter_handler() {
jQuery('[id^=subscribe]').submit(function() {
$response = jQuery(this).find('[id^=response]');
$response.html(
'Adding email address...');
var name = jQuery(this).find('.NewsletterName').val().split(' ');
var provider = jQuery(this).find('.provider').val() || 'mailchimp';
var apiKey = jQuery(this).find('.apiKey').val() || '';
var listId = jQuery(this).find('.listId').val() || '';
var dopt = jQuery(this).find('.dopt').val() || '';
var fname = name[0] || '';
var lname = name[1] || '';
var templateUrl = locale.templateUrl;
// Prepare query string and send AJAX request
jQuery.ajax({
url: templateUrl + '/includes/mailing-list/mailing-list.php',
data: 'ajax=true&email=' + escape(jQuery(this).find(
'.NewsletterEmail')
.val()) + '&fname=' + fname + '&lname=' + lname + '&akey=' +
apiKey + '&lid=' + listId + '&dopt=' + dopt + '&provider=' +
provider,
success: function(msg) {
if (msg.indexOf("Success") != -1) {
$response.html(
'Success! You are now subscribed to our newsletter!'
);
} else {
$response.html('' + msg +
'');
}
}
});
return false;
});
if (jQuery('.cycle').length > 0 && lp_custom.disable_home_cta != 1) {
jQuery('.cycle').each(function(index, el) {
var _labels = jQuery(el).prev('div');
_labels = _labels.text().split(',');
var counter = 0;
setInterval(function() {
// var arr = ['FHA Loans', 'Refinancing', 'HARP Loans',
// 'Home Loans',
// 'Reverse Mtgs'
// ];
var target = jQuery(el).find('b');
counter = (counter == (_labels.length - 1)) ? 0 : counter += 1;
target.animate({
top: '-170px'
}, function() {
target.html(_labels[counter]).animate({
top: '0'
});
});
}, 4000);
});
}
}
// requestAnimationFrame polyfill starts here
(function () {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] ||
window[vendors[x] + 'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame)
window.requestAnimationFrame = function (callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function () {
callback(currTime + timeToCall);
},
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
if (!window.cancelAnimationFrame)
window.cancelAnimationFrame = function (id) {
clearTimeout(id);
};
}());
// requestAnimationFrame polyfill ends here
jQuery(document).ready(function (){
var $ = jQuery;
var regex = /lpSupercalcHeight=(\d+)/;
var $iframe = $('.cal_iframe.lp-supercalc');
if( ! $iframe.length ){
return;
}
try {
var iframe = $iframe[0];
// return if postMessage API is not supported
if( !( iframe.contentWindow && iframe.contentWindow.postMessage ) ){
return;
}
} catch (e){
return;
}
$('body').addClass('supercalc-loaded');
var protocolEstablished = false;
window.addEventListener('message', function (e){
var msg = e.data;
var height = msg.match(regex);
if( height ){
height = parseInt( height[1] );
$iframe.height(height);
if( !protocolEstablished ){
requestAnimationFrame( function (){
iframe.contentWindow.postMessage( 'lpSupercalcHeightReceived' , '*');
});
}
} else if ( msg == 'lpSupercalcHeightProtocolEstablished' ){
protocolEstablished = true;
}
});
});