/*--Michelle Meenach Metro custom.js--*/ document.addEventListener("DOMContentLoaded", function () { const company = account_info.website_owner_type==="company"; const office = account_info.website_owner_type==="entity"; const team = account_info.website_owner_type==="entity"&& account_info.is_team_site===true; const agent = account_info.website_owner_type === "user"; var homePage = function() { if ( $("#home-bodycontent").length ) { return true; } else { return false; } }(); var siteEditor = function() { if ( !(window.location.href.indexOf("?editkey=") > -1) ) { return false; } else { return true; } }(); contactSocialBar(); customNav(); seoAreas(); kvCorrections(); credits(); loadCognito(); responsiveYoutube(); calendlyInit(); successStories({ array: account_info.testiomonials, wrapperName: "custom-success-stories", containerType: "container", makeSlider: false, slidePauseTime: 10000, numOfItems: 30, shuffle: true, appendTo: "#resources-bodycontent #success-stories", insertAfter: "", });; var counterAnimated = false; $(window).scroll(function() { if ( !siteEditor && $('.counter-box').length && $('.counter-box').isInViewport() && !counterAnimated) { counterAnimated = true; statCounter(); } }); //On home page and NOT in editor if ( $("#home-bodycontent").length && window.location.href.indexOf("?editkey=") === -1 ) { homeHero(); reviewsSummary(); socialAccordian(); homeAbout(); homeBlog(); } //If in site editor disable aos slide in effect if ( (window.location.href.indexOf("?editkey=") > -1) ) { $("#aos-stylesheet").attr("disabled", "disabled"); } else { customTestimonials(); animateOnScroll(); } //Customize Before Header Top Bar function contactSocialBar() { if ( team ) { $(`
`).prependTo('#header .container .row-flex:first-child'); } else { $(` `).prependTo('#header .container .row-flex:first-child'); } } function customNav() { /*--Remove first three nav items (search, sell, agents)--*/ $('.nav-primary').find('.nav-item:lt(4)').remove(); /*--Move custom page links to end--*/ $('.nav-primary .nav-item a:contains("Your Neighborhood")').parent().appendTo('.nav-primary'); $('.nav-primary').append('${review}`) const testimonialFooter = $(` `); const starRating = $(` `).prependTo(testimonialFooter); var createStar = function starCreator(num) { for (var i = 0; i < num; i++) { $('').prependTo(starRating); } for (var i = num; i < 5; i++) { $('').appendTo(starRating); } }; if (rating === 5) { createStar(5); } else if (rating === 4) { createStar(4); } else if (rating === 3) { createStar(3); } else if (rating === 2) { createStar(2); } else if (rating === 1) { createStar(1); } testimonialFooter.appendTo(testimonialItem); testimonialItem.appendTo(wrapper); $('#home-bodycontent #testimonials-intro .default-blockquote').remove(); }); if ( data.makeSlider ) { $(wrapper).addClass('owl-carousel'); const customTestimonialSlider = $('#custom-testimonials.owl-carousel'); customTestimonialSlider.owlCarousel({ nav: false, dots: false, mouseDrag: true, touchDrag: true, loop: true, margin: 0, autoplay: data.makeSlider, navText: [ "Prev", "Next", ], autoplayTimeout: data.slidePauseTime, responsive: { 0: { items: 1, }, }, }); customTestimonialSlider.on("changed.owl.carousel", function(e) { customTestimonialSlider.trigger("stop.owl.autoplay"); customTestimonialSlider.trigger("play.owl.autoplay"); }); } } } function animateOnScroll() { $.getScript('https://unpkg.com/aos@2.3.1/dist/aos.js', function() { AOS.init(); }); } function kvCorrections() { $('#quick_header_search').attr('aria-label','Search By Area'); $('#horizontal-search #location_search').attr('aria-label','Search By Area'); $('#horizontal-search #qs-submit').attr('aria-label','Submit'); $('.footer-bottom .nav .nav-item:nth-child(5) img').attr('alt','Equal Housing Opportunity'); } //END KVCORRECTIONS function credits() { var year = new Date().getFullYear(); $(` `).appendTo(".footer-bottom"); } //END CREDITS function loadCognito() { if ( $('iframe[src*="cognitoforms.com"]').length ) { console.log('CognitoForm found.'); $.getScript( "https://www.cognitoforms.com/f/iframe.js", function( ) { Cognito.setCss( ".cog-form__container{padding:12px 12px 0!important;}.cog-branding{margin-left:-10000px!important;padding-top:0!important;}.cog-abuse{display:none!important;}"); }); } } function calendlyInit() { $('a[href*="calendly.com"]').on('click', function(e) { e.preventDefault(); Calendly.showPopupWidget( $(this).attr('href') ); return false; }); } function responsiveYoutube() { $('iframe[src*="youtube.com"]:not(.embed-responsive-item):not(.background_screen)').addClass('embed-responsive-item').wrap(''); } function statCounter() { $('.count-up').each(function (index) { var size = $(this).text().split(".")[1] ? $(this).text().split(".")[1].length : 0; $(this).prop('Counter',0).animate({ Counter: $(this).text() }, { duration: 3000, easing: 'swing', step: function (now) { if ( $(this).text().indexOf('.') !== -1 ) { $(this).text(parseFloat(now).toFixed(size)); } else { $(this).text(Math.ceil(now).toLocaleString('en')); } } }); }); $('.count-down').each(function (index) { var size = $(this).text().split(".")[1] ? $(this).text().split(".")[1].length : 0; $(this).prop('Counter',100).animate({ Counter: $(this).text() }, { duration: 3000, easing: 'swing', step: function (now) { if ( $(this).text().indexOf('.') !== -1 ) { $(this).text(parseFloat(now).toFixed(size)); } else { $(this).text(Math.ceil(now).toLocaleString('en')); } } }); }); } $.fn.isInViewport = function( ) { var elementTop = $(this).offset().top; var elementBottom = elementTop + $(this).outerHeight(); var viewportTop = $(window).scrollTop(); var viewportBottom = viewportTop + $(window).height(); return elementBottom > viewportTop && elementTop < viewportBottom; }; });